diff --git a/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-app/app-compute.tsx b/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-app/app-compute.tsx index d0f17c73a..1df4ae993 100644 --- a/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-app/app-compute.tsx +++ b/src/apps/console/routes/_main+/$account+/$project+/$environment+/new-app/app-compute.tsx @@ -7,13 +7,15 @@ import Yup from '~/root/lib/server/helpers/yup'; import { FadeIn, parseValue } from '~/console/page-components/util'; import Select from '~/components/atoms/select'; import ExtendedFilledTab from '~/console/components/extended-filled-tab'; -import { parseNodes } from '~/console/server/r-utils/common'; +import {parseName, parseNodes} from '~/console/server/r-utils/common'; import useCustomSwr from '~/lib/client/hooks/use-custom-swr'; import { useConsoleApi } from '~/console/server/gql/api-provider'; import { useMapper } from '~/components/utils'; import { registryHost } from '~/lib/configs/base-url.cjs'; import { BottomNavigation } from '~/console/components/commons'; import { plans } from './datas'; +import {useOutletContext } from '@remix-run/react'; +import {IAppContext} from "~/console/routes/_main+/$account+/$project+/$environment+/app+/$app+/_layout"; const valueRender = ({ label, @@ -47,6 +49,8 @@ const AppCompute = () => { getImageTag, } = useAppState(); const api = useConsoleApi(); + const {cluster} = useOutletContext() + const { data, @@ -56,6 +60,14 @@ const AppCompute = () => { return api.listRepo({}); }); + const { + data: nodepoolData, + isLoading: nodepoolLoading, + error: nodepoolLoadingError, + } = useCustomSwr('/nodepools', async () => { + return api.listNodePools({clusterName: parseName(cluster)}) + }) + const { values, errors, handleChange, isLoading, submit } = useForm({ initialValues: { imageUrl: app.spec.containers[activeContIndex]?.image || '', @@ -97,6 +109,8 @@ const AppCompute = () => { app.spec.containers[activeContIndex].resourceMemory?.max, 0 ), + + nodepoolName: app.spec.nodeSelector?.[keyconstants.nodepoolName] || '' }, validationSchema: Yup.object({ pullSecret: Yup.string(), @@ -121,6 +135,10 @@ const AppCompute = () => { }, spec: { ...s.spec, + nodeSelector: { + ...(s.spec.nodeSelector || {}), + [keyconstants.nodepoolName]: val.nodepoolName + }, containers: [ { ...(s.spec.containers?.[0] || {}), @@ -166,6 +184,11 @@ const AppCompute = () => { accName: val.accountName, })); + const nodepools = useMapper(parseNodes(nodepoolData), (val) => ({ + label: val.metadata?.name || '', + value: val.metadata?.name || '', + })) + const { data: digestData, isLoading: digestLoading, @@ -196,6 +219,24 @@ const AppCompute = () => { manipulation and calculations in a system.
+ + { const { app, setPage, resetState } = useAppState(); @@ -114,12 +115,19 @@ const AppReview = () => {
- {}}> +
+
+ Nodepool Selector +
+
{app.spec.nodeSelector[keyconstants.nodepoolName]}
+
+
+ { setPage(3); - }} - > + }}>
diff --git a/src/apps/console/routes/_main+/$account+/$project+/new-managed-service/_index.tsx b/src/apps/console/routes/_main+/$account+/$project+/new-managed-service/_index.tsx index 776ec3e4c..b7aa7d629 100644 --- a/src/apps/console/routes/_main+/$account+/$project+/new-managed-service/_index.tsx +++ b/src/apps/console/routes/_main+/$account+/$project+/new-managed-service/_index.tsx @@ -14,7 +14,7 @@ import { import { Switch } from '~/components/atoms/switch'; import { NumberInput, TextInput } from '~/components/atoms/input'; import { handleError } from '~/root/lib/utils/common'; -import { titleCase } from '~/components/utils'; +import {titleCase, useMapper} from '~/components/utils'; import { flatMapValidations, flatM } from '~/console/utils/commons'; import MultiStepProgress, { useMultiStepProgress, @@ -25,6 +25,10 @@ import { ReviewComponent, } from '~/console/components/commons'; import { IProjectContext } from '../_layout'; +import {parseName, parseNodes} from "~/console/server/r-utils/common"; +import useCustomSwr from "~/lib/client/hooks/use-custom-swr"; +import {INodepools} from "~/console/server/gql/queries/nodepool-queries"; +import {keyconstants} from "~/console/server/r-utils/key-constants"; const valueRender = ({ label, icon }: { label: string; icon: string }) => { return ( @@ -239,6 +243,7 @@ const TemplateView = ({ const FieldView = ({ selectedTemplate, + nodepools, values, handleSubmit, handleChange, @@ -249,6 +254,7 @@ const FieldView = ({ values: Record; errors: Record; selectedTemplate: ISelectedTemplate | null; + nodepools: {label: string, value: string}[] }) => { const nameRef = useRef(null); useEffect(() => { @@ -276,6 +282,21 @@ const FieldView = ({ handleChange={handleChange} nameErrorLabel="isNameError" /> + +