Skip to content

Commit a9fe3cb

Browse files
committed
refactor: refactored some functions and field names
1 parent b4b4173 commit a9fe3cb

File tree

15 files changed

+84
-68
lines changed

15 files changed

+84
-68
lines changed

console/ui/.eslintrc.cjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@ module.exports = {
2222
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
2323
'@typescript-eslint/no-misused-promises': 'off',
2424
'@typescript-eslint/no-unsafe-argument': 'off',
25-
'react-hooks/exhaustive-deps': 'off',
2625
},
2726
};
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export const DATABASE_SERVERS_FIELD_NAMES = Object.freeze({
2-
IS_CLUSTER_EXISTS: 'existingCluster',
2+
IS_CLUSTER_EXISTS: 'databaseServerExistingCluster',
33
DATABASE_SERVERS: 'databaseServers',
44
DATABASE_HOSTNAME: 'databaseServerHostname',
5-
IP_ADDRESS: 'databaseServerIpAddress',
6-
LOCATION: 'location',
7-
IS_POSTGRESQL_EXISTS: 'isPostgreSQLExist',
5+
DATABASE_IP_ADDRESS: 'databaseServerIpAddress',
6+
DATABASE_LOCATION: 'databaseServerLocation',
7+
IS_POSTGRESQL_EXISTS: 'databaseServerIsPostgreSQLExist',
88
});

console/ui/src/entities/cluster/database-servers-block/model/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export interface DatabaseServerBlockValues {
1010
[DATABASE_SERVERS_FIELD_NAMES.IS_CLUSTER_EXISTS]?: boolean;
1111
[DATABASE_SERVERS_FIELD_NAMES.DATABASE_SERVERS]: {
1212
[DATABASE_SERVERS_FIELD_NAMES.DATABASE_HOSTNAME]: string;
13-
[DATABASE_SERVERS_FIELD_NAMES.IP_ADDRESS]: string;
14-
[DATABASE_SERVERS_FIELD_NAMES.LOCATION]: string;
13+
[DATABASE_SERVERS_FIELD_NAMES.DATABASE_IP_ADDRESS]: string;
14+
[DATABASE_SERVERS_FIELD_NAMES.DATABASE_LOCATION]: string;
1515
[DATABASE_SERVERS_FIELD_NAMES.IS_POSTGRESQL_EXISTS]?: boolean;
1616
}[];
1717
}

console/ui/src/entities/cluster/database-servers-block/model/validation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ export const databaseServersBlockValidation = (t: TFunction) =>
1616
[DATABASE_SERVERS_FIELD_NAMES.DATABASE_HOSTNAME]: yup
1717
.string()
1818
.required(t('requiredField', { ns: 'validation' })),
19-
[DATABASE_SERVERS_FIELD_NAMES.IP_ADDRESS]: yup
19+
[DATABASE_SERVERS_FIELD_NAMES.DATABASE_IP_ADDRESS]: yup
2020
.string()
2121
.required(t('requiredField', { ns: 'validation' }))
2222
.test('should be a correct IP', t('shouldBeACorrectV4Ip', { ns: 'validation' }), (value) =>
2323
ipRegex.v4({ exact: true }).test(value),
2424
),
25-
[DATABASE_SERVERS_FIELD_NAMES.LOCATION]: yup.string(),
25+
[DATABASE_SERVERS_FIELD_NAMES.DATABASE_LOCATION]: yup.string(),
2626
}),
2727
)
2828
: schema.notRequired(),

