bfg-common 1.5.392 → 1.5.394

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.
@@ -1,234 +1,242 @@
1
- import type Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
2
- import type { UI_T_Project } from '~/lib/models/types'
3
- import type { UI_I_Localization } from '~/lib/models/interfaces'
4
- import type {
5
- UI_I_AsyncCheckReturn,
6
- UI_I_ValidationReturn,
7
- UI_I_WizardStep,
8
- } from '~/components/atoms/wizard/lib/models/interfaces'
9
- import type { UI_I_CreateDatastoreForm } from '~/components/common/backup/storage/actions/add/lib/models/interfaces'
10
- import { checkValidityName } from '~/components/common/backup/storage/actions/add/lib/utils'
11
- import { dynamicSteps } from '~/components/common/backup/storage/actions/add/lib/config/steps'
12
-
13
- const checkName = async (
14
- form: UI_I_CreateDatastoreForm,
15
- localization: UI_I_Localization,
16
- wizard: Wizard,
17
- project: UI_T_Project
18
- ): Promise<UI_I_AsyncCheckReturn> => {
19
- if (form.name) {
20
- return new Promise((resolve, _reject) =>
21
- checkValidityName(form.name, wizard, project, (message: string) => {
22
- resolve({
23
- isValid: message === '',
24
- message: message === '' ? '' : message,
25
- })
26
- })
27
- )
28
- } else {
29
- return {
30
- isValid: false,
31
- message: !form.name ? localization.common.fieldRequired : '',
32
- }
33
- }
34
- }
35
- export const checkDatastoreNameAsync = async (
36
- localization: UI_I_Localization,
37
- value: UI_I_WizardStep[],
38
- form: UI_I_CreateDatastoreForm,
39
- stepId: number,
40
- fieldName: string,
41
- wizard: Wizard,
42
- project: UI_T_Project
43
- ): Promise<UI_I_ValidationReturn> => {
44
- let stepHasError = false
45
-
46
- const labelValidation: {
47
- isValid: boolean
48
- message: string
49
- } = await checkName(form, localization, wizard, project)
50
-
51
- if (!labelValidation.isValid) {
52
- stepHasError = wizard.setValidation(stepId, fieldName, {
53
- fieldMessage: labelValidation.message,
54
- alertMessage: form.name ? labelValidation.message : '',
55
- })
56
- } else if (wizard.hasMessage(stepId, fieldName)) {
57
- value = wizard.removeValidation(stepId, fieldName, value)
58
- }
59
-
60
- return {
61
- newValue: value,
62
- stepHasError,
63
- }
64
- }
65
-
66
- export const checkFolderSync = (
67
- localization: UI_I_Localization,
68
- name: string,
69
- wizard: Wizard,
70
- value: UI_I_WizardStep[]
71
- ): UI_I_ValidationReturn => {
72
- let stepHasError = false
73
-
74
- if (!name) {
75
- stepHasError = wizard.setValidation(
76
- dynamicSteps.nameAndConfigure,
77
- 'folder',
78
- {
79
- fieldMessage: localization.common.fieldRequired,
80
- alertMessage: '',
81
- }
82
- )
83
- } else if (wizard.hasMessage(dynamicSteps.nameAndConfigure, 'folder')) {
84
- value = wizard.removeValidation(
85
- dynamicSteps.nameAndConfigure,
86
- 'folder',
87
- value
88
- )
89
- }
90
-
91
- return {
92
- newValue: value,
93
- stepHasError,
94
- }
95
- }
96
-
97
- export const checkServerSync = (
98
- localization: UI_I_Localization,
99
- name: string,
100
- wizard: Wizard,
101
- value: UI_I_WizardStep[]
102
- ): UI_I_ValidationReturn => {
103
- let stepHasError = false
104
-
105
- if (!name) {
106
- stepHasError = wizard.setValidation(
107
- dynamicSteps.nameAndConfigure,
108
- 'server',
109
- {
110
- fieldMessage: localization.common.fieldRequired,
111
- alertMessage: '',
112
- }
113
- )
114
- } else if (wizard.hasMessage(dynamicSteps.nameAndConfigure, 'server')) {
115
- value = wizard.removeValidation(
116
- dynamicSteps.nameAndConfigure,
117
- 'server',
118
- value
119
- )
120
- }
121
-
122
- return {
123
- newValue: value,
124
- stepHasError,
125
- }
126
- }
127
-
128
- export const checkUsernameSync = (
129
- localization: UI_I_Localization,
130
- name: string,
131
- wizard: Wizard,
132
- value: UI_I_WizardStep[]
133
- ): UI_I_ValidationReturn => {
134
- let stepHasError = false
135
-
136
- if (!name) {
137
- stepHasError = wizard.setValidation(
138
- dynamicSteps.nameAndConfigure,
139
- 'user',
140
- {
141
- fieldMessage: localization.common.fieldRequired,
142
- alertMessage: '',
143
- }
144
- )
145
- } else if (wizard.hasMessage(dynamicSteps.nameAndConfigure, 'user')) {
146
- value = wizard.removeValidation(
147
- dynamicSteps.nameAndConfigure,
148
- 'user',
149
- value
150
- )
151
- }
152
-
153
- return {
154
- newValue: value,
155
- stepHasError,
156
- }
157
- }
158
-
159
- export const checkPasswordSync = (
160
- localization: UI_I_Localization,
161
- name: string,
162
- wizard: Wizard,
163
- value: UI_I_WizardStep[]
164
- ): UI_I_ValidationReturn => {
165
- let stepHasError = false
166
-
167
- if (!name) {
168
- stepHasError = wizard.setValidation(
169
- dynamicSteps.nameAndConfigure,
170
- 'password',
171
- {
172
- fieldMessage: localization.common.fieldRequired,
173
- alertMessage: '',
174
- }
175
- )
176
- } else if (wizard.hasMessage(dynamicSteps.nameAndConfigure, 'password')) {
177
- value = wizard.removeValidation(
178
- dynamicSteps.nameAndConfigure,
179
- 'password',
180
- value
181
- )
182
- }
183
-
184
- return {
185
- newValue: value,
186
- stepHasError,
187
- }
188
- }
189
-
190
- export const checkHostsAccessibilitySync = (
191
- localization: UI_I_Localization,
192
- hosts: string[],
193
- wizard: Wizard,
194
- value: UI_I_WizardStep[]
195
- ): UI_I_ValidationReturn => {
196
- let stepHasError = false
197
-
198
- if (!hosts.length) {
199
- stepHasError = wizard.setValidation(dynamicSteps.hostAccessibility, 'hostsAccessibility', {
200
- fieldMessage: '',
201
- alertMessage: localization.common.selectLeastEntityContinue,
202
- })
203
- } else if (wizard.hasMessage(dynamicSteps.hostAccessibility, 'hostsAccessibility')) {
204
- value = wizard.removeValidation(dynamicSteps.hostAccessibility, 'hostsAccessibility', value)
205
- }
206
-
207
- return {
208
- newValue: value,
209
- stepHasError,
210
- }
211
- }
212
-
213
- export const checkStorageSync = (
214
- localization: UI_I_Localization,
215
- storm_id: string,
216
- wizard: Wizard,
217
- value: UI_I_WizardStep[]
218
- ): UI_I_ValidationReturn => {
219
- let stepHasError = false
220
-
221
- if (!storm_id) {
222
- stepHasError = wizard.setValidation(dynamicSteps.storage, 'storage', {
223
- fieldMessage: '',
224
- alertMessage: localization.common.selectValidDestinationStorage,
225
- })
226
- } else if (wizard.hasMessage(dynamicSteps.storage, 'storage')) {
227
- value = wizard.removeValidation(dynamicSteps.storage, 'storage', value)
228
- }
229
-
230
- return {
231
- newValue: value,
232
- stepHasError,
233
- }
234
- }
1
+ import type Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
2
+ import type { UI_T_Project } from '~/lib/models/types'
3
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
4
+ import type {
5
+ UI_I_AsyncCheckReturn,
6
+ UI_I_ValidationReturn,
7
+ UI_I_WizardStep,
8
+ } from '~/components/atoms/wizard/lib/models/interfaces'
9
+ import type { UI_I_CreateDatastoreForm } from '~/components/common/backup/storage/actions/add/lib/models/interfaces'
10
+ import { checkValidityName } from '~/components/common/backup/storage/actions/add/lib/utils'
11
+ import { dynamicSteps } from '~/components/common/backup/storage/actions/add/lib/config/steps'
12
+
13
+ const checkName = async (
14
+ form: UI_I_CreateDatastoreForm,
15
+ localization: UI_I_Localization,
16
+ wizard: Wizard,
17
+ project: UI_T_Project
18
+ ): Promise<UI_I_AsyncCheckReturn> => {
19
+ if (form.name) {
20
+ return new Promise((resolve, _reject) =>
21
+ checkValidityName(form.name, wizard, project, (message: string) => {
22
+ resolve({
23
+ isValid: message === '',
24
+ message: message === '' ? '' : message,
25
+ })
26
+ })
27
+ )
28
+ } else {
29
+ return {
30
+ isValid: false,
31
+ message: !form.name ? localization.common.fieldRequired : '',
32
+ }
33
+ }
34
+ }
35
+ export const checkDatastoreNameAsync = async (
36
+ localization: UI_I_Localization,
37
+ value: UI_I_WizardStep[],
38
+ form: UI_I_CreateDatastoreForm,
39
+ stepId: number,
40
+ fieldName: string,
41
+ wizard: Wizard,
42
+ project: UI_T_Project
43
+ ): Promise<UI_I_ValidationReturn> => {
44
+ let stepHasError = false
45
+
46
+ const labelValidation: {
47
+ isValid: boolean
48
+ message: string
49
+ } = await checkName(form, localization, wizard, project)
50
+
51
+ if (!labelValidation.isValid) {
52
+ stepHasError = wizard.setValidation(stepId, fieldName, {
53
+ fieldMessage: labelValidation.message,
54
+ alertMessage: form.name ? labelValidation.message : '',
55
+ })
56
+ } else if (wizard.hasMessage(stepId, fieldName)) {
57
+ value = wizard.removeValidation(stepId, fieldName, value)
58
+ }
59
+
60
+ return {
61
+ newValue: value,
62
+ stepHasError,
63
+ }
64
+ }
65
+
66
+ export const checkFolderSync = (
67
+ localization: UI_I_Localization,
68
+ name: string,
69
+ wizard: Wizard,
70
+ value: UI_I_WizardStep[]
71
+ ): UI_I_ValidationReturn => {
72
+ let stepHasError = false
73
+
74
+ if (!name) {
75
+ stepHasError = wizard.setValidation(
76
+ dynamicSteps.nameAndConfigure,
77
+ 'folder',
78
+ {
79
+ fieldMessage: localization.common.fieldRequired,
80
+ alertMessage: '',
81
+ }
82
+ )
83
+ } else if (wizard.hasMessage(dynamicSteps.nameAndConfigure, 'folder')) {
84
+ value = wizard.removeValidation(
85
+ dynamicSteps.nameAndConfigure,
86
+ 'folder',
87
+ value
88
+ )
89
+ }
90
+
91
+ return {
92
+ newValue: value,
93
+ stepHasError,
94
+ }
95
+ }
96
+
97
+ export const checkServerSync = (
98
+ localization: UI_I_Localization,
99
+ name: string,
100
+ wizard: Wizard,
101
+ value: UI_I_WizardStep[]
102
+ ): UI_I_ValidationReturn => {
103
+ let stepHasError = false
104
+
105
+ if (!name) {
106
+ stepHasError = wizard.setValidation(
107
+ dynamicSteps.nameAndConfigure,
108
+ 'server',
109
+ {
110
+ fieldMessage: localization.common.fieldRequired,
111
+ alertMessage: '',
112
+ }
113
+ )
114
+ } else if (wizard.hasMessage(dynamicSteps.nameAndConfigure, 'server')) {
115
+ value = wizard.removeValidation(
116
+ dynamicSteps.nameAndConfigure,
117
+ 'server',
118
+ value
119
+ )
120
+ }
121
+
122
+ return {
123
+ newValue: value,
124
+ stepHasError,
125
+ }
126
+ }
127
+
128
+ // PC-2542
129
+ // export const checkUsernameSync = (
130
+ // localization: UI_I_Localization,
131
+ // name: string,
132
+ // wizard: Wizard,
133
+ // value: UI_I_WizardStep[]
134
+ // ): UI_I_ValidationReturn => {
135
+ // let stepHasError = false
136
+ //
137
+ // if (!name) {
138
+ // stepHasError = wizard.setValidation(dynamicSteps.nameAndConfigure, 'user', {
139
+ // fieldMessage: localization.common.fieldRequired,
140
+ // alertMessage: '',
141
+ // })
142
+ // } else if (wizard.hasMessage(dynamicSteps.nameAndConfigure, 'user')) {
143
+ // value = wizard.removeValidation(
144
+ // dynamicSteps.nameAndConfigure,
145
+ // 'user',
146
+ // value
147
+ // )
148
+ // }
149
+ //
150
+ // return {
151
+ // newValue: value,
152
+ // stepHasError,
153
+ // }
154
+ // }
155
+
156
+ // PC-2542
157
+ // export const checkPasswordSync = (
158
+ // localization: UI_I_Localization,
159
+ // name: string,
160
+ // wizard: Wizard,
161
+ // value: UI_I_WizardStep[]
162
+ // ): UI_I_ValidationReturn => {
163
+ // let stepHasError = false
164
+ //
165
+ // if (!name) {
166
+ // stepHasError = wizard.setValidation(
167
+ // dynamicSteps.nameAndConfigure,
168
+ // 'password',
169
+ // {
170
+ // fieldMessage: localization.common.fieldRequired,
171
+ // alertMessage: '',
172
+ // }
173
+ // )
174
+ // } else if (wizard.hasMessage(dynamicSteps.nameAndConfigure, 'password')) {
175
+ // value = wizard.removeValidation(
176
+ // dynamicSteps.nameAndConfigure,
177
+ // 'password',
178
+ // value
179
+ // )
180
+ // }
181
+ //
182
+ // return {
183
+ // newValue: value,
184
+ // stepHasError,
185
+ // }
186
+ // }
187
+
188
+ export const checkHostsAccessibilitySync = (
189
+ localization: UI_I_Localization,
190
+ hosts: string[],
191
+ wizard: Wizard,
192
+ value: UI_I_WizardStep[]
193
+ ): UI_I_ValidationReturn => {
194
+ let stepHasError = false
195
+
196
+ if (!hosts.length) {
197
+ stepHasError = wizard.setValidation(
198
+ dynamicSteps.hostAccessibility,
199
+ 'hostsAccessibility',
200
+ {
201
+ fieldMessage: '',
202
+ alertMessage: localization.common.selectLeastEntityContinue,
203
+ }
204
+ )
205
+ } else if (
206
+ wizard.hasMessage(dynamicSteps.hostAccessibility, 'hostsAccessibility')
207
+ ) {
208
+ value = wizard.removeValidation(
209
+ dynamicSteps.hostAccessibility,
210
+ 'hostsAccessibility',
211
+ value
212
+ )
213
+ }
214
+
215
+ return {
216
+ newValue: value,
217
+ stepHasError,
218
+ }
219
+ }
220
+
221
+ export const checkStorageSync = (
222
+ localization: UI_I_Localization,
223
+ storm_id: string,
224
+ wizard: Wizard,
225
+ value: UI_I_WizardStep[]
226
+ ): UI_I_ValidationReturn => {
227
+ let stepHasError = false
228
+
229
+ if (!storm_id) {
230
+ stepHasError = wizard.setValidation(dynamicSteps.storage, 'storage', {
231
+ fieldMessage: '',
232
+ alertMessage: localization.common.selectValidDestinationStorage,
233
+ })
234
+ } else if (wizard.hasMessage(dynamicSteps.storage, 'storage')) {
235
+ value = wizard.removeValidation(dynamicSteps.storage, 'storage', value)
236
+ }
237
+
238
+ return {
239
+ newValue: value,
240
+ stepHasError,
241
+ }
242
+ }
@@ -1,44 +1,42 @@
1
- <template>
2
- <common-backup-storage-actions-add-steps-name-and-configure-new
3
- v-if="isNewView"
4
- v-model="formModel"
5
- v-model:alert-info="isShowAlertInfo"
6
- :alert-messages="props.alertMessages"
7
- :messages-fields="props.messagesFields"
8
- :is-disabled-name-field="props.isDisabledNameField"
9
- />
10
-
11
- <common-backup-storage-actions-add-steps-name-and-configure-old
12
- v-else
13
- v-model="formModel"
14
- v-model:alert-info="isShowAlertInfo"
15
- :alert-messages="props.alertMessages"
16
- :messages-fields="props.messagesFields"
17
- @hide-alert="(e) => emits('hide-alert', e)"
18
- />
19
- </template>
20
-
21
- <script lang="ts" setup>
22
- import type { UI_T_Project } from '~/lib/models/types'
23
- import type { UI_I_WizardStep } from '~/components/atoms/wizard/lib/models/interfaces'
24
- import type { UI_I_CreateDatastoreForm } from '~/components/common/backup/storage/actions/add/lib/models/interfaces'
25
-
26
- const formModel = defineModel<UI_I_CreateDatastoreForm>({ required: true })
27
- const props = defineProps<{
28
- project: UI_T_Project
29
- alertMessages: string[]
30
- messagesFields: UI_I_WizardStep['fields']
31
- isDisabledNameField?: boolean
32
- }>()
33
- const emits = defineEmits<{
34
- (event: 'hide-alert', value: number): void
35
- }>()
36
-
37
- const { $store }: any = useNuxtApp()
38
-
39
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
40
-
41
- const isShowAlertInfo = ref<boolean>(true)
42
- </script>
43
-
44
- <style lang="scss" scoped></style>
1
+ <template>
2
+ <common-backup-storage-actions-add-steps-name-and-configure-new
3
+ v-if="isNewView"
4
+ v-model="formModel"
5
+ v-model:alert-info="isShowAlertInfo"
6
+ :alert-messages="props.alertMessages"
7
+ :messages-fields="props.messagesFields"
8
+ :is-disabled-name-field="props.isDisabledNameField"
9
+ />
10
+
11
+ <common-backup-storage-actions-add-steps-name-and-configure-old
12
+ v-else
13
+ v-model="formModel"
14
+ v-model:alert-info="isShowAlertInfo"
15
+ :alert-messages="props.alertMessages"
16
+ :messages-fields="props.messagesFields"
17
+ @hide-alert="(e) => emits('hide-alert', e)"
18
+ />
19
+ </template>
20
+
21
+ <script lang="ts" setup>
22
+ import type { UI_I_WizardStep } from '~/components/atoms/wizard/lib/models/interfaces'
23
+ import type { UI_I_CreateDatastoreForm } from '~/components/common/backup/storage/actions/add/lib/models/interfaces'
24
+
25
+ const formModel = defineModel<UI_I_CreateDatastoreForm>({ required: true })
26
+ const props = defineProps<{
27
+ alertMessages: string[]
28
+ messagesFields: UI_I_WizardStep['fields']
29
+ isDisabledNameField?: boolean
30
+ }>()
31
+ const emits = defineEmits<{
32
+ (event: 'hide-alert', value: number): void
33
+ }>()
34
+
35
+ const { $store }: any = useNuxtApp()
36
+
37
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
38
+
39
+ const isShowAlertInfo = ref<boolean>(true)
40
+ </script>
41
+
42
+ <style lang="scss" scoped></style>