fix: remove description json format
This commit is contained in:
@@ -5,13 +5,7 @@ import { ColumnWrapper } from '@gpustack/core-ui';
|
|||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, {
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
useEffect,
|
|
||||||
useLayoutEffect,
|
|
||||||
useMemo,
|
|
||||||
useRef,
|
|
||||||
useState
|
|
||||||
} from 'react';
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import {
|
import {
|
||||||
createCluster,
|
createCluster,
|
||||||
@@ -61,6 +55,9 @@ const MainWrapper = styled.div`
|
|||||||
|
|
||||||
const ClusterCreate: React.FC<{
|
const ClusterCreate: React.FC<{
|
||||||
action: PageActionType;
|
action: PageActionType;
|
||||||
|
// Preselect a provider and skip the provider-catalog step. Set by
|
||||||
|
// empty-state CTAs that already know which kind of cluster the user
|
||||||
|
// is heading for (e.g. GPU Service's "Add a Kubernetes Cluster").
|
||||||
providerHint?: string;
|
providerHint?: string;
|
||||||
setCurrentTitle?: (title: string) => void;
|
setCurrentTitle?: (title: string) => void;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
@@ -71,7 +68,9 @@ const ClusterCreate: React.FC<{
|
|||||||
const [credentialList, setCredentialList] = useState<
|
const [credentialList, setCredentialList] = useState<
|
||||||
Global.BaseOption<number, { provider: ProviderType }>[]
|
Global.BaseOption<number, { provider: ProviderType }>[]
|
||||||
>([]);
|
>([]);
|
||||||
const [currentStep, setCurrentStep] = useState<number>(0);
|
// When the caller already picked a provider for us, start one step
|
||||||
|
// in — provider catalog is step 0; configure is step 1.
|
||||||
|
const [currentStep, setCurrentStep] = useState<number>(providerHint ? 1 : 0);
|
||||||
const [registrationInfo, setRegistrationInfo] = useState<{
|
const [registrationInfo, setRegistrationInfo] = useState<{
|
||||||
token: string;
|
token: string;
|
||||||
image: string;
|
image: string;
|
||||||
@@ -85,7 +84,7 @@ const ClusterCreate: React.FC<{
|
|||||||
cluster_id: 0
|
cluster_id: 0
|
||||||
});
|
});
|
||||||
const [extraData, setExtraData] = useState<ClusterFormData>({
|
const [extraData, setExtraData] = useState<ClusterFormData>({
|
||||||
provider: ProviderValueMap.Docker
|
provider: (providerHint as ProviderType) ?? ProviderValueMap.Docker
|
||||||
} as ClusterFormData);
|
} as ClusterFormData);
|
||||||
const [formValues, setFormValues] = useState<Record<string, any>>({});
|
const [formValues, setFormValues] = useState<Record<string, any>>({});
|
||||||
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
|
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
|
||||||
@@ -218,12 +217,6 @@ const ClusterCreate: React.FC<{
|
|||||||
fetchData();
|
fetchData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
if (providerHint) {
|
|
||||||
handleSelectProvider(providerHint);
|
|
||||||
}
|
|
||||||
}, [providerHint]);
|
|
||||||
|
|
||||||
const renderForms = () => {
|
const renderForms = () => {
|
||||||
const step = steps[currentStep];
|
const step = steps[currentStep];
|
||||||
const formKeys = step?.showForms || [];
|
const formKeys = step?.showForms || [];
|
||||||
@@ -368,6 +361,11 @@ const ClusterCreate: React.FC<{
|
|||||||
>
|
>
|
||||||
<div style={{ flex: 1 }}>
|
<div style={{ flex: 1 }}>
|
||||||
{currentStep === 0 && (
|
{currentStep === 0 && (
|
||||||
|
// Catalog belongs to step 0 only. The previous gate used
|
||||||
|
// ``startStep`` which is 1 when ``providerHint`` skips the
|
||||||
|
// catalog — that wrongly re-rendered it on top of the
|
||||||
|
// configure form for entry points like "Add a Kubernetes
|
||||||
|
// Cluster".
|
||||||
<ProviderCatalog
|
<ProviderCatalog
|
||||||
cols={2}
|
cols={2}
|
||||||
dataList={providerList}
|
dataList={providerList}
|
||||||
|
|||||||
@@ -62,7 +62,12 @@ const ClusterSteps: React.FC<{
|
|||||||
.map((step, index) => {
|
.map((step, index) => {
|
||||||
return {
|
return {
|
||||||
..._.pick(step, ANTD_STEP_KEYS),
|
..._.pick(step, ANTD_STEP_KEYS),
|
||||||
subTitle: index === 0 ? <span>[{props.selectedProvider}]</span> : ''
|
subTitle:
|
||||||
|
index === 0 && props.selectedProvider ? (
|
||||||
|
<span>[{props.selectedProvider}]</span>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -115,16 +115,12 @@ const AddModal: React.FC<AddModalProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveInstanceDataInDescription = (instanceType: InstanceTypeItem) => {
|
const saveInstanceDataInDescription = (instanceType: InstanceTypeItem) => {
|
||||||
return JSON.stringify(
|
return JSON.stringify({
|
||||||
{
|
name: instanceType.name,
|
||||||
name: instanceType.name,
|
spec: {
|
||||||
spec: {
|
...instanceType.spec
|
||||||
...instanceType.spec
|
}
|
||||||
}
|
});
|
||||||
},
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// apply the selection of instance type and template
|
// apply the selection of instance type and template
|
||||||
|
|||||||
Reference in New Issue
Block a user