}
variant="outline"
onClick={() => {
- setPage('Network');
+ setPage(4);
}}
/>
diff --git a/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-app/route.tsx b/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-app/route.tsx
index 40a42a72f..2bcf367d0 100644
--- a/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-app/route.tsx
+++ b/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-app/route.tsx
@@ -1,85 +1,61 @@
-import { useMapper } from '~/components/utils';
import {
AppContextProvider,
- createAppTabs,
useAppState,
} from '~/console/page-components/app-states';
-import ProgressWrapper from '~/console/components/progress-wrapper';
+import MultiStepProgress, {
+ useMultiStepProgress,
+} from '~/console/components/multi-step-progress';
+import MultiStepProgressWrapper from '~/console/components/multi-step-progress-wrapper';
+import { useEffect } from 'react';
import AppCompute from './app-compute';
import AppDetail from './app-detail';
import AppEnvironment from './app-environment';
import AppNetwork from './app-network';
import AppReview from './app-review';
-import { FadeIn } from '../../../../../../page-components/util';
const AppComp = () => {
const { setPage, page, isPageComplete } = useAppState();
- const isActive = (t: createAppTabs) => t === page;
- const progressItems: {
- label: createAppTabs;
- }[] = [
- {
- label: 'Application details',
- },
- {
- label: 'Compute',
- },
- {
- label: 'Environment',
- },
- {
- label: 'Network',
- },
- {
- label: 'Review',
- },
- ];
-
- const tab = () => {
- switch (page) {
- case 'Application details':
- return
;
- case 'Compute':
- return
;
- case 'Environment':
- return
;
- case 'Network':
- return
;
- case 'Review':
- return
;
- default:
- return (
-
- 404 | page not found
-
- );
- }
- };
-
- const items = useMapper(progressItems, (i) => {
- return {
- label: i.label,
- active: isActive(i.label),
- completed: isPageComplete(i.label),
- children: isActive(i.label) ? tab() : null,
- };
+ const { currentStep, jumpStep } = useMultiStepProgress({
+ defaultStep: page || 1,
+ totalSteps: 5,
});
- return (
-
{
- console.log(p);
+ useEffect(() => {
+ jumpStep(page);
+ }, [page]);
- if (isPageComplete(p.label as createAppTabs))
- setPage(p.label as createAppTabs);
- }}
+ return (
+
+ >
+ setPage(step)}
+ noJump={(step) => !isPageComplete(step)}
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
);
};
diff --git a/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-managed-resource/_index.tsx b/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-managed-resource/_index.tsx
index 0125b5ab6..515b96238 100644
--- a/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-managed-resource/_index.tsx
+++ b/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-managed-resource/_index.tsx
@@ -10,17 +10,10 @@ import {
import { Button } from '~/components/atoms/button';
import Select from '~/components/atoms/select';
import { NameIdView } from '~/console/components/name-id-view';
-import ProgressWrapper from '~/console/components/progress-wrapper';
import { useConsoleApi } from '~/console/server/gql/api-provider';
import useForm, { dummyEvent } from '~/root/lib/client/hooks/use-form';
import Yup from '~/root/lib/server/helpers/yup';
-import {
- Dispatch,
- FormEventHandler,
- SetStateAction,
- useEffect,
- useState,
-} from 'react';
+import { FormEventHandler, useEffect, useState } from 'react';
import { IMSvTemplate } from '~/console/server/gql/queries/managed-templates-queries';
import { Switch } from '~/components/atoms/switch';
import { NumberInput, TextInput } from '~/components/atoms/input';
@@ -37,6 +30,10 @@ import {
} from '~/console/server/r-utils/common';
import { IProjectMSvs } from '~/console/server/gql/queries/project-managed-services-queries';
import { getManagedTemplate } from '~/console/utils/commons';
+import MultiStepProgressWrapper from '~/console/components/multi-step-progress-wrapper';
+import MultiStepProgress, {
+ useMultiStepProgress,
+} from '~/console/components/multi-step-progress';
import { ReviewComponent } from '../new-app/app-review';
import { IProjectContext } from '../../_layout';
@@ -57,11 +54,6 @@ export const loader = (ctx: IRemixCtx) => {
return defer({ promise });
};
-type steps = 'Select service' | 'Configure resource' | 'Review';
-
-const hasResource = (res: any) =>
- (!!res && res?.resource?.fields.length > 0) || !res;
-
const RenderField = ({
field,
value,
@@ -252,7 +244,7 @@ const TemplateView = ({
isLoading,
}: ITemplateView) => {
return (
-