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