bfg-common 1.3.455 → 1.3.457

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.
@@ -55,11 +55,8 @@
55
55
  :datastore-type="datastoreType"
56
56
  :alert-messages="alertMessages[selectedStep.id]"
57
57
  :messages-fields="selectedStep.fields"
58
- :nfs-configuration-submit="nfsConfigurationSubmit"
59
58
  :host-accessibility-submit="hostAccessibilitySubmit"
60
59
  :hosts="props.nfsHosts"
61
- @loading="(e) => (loading = e)"
62
- @change-nfs-version="updateNfsVersion"
63
60
  @submit="saveChangesAndNextNfs"
64
61
  />
65
62
 
@@ -136,7 +133,6 @@ const datastoreType = ref<UI_T_DatastoreType>(
136
133
  // const nfsVersion = ref<UI_T_NfsType>('nfs-3')
137
134
  // const dataReadyView = ref<any>([])
138
135
 
139
-
140
136
  const form = ref<any>({
141
137
  name: '',
142
138
  lunDisk: [],
@@ -170,7 +166,7 @@ const datastoreForm = ref<UI_I_CreateDatastoreForm>({
170
166
  },
171
167
  })
172
168
 
173
- const checkNetwork = async (
169
+ const checkName = async (
174
170
  label: string,
175
171
  localization: UI_I_Localization,
176
172
  wizard: Wizard
@@ -192,11 +188,12 @@ const checkNetwork = async (
192
188
  }
193
189
  }
194
190
  }
195
-
196
- const checkNameAsync = async (
191
+ const checkDatastoreNameAsync = async (
197
192
  localization: UI_I_Localization,
198
193
  value: UI_I_WizardStep[],
199
194
  label: string,
195
+ stepId: number,
196
+ fieldName: string,
200
197
  wizard: Wizard
201
198
  ): Promise<UI_I_ValidationReturn> => {
202
199
  let stepHasError = false
@@ -204,15 +201,15 @@ const checkNameAsync = async (
204
201
  const labelValidation: {
205
202
  isValid: boolean
206
203
  message: string
207
- } = await checkNetwork(label, localization, wizard)
204
+ } = await checkName(label, localization, wizard)
208
205
 
209
206
  if (!labelValidation.isValid) {
210
- stepHasError = wizard.setValidation(1, 'datastoreName', {
207
+ stepHasError = wizard.setValidation(stepId, fieldName, {
211
208
  fieldMessage: labelValidation.message,
212
209
  alertMessage: label ? labelValidation.message : '',
213
210
  })
214
- } else if (wizard.hasMessage(1, 'datastoreName')) {
215
- value = wizard.removeValidation(1, 'datastoreName', value)
211
+ } else if (wizard.hasMessage(stepId, fieldName)) {
212
+ value = wizard.removeValidation(stepId, fieldName, value)
216
213
  }
217
214
 
218
215
  return {
@@ -221,7 +218,7 @@ const checkNameAsync = async (
221
218
  }
222
219
  }
223
220
 
224
- const checkNetwork2 = async (
221
+ const checkNameAndDevice = async (
225
222
  form: any,
226
223
  localization: UI_I_Localization,
227
224
  wizard: Wizard
@@ -245,7 +242,7 @@ const checkNetwork2 = async (
245
242
  }
246
243
  }
247
244
  }
248
- const checkName2Async = async (
245
+ const checkNameAndDeviceAsync = async (
249
246
  localization: UI_I_Localization,
250
247
  value: UI_I_WizardStep[],
251
248
  form: any,
@@ -256,7 +253,7 @@ const checkName2Async = async (
256
253
  const labelValidation: {
257
254
  isValid: boolean
258
255
  message: string
259
- } = await checkNetwork2(form, localization, wizard)
256
+ } = await checkNameAndDevice(form, localization, wizard)
260
257
 
261
258
  if (!labelValidation.isValid) {
262
259
  stepHasError = wizard.setValidation(2, 'datastoreName', {
@@ -273,6 +270,29 @@ const checkName2Async = async (
273
270
  }
274
271
  }
275
272
 
273
+ const checkNfsFolderSync = (
274
+ localization: UI_I_Localization,
275
+ name: string,
276
+ wizard: Wizard,
277
+ value: UI_I_WizardStep[]
278
+ ): UI_I_ValidationReturn => {
279
+ let stepHasError = false
280
+
281
+ if (!name) {
282
+ stepHasError = wizard.setValidation(5, 'folder', {
283
+ fieldMessage: localization.noHostOrClusterSelected,
284
+ alertMessage: '',
285
+ })
286
+ } else if (wizard.hasMessage(5, 'folder')) {
287
+ value = wizard.removeValidation(5, 'folder', value)
288
+ }
289
+
290
+ return {
291
+ newValue: value,
292
+ stepHasError,
293
+ }
294
+ }
295
+
276
296
  const validationFunc = async (
277
297
  value: UI_I_WizardStep[],
278
298
  currentStep: UI_I_WizardStep,
@@ -281,10 +301,12 @@ const validationFunc = async (
281
301
  let stepHasError = false
282
302
 
283
303
  if (wizard.isValidateForStep(1, currentStep.id, nextStep.id)) {
284
- const nameValidation = await checkNameAsync(
304
+ const nameValidation = await checkDatastoreNameAsync(
285
305
  localization.value,
286
306
  value,
287
307
  form.value.name,
308
+ 1,
309
+ 'datastoreName',
288
310
  wizard
289
311
  )
290
312
 
@@ -294,7 +316,7 @@ const validationFunc = async (
294
316
  }
295
317
 
296
318
  if (wizard.isValidateForStep(2, currentStep.id, nextStep.id)) {
297
- const nameValidation = await checkName2Async(
319
+ const nameValidation = await checkNameAndDeviceAsync(
298
320
  localization.value,
299
321
  value,
300
322
  form.value,
@@ -306,6 +328,28 @@ const validationFunc = async (
306
328
  stepHasError = nameValidation.stepHasError
307
329
  }
308
330
 
331
+ if (wizard.isValidateForStep(5, currentStep.id, nextStep.id)) {
332
+ const nameValidation = await checkDatastoreNameAsync(
333
+ localization.value,
334
+ value,
335
+ form.value.name,
336
+ 5,
337
+ 'name',
338
+ wizard
339
+ )
340
+
341
+ value = nameValidation.newValue
342
+
343
+ const folderValidation = checkNfsFolderSync(
344
+ localization.value,
345
+ form.value.folder,
346
+ wizard,
347
+ value
348
+ )
349
+
350
+ stepHasError = folderValidation.stepHasError || nameValidation.stepHasError
351
+ }
352
+
309
353
  return {
310
354
  newValue: value,
311
355
  stepHasError,
@@ -343,50 +387,8 @@ const dataReadyView = computed<UI_I_DetailsItem>(() =>
343
387
  form.value
344
388
  )
345
389
  )
390
+ const onNextStep = (_force = false): void => {}
346
391
 
347
- // let cashStep = -1
348
- const onNextStep = (_force = false): void => {
349
- // const isValid = checkSubmit(force)
350
- //
351
- // if (!isValid) {
352
- // return
353
- // }
354
- //
355
- // const isDisabled = stepItems.value[cashStep]?.disabled
356
- // if (cashStep !== -1 && !isDisabled) {
357
- // stepPosition.value = cashStep
358
- // cashStep = -1
359
- // return
360
- // }
361
- //
362
- // stepItems.value[stepPosition.value].complete = true
363
- // stepItems.value[stepPosition.value + 1].disabled = false
364
- // stepPosition.value++
365
- }
366
-
367
- // const onChangeStep = (key: number): void => {
368
- // if (key < stepPosition.value) {
369
- // stepPosition.value = key
370
- // return
371
- // }
372
- //
373
- // const isValid = checkSubmit()
374
- //
375
- // if (!isValid) {
376
- // cashStep = key
377
- // return
378
- // }
379
- //
380
- // stepPosition.value = key
381
- // }
382
-
383
- const updateNfsVersion = (event: UI_T_NfsType): void => {
384
- // nfsVersion.value = event
385
- const { name, server, folder, hosts } = datastoreForm.value.nfs
386
- saveChangesAndNextNfs({ name, server, folder, hosts }, false)
387
- }
388
-
389
- const nfsConfigurationSubmit = ref<number>(0)
390
392
  const hostAccessibilitySubmit = ref<number>(0)
391
393
 
392
394
  const isWizardModeForSphere = computed<boolean>(
@@ -10,9 +10,7 @@
10
10
  v-model="model"
11
11
  :project="props.project"
12
12
  :alert-messages="props.alertMessages"
13
- :messages-fields="props.selectedStep"
14
- :nfs-configuration-submit="nfsConfigurationSubmit"
15
- @loading="(e) => emits('loading', e)"
13
+ :messages-fields="props.messagesFields"
16
14
  @next="onChangeConfigurationAndNext"
17
15
  />
18
16
 
@@ -46,13 +44,11 @@ const props = defineProps<{
46
44
  datastoreType: UI_T_DatastoreType
47
45
  alertMessages: string[]
48
46
  messagesFields: UI_I_ArbitraryObject<UI_I_ErrorFields>
49
- nfsConfigurationSubmit: number
50
47
  hostAccessibilitySubmit: number
51
48
  hosts?: any
52
49
  }>()
53
50
  const model = defineModel<any>()
54
51
  const emits = defineEmits<{
55
- (event: 'loading', value: boolean): void
56
52
  (event: 'submit', value: UI_I_ConfigurationSendDataNfs): void
57
53
  }>()
58
54
 
@@ -2,11 +2,11 @@
2
2
  <div class="configuration">
3
3
  <div>
4
4
  <atoms-alert
5
- v-show="errors.length"
5
+ v-show="props.alertMessages?.length"
6
6
  test-id="configuration-error"
7
7
  status="alert-danger"
8
- :items="errors"
9
- @remove="onCloseAlertDanger"
8
+ :items="props.alertMessages"
9
+ @remove="onHideAlert"
10
10
  />
11
11
 
12
12
  <atoms-alert
@@ -124,9 +124,9 @@
124
124
  </div>
125
125
 
126
126
  <div v-if="false" class="clr-form-control clr-row mt-1">
127
- <label for="" class="clr-control-label clr-col-md-2">{{
128
- localization.accessMode
129
- }}</label>
127
+ <label for="" class="clr-control-label clr-col-md-2">
128
+ {{ localization.accessMode }}
129
+ </label>
130
130
 
131
131
  <div class="clr-col-md-10 clr-col-12 clr-checkbox-wrapper">
132
132
  <input
@@ -145,54 +145,26 @@
145
145
 
146
146
  <script lang="ts" setup>
147
147
  import type { UI_T_Project } from '~/lib/models/types'
148
- import { UI_I_ValidationTouchResult } from '~/lib/models/plugins/validation/interfaces'
149
148
  import type {
150
149
  UI_I_Localization,
151
150
  UI_I_ArbitraryObject,
152
151
  } from '~/lib/models/interfaces'
153
152
  import type { UI_I_ErrorFields } from '~/components/atoms/wizard/lib/models/interfaces'
154
- import {
155
- UI_I_DataServersListItem,
156
- UI_I_FormValidationConfiguration,
157
- } from '~/components/common/wizards/datastore/add/nfs/configuration/serversList/lib/models/interfaces'
158
- import {
159
- UI_I_ConfigurationSendDataNfs,
160
- UI_I_InitialValidationFields,
161
- } from '~/components/common/wizards/datastoreNew/add/nfs/configuration/lib/models/interfaces'
162
- import { defaultFormFunc } from '~/components/common/wizards/datastore/add/nfs/configuration/lib/config/defaultForm'
163
- import { checkValidityName } from '~/components/common/wizards/datastore/add/lib/utils'
153
+ import type { UI_I_DataServersListItem } from '~/components/common/wizards/datastoreNew/add/nfs/configuration/serversList/lib/models/interfaces'
154
+ import type { UI_I_InitialValidationFields } from '~/components/common/wizards/datastoreNew/add/nfs/configuration/lib/models/interfaces'
164
155
 
165
156
  const props = defineProps<{
166
157
  project: UI_T_Project
167
158
  alertMessages: string[]
168
159
  messagesFields: UI_I_ArbitraryObject<UI_I_ErrorFields>
169
- nfsConfigurationSubmit: number
170
160
  }>()
171
161
  const model = defineModel<any>()
172
162
  const emits = defineEmits<{
173
- (event: 'loading', value: boolean): void
174
- (event: 'next', value: UI_I_ConfigurationSendDataNfs): void
163
+ (event: 'hide-alert', value: number): void
175
164
  }>()
176
165
 
177
166
  const localization = computed<UI_I_Localization>(() => useLocal())
178
- const { $validation } = useNuxtApp()
179
167
 
180
- const validation = $validation.call({})
181
- const defaultForm: UI_I_FormValidationConfiguration = defaultFormFunc(
182
- localization.value
183
- )
184
- const form = ref<UI_I_FormValidationConfiguration>(useDeepCopy(defaultForm))
185
- const setForm = () => {
186
- form.value = useDeepCopy(defaultForm)
187
- validation.setForm(form)
188
- }
189
- setForm()
190
-
191
- const validForm = ref<UI_I_ValidationTouchResult | null>(null)
192
-
193
- const isInitNameValidation = ref<boolean>(false) // Удалить
194
- const isInitFolderValidation = ref<boolean>(false) // Удалить
195
- const isInitServerValidation = ref<boolean>(false) // Удалить
196
168
  const initValidationFields = ref<UI_I_InitialValidationFields>({
197
169
  name: false,
198
170
  folder: false,
@@ -219,7 +191,7 @@ const folderErrorText = computed<string>(() => {
219
191
  }
220
192
 
221
193
  if (!initValidationFields.value.folder) return ''
222
- return !model.value.folder ? localization.value.specifyDatastoreName : ''
194
+ return !model.value.folder ? localization.value.specifyFolderName : ''
223
195
  })
224
196
 
225
197
  /* Validation error text for Server input field */
@@ -230,11 +202,10 @@ const serverErrorText = computed<string>(() => {
230
202
 
231
203
  // if (!initValidationFields.value.server || dataServers.value.length) return ''
232
204
  if (!initValidationFields.value.server) return ''
233
- return !model.value.server ? localization.value.specifyDatastoreName : ''
205
+ return !model.value.server ? localization.value.specifyServerName : ''
234
206
  })
235
207
 
236
208
  const accessMode = ref<boolean>(false)
237
-
238
209
  const dataServers = ref<UI_I_DataServersListItem[]>([])
239
210
  // const onAddServerToList = (): void => {
240
211
  // const { server } = form.value
@@ -261,72 +232,10 @@ const dataServers = ref<UI_I_DataServersListItem[]>([])
261
232
  //
262
233
  // // if (nfsVersion === 'nfs-4.1') server.value = ''
263
234
  // }
264
-
265
- const alertInfo = ref<boolean>(props.project === 'procurator')
266
-
267
- const resetValidation = (): void => {
268
- isInitNameValidation.value =
269
- isInitFolderValidation.value =
270
- isInitServerValidation.value =
271
- false
272
- validForm.value = null
273
- errors.value = []
274
- }
275
-
276
- watch(
277
- () => props.nfsConfigurationSubmit,
278
- () => {
279
- submit()
280
- }
281
- )
282
- const submit = async (): Promise<void> => {
283
- const { name, server, folder } = form.value
284
-
285
- validForm.value = validation.touch()
286
- isInitNameValidation.value =
287
- isInitFolderValidation.value =
288
- isInitServerValidation.value =
289
- true
290
-
291
- if (nameErrorText.value || folderErrorText.value || serverErrorText.value) {
292
- return
293
- }
294
-
295
- emits('loading', true)
296
-
297
- const { valid, msg } = await checkValidityName(name.value, props.project)
298
-
299
- emits('loading', false)
300
-
301
- if (!valid) {
302
- showValidationErrors(msg)
303
- return
304
- }
305
-
306
- // if (server.value) onAddServerToList()
307
-
308
- resetValidation()
309
-
310
- const configurationData: UI_I_ConfigurationSendDataNfs = {
311
- name: name.value,
312
- folder: folder.value,
313
- server: server.value,
314
- }
315
-
316
- emits('next', configurationData)
317
- // if (props.nfsVersion !== 'nfs-4.1') {
318
- // dataServers.value = []
319
- // }
320
- }
321
-
322
- const errors = ref<string[]>([])
323
-
324
- const showValidationErrors = (errorText: string): void => {
325
- errors.value = [errorText]
326
- }
327
- const onCloseAlertDanger = (): void => {
328
- errors.value = []
235
+ const onHideAlert = (): void => {
236
+ emits('hide-alert', 5)
329
237
  }
238
+ const alertInfo = ref<boolean>(props.project === 'procurator')
330
239
  </script>
331
240
 
332
241
  <style lang="scss" scoped>
@@ -1,11 +1,3 @@
1
- import { UI_I_Validation } from '~/lib/models/plugins/validation/interfaces'
2
-
3
- export interface UI_I_FormValidationConfiguration {
4
- name: UI_I_Validation
5
- folder: UI_I_Validation
6
- server: UI_I_Validation
7
- }
8
-
9
1
  export interface UI_I_DataServersListItem {
10
2
  server_name: string
11
3
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.3.455",
4
+ "version": "1.3.457",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",
@@ -1,33 +0,0 @@
1
- import { UI_I_Localization } from '~/lib/models/interfaces'
2
-
3
- export const defaultFormFunc = (localization: UI_I_Localization): any => {
4
- return {
5
- name: {
6
- value: 'Datastore',
7
- validations: [
8
- {
9
- value: 'required',
10
- errorText: localization.specifyDatastoreName,
11
- },
12
- ],
13
- },
14
- folder: {
15
- value: '',
16
- validations: [
17
- {
18
- value: 'required',
19
- errorText: localization.specifyFolderName,
20
- },
21
- ],
22
- },
23
- server: {
24
- value: '',
25
- validations: [
26
- {
27
- value: 'required',
28
- errorText: localization.specifyServerName,
29
- },
30
- ],
31
- },
32
- }
33
- }