bfg-common 1.3.538 → 1.3.540

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.
@@ -42,8 +42,12 @@ export const checkValidityName = async (
42
42
  return { valid: true, msg: null }
43
43
  }
44
44
 
45
- export const validateNameAndGenerateDataId = (name: string, _errorMessage: string): string => {
46
- let baseDataId = 'storage-name-alert-error'
45
+ export const validateNameAndGenerateDataId = (
46
+ name: string,
47
+ _errorMessage: string,
48
+ defaultDataId?: string
49
+ ): string => {
50
+ let baseDataId = defaultDataId || 'storage-name-alert-error'
47
51
 
48
52
  const patterns = [
49
53
  {
@@ -55,14 +59,13 @@ export const validateNameAndGenerateDataId = (name: string, _errorMessage: strin
55
59
  {
56
60
  regex: /^.{3,64}$/,
57
61
  error_message:
58
- /invalid name length, must be between: \d+ and \d+ characters/,
62
+ /invalid name length, must be between: \d+ and \d+ characters/,
59
63
  suffix: '-invalid-name-length',
60
64
  },
61
65
  ]
62
66
 
63
67
  // Проверка error_message на соответствие шаблонам
64
68
 
65
-
66
69
  for (const pattern of patterns) {
67
70
  if (!pattern.regex.test(name)) {
68
71
  return `${baseDataId}${pattern.suffix}`
@@ -2,7 +2,7 @@
2
2
  <div class="device-selection">
3
3
  <atoms-alert
4
4
  v-show="errors.length"
5
- test-id="device-selection-alert-error"
5
+ :test-id="errorAlertDataId"
6
6
  status="alert-danger"
7
7
  :items="errors"
8
8
  @remove="onCloseAlertDanger"
@@ -119,6 +119,7 @@ import {
119
119
  import { defaultFormFunc } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/config/defaultForm'
120
120
  import { hostsOptionsFunc } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/config/selectOptions'
121
121
  import { checkValidityName } from '~/components/common/wizards/datastore/add/lib/utils'
122
+ import { validateNameAndGenerateDataId } from '~/components/common/wizards/datastore/add/lib/utils'
122
123
 
123
124
  const props = defineProps<{
124
125
  mode: UI_T_WizardDatastoreMode
@@ -178,6 +179,7 @@ const onHideAlertInfo = (): void => {
178
179
  }
179
180
 
180
181
  const errors = ref<string[]>([])
182
+ const errorAlertDataId = ref<string>('device-selection-alert-error')
181
183
  const formErrors = ref<UI_I_ValidationTouchResult[]>([])
182
184
 
183
185
  /* Lun disk table */
@@ -246,7 +248,14 @@ const showValidationErrors = (
246
248
  errorText = '',
247
249
  alert = false
248
250
  ): void => {
249
- if (alert) errors.value = [errorText]
251
+ if (alert) {
252
+ errors.value = [errorText]
253
+ errorAlertDataId.value = validateNameAndGenerateDataId(
254
+ form.value.name.value,
255
+ errorText,
256
+ errorAlertDataId.value
257
+ )
258
+ }
250
259
  formErrors.value = data
251
260
  }
252
261
 
@@ -326,11 +335,11 @@ const submit = async (): Promise<void> => {
326
335
  : validatePropertiesForSphere()
327
336
 
328
337
  if (!valid.isValid || isShowAlertDanger) {
329
- const isModeSphere = mode === 'sphere' && props.datastoreType === 'local'
338
+ const isModeSphere = mode === 'sphere'
330
339
 
331
340
  const errorText =
332
341
  localization.value[
333
- isModeSphere ? 'selectHostToContinueAlert' : validationTextForSphere()
342
+ isModeSphere ? validationTextForSphere() : 'selectDiskToContinueAlert'
334
343
  ]
335
344
 
336
345
  showValidationErrors(valid, errorText, isShowAlertDanger)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.3.538",
4
+ "version": "1.3.540",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",