Skip to content

Commit

Permalink
refactor(create-forms): 🎉 update create forms
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Nov 2, 2023
1 parent 93b403b commit 255cdc7
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/components/CreateForms/CreateRobotFormStep1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { envOnPremiseRobot } from "../../helpers/envProvider";
import CreateRobotRosDistrobutions from "../CreateRobotRosDistrobutions/CreateRobotRosDistrobutions";
import CreateRobotFormCancelButton from "../CFCancelButton/CFCancelButton";
import CreateRobotFormLoader from "../CFLoader/CFLoader";
import { CreateRobotFormStep1Validations } from "../../validations/RobotsValidations";
import { CFRobotStep1Validations } from "../../validations/RobotsValidations";
import CreateRobotStorage from "../CFStorageRange/CFStorageRange";
import { addPhysicalInstanceToFleet } from "../../toolkit/InstanceSlice";
import CreateRobotTypes from "../CreateRobotTypes/CreateRobotTypes";
Expand Down Expand Up @@ -79,7 +79,7 @@ export default function CreateRobotFormStep1({
}

const formik = useFormik({
validationSchema: CreateRobotFormStep1Validations,
validationSchema: CFRobotStep1Validations,
initialValues: robotData?.step1,
onSubmit: async () => {
formik.setSubmitting(true);
Expand Down
18 changes: 9 additions & 9 deletions src/components/CreateForms/CreateRobotFormStep2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ import {
envOnPremiseFleet,
envOnPremiseRobot,
} from "../../helpers/envProvider";
import { CreateEnvironmentFormStep2Validations } from "../../validations/AppsValidations";
import { CreateRobotFormStep2Validations } from "../../validations/RobotsValidations";
import CFAddWorkspaceButton from "../CFAddWorkspaceButton/CFAddWorkspaceButton";
import React, { Fragment, ReactElement, useEffect, useState } from "react";
import { CFRobotStep2Validations } from "../../validations/RobotsValidations";
import CFWorkspacesMapper from "../CFWorkspacesMapper/CFWorkspacesMapper";
import { IWorkspaces } from "../../interfaces/robotInterfaces";
import { CFAppStep2Validations } from "../../validations/AppsValidations";
import { Fragment, ReactElement, useEffect, useState } from "react";
import { createEnvironment } from "../../toolkit/EnvironmentSlice";
import { IWorkspaces } from "../../interfaces/robotInterfaces";
import CFCancelButton from "../CFCancelButton/CFCancelButton";
import useCreateRobot from "../../hooks/useCreateRobot";
import { createRobot } from "../../toolkit/RobotSlice";
import SidebarInfo from "../SidebarInfo/SidebarInfo";
import useFunctions from "../../hooks/useFunctions";
import { useAppDispatch } from "../../hooks/redux";
import { FormikProps, useFormik } from "formik";
import { useParams } from "react-router-dom";
import CFLoader from "../CFLoader/CFLoader";
import useMain from "../../hooks/useMain";
import Button from "../Button/Button";
import { useFormik } from "formik";
import { toast } from "sonner";
import SidebarInfo from "../SidebarInfo/SidebarInfo";

interface ICreateRobotFormStep2 {
isImportRobot?: boolean;
Expand All @@ -40,10 +40,10 @@ export default function CreateRobotFormStep2({
const url = useParams();
const dispatch = useAppDispatch();

const formik: FormikProps<IWorkspaces> = useFormik<IWorkspaces>({
const formik = useFormik<IWorkspaces>({
validationSchema: envOnPremiseRobot
? CreateEnvironmentFormStep2Validations
: CreateRobotFormStep2Validations,
? CFAppStep2Validations
: CFRobotStep2Validations,
initialValues: robotData?.step2,
onSubmit: () => {
formik.setSubmitting(true);
Expand Down
4 changes: 2 additions & 2 deletions src/components/CreateForms/CreateRobotFormStep3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Fragment, ReactElement, useEffect, useState } from "react";
import RobotDeleteBuildManagerButton from "../RobotDeleteBuildManagerButton/RobotDeleteBuildManagerButton";
import CreateRobotFormAddButton from "../CreateRobotFormAddButton/CreateRobotFormAddButton";
import CFAddBuildButton from "../CFAddBuildButton/CFAddBuildButton";
import { IRobotBuildSteps } from "../../interfaces/robotInterfaces";
import { IBuildSteps } from "../../interfaces/robotInterfaces";
import { createBuildManager } from "../../toolkit/RobotSlice";
import CFCancelButton from "../CFCancelButton/CFCancelButton";
import CFBuildMapper from "../CFBuildMapper/CFBuildMapper";
Expand Down Expand Up @@ -104,7 +104,7 @@ export default function CreateRobotFormStep3({
);
}

const formik: FormikProps<IRobotBuildSteps> = useFormik<IRobotBuildSteps>({
const formik: FormikProps<IBuildSteps> = useFormik<IBuildSteps>({
validationSchema: Yup.object().shape({
buildManagerName: Yup.string().required("Build Manager Name is required"),
robotBuildSteps: Yup.array().of(
Expand Down
21 changes: 10 additions & 11 deletions src/components/CreateForms/CreateRobotFormStep4.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import React, { Fragment, ReactElement, useEffect, useState } from "react";
import { IRobotLaunchStep } from "../../interfaces/robotInterfaces";
import RobotDeleteLaunchManagerButton from "../RobotDeleteLaunchManagerButton/RobotDeleteLaunchManagerButton";
import CreateRobotFormCancelButton from "../CFCancelButton/CFCancelButton";
import CreateRobotFormLoader from "../CFLoader/CFLoader";
import { organizationNameViewer } from "../../functions/GeneralFunctions";
import CFLaunchWorkspace from "../CFLaunchWorkspace/CFLaunchWorkspace";
import { Fragment, ReactElement, useEffect, useState } from "react";
import { ILaunchStep } from "../../interfaces/robotInterfaces";
import { createLaunchManager } from "../../toolkit/RobotSlice";
import CFLaunchScope from "../CFLaunchScope/CFLaunchScope";
import CreateRobotFormLoader from "../CFLoader/CFLoader";
import useCreateRobot from "../../hooks/useCreateRobot";
import CFLaunchName from "../CFLaunchName/CFLaunchName";
import CFLaunchCode from "../CFLaunchCode/CFLaunchCode";
import CFEnvMapper from "../CFEnvMapper/CFEnvMapper";
import useFunctions from "../../hooks/useFunctions";
import { useAppDispatch } from "../../hooks/redux";
import { FormikProps, useFormik } from "formik";
import { useParams } from "react-router-dom";
import useMain from "../../hooks/useMain";
import Button from "../Button/Button";
import { useFormik } from "formik";
import { toast } from "sonner";
import * as Yup from "yup";
import CFLaunchName from "../CFLaunchName/CFLaunchName";
import CFLaunchWorkspace from "../CFLaunchWorkspace/CFLaunchWorkspace";
import CFLaunchCode from "../CFLaunchCode/CFLaunchCode";
import CFLaunchScope from "../CFLaunchScope/CFLaunchScope";
import CFEnvMapper from "../CFEnvMapper/CFEnvMapper";

interface ICreateRobotFormStep4 {
isImportRobot?: boolean;
Expand All @@ -39,7 +39,7 @@ export default function CreateRobotFormStep4({
const { getBuildManager } = useFunctions();
const url = useParams();

const formik: FormikProps<IRobotLaunchStep> = useFormik<IRobotLaunchStep>({
const formik = useFormik<ILaunchStep>({
initialValues:
robotData?.step4?.robotLaunchSteps[
robotDataLaunchIndex ? robotDataLaunchIndex : 0
Expand Down Expand Up @@ -103,7 +103,6 @@ export default function CreateRobotFormStep4({
!isImportRobot && handleGetBuildManager();
}, 10000);

console.log(responseBuildManager);
if (
!responseBuildManager?.robotClusters?.filter(
(robotCluster: any) => robotCluster?.buildManagerStatus !== "Ready",
Expand Down
8 changes: 4 additions & 4 deletions src/contexts/CreateRobotContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
IRobotData,
IRobotWorkspace,
IRobotWorkspaceRepository,
IWorkspace,
IWorkspaceRepository,
} from "../interfaces/robotInterfaces";
import React, { createContext, useEffect, useState } from "react";
import { envOnPremiseRobot } from "../helpers/envProvider";
Expand Down Expand Up @@ -124,9 +124,9 @@ export default ({ children }: any) => {
formik: any,
workspaceIndex: number,
): void {
const robotWorkspaces: IRobotWorkspace[] = [...formik.values.workspaces];
const robotWorkspaces: IWorkspace[] = [...formik.values.workspaces];

const robotWorkspace: IRobotWorkspaceRepository = {
const robotWorkspace: IWorkspaceRepository = {
name: "",
url: "",
branch: "",
Expand Down
20 changes: 20 additions & 0 deletions src/contexts/FunctionsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,26 @@ export default ({ children }: any) => {
responseFederatedRobot?.payload?.data[0]?.roboticsClouds[0]
?.cloudInstances[0]?.robolaunchFederatedRobots[0]
?.idePodName,
ideCustomPorts:
responseFederatedRobot?.payload?.data[0]?.roboticsClouds[0]?.cloudInstances[0]?.environments[0]?.ideCustomPorts
?.split("/")
?.map((item: string) => {
return {
name: item?.split("-")[0],
port: item?.split("-")[1].split(":")[1],
backendPort: item?.split("-")[1].split(":")[0],
};
}),
vdiCustomPorts:
responseFederatedRobot?.payload?.data[0]?.roboticsClouds[0]?.cloudInstances[0]?.environments[0]?.vdiCustomPorts
?.split("/")
?.map((item: string) => {
return {
name: item?.split("-")[0],
port: item?.split("-")[1].split(":")[1],
backendPort: item?.split("-")[1].split(":")[0],
};
}),
},
step2: {
workspaces:
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RobotPage/RobotPage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { ReactElement } from "react";
import RosConnector from "../../components/RosConnector/RosConnector";
import RobotHeader from "../../components/RobotHeader/RobotHeader";
import HiddenFrame from "../../components/HiddenFrame/HiddenFrame";
import RobotSubPageLayout from "../../layouts/RobotSubPageLayout";
import { envOnPremiseRobot } from "../../helpers/envProvider";
import { ReactElement } from "react";

export default function RobotPage(): ReactElement {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/validations/AppsValidations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const CFAppStep1Validations = Yup.object().shape({
),
});

export const CreateEnvironmentFormStep2Validations = Yup.object().shape({
export const CFAppStep2Validations = Yup.object().shape({
workspaces: Yup.array().of(
Yup.object().shape({
name: Yup.string().required("Workspace Name is required"),
Expand Down
4 changes: 2 additions & 2 deletions src/validations/RobotsValidations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const ImportRobotSetSidebarState = Yup.object().shape({
fleet: Yup.string().required("Fleet is required."),
});

export const CreateRobotFormStep1Validations = Yup.object().shape({
export const CFRobotStep1Validations = Yup.object().shape({
robotName: Yup.string()
.required("Robot name is required.")
.min(3, "Minimum 3 characters.")
Expand All @@ -32,7 +32,7 @@ export const CreateRobotFormStep1Validations = Yup.object().shape({
}),
});

export const CreateRobotFormStep2Validations = Yup.object().shape({
export const CFRobotStep2Validations = Yup.object().shape({
workspaces: Yup.array().of(
Yup.object().shape({
name: Yup.string().required("Workspace Name is required"),
Expand Down

0 comments on commit 255cdc7

Please sign in to comment.