console/ui/src/entities/cluster/database-servers-block/ui/DatabaseServerBox.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const DatabaseServerBox: FC<DatabaseServerBlockProps> = ({ index, remove }) => {
4949
/>
5050
<Controller
5151
control={control}
52-
name={`${DATABASE_SERVERS_FIELD_NAMES.DATABASE_SERVERS}.${index}.${DATABASE_SERVERS_FIELD_NAMES.IP_ADDRESS}`}
52+
name={`${DATABASE_SERVERS_FIELD_NAMES.DATABASE_SERVERS}.${index}.${DATABASE_SERVERS_FIELD_NAMES.DATABASE_IP_ADDRESS}`}
5353
render={({ field: { value, onChange } }) => (
5454
<TextField
5555
required
@@ -59,20 +59,20 @@ const DatabaseServerBox: FC<DatabaseServerBlockProps> = ({ index, remove }) => {
5959
label={t('ipAddress', { ns: 'clusters' })}
6060
error={
6161
!!errors[DATABASE_SERVERS_FIELD_NAMES.DATABASE_SERVERS]?.[index]?.[
62-
DATABASE_SERVERS_FIELD_NAMES.IP_ADDRESS
62+
DATABASE_SERVERS_FIELD_NAMES.DATABASE_IP_ADDRESS
6363
]
6464
}
6565
helperText={
6666
errors?.[DATABASE_SERVERS_FIELD_NAMES.DATABASE_SERVERS]?.[index]?.[
67-
DATABASE_SERVERS_FIELD_NAMES.IP_ADDRESS
67+
DATABASE_SERVERS_FIELD_NAMES.DATABASE_IP_ADDRESS
6868
]?.message ?? ' '
6969
}
7070
/>
7171
)}
7272
/>
7373
<Controller
7474
control={control}
75-
name={`${DATABASE_SERVERS_FIELD_NAMES.DATABASE_SERVERS}.${index}.${DATABASE_SERVERS_FIELD_NAMES.LOCATION}`}
75+
name={`${DATABASE_SERVERS_FIELD_NAMES.DATABASE_SERVERS}.${index}.${DATABASE_SERVERS_FIELD_NAMES.DATABASE_LOCATION}`}
7676
render={({ field: { value, onChange } }) => (
7777
<TextField
7878
value={value}

console/ui/src/entities/cluster/expert-mode/dcs-block/model/const.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const DCS_DATABASES_DEFAULT_VALUES = Object.freeze({
1414
[DCS_BLOCK_FIELD_NAMES.DCS_DATABASE_PORT]: '2379',
1515
});
1616

17-
export const DCS_TYPES = Object.freeze(['etcd', 'consul']);
17+
export const DCS_TYPES = Object.freeze({ ETCD: 'etcd', CONSUL: 'consul' });
1818

1919
export const getCorrectFields = ({ watchIsDeployToDcsCluster, watchIsDeployToDbServers, watchDcsType, t }) => {
2020
const fields = [];
@@ -24,7 +24,7 @@ export const getCorrectFields = ({ watchIsDeployToDcsCluster, watchIsDeployToDbS
2424
fieldName: DCS_BLOCK_FIELD_NAMES.DCS_DATABASE_IP_ADDRESS,
2525
label: t('ipAddress'),
2626
});
27-
if (watchDcsType === DCS_TYPES[0]) {
27+
if (watchDcsType === DCS_TYPES.ETCD) {
2828
fields.push({ fieldName: DCS_BLOCK_FIELD_NAMES.DCS_DATABASE_PORT, label: t('port') });
2929
}
3030
}

console/ui/src/entities/cluster/expert-mode/dcs-block/ui/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const DcsBlock: FC = () => {
6262
<FormControl fullWidth size="small">
6363
<InputLabel size="small">{t('dcsType')}</InputLabel>
6464
<Select {...field} size="small" label={t('dcsType')} error={!!errors[DCS_BLOCK_FIELD_NAMES.TYPE]}>
65-
{DCS_TYPES.map((mode) => (
65+
{Object.values(DCS_TYPES).map((mode) => (
6666
<MenuItem key={mode} value={mode}>
6767
{mode}
6868
</MenuItem>
-5.86 KB
Binary file not shown.
-19.9 KB
Binary file not shown.
-24.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)