Skip to content

Commit

Permalink
fix(*): fixed while creating robot fleet bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Aug 17, 2023
1 parent 7bbe5b1 commit 680348d
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<img src="https://img.shields.io/badge/nodejs-18.15.0-dgreen" alt="node">
</a>
<a href="https://github.com/robolaunch/ui/releases">
<img src="https://img.shields.io/badge/release-v0.12.7-red" alt="release">
<img src="https://img.shields.io/badge/release-v0.13.0-red" alt="release">
</a>
<a href="#">
<img src="https://img.shields.io/badge/language-typescript-blue" alt="language">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui",
"version": "0.12.9",
"version": "0.13.0",
"private": true,
"dependencies": {
"@emotion/css": "^11.10.6",
Expand Down
1 change: 1 addition & 0 deletions src/components/Cells/StateCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default function StateCell({ state, isRobolaunchState }: IStateCell) {
state === "Connected" ||
state === "Completed" ||
state === "Running" ||
state === "Active" ||
state === "EnvironmentReady" ? (
<div className="w-2.5 h-2.5 bg-green-500 rounded-full" />
) : state === "stopping" ||
Expand Down
44 changes: 38 additions & 6 deletions src/components/CreateForms/CreateRobotFormStep2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { CreateRobotFormStep2Validations } from "../../validations/RobotsValidat
import { toast } from "sonner";
import CreateRobotFormAddButton from "../CreateRobotFormAddButton/CreateRobotFormAddButton";
import CreateRobotFormCancelButton from "../CreateRobotFormCancelButton/CreateRobotFormCancelButton";
import { envOnPremiseRobot } from "../../helpers/envProvider";
import {
envOnPremiseFleet,
envOnPremiseRobot,
} from "../../helpers/envProvider";
import { CreateEnvironmentFormStep2Validations } from "../../validations/EnvironmentsValidations";
import { createEnvironment } from "../../toolkit/EnvironmentSlice";
import { useParams } from "react-router-dom";
Expand All @@ -32,7 +35,7 @@ export default function CreateRobotFormStep2({
const dispatch = useAppDispatch();
const [isLoadingImportRobot, setIsLoadingImportRobot] =
useState<boolean>(true);
const { getRobot, getFleet, getEnvironment } = useFunctions();
const { getRobot, getFleet, getEnvironment, getNamespace } = useFunctions();
const [responseRobot, setResponseRobot] = useState<any>(undefined);
const url = useParams();

Expand Down Expand Up @@ -134,12 +137,14 @@ export default function CreateRobotFormStep2({
}, 2000);
} else {
if (!responseFleet) {
handleGetFleet();
envOnPremiseFleet ? handleGetNamespace() : handleGetFleet();
}
}

const timer = setInterval(() => {
!isImportRobot && !robotData?.step1?.isVirtualRobot && handleGetFleet();
if (!isImportRobot && !robotData?.step1?.isVirtualRobot) {
envOnPremiseFleet ? handleGetNamespace() : handleGetFleet();
}
}, 10000);

return () => {
Expand Down Expand Up @@ -201,6 +206,22 @@ export default function CreateRobotFormStep2({
);
}

function handleGetNamespace() {
getNamespace(
{
organizationId: selectedState?.organization?.organizationId,
roboticsCloudName: selectedState?.roboticsCloud?.name,
instanceId: selectedState?.instance?.instanceId,
region: selectedState?.instance?.region,
namespaceName: selectedState?.fleet?.name,
},
{
ifErrorNavigateTo404: false,
setResponse: setResponseFleet,
}
);
}

useEffect(() => {
console.log(
!formik?.isValid,
Expand All @@ -211,12 +232,22 @@ export default function CreateRobotFormStep2({
);
}, [formik]);

useEffect(() => {
console.log(
responseFleet?.fleetStatus !== "Ready" ||
responseFleet?.namespaceStatus !== "Active"
);
}, [responseFleet]);

return (
<CreateRobotFormLoader
isLoading={
isImportRobot
? isLoadingImportRobot
: !responseFleet || responseFleet?.fleetStatus !== "Ready"
: !responseFleet ||
(envOnPremiseFleet
? responseFleet?.namespaceStatus !== "Active"
: responseFleet?.fleetStatus !== "Ready")
}
loadingText={
isImportRobot
Expand All @@ -229,7 +260,8 @@ export default function CreateRobotFormStep2({
: [
{
name: responseFleet?.name,
status: responseFleet?.fleetStatus,
status:
responseFleet?.fleetStatus || responseFleet?.namespaceStatus,
},
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/SidebarLists/NamespacesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function NamespacesList({
<div className="flex gap-2">
<div className="flex gap-1.5">
<span className="font-medium">VI:</span>
<StateCell state={fleet?.fleetStatus} />
<StateCell state={fleet?.namespaceStatus} />
</div>
{responseNamespaces?.filter(
(pFleet: any) => fleet?.name === pFleet?.fleetName
Expand Down
5 changes: 3 additions & 2 deletions src/components/SidebarLists/SidebarListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ export default function SidebarListItem({
break;
case "fleet":
if (
data?.fleetStatus === "Ready" &&
data?.physicalInstance?.length === 0
data?.namespaceStatus === "Active" ||
(data?.fleetStatus === "Ready" &&
data?.physicalInstance?.length === 0)
) {
if (selectedState?.fleet?.name === data?.name) {
setSelectedState({ ...selectedState, fleet: null });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function CloudInstanceDashboardPage(): ReactElement {
organization: url?.organizationName,
roboticsCloud: url?.roboticsCloudName,
instance: url?.instanceName,
state: fleet?.fleetStatus,
state: fleet?.fleetStatus || fleet?.namespaceStatus,
actions: fleet,
};
}),
Expand Down

0 comments on commit 680348d

Please sign in to comment.