bfg-common 1.3.285 → 1.3.287

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.
@@ -18,4 +18,5 @@ export interface UI_I_TreeNode<N = UI_I_TreeNodeDuplicate, T = string>
18
18
  available?: number
19
19
  modified?: number
20
20
  testId?: string
21
+ kind?: number
21
22
  }
@@ -13,7 +13,8 @@ export const stepsFunc = (
13
13
  subTitle: localization.howWouldLikeCreateVirtualMachine,
14
14
  status: UI_E_WIZARD_STATUS.SELECTED,
15
15
  isValid: true,
16
- fields: {},
16
+ testId: 'vm-select-creation-type',
17
+ fields: {}
17
18
  },
18
19
  // Procurator
19
20
  {
@@ -23,6 +24,7 @@ export const stepsFunc = (
23
24
  subTitle: localization.specifyUniqueName,
24
25
  status: UI_E_WIZARD_STATUS.INACTIVE,
25
26
  isValid: true,
27
+ testId: 'vm-select-name',
26
28
  fields: {
27
29
  name: {
28
30
  field: '',
@@ -38,6 +40,7 @@ export const stepsFunc = (
38
40
  subTitle: localization.specifyUniqueNameTargetLocation,
39
41
  status: UI_E_WIZARD_STATUS.INACTIVE,
40
42
  isValid: true,
43
+ testId: 'vm-select-name-folder',
41
44
  fields: {
42
45
  name: {
43
46
  field: '',
@@ -53,6 +56,7 @@ export const stepsFunc = (
53
56
  subTitle: localization.selectDestinationComputeResourceOperation,
54
57
  status: UI_E_WIZARD_STATUS.INACTIVE,
55
58
  isValid: true,
59
+ testId: 'vm-select-compute-resource',
56
60
  fields: {},
57
61
  },
58
62
  {
@@ -62,6 +66,7 @@ export const stepsFunc = (
62
66
  subTitle: localization.selectStorageConfigurationDiskFiles,
63
67
  status: UI_E_WIZARD_STATUS.INACTIVE,
64
68
  isValid: true,
69
+ testId: 'vm-select-storage',
65
70
  fields: {
66
71
  storage: {
67
72
  field: '',
@@ -76,6 +81,7 @@ export const stepsFunc = (
76
81
  subTitle: localization.selectCompatibilityVmDependingHostsEnvironment,
77
82
  status: UI_E_WIZARD_STATUS.INACTIVE,
78
83
  isValid: true,
84
+ testId: 'vm-select-compatibility',
79
85
  fields: {},
80
86
  },
81
87
  // Procurator
@@ -86,6 +92,7 @@ export const stepsFunc = (
86
92
  subTitle: localization.chooseGuestOSInstalledVmAndMachineTypeUsedCreateVm,
87
93
  status: UI_E_WIZARD_STATUS.INACTIVE,
88
94
  isValid: true,
95
+ testId: 'vm-select-guest-os-machine-type',
89
96
  fields: {},
90
97
  },
91
98
  // Sphere
@@ -96,6 +103,7 @@ export const stepsFunc = (
96
103
  subTitle: localization.chooseGuestOSInstalledVM,
97
104
  status: UI_E_WIZARD_STATUS.INACTIVE,
98
105
  isValid: true,
106
+ testId: 'vm-select-guest-os',
99
107
  fields: {},
100
108
  },
101
109
  {
@@ -105,6 +113,7 @@ export const stepsFunc = (
105
113
  subTitle: localization.configureVirtualMachineHardware,
106
114
  status: UI_E_WIZARD_STATUS.INACTIVE,
107
115
  isValid: true,
116
+ testId: 'vm-select-customize-hardware',
108
117
  fields: {
109
118
  customizeHardware: {
110
119
  field: '',
@@ -119,6 +128,7 @@ export const stepsFunc = (
119
128
  subTitle: localization.clickFinishStartCreation,
120
129
  status: UI_E_WIZARD_STATUS.INACTIVE,
121
130
  isValid: true,
131
+ testId: 'vm-ready-complete',
122
132
  fields: {},
123
133
  },
124
134
  ]
@@ -1,227 +1,229 @@
1
- <template>
2
- <div class="select-name">
3
- <atoms-alert
4
- v-show="errors.length"
5
- status="alert-danger"
6
- :items="errors"
7
- test-id="name-alert"
8
- @remove="onRemoveValidationErrors"
9
- />
10
-
11
- <form id="virtual-machine-form" @submit.prevent>
12
- <label for="virtual-machine-name"
13
- >{{ localization.virtualMachineName }}:</label
14
- >
15
- <input
16
- id="virtual-machine-name"
17
- v-model.trim="vmName"
18
- data-id="virtual-machine-name-input"
19
- type="text"
20
- />
21
- <div id="vm-name-help-icon" class="content-signpost relative">
22
- <atoms-the-icon
23
- data-id="show-vm-name-help-icon"
24
- class="icon-show-help"
25
- fill="#0072a3"
26
- width="24px"
27
- height="24px"
28
- name="info-circle"
29
- @click="isShowHelp = !isShowHelp"
30
- />
31
- <atoms-tooltip-signpost
32
- v-if="isShowHelp"
33
- test-id="help-signpost"
34
- elem-id="vm-name-help-icon"
35
- @hide="isShowHelp = false"
36
- >
37
- <p>
38
- {{ localization.vmNameValidationDescription2 }}
39
- </p>
40
- </atoms-tooltip-signpost>
41
- </div>
42
- </form>
43
-
44
- <template v-if="props.project === 'sphere'">
45
- <p class="new-vm-name-and-folder-instructions mt-1">
46
- {{ localization.selectLocationVirtualMachine }}
47
- </p>
48
- <div class="tree-view-wrap">
49
- <common-vm-actions-add-folder-tree-view
50
- :data-center="props.dataCenter"
51
- @select-node="onSelectNode"
52
- />
53
- </div>
54
- </template>
55
- </div>
56
- </template>
57
-
58
- <script setup lang="ts">
59
- // import { API_UI_I_Error } from '~/lib/models/store/interfaces'
60
- import { UI_I_Localization } from '~/lib/models/interfaces'
61
- import { UI_T_Project } from '~/lib/models/types'
62
- import { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
63
-
64
- const props = defineProps<{
65
- nameFormSubmit: null | Function
66
- show: boolean
67
- project: UI_T_Project
68
- dataCenter?: UI_I_TreeNode // для сферы
69
- }>()
70
- const emits = defineEmits<{
71
- (event: 'submit', value: [string, UI_I_TreeNode | null]): void
72
- (event: 'loading', value: boolean): void
73
- (
74
- event: 'check-name',
75
- value: [[string, UI_I_TreeNode | null], (error: any) => void]
76
- ): void
77
- }>()
78
-
79
- const localization = computed<UI_I_Localization>(() => useLocal())
80
-
81
- const vmName = ref<string>('')
82
-
83
- const selectedNode = ref<UI_I_TreeNode | null>(null)
84
- const onSelectNode = (node: UI_I_TreeNode): void => {
85
- selectedNode.value = node
86
- }
87
-
88
- watch(
89
- () => props.nameFormSubmit,
90
- (newValue) => {
91
- newValue && submit(newValue)
92
- }
93
- )
94
-
95
- const isParentDatacenter = (node: UI_I_TreeNode | null): boolean => {
96
- if (!node) return false
97
-
98
- if (node.parent?.type === 'datacenter') return true
99
- if (node.parent?.type === 'folder') return isParentDatacenter(node.parent)
100
- return false
101
- }
102
- const submit = async (cb: Function): Promise<void> => {
103
- const name = vmName.value
104
-
105
- if (name !== '') {
106
- const isNameValid = await checkNameIsValid(name)
107
- if (!isNameValid) {
108
- cb(false)
109
- return
110
- }
111
- }
112
-
113
- if (props.project === 'sphere') {
114
- const isDatacenterFolder = isParentDatacenter(selectedNode.value)
115
-
116
- if (
117
- selectedNode.value?.type !== 'datacenter' &&
118
- selectedNode.value?.type === 'folder' &&
119
- !isDatacenterFolder
120
- ) {
121
- showValidationErrors([
122
- localization.value.enterValidLocationVirtualMachine,
123
- ])
124
- cb(false)
125
- return
126
- }
127
- }
128
-
129
- onRemoveValidationErrors()
130
- emits('submit', [name, selectedNode.value])
131
- cb(true)
132
- }
133
- const checkNameIsValid = async (name: string): Promise<boolean> => {
134
- emits('loading', true)
135
-
136
- return new Promise((resolve) => {
137
- emits('check-name', [
138
- [name, selectedNode.value],
139
- (error) => {
140
- emits('loading', false)
141
-
142
- const status = error?.statusCode || 200
143
- switch (status) {
144
- case 406: // Invalid name
145
- showValidationErrors([
146
- localization.value.vmNameValidationDescription2,
147
- ])
148
- resolve(false)
149
- break
150
- case 409: // Name exist
151
- showValidationErrors([
152
- localization.value.vmNameExistInSelectedLocation,
153
- ])
154
- resolve(false)
155
- break
156
- }
157
-
158
- resolve(true)
159
- },
160
- ])
161
- })
162
- }
163
-
164
- const errors = ref<string[]>([])
165
- const showValidationErrors = (data: string[]): void => {
166
- errors.value = data
167
- }
168
- const onRemoveValidationErrors = (): void => {
169
- errors.value = []
170
- }
171
-
172
- watch(
173
- () => props.show,
174
- (newValue) => {
175
- if (!newValue) return
176
-
177
- const input = document.getElementById('virtual-machine-name')
178
- if (!input) return
179
-
180
- setTimeout(() => {
181
- input.focus()
182
- }, 0)
183
- }
184
- )
185
-
186
- const isShowHelp = ref<boolean>(false)
187
- </script>
188
-
189
- <style scoped lang="scss">
190
- .select-name {
191
- form {
192
- display: flex;
193
- align-items: center;
194
- padding-top: 20px;
195
-
196
- label {
197
- width: 216px;
198
- }
199
- input {
200
- width: 345px;
201
- }
202
- }
203
-
204
- .tree-view-wrap {
205
- position: relative;
206
- border: 1px solid #000;
207
- padding: 5px;
208
- max-height: 300px;
209
- min-height: 200px;
210
- overflow: auto;
211
- margin-bottom: 10px;
212
- }
213
- }
214
- .content-signpost {
215
- .icon-show-help {
216
- cursor: pointer;
217
- }
218
-
219
- .help-title {
220
- font-size: 22px;
221
- margin-bottom: 24px;
222
- }
223
- .signpost {
224
- max-width: 360px;
225
- }
226
- }
227
- </style>
1
+ <template>
2
+ <div class="select-name">
3
+ <atoms-alert
4
+ v-show="errors.length"
5
+ status="alert-danger"
6
+ :items="errors"
7
+ test-id="name-alert"
8
+ @remove="onRemoveValidationErrors"
9
+ />
10
+
11
+ <form id="virtual-machine-form" @submit.prevent>
12
+ <label for="virtual-machine-name"
13
+ >{{ localization.virtualMachineName }}:</label
14
+ >
15
+ <input
16
+ id="virtual-machine-name"
17
+ v-model.trim="vmName"
18
+ data-id="virtual-machine-name-input"
19
+ type="text"
20
+ />
21
+ <div id="vm-name-help-icon" class="content-signpost relative">
22
+ <atoms-the-icon
23
+ data-id="show-vm-name-help-icon"
24
+ class="icon-show-help"
25
+ fill="#0072a3"
26
+ width="24px"
27
+ height="24px"
28
+ name="info-circle"
29
+ @click="isShowHelp = !isShowHelp"
30
+ />
31
+ <atoms-tooltip-signpost
32
+ v-if="isShowHelp"
33
+ test-id="help-signpost"
34
+ elem-id="vm-name-help-icon"
35
+ @hide="isShowHelp = false"
36
+ >
37
+ <p>
38
+ {{ localization.vmNameValidationDescription2 }}
39
+ </p>
40
+ </atoms-tooltip-signpost>
41
+ </div>
42
+ </form>
43
+
44
+ <template v-if="props.project === 'sphere'">
45
+ <p class="new-vm-name-and-folder-instructions mt-1">
46
+ {{ localization.selectLocationVirtualMachine }}
47
+ </p>
48
+ <div class="tree-view-wrap">
49
+ <common-vm-actions-add-folder-tree-view
50
+ :data-center="props.dataCenter"
51
+ @select-node="onSelectNode"
52
+ />
53
+ </div>
54
+ </template>
55
+ </div>
56
+ </template>
57
+
58
+ <script setup lang="ts">
59
+ // import { API_UI_I_Error } from '~/lib/models/store/interfaces'
60
+ import { UI_I_Localization } from '~/lib/models/interfaces'
61
+ import { UI_T_Project } from '~/lib/models/types'
62
+ import { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
63
+
64
+ const props = defineProps<{
65
+ nameFormSubmit: null | Function
66
+ show: boolean
67
+ project: UI_T_Project
68
+ dataCenter?: UI_I_TreeNode // для сферы
69
+ }>()
70
+ const emits = defineEmits<{
71
+ (event: 'submit', value: [string, UI_I_TreeNode | null]): void
72
+ (event: 'loading', value: boolean): void
73
+ (
74
+ event: 'check-name',
75
+ value: [[string, UI_I_TreeNode | null], (error: any) => void]
76
+ ): void
77
+ }>()
78
+
79
+ const localization = computed<UI_I_Localization>(() => useLocal())
80
+
81
+ const vmName = ref<string>('')
82
+
83
+ const selectedNode = ref<UI_I_TreeNode | null>(null)
84
+ const onSelectNode = (node: UI_I_TreeNode): void => {
85
+ selectedNode.value = node
86
+ }
87
+
88
+ watch(
89
+ () => props.nameFormSubmit,
90
+ (newValue) => {
91
+ newValue && submit(newValue)
92
+ }
93
+ )
94
+
95
+ const isParentDatacenter = (node: UI_I_TreeNode | null): boolean => {
96
+ if (!node) return false
97
+
98
+ if (node.parent?.type === 'datacenter') return true
99
+ if (node.parent?.type === 'folder') return isParentDatacenter(node.parent)
100
+ return false
101
+ }
102
+ const submit = async (cb: Function): Promise<void> => {
103
+ const name = vmName.value
104
+
105
+ if (name !== '') {
106
+ const isNameValid = await checkNameIsValid(name)
107
+ if (!isNameValid) {
108
+ cb(false)
109
+ return
110
+ }
111
+ }
112
+
113
+ if (props.project === 'sphere') {
114
+ // const isDatacenterFolder = isParentDatacenter(selectedNode.value)
115
+
116
+ if (
117
+ // selectedNode.value?.type !== 'datacenter' &&
118
+ // selectedNode.value?.type === 'folder' &&
119
+ // !isDatacenterFolder
120
+ // TODO рефакторинг, здесь сейчас проверяем является ли выбранный элемент датацентром или папкой(вм)
121
+ ![3, 7].includes(selectedNode.value?.kind)
122
+ ) {
123
+ showValidationErrors([
124
+ localization.value.enterValidLocationVirtualMachine,
125
+ ])
126
+ cb(false)
127
+ return
128
+ }
129
+ }
130
+
131
+ onRemoveValidationErrors()
132
+ emits('submit', [name, selectedNode.value])
133
+ cb(true)
134
+ }
135
+ const checkNameIsValid = async (name: string): Promise<boolean> => {
136
+ emits('loading', true)
137
+
138
+ return new Promise((resolve) => {
139
+ emits('check-name', [
140
+ [name, selectedNode.value],
141
+ (error) => {
142
+ emits('loading', false)
143
+
144
+ const status = error?.statusCode || 200
145
+ switch (status) {
146
+ case 406: // Invalid name
147
+ showValidationErrors([
148
+ localization.value.vmNameValidationDescription2,
149
+ ])
150
+ resolve(false)
151
+ break
152
+ case 409: // Name exist
153
+ showValidationErrors([
154
+ localization.value.vmNameExistInSelectedLocation,
155
+ ])
156
+ resolve(false)
157
+ break
158
+ }
159
+
160
+ resolve(true)
161
+ },
162
+ ])
163
+ })
164
+ }
165
+
166
+ const errors = ref<string[]>([])
167
+ const showValidationErrors = (data: string[]): void => {
168
+ errors.value = data
169
+ }
170
+ const onRemoveValidationErrors = (): void => {
171
+ errors.value = []
172
+ }
173
+
174
+ watch(
175
+ () => props.show,
176
+ (newValue) => {
177
+ if (!newValue) return
178
+
179
+ const input = document.getElementById('virtual-machine-name')
180
+ if (!input) return
181
+
182
+ setTimeout(() => {
183
+ input.focus()
184
+ }, 0)
185
+ }
186
+ )
187
+
188
+ const isShowHelp = ref<boolean>(false)
189
+ </script>
190
+
191
+ <style scoped lang="scss">
192
+ .select-name {
193
+ form {
194
+ display: flex;
195
+ align-items: center;
196
+ padding-top: 20px;
197
+
198
+ label {
199
+ width: 216px;
200
+ }
201
+ input {
202
+ width: 345px;
203
+ }
204
+ }
205
+
206
+ .tree-view-wrap {
207
+ position: relative;
208
+ border: 1px solid #000;
209
+ padding: 5px;
210
+ max-height: 300px;
211
+ min-height: 200px;
212
+ overflow: auto;
213
+ margin-bottom: 10px;
214
+ }
215
+ }
216
+ .content-signpost {
217
+ .icon-show-help {
218
+ cursor: pointer;
219
+ }
220
+
221
+ .help-title {
222
+ font-size: 22px;
223
+ margin-bottom: 24px;
224
+ }
225
+ .signpost {
226
+ max-width: 360px;
227
+ }
228
+ }
229
+ </style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.3.285",
4
+ "version": "1.3.287",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",