fix: success message in creation cluster

This commit is contained in:
jialin
2026-02-08 10:27:49 +08:00
parent 21ffd2a564
commit f35ba8f8e5
7 changed files with 76 additions and 36 deletions
@@ -1,11 +1,11 @@
import useAddWorkerMessage from '@/pages/cluster-management/hooks/use-add-worker-message';
import { useIntl } from '@umijs/max';
import { Alert } from 'antd';
import React, { useMemo } from 'react';
import styled from 'styled-components';
import { ProviderType, ProviderValueMap } from '../../config';
import { ClusterListItem } from '../../config/types';
import { AddWorkerContext } from './add-worker-context';
import AddedMessage from './added-message';
import CheckEnvironment from './check-environment';
import { StepName, StepNamesMap } from './config';
import DockerRunCommand from './docker-run-command';
@@ -90,23 +90,6 @@ const AddWorkerSteps: React.FC<AddWorkerProps> = (props) => {
}
}, [actionSource, registrationInfo?.cluster_id]);
const renderMessage = (count: number) => {
if (count === 1) {
return intl.formatMessage(
{
id: 'clusters.addworker.message.success_single'
},
{ count: addedCount }
);
}
return intl.formatMessage(
{
id: 'clusters.addworker.message.success_multiple'
},
{ count: addedCount }
);
};
const disabled = useMemo(() => {
return (
stepList.includes(StepNamesMap.SelectCluster) && !clusterList?.length
@@ -154,17 +137,8 @@ const AddWorkerSteps: React.FC<AddWorkerProps> = (props) => {
)}
</>
)}
{addedCount > 0 && (
<Alert
style={{
textAlign: 'left',
borderColor: 'var(--ant-color-success)',
width: '100%'
}}
type="success"
title={renderMessage(addedCount)}
closable
/>
{actionSource === 'modal' && (
<AddedMessage addedCount={addedCount}></AddedMessage>
)}
</Container>
</AddWorkerContext.Provider>
@@ -0,0 +1,39 @@
import { useIntl } from '@umijs/max';
import { Alert } from 'antd';
import React from 'react';
const AddedMessage: React.FC<{ addedCount: number }> = ({ addedCount }) => {
const intl = useIntl();
const renderMessage = (count: number) => {
if (count === 1) {
return intl.formatMessage(
{
id: 'clusters.addworker.message.success_single'
},
{ count: addedCount }
);
}
return intl.formatMessage(
{
id: 'clusters.addworker.message.success_multiple'
},
{ count: addedCount }
);
};
return addedCount > 0 ? (
<Alert
style={{
textAlign: 'left',
fontWeight: 400,
borderColor: 'var(--ant-color-success)',
width: '100%'
}}
type="success"
title={renderMessage(addedCount)}
closable
/>
) : null;
};
export default AddedMessage;
@@ -1,14 +1,18 @@
import { workerAddedCountAtom } from '@/atoms/clusters';
import { ArrowLeftOutlined, ArrowRightOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button } from 'antd';
import { useAtom } from 'jotai';
import styled from 'styled-components';
import AddedMessage from './add-worker/added-message';
const Title = styled.span`
display: flex;
align-items: center;
justify-content: flex-end;
justify-content: space-between;
font-weight: 700;
font-size: 16px;
gap: 16px;
padding-inline: 24px;
.text {
font-size: 20px;
@@ -33,11 +37,15 @@ const FooterButtons: React.FC<FooterButtonsProps> = (props) => {
loading
} = props;
const intl = useIntl();
const [addedCount] = useAtom(workerAddedCountAtom);
const handleOnNext = () => {
onNext();
};
return (
<Title style={{ padding: '16px 24px 24px' }}>
<div className="added-msge">
<AddedMessage addedCount={addedCount} />
</div>
<div className="flex-center gap-20">
{showButtons.previous && (
<Button