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 { useAtom } from 'jotai';
|
||||
import _ from 'lodash';
|
||||
import React, {
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState
|
||||
} from 'react';
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import {
|
||||
createCluster,
|
||||
@@ -61,6 +55,9 @@ const MainWrapper = styled.div`
|
||||
|
||||
const ClusterCreate: React.FC<{
|
||||
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;
|
||||
setCurrentTitle?: (title: string) => void;
|
||||
onClose?: () => void;
|
||||
@@ -71,7 +68,9 @@ const ClusterCreate: React.FC<{
|
||||
const [credentialList, setCredentialList] = useState<
|
||||
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<{
|
||||
token: string;
|
||||
image: string;
|
||||
@@ -85,7 +84,7 @@ const ClusterCreate: React.FC<{
|
||||
cluster_id: 0
|
||||
});
|
||||
const [extraData, setExtraData] = useState<ClusterFormData>({
|
||||
provider: ProviderValueMap.Docker
|
||||
provider: (providerHint as ProviderType) ?? ProviderValueMap.Docker
|
||||
} as ClusterFormData);
|
||||
const [formValues, setFormValues] = useState<Record<string, any>>({});
|
||||
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
|
||||
@@ -218,12 +217,6 @@ const ClusterCreate: React.FC<{
|
||||
fetchData();
|
||||
}, []);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (providerHint) {
|
||||
handleSelectProvider(providerHint);
|
||||
}
|
||||
}, [providerHint]);
|
||||
|
||||
const renderForms = () => {
|
||||
const step = steps[currentStep];
|
||||
const formKeys = step?.showForms || [];
|
||||
@@ -368,6 +361,11 @@ const ClusterCreate: React.FC<{
|
||||
>
|
||||
<div style={{ flex: 1 }}>
|
||||
{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
|
||||
cols={2}
|
||||
dataList={providerList}
|
||||
|
||||
@@ -62,7 +62,12 @@ const ClusterSteps: React.FC<{
|
||||
.map((step, index) => {
|
||||
return {
|
||||
..._.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) => {
|
||||
return JSON.stringify(
|
||||
{
|
||||
name: instanceType.name,
|
||||
spec: {
|
||||
...instanceType.spec
|
||||
}
|
||||
},
|
||||
null,
|
||||
2
|
||||
);
|
||||
return JSON.stringify({
|
||||
name: instanceType.name,
|
||||
spec: {
|
||||
...instanceType.spec
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// apply the selection of instance type and template
|
||||
|
||||
Reference in New Issue
Block a user