Unverified Commit fda2de4f authored by Zzm0809's avatar Zzm0809 Committed by GitHub

[Optimization-2757] optimization flink-instance render type (#2852)

* optimization-flink-instance-reg * Spotless Apply * optimization-flink-instance-reg * Spotless Apply --------- Co-authored-by: 's avatarZzm0809 <Zzm0809@users.noreply.github.com>
parent 0e6a80cd
......@@ -791,6 +791,8 @@ export default {
'rc.ci.management': 'Cluster Instance Management',
'rc.ci.modify': 'Modify cluster Instance',
'rc.ci.name': 'Name',
'rc.ci.autoRegisterCannotModify':
'Automatically registered instances can only modify the `JobManger high-availability address` attribute, and others cannot be modified!',
'rc.ci.namePlaceholder': 'Please enter a name!',
'rc.ci.recycle': 'Recycle Flink Cluster Instances',
'rc.ci.recycleConfirm':
......
......@@ -760,6 +760,8 @@ export default {
'rc.ci.management': '集群实例管理',
'rc.ci.modify': '修改集群',
'rc.ci.name': '实例名称',
'rc.ci.autoRegisterCannotModify':
'自动注册的实例仅能修改 `JobManger高可用地址` 属性,其他无法修改!',
'rc.ci.namePlaceholder': '请输入名称!',
'rc.ci.recycle': '回收 Flink 实例',
'rc.ci.recycleConfirm': '确定回收所有自动创建且过期的 Flink 实例吗?',
......
......@@ -17,6 +17,7 @@
*
*/
import { ClusterType } from '@/pages/RegCenter/Cluster/constants';
import { CLUSTER_INSTANCE_TYPE } from '@/pages/RegCenter/Cluster/Instance/components/contants';
import { validatorJMHAAdderess } from '@/pages/RegCenter/Cluster/Instance/components/function';
import { handleAddOrUpdate } from '@/services/BusinessCrud';
......@@ -84,7 +85,7 @@ const EditJobInstanceForm = (props: {
name='type'
label={l('rc.ci.type')}
disabled
options={CLUSTER_INSTANCE_TYPE}
options={CLUSTER_INSTANCE_TYPE([ClusterType.YARN_APPLICATION])}
rules={[{ required: true, message: l('rc.ci.typePlaceholder') }]}
placeholder={l('rc.ci.typePlaceholder')}
/>
......
......@@ -205,7 +205,7 @@ export default () => {
disabled={!HasAuthority('/registration/cluster/instance/edit')}
/>
<Tag color='cyan'>
{CLUSTER_INSTANCE_TYPE.find((record) => item.type === record.value)?.label}
{CLUSTER_INSTANCE_TYPE().find((record) => item.type === record.value)?.label}
</Tag>
<Tag
icon={item.status === 1 ? <CheckCircleOutlined /> : <ExclamationCircleOutlined />}
......
......@@ -17,8 +17,10 @@
*
*/
import { ClusterType } from '@/pages/RegCenter/Cluster/constants';
import { CLUSTER_INSTANCE_TYPE } from '@/pages/RegCenter/Cluster/Instance/components/contants';
import { validatorJMHAAdderess } from '@/pages/RegCenter/Cluster/Instance/components/function';
import { Cluster } from '@/types/RegCenter/data.d';
import { l } from '@/utils/intl';
import {
ProFormGroup,
......@@ -26,16 +28,26 @@ import {
ProFormText,
ProFormTextArea
} from '@ant-design/pro-components';
import { Alert } from 'antd';
import React from 'react';
const InstanceForm = () => {
type InstanceFormProps = {
values: Partial<Cluster.Instance>;
};
const InstanceForm: React.FC<InstanceFormProps> = (props) => {
const { values } = props;
const renderForm = () => {
return (
<>
{values && values.autoRegisters && (
<Alert type={'warning'} message={l('rc.ci.autoRegisterCannotModify')} showIcon />
)}
<ProFormGroup>
<ProFormText
name='name'
label={l('rc.ci.name')}
width='md'
disabled={values && values.autoRegisters}
rules={[{ required: true, message: l('rc.ci.namePlaceholder') }]}
placeholder={l('rc.ci.namePlaceholder')}
/>
......@@ -44,6 +56,7 @@ const InstanceForm = () => {
name='alias'
label={l('rc.ci.alias')}
width='sm'
disabled={values && values.autoRegisters}
placeholder={l('rc.ci.aliasPlaceholder')}
/>
......@@ -51,7 +64,8 @@ const InstanceForm = () => {
name='type'
label={l('rc.ci.type')}
width='sm'
options={CLUSTER_INSTANCE_TYPE}
disabled={values && values.autoRegisters}
options={CLUSTER_INSTANCE_TYPE([ClusterType.YARN_APPLICATION])}
rules={[{ required: true, message: l('rc.ci.typePlaceholder') }]}
placeholder={l('rc.ci.typePlaceholder')}
/>
......@@ -72,6 +86,7 @@ const InstanceForm = () => {
/>
<ProFormTextArea
name='note'
disabled={values && values.autoRegisters}
label={l('global.table.note')}
width='md'
placeholder={l('global.table.notePlaceholder')}
......
......@@ -109,7 +109,7 @@ const InstanceModal: React.FC<InstanceModalProps> = (props) => {
submitter={{ render: () => [...renderFooter()] }}
initialValues={value}
>
<InstanceForm />
<InstanceForm values={value} />
</ModalForm>
</>
);
......
......@@ -25,33 +25,36 @@ import { DefaultOptionType } from 'rc-select/es/Select';
/**
* Cluster instance type
*/
export const CLUSTER_INSTANCE_TYPE: DefaultOptionType[] = [
{
value: ClusterType.STANDALONE,
label: 'Standalone',
key: ClusterType.STANDALONE
},
{
value: ClusterType.YARN_SESSION,
label: 'Yarn Session',
key: ClusterType.YARN_SESSION
},
{
value: ClusterType.KUBERNETES_SESSION,
label: 'Kubernetes Session',
key: ClusterType.KUBERNETES_SESSION
},
{
value: ClusterType.YARN_APPLICATION,
label: 'Yarn Application',
key: ClusterType.YARN_APPLICATION
},
{
value: ClusterType.LOACL,
label: 'Local',
key: ClusterType.LOACL
}
];
export const CLUSTER_INSTANCE_TYPE = (hiddenOptions: string[] = []): DefaultOptionType[] => {
const returnResult: DefaultOptionType[] = [
{
value: ClusterType.STANDALONE,
label: 'Standalone',
key: ClusterType.STANDALONE
},
{
value: ClusterType.YARN_SESSION,
label: 'Yarn Session',
key: ClusterType.YARN_SESSION
},
{
value: ClusterType.KUBERNETES_SESSION,
label: 'Kubernetes Session',
key: ClusterType.KUBERNETES_SESSION
},
{
value: ClusterType.YARN_APPLICATION,
label: 'Yarn Application',
key: ClusterType.YARN_APPLICATION
},
{
value: ClusterType.LOCAL,
label: 'Local',
key: ClusterType.LOCAL
}
];
return returnResult.filter((item) => !hiddenOptions.includes(item.value as string));
};
/**
* Cluster instance status enum
......
......@@ -25,5 +25,5 @@ export enum ClusterType {
KUBERNETES_NATIVE = 'kubernetes-application',
KUBERNETES_OPERATOR = 'kubernetes-application-operator',
YARN_APPLICATION = 'yarn-application',
LOACL = 'local'
LOCAL = 'local'
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment