chore: default cluster by state
This commit is contained in:
+1
-3
@@ -64,9 +64,7 @@ export async function getInitialState(): Promise<{
|
||||
message.error({
|
||||
content: (
|
||||
<div>
|
||||
<span>{data?.message || 'Please login again.'}</span>
|
||||
<br />
|
||||
<div>Please contact the administrator.</div>
|
||||
<span>{data?.message}</span>
|
||||
</div>
|
||||
),
|
||||
duration: 5
|
||||
|
||||
@@ -9,7 +9,7 @@ export interface CredentialFormData {
|
||||
id?: number;
|
||||
}
|
||||
|
||||
export type ClusterStatusType = 0 | 1 | 3;
|
||||
export type ClusterStatusType = 'provisioning' | 'provisioned' | 'ready';
|
||||
|
||||
export interface CredentialListItem {
|
||||
id: number;
|
||||
|
||||
@@ -2,7 +2,7 @@ import ModalFooter from '@/components/modal-footer';
|
||||
import GSDrawer from '@/components/scroller-modal/gs-drawer';
|
||||
import { PageActionType } from '@/config/types';
|
||||
import { createAxiosToken } from '@/hooks/use-chunk-request';
|
||||
import { ProviderValueMap } from '@/pages/cluster-management/config';
|
||||
import { ClusterStatusValueMap } from '@/pages/cluster-management/config';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Button } from 'antd';
|
||||
import _ from 'lodash';
|
||||
@@ -356,10 +356,9 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
|
||||
const initClusterId = () => {
|
||||
const cluster_id =
|
||||
clusterList?.find((item) => item.provider === ProviderValueMap.Docker)
|
||||
?.value || clusterList?.[0]?.value;
|
||||
clusterList?.find((item) => item.state === ClusterStatusValueMap.Ready)
|
||||
?.value || '';
|
||||
|
||||
console.log('cluster_id:', cluster_id);
|
||||
return cluster_id;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import ModalFooter from '@/components/modal-footer';
|
||||
import GSDrawer from '@/components/scroller-modal/gs-drawer';
|
||||
import { PageActionType } from '@/config/types';
|
||||
import useDeferredRequest from '@/hooks/use-deferred-request';
|
||||
import { ProviderValueMap } from '@/pages/cluster-management/config';
|
||||
import { ClusterStatusValueMap } from '@/pages/cluster-management/config';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { useMemoizedFn } from 'ahooks';
|
||||
import { Button } from 'antd';
|
||||
@@ -440,8 +440,8 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
return initialValues.cluster_id;
|
||||
}
|
||||
const cluster_id =
|
||||
clusterList?.find((item) => item.provider === ProviderValueMap.Docker)
|
||||
?.value || clusterList?.[0]?.value;
|
||||
clusterList?.find((item) => item.state === ClusterStatusValueMap.Ready)
|
||||
?.value || '';
|
||||
|
||||
return cluster_id;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { clusterListAtom } from '@/atoms/models';
|
||||
import { queryClusterList } from '@/pages/cluster-management/apis';
|
||||
import {
|
||||
ClusterStatusLabelMap,
|
||||
ClusterStatusValueMap
|
||||
} from '@/pages/cluster-management/config';
|
||||
import { ClusterListItem } from '@/pages/cluster-management/config/types';
|
||||
import { queryWorkersList } from '@/pages/resources/apis';
|
||||
import {
|
||||
@@ -245,8 +249,12 @@ export default function useFormInitialValues() {
|
||||
perPage: 100
|
||||
});
|
||||
const list = response.items.map((item) => ({
|
||||
label: item.name,
|
||||
label:
|
||||
item.state === ClusterStatusValueMap.Ready
|
||||
? item.name
|
||||
: `${item.name} [${ClusterStatusLabelMap[item.state]}]`,
|
||||
value: item.id,
|
||||
disabled: item.state !== ClusterStatusValueMap.Ready,
|
||||
provider: item.provider as string,
|
||||
state: item.state
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user