bfg-common 1.5.490 → 1.5.492
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/common/backup/storage/actions/add/Add.vue +251 -248
- package/components/common/backup/storage/actions/add/lib/utils.ts +62 -30
- package/components/common/backup/storage/actions/add/lib/validations.ts +16 -8
- package/components/common/vm/actions/add/Add.vue +2 -2
- package/components/common/vm/actions/add/New.vue +1 -1
- package/components/common/vm/actions/add/Old.vue +1 -1
- package/components/common/vm/actions/add/lib/config/steps.ts +347 -331
- package/components/common/vm/actions/clone/Clone.vue +1 -1
- package/components/common/vm/actions/clone/toTemplate/ToTemplate.vue +1 -1
- package/components/common/vm/actions/common/select/name/Name.vue +6 -6
- package/components/common/vm/actions/common/select/name/New.vue +3 -4
- package/components/common/vm/actions/common/select/name/Old.vue +4 -5
- package/components/common/vm/actions/register/Register.vue +1 -1
- package/components/common/wizards/datastore/add/Add.vue +228 -224
- package/components/common/wizards/datastore/add/lib/utils.ts +93 -63
- package/components/common/wizards/datastore/add/lib/validations.ts +16 -8
- package/package.json +1 -1
- package/components/common/vmt/actions/add/Add.vue +0 -549
- package/components/common/vmt/actions/add/New.vue +0 -346
- package/components/common/vmt/actions/add/Old.vue +0 -305
- package/components/common/vmt/actions/add/lib/config/steps.ts +0 -107
- package/components/common/vmt/actions/add/lib/models/interfaces.ts +0 -23
|
@@ -1,63 +1,93 @@
|
|
|
1
|
-
import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
|
|
2
|
-
import type { API_UI_I_Error } from '~/lib/models/store/interfaces'
|
|
3
|
-
import type { UI_T_Project } from '~/lib/models/types'
|
|
4
|
-
import { UI_E_Kind } from '~/lib/models/enums'
|
|
5
|
-
|
|
6
|
-
export const checkValidityName = async (
|
|
7
|
-
name
|
|
8
|
-
wizard
|
|
9
|
-
project
|
|
10
|
-
sendMessage
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
|
|
2
|
+
import type { API_UI_I_Error } from '~/lib/models/store/interfaces'
|
|
3
|
+
import type { UI_T_Project } from '~/lib/models/types'
|
|
4
|
+
import { UI_E_Kind } from '~/lib/models/enums'
|
|
5
|
+
|
|
6
|
+
export const checkValidityName = async ({
|
|
7
|
+
name,
|
|
8
|
+
wizard,
|
|
9
|
+
project,
|
|
10
|
+
sendMessage,
|
|
11
|
+
datacenterId,
|
|
12
|
+
}: {
|
|
13
|
+
name: string
|
|
14
|
+
wizard: Wizard
|
|
15
|
+
project: UI_T_Project
|
|
16
|
+
sendMessage: (message: string) => void
|
|
17
|
+
datacenterId?: string
|
|
18
|
+
}): Promise<void> => {
|
|
19
|
+
wizard.setLoader(true)
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const url = buildValidationUrl(name, project, datacenterId)
|
|
23
|
+
|
|
24
|
+
const { error } = await useMyFetch<null, API_UI_I_Error>(url, {
|
|
25
|
+
method: 'GET',
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
if (error?.value?.data?.error_code !== 0) {
|
|
29
|
+
const existError =
|
|
30
|
+
error.value.data?.error_message ?? String(error.value.data)
|
|
31
|
+
sendMessage(existError)
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
sendMessage('')
|
|
36
|
+
} catch (e) {
|
|
37
|
+
const msg = e instanceof Error ? e.message : 'Unknown error'
|
|
38
|
+
sendMessage(msg)
|
|
39
|
+
} finally {
|
|
40
|
+
wizard.setLoader(false)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const buildValidationUrl = (
|
|
45
|
+
name: string,
|
|
46
|
+
project: UI_T_Project,
|
|
47
|
+
datacenterId?: string
|
|
48
|
+
): string => {
|
|
49
|
+
if (project === 'procurator') {
|
|
50
|
+
const params = new URLSearchParams({ name })
|
|
51
|
+
return `/ui/ds/validate?${params.toString()}`
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const params = new URLSearchParams()
|
|
55
|
+
params.set('name', name)
|
|
56
|
+
params.set('kind', String(UI_E_Kind.STORAGE_VALIDATION_NAME))
|
|
57
|
+
if (datacenterId) params.set('datacenter', datacenterId)
|
|
58
|
+
|
|
59
|
+
return `/ui/object/validate_name?${params.toString()}`
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const validateNameAndGenerateDataId = (
|
|
63
|
+
name: string,
|
|
64
|
+
_errorMessage: string,
|
|
65
|
+
defaultDataId?: string
|
|
66
|
+
): string => {
|
|
67
|
+
let baseDataId = defaultDataId || 'storage-name-alert-error'
|
|
68
|
+
|
|
69
|
+
const patterns = [
|
|
70
|
+
{
|
|
71
|
+
regex: /^[a-zA-Z0-9_\-\.]+$/,
|
|
72
|
+
error_message:
|
|
73
|
+
/invalid name, must only contain letters, numbers, and '_', '-' '.' symbols/,
|
|
74
|
+
suffix: '-invalid-name-symbols',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
regex: /^.{3,64}$/,
|
|
78
|
+
error_message:
|
|
79
|
+
/invalid name length, must be between: \d+ and \d+ characters/,
|
|
80
|
+
suffix: '-invalid-name-length',
|
|
81
|
+
},
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
// Проверка error_message на соответствие шаблонам
|
|
85
|
+
|
|
86
|
+
for (const pattern of patterns) {
|
|
87
|
+
if (!pattern.regex.test(name)) {
|
|
88
|
+
return `${baseDataId}${pattern.suffix}`
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return baseDataId
|
|
93
|
+
}
|
|
@@ -13,7 +13,8 @@ const checkName = async (
|
|
|
13
13
|
form: UI_I_CreateDatastoreForm,
|
|
14
14
|
localization: UI_I_Localization,
|
|
15
15
|
wizard: Wizard,
|
|
16
|
-
project: UI_T_Project
|
|
16
|
+
project: UI_T_Project,
|
|
17
|
+
datacenterId?: string
|
|
17
18
|
): Promise<UI_I_AsyncCheckReturn> => {
|
|
18
19
|
const typeCode = form.type_code
|
|
19
20
|
|
|
@@ -26,11 +27,17 @@ const checkName = async (
|
|
|
26
27
|
}
|
|
27
28
|
if (form.name && help) {
|
|
28
29
|
return new Promise((resolve, _reject) =>
|
|
29
|
-
checkValidityName(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
checkValidityName({
|
|
31
|
+
name: form.name,
|
|
32
|
+
wizard,
|
|
33
|
+
project,
|
|
34
|
+
datacenterId,
|
|
35
|
+
sendMessage: (message: string) => {
|
|
36
|
+
resolve({
|
|
37
|
+
isValid: message === '',
|
|
38
|
+
message: message === '' ? '' : message,
|
|
39
|
+
})
|
|
40
|
+
},
|
|
34
41
|
})
|
|
35
42
|
)
|
|
36
43
|
} else {
|
|
@@ -47,14 +54,15 @@ export const checkDatastoreNameAsync = async (
|
|
|
47
54
|
stepId: number,
|
|
48
55
|
fieldName: string,
|
|
49
56
|
wizard: Wizard,
|
|
50
|
-
project: UI_T_Project
|
|
57
|
+
project: UI_T_Project,
|
|
58
|
+
datacenterId?: string
|
|
51
59
|
): Promise<UI_I_ValidationReturn> => {
|
|
52
60
|
let stepHasError = false
|
|
53
61
|
|
|
54
62
|
const labelValidation: {
|
|
55
63
|
isValid: boolean
|
|
56
64
|
message: string
|
|
57
|
-
} = await checkName(form, localization, wizard, project)
|
|
65
|
+
} = await checkName(form, localization, wizard, project, datacenterId)
|
|
58
66
|
|
|
59
67
|
if (!labelValidation.isValid) {
|
|
60
68
|
stepHasError = wizard.setValidation(stepId, fieldName, {
|