Skip to content

Commit

Permalink
refactor(app-form): 🎉 update form logic and update host-directories
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Feb 12, 2024
1 parent 03486a9 commit dd70ad1
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/components/CFCodeType/CFCodeType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function CFCodeType({
});
}}
disabled={formik?.isSubmitting}
className="!text-xs"
>
<Fragment>
<option value="isCommandCode">Bash Code</option>
Expand Down
2 changes: 1 addition & 1 deletion src/components/CFGpuCore/CFGpuCore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function CFGpuCore({
({ name }) => name === formik.values.services?.ide?.gpuModelName!,
)?.available! -
environmentGPUCoreUsagebility(
selectedState.instance!.resources.hardware.gpu.hardware!,
selectedState.instance!.resources.hardware.gpu.hardware || [],
) || 0
}
disabled={formik.isSubmitting || disabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ export default function CFDirectoriesInputGroup({
setIsFileManagerHealthly(response?.length > 0);
}

useEffect(() => {
console.log("!!!!!!!!!", formik.values.directories?.hostDirectories?.[0]);
}, [formik]);

return (
<div className="flex w-full gap-4 rounded-md border border-light-100 p-4 shadow-sm">
{isFileManagerHealthly ? (
Expand Down
6 changes: 3 additions & 3 deletions src/components/CreateForms/CFStep3.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import CreateRobotFormAddButton from "../CreateRobotFormAddButton/CreateRobotFormAddButton";
import { handleAddBuild } from "../../functions/form.build.function";
import CFAddBuildButton from "../CFAddBuildButton/CFAddBuildButton";
import CFRobotButtons from "../CFRobotButtons/CFRobotButtons";
import CFBuildMapper from "../CFBuildMapper/CFBuildMapper";
import { Fragment, ReactElement, useEffect } from "react";
import CreateRobotFormLoader from "../CFLoader/CFLoader";
import SidebarInfo from "../SidebarInfo/SidebarInfo";
import CFBuildName from "../CFBuildName/CFBuildName";
// import CFBuildName from "../CFBuildName/CFBuildName";
import useFunctions from "../../hooks/useFunctions";
import useMain from "../../hooks/useMain";
import { handleAddBuild } from "../../functions/form.build.function";
import useForm from "../../hooks/useForm";

interface ICFStep3 {
Expand Down Expand Up @@ -212,7 +212,7 @@ export default function CFStep3({
</div>
) : (
<Fragment>
<CFBuildName formik={formik} />
{/* <CFBuildName formik={formik} /> */}

<CFBuildMapper formik={formik} isImportRobot={isImportRobot} />

Expand Down
4 changes: 2 additions & 2 deletions src/components/CreateForms/CFStep4.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import RobotDeleteLaunchManagerButton from "../RobotDeleteLaunchManagerButton/RobotDeleteLaunchManagerButton";
import { IEnvironmentStep4LaunchStep } from "../../interfaces/environment/environment.step4.interface";
import CFLaunchWorkspace from "../CFLaunchWorkspace/CFLaunchWorkspace";
import { Fragment, ReactElement, useEffect, useState } from "react";
import { orgSplitter } from "../../functions/general.function";
import { createLaunchManager } from "../../toolkit/RobotSlice";
import CFRobotButtons from "../CFRobotButtons/CFRobotButtons";
import CFLaunchScope from "../CFLaunchScope/CFLaunchScope";
Expand All @@ -14,8 +16,6 @@ import useMain from "../../hooks/useMain";
import { useFormik } from "formik";
import { toast } from "sonner";
import * as Yup from "yup";
import { IEnvironmentStep4LaunchStep } from "../../interfaces/environment/environment.step4.interface";
import { orgSplitter } from "../../functions/general.function";

interface ICFStep4 {
isImportRobot?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ export default function EnvironmentSidebarMenuItems(): ReactElement {
)}
<SideBarMenuItem
type="robot"
description={`You can access all your ${
applicationMode ? "applications" : "robots"
} here.`}
description={
url?.robotName
? `You can update your ${applicationMode ? "application" : "robot"} from here.`
: `You can access all your ${applicationMode ? "applications" : "robots"} here.`
}
loading={isLoading}
disabled={
sidebarState?.isCreateMode &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,29 @@ export default function HostDirectoriesSearchIframe(): ReactElement {

const { selectedState } = useMain();

function handleGenerateURL() {
if (window.location.hostname.split(".").length - 1) {
const url = window.location.hostname.split(".").slice(1).join(".");

return url;
}
return window.location.hostname;
}

return (
<Fragment>
<div className="cursor-pointer" onClick={() => setIsOpened(true)}>
<IoSearch className="text-light-500" size={16} />
</div>
{isOpened && (
<IframeModal
header="Host Directories Search"
handleCloseModal={() => setIsOpened(false)}
url={`https://${selectedState?.instance?.endpoint!}/host`}
url={
selectedState?.instance?.endpoint
? `https://${selectedState?.instance?.endpoint!}/host`
: `https://${selectedState?.instance?.name}.${handleGenerateURL()}/host`
}
/>
)}
</Fragment>
Expand Down
4 changes: 3 additions & 1 deletion src/components/SidebarStaticItem/SidebarStaticItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export default function SidebarStaticItem({
? "You can access all your bills here"
: to === "/user-role-management"
? "You can access all users here."
: "You can access all your applications here."
: to === "/data-science"
? "You can access all your data science apps here."
: ""
}
/>
)}
Expand Down
8 changes: 4 additions & 4 deletions src/contexts/FormContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ export default ({ children }: any) => {
}),
sharing: Yup.object().shape({
alias: Yup.string().when("private", {
is: false,
then: Yup.string(),
// otherwise: Yup.string().required("Name is required."),
is: true,
then: Yup.string().required("Name is required."),
otherwise: Yup.string(),
}),
private: Yup.boolean(),
organization: Yup.boolean(),
Expand Down Expand Up @@ -235,7 +235,7 @@ export default ({ children }: any) => {
);
return temp.length > 1 ? false : true;
}),
workspace: Yup.string().required("Workspace is required"),
// workspace: Yup.string().required("Workspace is required"),
isCommandCode: Yup.boolean(),
command: Yup.string().when("isCommandCode", {
is: true,
Expand Down
4 changes: 2 additions & 2 deletions src/contexts/FunctionsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ export default ({ children }: any) => {
region: selectedState?.roboticsCloud?.region!,
fleetName: selectedState?.fleet?.name!,
environmentName: robotData?.step1?.details?.name,
buildManagerName: robotData?.step3?.name,
buildManagerName: `build-manager-${Math.floor(Date.now() / 1000)}`,
steps: robotData?.step3?.steps,
}),
);
Expand Down Expand Up @@ -670,7 +670,7 @@ export default ({ children }: any) => {
robotData?.step1?.resources.storage.allocatedCapacity,
vdiSessionCount: robotData?.step1?.services.vdi?.sessionCount,
vdiGpuResource: environmentGPUCoreUsagebility(
selectedState?.instance?.resources?.hardware?.gpu?.hardware!,
selectedState?.instance?.resources?.hardware?.gpu?.hardware || [],
),
domainName: robotData?.step1?.applicationConfig.domainName,
ideGpuResource: robotData?.step1?.services.ide.gpuAllocation,
Expand Down

0 comments on commit dd70ad1

Please sign in to comment.