Skip to content

Commit

Permalink
refactor(create-form and dashboard) 🎉 update robotics-cloud dashboard…
Browse files Browse the repository at this point in the history
… and create-form
  • Loading branch information
gokhangunduz committed Aug 28, 2023
1 parent 4bc7d3b commit eabaa56
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 56 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.14.2-red" alt="release">
<img src="https://img.shields.io/badge/release-v0.14.4-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.14.2",
"version": "0.14.4",
"private": true,
"dependencies": {
"@emotion/css": "^11.10.6",
Expand Down
11 changes: 7 additions & 4 deletions src/components/CreateForms/CreateEnvironmentFormStep1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export default function CreateEnvironmentFormStep1({
instanceId: selectedState?.instance?.instanceId,
region: selectedState?.roboticsCloud?.region!,
fleetName: selectedState?.fleet?.name,
environmentName: robotData?.step1?.robotName || url?.robotName,
environmentName: url?.robotName!,
},
{
ifErrorNavigateTo404: false,
ifErrorNavigateTo404: !responseRobot,
setResponse: setResponseRobot,
setRobotData: setRobotData,
setRobotData: true,
}
);
}
Expand Down Expand Up @@ -159,7 +159,10 @@ export default function CreateEnvironmentFormStep1({
{/* RobotName */}

{/* Environment Selector */}
<EnvironmentSelector formik={formik} isImportRobot />
<EnvironmentSelector
formik={formik}
isImportRobot={isImportRobot}
/>
{/* Environment Selector */}

{formik.values.application?.name && <Seperator />}
Expand Down
72 changes: 36 additions & 36 deletions src/components/CreateForms/CreateRobotFormStep2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,44 +292,44 @@ export default function CreateRobotFormStep2({
onClick={() => handleAddWorkspaceStep(formik)}
/>

{/* Buttons */}
<div className="flex gap-2 mt-10">
{!isImportRobot && (
<CreateRobotFormCancelButton disabled={formik.isSubmitting} />
)}
<Button
type="submit"
disabled={
!formik?.isValid ||
formik.isSubmitting ||
JSON.stringify(formik.initialValues) ===
JSON.stringify(formik.values) ||
envOnPremiseRobot
}
loading={formik.isSubmitting}
className="w-full !h-11 text-xs"
text={
formik.isSubmitting ? (
<img
className="w-10 h-10"
src="/svg/general/loading.svg"
alt="loading"
/>
) : isImportRobot ? (
`Update Robot`
) : robotData?.step1?.isDevelopmentMode ? (
envOnPremiseRobot ? (
`Create Application`
{!(envOnPremiseRobot && url?.robotName ? true : false) && (
<div className="flex gap-2 mt-10">
{!isImportRobot && (
<CreateRobotFormCancelButton disabled={formik.isSubmitting} />
)}
<Button
type="submit"
disabled={
!formik?.isValid ||
formik.isSubmitting ||
JSON.stringify(formik.initialValues) ===
JSON.stringify(formik.values) ||
(envOnPremiseRobot && url?.robotName ? true : false)
}
loading={formik.isSubmitting}
className="w-full !h-11 text-xs"
text={
formik.isSubmitting ? (
<img
className="w-10 h-10"
src="/svg/general/loading.svg"
alt="loading"
/>
) : isImportRobot ? (
`Update Robot`
) : robotData?.step1?.isDevelopmentMode ? (
envOnPremiseRobot ? (
`Create Application`
) : (
`Create Robot`
)
) : (
`Create Robot`
`Next Step`
)
) : (
`Next Step`
)
}
/>
</div>
{/* Buttons */}
}
/>
</div>
)}
</form>
</CreateRobotFormLoader>
);
Expand Down
6 changes: 3 additions & 3 deletions src/components/EnvironmentSelector/EnvironmentSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import InfoTip from "../InfoTip/InfoTip";

interface IEnvironmentSelector {
formik: any;
isImportRobot: boolean;
isImportRobot?: boolean;
}

export default function EnvironmentSelector({
Expand All @@ -26,7 +26,7 @@ export default function EnvironmentSelector({
}, [dispatch]);

useEffect(() => {
if (formik.values?.domainName) {
if (formik.initialValues?.domainName !== formik.values?.domainName) {
formik.setFieldValue("application", {
name: undefined,
version: undefined,
Expand All @@ -38,7 +38,7 @@ export default function EnvironmentSelector({
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [formik.values?.domainName]);
}, [formik?.values?.domainName, formik?.initialValues?.domainName]);

return (
<Fragment>
Expand Down
16 changes: 13 additions & 3 deletions src/components/TableActionCells/InstanceActionCells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import Button from "../Button/Button";
import { BiTrash, BiStopCircle, BiPlayCircle } from "react-icons/bi";
import ChangeStateInstanceModal from "../../modals/ChangeStateInstanceModal";
import TerminateInstanceModal from "../../modals/TerminateInstanceModal";
import { envOnPremiseRobot } from "../../helpers/envProvider";
import {
envOnPremiseFleet,
envOnPremiseRobot,
} from "../../helpers/envProvider";

interface IInstanceActionCells {
data: any;
Expand All @@ -19,6 +22,8 @@ export default function InstanceActionCells({
const [isTerminateModalVisible, setIsTerminateModalVisible] =
useState<boolean>(false);

console.log(data);

return (
<Fragment>
<div className="card flex gap-4 float-right">
Expand All @@ -29,7 +34,9 @@ export default function InstanceActionCells({
: "!border-layer-dark-100"
}`}
text={
data?.state === "running" ? (
data?.state === "running" ||
envOnPremiseRobot ||
envOnPremiseFleet ? (
<BiStopCircle
size={20}
className={`${
Expand Down Expand Up @@ -70,7 +77,10 @@ export default function InstanceActionCells({
: "!border-layer-dark-100"
}`}
text={
data?.state === "running" || data?.state === "stopped" ? (
data?.state === "running" ||
data?.state === "stopped" ||
envOnPremiseRobot ||
envOnPremiseFleet ? (
<BiTrash
className={`${
envOnPremiseRobot ? "text-layer-light-500" : "text-red-600"
Expand Down
9 changes: 5 additions & 4 deletions src/components/TableInformationCells/WorkspacesCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export default function WorkspacesCell({
const [githubWorkspaces, setGithubWorkspaces] = useState<any[]>([]);

useEffect(() => {
const workspacesData = workspaces;

setGithubWorkspaces([]);
workspaces?.forEach(async (workspace: any) => {
workspacesData?.forEach(async (workspace: any) => {
try {
const response = await axios.get(
workspace?.url.replace(
Expand All @@ -32,11 +34,11 @@ export default function WorkspacesCell({
},
]);
} catch (error) {
// Hata durumunda işlemi burada yönetebilirsiniz
console.error("Error:", error);
}
});
}, [workspaces]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<div className="flex flex-col items-center gap-2">
Expand All @@ -59,7 +61,6 @@ export default function WorkspacesCell({
src="/svg/apps/github.svg"
alt="github"
/>

<span> {workspace?.full_name}</span>
</div>
<div className="flex gap-1 items-center">
Expand Down
4 changes: 0 additions & 4 deletions src/contexts/FunctionsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1041,10 +1041,6 @@ export default ({ children }: any) => {
responseEnvironment?.payload?.data[0].roboticsClouds[0]
?.cloudInstances[0]?.environments
) {
console.log(
responseEnvironment?.payload?.data[0].roboticsClouds[0]
?.cloudInstances[0]?.environments
);
parameters?.setRobotData &&
setRobotData((prevState: any) => {
return {
Expand Down

0 comments on commit eabaa56

Please sign in to comment.