fix: add worker ux when only DO cluster
This commit is contained in:
@@ -236,8 +236,12 @@ const ClusterCreate: React.FC<{
|
||||
|
||||
// add worker or cluster registration step
|
||||
const handleAddWorker = () => {
|
||||
const currentTitle =
|
||||
extraData.provider === ProviderValueMap.Docker
|
||||
? 'resources.button.create'
|
||||
: 'clusters.button.register';
|
||||
setIsAddWorkerStep(true);
|
||||
setCurrentTitle?.(intl.formatMessage({ id: 'resources.button.create' }));
|
||||
setCurrentTitle?.(intl.formatMessage({ id: currentTitle }));
|
||||
onNext();
|
||||
};
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ const ClusterModal: React.FC<ClusterModalProps> = ({
|
||||
body: {
|
||||
paddingBlock: 0
|
||||
},
|
||||
wrapper: { width: 700 }
|
||||
wrapper: { width: 710 }
|
||||
}}
|
||||
footer={false}
|
||||
>
|
||||
|
||||
@@ -52,7 +52,7 @@ const AddCluster: React.FC<AddModalProps> = ({
|
||||
open={open}
|
||||
onCancel={handleCancel}
|
||||
onSubmit={handleSubmit}
|
||||
width={700}
|
||||
width={710}
|
||||
>
|
||||
<ClusterForm
|
||||
ref={form}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import AlertBlockInfo from '@/components/alert-info/block';
|
||||
import useAddWorkerMessage from '@/pages/cluster-management/hooks/use-add-worker-message';
|
||||
import { ExclamationCircleFilled } from '@ant-design/icons';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Alert } from 'antd';
|
||||
import React, { useMemo } from 'react';
|
||||
@@ -135,18 +133,6 @@ const AddWorkerSteps: React.FC<AddWorkerProps> = (props) => {
|
||||
{stepList.includes(StepNamesMap.SelectCluster) && (
|
||||
<SelectCluster disabled={disabled}></SelectCluster>
|
||||
)}
|
||||
{stepList.includes(StepNamesMap.SelectCluster) &&
|
||||
!clusterList?.length && (
|
||||
<AlertBlockInfo
|
||||
maxHeight={200}
|
||||
style={{ marginBottom: 8 }}
|
||||
type="warning"
|
||||
icon={<ExclamationCircleFilled />}
|
||||
message={intl.formatMessage({
|
||||
id: 'resources.worker.noCluster.tips'
|
||||
})}
|
||||
></AlertBlockInfo>
|
||||
)}
|
||||
{/* render the steps only when there is at least one cluster available or cluster selection is not required */}
|
||||
{((clusterList && clusterList.length > 0) ||
|
||||
!stepList.includes(StepNamesMap.SelectCluster)) && (
|
||||
|
||||
@@ -131,7 +131,7 @@ const AddWorker: React.FC<AddWorkerProps> = (props) => {
|
||||
body: {
|
||||
paddingBlock: 0
|
||||
},
|
||||
wrapper: { width: 700 }
|
||||
wrapper: { width: 710 }
|
||||
}}
|
||||
footer={false}
|
||||
>
|
||||
|
||||
@@ -50,11 +50,24 @@ const SelectCluster: React.FC<AddWorkerStepProps> = ({ disabled }) => {
|
||||
{stepIndex}.{' '}
|
||||
{intl.formatMessage({ id: 'clusters.addworker.selectCluster' })}
|
||||
</Title>
|
||||
<span style={{ color: 'var(--ant-color-text-tertiary)' }}>
|
||||
{intl.formatMessage({
|
||||
id: 'clusters.addworker.selectCluster.tips'
|
||||
})}
|
||||
</span>
|
||||
<Typography.Paragraph
|
||||
type="secondary"
|
||||
style={{
|
||||
marginBottom: 0,
|
||||
whiteSpace: 'pre-wrap',
|
||||
lineHeight: 1.2,
|
||||
paddingBlock: 4
|
||||
}}
|
||||
ellipsis={{ rows: 2 }}
|
||||
>
|
||||
<span
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: intl.formatMessage({
|
||||
id: 'clusters.addworker.selectCluster.tips'
|
||||
})
|
||||
}}
|
||||
></span>
|
||||
</Typography.Paragraph>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
|
||||
@@ -69,15 +69,29 @@ const useAddWorker = (props: {
|
||||
item.provider !== ProviderValueMap.Docker
|
||||
};
|
||||
})
|
||||
.filter((item) => item.state === ClusterStatusValueMap.Ready);
|
||||
.filter(
|
||||
(item) =>
|
||||
item.state === ClusterStatusValueMap.Ready &&
|
||||
item.provider === ProviderValueMap.Docker
|
||||
);
|
||||
}, [clusterList]);
|
||||
|
||||
/**
|
||||
* Add Worker only for Docker clusters, for k8s and digitalocean do something in the cluster list page.
|
||||
* @param clusterList
|
||||
* @param includeDigitalOcean
|
||||
* @returns
|
||||
*/
|
||||
const checkDefaultCluster = (
|
||||
clusterList: Global.BaseOption<number, ClusterListItem>[]
|
||||
clusterList: Global.BaseOption<number, ClusterListItem>[],
|
||||
includeDigitalOcean?: boolean
|
||||
) => {
|
||||
// select default and ready cluster first, digitalocean no READY state
|
||||
let currentData = clusterList.find(
|
||||
(item) => item.is_default && item.state === ClusterStatusValueMap.Ready
|
||||
(item) =>
|
||||
item.is_default &&
|
||||
item.state === ClusterStatusValueMap.Ready &&
|
||||
item.provider === ProviderValueMap.Docker
|
||||
);
|
||||
|
||||
if (!currentData) {
|
||||
|
||||
Reference in New Issue
Block a user