Skip to content

Commit

Permalink
[Fix] Fix k8s application type can not render (DataLinkDC#3202)
Browse files Browse the repository at this point in the history
Co-authored-by: Zzm0809 <[email protected]>
  • Loading branch information
2 people authored and gaoyan1998 committed Mar 19, 2024
1 parent ddbe868 commit 3ef825c
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
*
*/

import { ClusterType } from '@/pages/RegCenter/Cluster/constants';
import { CLUSTER_INSTANCE_TYPE } from '@/pages/RegCenter/Cluster/Instance/components/contants';
import { CLUSTER_INSTANCE_TYPE } from '@/pages/RegCenter/Cluster/constants';
import { validatorJMHAAdderess } from '@/pages/RegCenter/Cluster/Instance/components/function';
import { handleAddOrUpdate } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints';
Expand Down Expand Up @@ -85,7 +84,7 @@ const EditJobInstanceForm = (props: {
name='type'
label={l('rc.ci.type')}
disabled
options={CLUSTER_INSTANCE_TYPE([ClusterType.YARN_APPLICATION])}
options={CLUSTER_INSTANCE_TYPE()}
rules={[{ required: true, message: l('rc.ci.typePlaceholder') }]}
placeholder={l('rc.ci.typePlaceholder')}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { DataAction } from '@/components/StyledComponents';
import { Authorized, HasAuthority } from '@/hooks/useAccess';
import { imgStyle } from '@/pages/Home/constants';
import ConfigurationModal from '@/pages/RegCenter/Cluster/Configuration/components/ConfigurationModal';
import { CLUSTER_CONFIG_TYPE } from '@/pages/RegCenter/Cluster/Configuration/components/contants';
import { CLUSTER_TYPE_OPTIONS } from '@/pages/RegCenter/Cluster/constants';
import {
handleAddOrUpdate,
handleOption,
Expand Down Expand Up @@ -237,7 +237,7 @@ export default () => {
disabled={!HasAuthority(PermissionConstants.REGISTRATION_CLUSTER_CONFIG_EDIT)}
/>
<Tag color='cyan'>
{CLUSTER_CONFIG_TYPE.find((record) => item.type === record.value)?.label}
{CLUSTER_TYPE_OPTIONS.find((record) => item.type === record.value)?.label}
</Tag>
<Tag
icon={item.isAvailable ? <CheckCircleOutlined /> : <ExclamationCircleOutlined />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

import { CLUSTER_CONFIG_TYPE } from '@/pages/RegCenter/Cluster/Configuration/components/contants';
import { ClusterType, CLUSTER_CONFIG_TYPE } from '@/pages/RegCenter/Cluster/constants';
import { l } from '@/utils/intl';
import {
ProFormDigit,
Expand All @@ -38,7 +38,11 @@ const BaseConfig: React.FC = () => {
name='type'
label={l('rc.cc.type')}
width='md'
options={CLUSTER_CONFIG_TYPE}
options={CLUSTER_CONFIG_TYPE([
ClusterType.KUBERNETES_OPERATOR,
ClusterType.KUBERNETES_APPLICATION,
ClusterType.YARN
])}
rules={[{ required: true, message: l('rc.cc.typePlaceholder') }]}
placeholder={l('rc.cc.typePlaceholder')}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const FlinkK8s = (props: { type: string; value: any; form: FormInstance<Values>
<Row gutter={[16, 16]}>
<Col span={10}>
<ProFormGroup>
{type && type === ClusterType.KUBERNETES_NATIVE && (
{type && type === ClusterType.KUBERNETES_APPLICATION && (
<ProFormSelect
name={[
'config',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,7 @@
*/

import { FormConfig } from '@/pages/RegCenter/Cluster/Configuration/components/data';
import { ClusterType } from '@/pages/RegCenter/Cluster/constants';
import { l } from '@/utils/intl';
import { DefaultOptionType } from 'rc-select/es/Select';

/**
* Cluster config type
*/
export const CLUSTER_CONFIG_TYPE: DefaultOptionType[] = [
{
value: ClusterType.YARN,
label: 'Flink On Yarn',
key: ClusterType.YARN
},
{
value: ClusterType.KUBERNETES_NATIVE,
label: 'Kubernetes Native',
key: ClusterType.KUBERNETES_NATIVE
},
{
value: ClusterType.KUBERNETES_OPERATOR,
label: 'Kubernetes Operator',
key: ClusterType.KUBERNETES_OPERATOR
}
];

export const FLINK_CONFIG_LIST: FormConfig[] = [
{
Expand Down Expand Up @@ -82,52 +59,6 @@ export const FLINK_CONFIG_LIST: FormConfig[] = [
}
];

export const DOCKER_CONFIG_LIST: FormConfig[] = [
{
name: 'dinky.remote.addr',
label: l('rc.cc.docker.dinky.addr'),
placeholder: l('rc.cc.docker.dinky.addrHelp'),
tooltip: l('rc.cc.docker.dinky.addrHelp'),
defaultValue: '127.0.0.1:8888'
},
{
name: 'docker.instance',
label: l('rc.cc.docker.instance'),
placeholder: l('rc.cc.docker.instanceHelp'),
tooltip: l('rc.cc.docker.instanceHelp')
},
{
name: 'docker.registry.url',
label: l('rc.cc.docker.url'),
placeholder: l('rc.cc.docker.urlHelp'),
tooltip: l('rc.cc.docker.urlHelp')
},
{
name: 'docker.registry.username',
label: l('rc.cc.docker.username'),
placeholder: l('rc.cc.docker.usernameHelp'),
tooltip: l('rc.cc.docker.usernameHelp')
},
{
name: 'docker.registry.password',
label: l('rc.cc.docker.password'),
placeholder: l('rc.cc.docker.passwordHelp'),
tooltip: l('rc.cc.docker.passwordHelp')
},
{
name: 'docker.image.tag',
label: l('rc.cc.docker.tag'),
placeholder: l('rc.cc.docker.tagHelp'),
tooltip: l('rc.cc.docker.tagHelp')
},
{
name: 'docker.image.dockerfile',
label: l('rc.cc.docker.file'),
placeholder: l('rc.cc.docker.fileHelp'),
tooltip: l('rc.cc.docker.fileHelp')
}
];

export const KUBERNETES_CONFIG_LIST: FormConfig[] = [
{
name: 'kubernetes.namespace',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { EnableSwitchBtn } from '@/components/CallBackButton/EnableSwitchBtn';
import { PopconfirmDeleteBtn } from '@/components/CallBackButton/PopconfirmDeleteBtn';
import { Authorized, HasAuthority } from '@/hooks/useAccess';
import useHookRequest from '@/hooks/useHookRequest';
import { CLUSTER_INSTANCE_TYPE } from '@/pages/RegCenter/Cluster/Instance/components/contants';
import { CLUSTER_TYPE_OPTIONS } from '@/pages/RegCenter/Cluster/constants';
import { renderWebUiRedirect } from '@/pages/RegCenter/Cluster/Instance/components/function';
import InstanceModal from '@/pages/RegCenter/Cluster/Instance/components/InstanceModal';
import { getData } from '@/services/api';
Expand Down Expand Up @@ -237,7 +237,7 @@ export default () => {
disabled={!HasAuthority(PermissionConstants.REGISTRATION_CLUSTER_INSTANCE_EDIT)}
/>
<Tag color='cyan'>
{CLUSTER_INSTANCE_TYPE().find((record) => item.type === record.value)?.label}
{CLUSTER_TYPE_OPTIONS.find((record) => item.type === record.value)?.label}
</Tag>
<Tag
icon={item.status === 1 ? <CheckCircleOutlined /> : <ExclamationCircleOutlined />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
*
*/

import { ClusterType } from '@/pages/RegCenter/Cluster/constants';
import { CLUSTER_INSTANCE_TYPE } from '@/pages/RegCenter/Cluster/Instance/components/contants';
import { ClusterType, CLUSTER_INSTANCE_TYPE } from '@/pages/RegCenter/Cluster/constants';
import { validatorJMHAAdderess } from '@/pages/RegCenter/Cluster/Instance/components/function';
import { Cluster } from '@/types/RegCenter/data.d';
import { l } from '@/utils/intl';
Expand Down Expand Up @@ -65,7 +64,11 @@ const InstanceForm: React.FC<InstanceFormProps> = (props) => {
label={l('rc.ci.type')}
width='sm'
disabled={values && values.autoRegisters}
options={CLUSTER_INSTANCE_TYPE([ClusterType.YARN_APPLICATION])}
options={CLUSTER_INSTANCE_TYPE([
ClusterType.YARN_APPLICATION,
ClusterType.KUBERNETES_OPERATOR,
ClusterType.KUBERNETES_APPLICATION
])}
rules={[{ required: true, message: l('rc.ci.typePlaceholder') }]}
placeholder={l('rc.ci.typePlaceholder')}
/>
Expand Down

This file was deleted.

58 changes: 57 additions & 1 deletion dinky-web/src/pages/RegCenter/Cluster/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,69 @@
*
*/

import { DefaultOptionType } from 'rc-select/es/Select';

export enum ClusterType {
STANDALONE = 'standalone',
YARN = 'yarn-application',
YARN_SESSION = 'yarn-session',
KUBERNETES_SESSION = 'kubernetes-session',
KUBERNETES_NATIVE = 'kubernetes-application',
KUBERNETES_APPLICATION = 'kubernetes-application',
KUBERNETES_OPERATOR = 'kubernetes-application-operator',
YARN_APPLICATION = 'yarn-application',
LOCAL = 'local'
}

export const CLUSTER_TYPE_OPTIONS: 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.KUBERNETES_APPLICATION,
label: 'Kubernetes Application',
key: ClusterType.KUBERNETES_APPLICATION
},
{
value: ClusterType.KUBERNETES_OPERATOR,
label: 'Kubernetes Operator',
key: ClusterType.KUBERNETES_OPERATOR
},
{
value: ClusterType.YARN_APPLICATION,
label: 'Yarn Application',
key: ClusterType.YARN_APPLICATION
},
{
value: ClusterType.LOCAL,
label: 'Local',
key: ClusterType.LOCAL
}
];

/**
* Cluster instance type
*/
export const CLUSTER_INSTANCE_TYPE = (hiddenOptions: string[] = []): DefaultOptionType[] => {
return CLUSTER_TYPE_OPTIONS.filter((item) => !hiddenOptions.includes(item.value as string));
};

/**
* Cluster config type
* @param renderOptions
* @constructor
*/
export const CLUSTER_CONFIG_TYPE = (renderOptions: string[] = []): DefaultOptionType[] => {
return CLUSTER_TYPE_OPTIONS.filter((item) => renderOptions.includes(item.value as string));
};

0 comments on commit 3ef825c

Please sign in to comment.