bfg-common 1.5.390 → 1.5.391

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,252 @@
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
+ export const checkUsernameSync = (
129
+ localization: UI_I_Localization,
130
+ name: string,
131
+ wizard: Wizard,
132
+ value: UI_I_WizardStep[],
133
+ project: UI_T_Project
134
+ ): UI_I_ValidationReturn => {
135
+ let stepHasError = false
136
+
137
+ // PC-2542
138
+ if (project !== 'procurator') {
139
+ if (!name) {
140
+ stepHasError = wizard.setValidation(
141
+ dynamicSteps.nameAndConfigure,
142
+ 'user',
143
+ {
144
+ fieldMessage: localization.common.fieldRequired,
145
+ alertMessage: '',
146
+ }
147
+ )
148
+ } else if (wizard.hasMessage(dynamicSteps.nameAndConfigure, 'user')) {
149
+ value = wizard.removeValidation(
150
+ dynamicSteps.nameAndConfigure,
151
+ 'user',
152
+ value
153
+ )
154
+ }
155
+ }
156
+
157
+ return {
158
+ newValue: value,
159
+ stepHasError,
160
+ }
161
+ }
162
+
163
+ export const checkPasswordSync = (
164
+ localization: UI_I_Localization,
165
+ name: string,
166
+ wizard: Wizard,
167
+ value: UI_I_WizardStep[],
168
+ project: UI_T_Project
169
+ ): UI_I_ValidationReturn => {
170
+ let stepHasError = false
171
+
172
+ // PC-2542
173
+ if (project !== 'procurator') {
174
+ if (!name) {
175
+ stepHasError = wizard.setValidation(
176
+ dynamicSteps.nameAndConfigure,
177
+ 'password',
178
+ {
179
+ fieldMessage: localization.common.fieldRequired,
180
+ alertMessage: '',
181
+ }
182
+ )
183
+ } else if (wizard.hasMessage(dynamicSteps.nameAndConfigure, 'password')) {
184
+ value = wizard.removeValidation(
185
+ dynamicSteps.nameAndConfigure,
186
+ 'password',
187
+ value
188
+ )
189
+ }
190
+ }
191
+
192
+ return {
193
+ newValue: value,
194
+ stepHasError,
195
+ }
196
+ }
197
+
198
+ export const checkHostsAccessibilitySync = (
199
+ localization: UI_I_Localization,
200
+ hosts: string[],
201
+ wizard: Wizard,
202
+ value: UI_I_WizardStep[]
203
+ ): UI_I_ValidationReturn => {
204
+ let stepHasError = false
205
+
206
+ if (!hosts.length) {
207
+ stepHasError = wizard.setValidation(
208
+ dynamicSteps.hostAccessibility,
209
+ 'hostsAccessibility',
210
+ {
211
+ fieldMessage: '',
212
+ alertMessage: localization.common.selectLeastEntityContinue,
213
+ }
214
+ )
215
+ } else if (
216
+ wizard.hasMessage(dynamicSteps.hostAccessibility, 'hostsAccessibility')
217
+ ) {
218
+ value = wizard.removeValidation(
219
+ dynamicSteps.hostAccessibility,
220
+ 'hostsAccessibility',
221
+ value
222
+ )
223
+ }
224
+
225
+ return {
226
+ newValue: value,
227
+ stepHasError,
228
+ }
229
+ }
230
+
231
+ export const checkStorageSync = (
232
+ localization: UI_I_Localization,
233
+ storm_id: string,
234
+ wizard: Wizard,
235
+ value: UI_I_WizardStep[]
236
+ ): UI_I_ValidationReturn => {
237
+ let stepHasError = false
238
+
239
+ if (!storm_id) {
240
+ stepHasError = wizard.setValidation(dynamicSteps.storage, 'storage', {
241
+ fieldMessage: '',
242
+ alertMessage: localization.common.selectValidDestinationStorage,
243
+ })
244
+ } else if (wizard.hasMessage(dynamicSteps.storage, 'storage')) {
245
+ value = wizard.removeValidation(dynamicSteps.storage, 'storage', value)
246
+ }
247
+
248
+ return {
249
+ newValue: value,
250
+ stepHasError,
251
+ }
252
+ }
@@ -1,44 +1,46 @@
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
+ :project="props.project"
10
+ />
11
+
12
+ <common-backup-storage-actions-add-steps-name-and-configure-old
13
+ v-else
14
+ v-model="formModel"
15
+ v-model:alert-info="isShowAlertInfo"
16
+ :alert-messages="props.alertMessages"
17
+ :messages-fields="props.messagesFields"
18
+ :project="props.project"
19
+ @hide-alert="(e) => emits('hide-alert', e)"
20
+ />
21
+ </template>
22
+
23
+ <script lang="ts" setup>
24
+ import type { UI_T_Project } from '~/lib/models/types'
25
+ import type { UI_I_WizardStep } from '~/components/atoms/wizard/lib/models/interfaces'
26
+ import type { UI_I_CreateDatastoreForm } from '~/components/common/backup/storage/actions/add/lib/models/interfaces'
27
+
28
+ const formModel = defineModel<UI_I_CreateDatastoreForm>({ required: true })
29
+ const props = defineProps<{
30
+ project: UI_T_Project
31
+ alertMessages: string[]
32
+ messagesFields: UI_I_WizardStep['fields']
33
+ isDisabledNameField?: boolean
34
+ }>()
35
+ const emits = defineEmits<{
36
+ (event: 'hide-alert', value: number): void
37
+ }>()
38
+
39
+ const { $store }: any = useNuxtApp()
40
+
41
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
42
+
43
+ const isShowAlertInfo = ref<boolean>(true)
44
+ </script>
45
+
46
+ <style lang="scss" scoped></style>