bfg-common 1.5.388 → 1.5.390

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,161 +1,161 @@
1
- <template>
2
- <ui-stack-block
3
- :has-children="true"
4
- test-id="general-options-stack-block"
5
- is-toggle-on-stack-view-key
6
- @toggle="blockIsOpen = $event"
7
- >
8
- <template #stackBlockKey>
9
- <div
10
- id="vm-wizard-toggle-block-general-options"
11
- data-id="vm-wizard-toggle-block-general-options"
12
- class="flex-align-center text-ellipsis"
13
- >
14
- <span class="text-ellipsis">{{
15
- localization.common.generalOptions
16
- }}</span>
17
- </div>
18
- </template>
19
- <template #stackBlockContent>
20
- <div v-show="!blockIsOpen" class="vm-name-wrap">
21
- <span class="vsphere-icon-vm"></span>
22
- <span>{{ vmName || '--' }}</span>
23
- </div>
24
- </template>
25
- <template #stackChildren>
26
- <ui-stack-block :has-children="false">
27
- <template #stackBlockKey>
28
- {{ props.nameLabel }}
29
- </template>
30
- <template #stackBlockContent>
31
- <div class="vm-name-wrap">
32
- <span class="vsphere-icon-vm"></span>
33
- <span>{{ vmName || '--' }}</span>
34
- </div>
35
- <!-- <span v-if="!props.isEdit">{{ vmName }}</span>-->
36
- <!-- <input-->
37
- <!-- v-else-->
38
- <!-- id="general-option-vm-name"-->
39
- <!-- v-models="vmName"-->
40
- <!-- type="text"-->
41
- <!-- />-->
42
- </template>
43
- </ui-stack-block>
44
-
45
- <ui-stack-block :has-children="false">
46
- <template #stackBlockKey>
47
- <span class="mt-2">{{ localization.common.machineType }}</span>
48
- </template>
49
- <template #stackBlockContent>
50
- <ui-select
51
- v-if="guestMachineType"
52
- id="guest-machine-type-select"
53
- v-model="guestMachineType"
54
- :items="props.machineTypeOptions"
55
- :disabled="props.isDisabled"
56
- width="auto"
57
- test-id="guest-machine-type-select"
58
- class="guest-machine-type-select"
59
- size="sm"
60
- />
61
- </template>
62
- </ui-stack-block>
63
-
64
- <ui-stack-block :has-children="false">
65
- <template #stackBlockKey>
66
- <span class="mt-2">{{ localization.common.guestOsFamily }}</span>
67
- </template>
68
- <template #stackBlockContent>
69
- <ui-select
70
- v-if="guestOsFamily"
71
- id="guest-os-family-select"
72
- v-model="guestOsFamily"
73
- :items="props.osOptions"
74
- :disabled="props.isDisabled"
75
- width="auto"
76
- test-id="guest-os-family-select"
77
- class="guest-os-family-select"
78
- size="sm"
79
- @change="emits('change-os')"
80
- />
81
- </template>
82
- </ui-stack-block>
83
-
84
- <ui-stack-block :has-children="false">
85
- <template #stackBlockKey>
86
- <span class="mt-2">{{ localization.common.guestOsVersion }}</span>
87
- </template>
88
- <template #stackBlockContent>
89
- <ui-select
90
- v-if="guestOsVersion"
91
- id="guest-os-version-select"
92
- v-model="guestOsVersion"
93
- :items="props.versionsOptions"
94
- :disabled="props.isDisabled"
95
- width="auto"
96
- test-id="guest-os-version-select"
97
- class="guest-os-version-select"
98
- size="sm"
99
- />
100
- </template>
101
- </ui-stack-block>
102
- </template>
103
- </ui-stack-block>
104
- </template>
105
-
106
- <script setup lang="ts">
107
- import type { UI_I_Localization } from '~/lib/models/interfaces'
108
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
109
-
110
- const blockIsOpen = defineModel<boolean>('blockIsOpen', { required: true })
111
- const vmName = defineModel<string>('vmName', { required: true })
112
- const guestMachineType = defineModel<UI_I_OptionItem | null>(
113
- 'guestMachineType',
114
- {
115
- required: true,
116
- }
117
- )
118
- const guestOsFamily = defineModel<UI_I_OptionItem | null>('guestOsFamily', {
119
- required: true,
120
- })
121
- const guestOsVersion = defineModel<UI_I_OptionItem | null>('guestOsVersion', {
122
- required: true,
123
- })
124
-
125
- const props = defineProps<{
126
- isDisabled: boolean
127
- nameLabel: string
128
- machineTypeOptions: UI_I_OptionItem[]
129
- osOptions: UI_I_OptionItem[]
130
- versionsOptions: UI_I_OptionItem[]
131
- }>()
132
- const emits = defineEmits<{
133
- (event: 'change-os'): void
134
- }>()
135
-
136
- const localization = computed<UI_I_Localization>(() => useLocal())
137
- </script>
138
-
139
- <style scoped lang="scss">
140
- .vm-name-wrap {
141
- display: flex;
142
- align-items: center;
143
- gap: 4px;
144
- }
145
-
146
- .vsphere-icon-vm {
147
- width: 20px;
148
- height: 20px;
149
- }
150
-
151
- :deep(.guest-os-family-select .ui-main-select-toggle),
152
- :deep(.guest-machine-type-select .ui-main-select-toggle) {
153
- width: 108px;
154
- }
155
- :deep(.guest-os-version-select .ui-main-select-toggle) {
156
- width: 196px;
157
- }
158
- :deep(.stack-block-label .stack-block-content) {
159
- flex: unset !important;
160
- }
161
- </style>
1
+ <template>
2
+ <ui-stack-block
3
+ :has-children="true"
4
+ test-id="general-options-stack-block"
5
+ is-toggle-on-stack-view-key
6
+ @toggle="blockIsOpen = $event"
7
+ >
8
+ <template #stackBlockKey>
9
+ <div
10
+ id="vm-wizard-toggle-block-general-options"
11
+ data-id="vm-wizard-toggle-block-general-options"
12
+ class="flex-align-center text-ellipsis"
13
+ >
14
+ <span class="text-ellipsis">{{
15
+ localization.common.generalOptions
16
+ }}</span>
17
+ </div>
18
+ </template>
19
+ <template #stackBlockContent>
20
+ <div v-show="!blockIsOpen" class="vm-name-wrap">
21
+ <span class="vsphere-icon-vm"></span>
22
+ <span>{{ vmName || '--' }}</span>
23
+ </div>
24
+ </template>
25
+ <template #stackChildren>
26
+ <ui-stack-block :has-children="false">
27
+ <template #stackBlockKey>
28
+ {{ props.nameLabel }}
29
+ </template>
30
+ <template #stackBlockContent>
31
+ <div class="vm-name-wrap">
32
+ <span class="vsphere-icon-vm"></span>
33
+ <span>{{ vmName || '--' }}</span>
34
+ </div>
35
+ <!-- <span v-if="!props.isEdit">{{ vmName }}</span>-->
36
+ <!-- <input-->
37
+ <!-- v-else-->
38
+ <!-- id="general-option-vm-name"-->
39
+ <!-- v-models="vmName"-->
40
+ <!-- type="text"-->
41
+ <!-- />-->
42
+ </template>
43
+ </ui-stack-block>
44
+
45
+ <ui-stack-block :has-children="false">
46
+ <template #stackBlockKey>
47
+ <span class="mt-2">{{ localization.common.machineType }}</span>
48
+ </template>
49
+ <template #stackBlockContent>
50
+ <ui-select
51
+ v-if="guestMachineType"
52
+ id="guest-machine-type-select"
53
+ v-model="guestMachineType"
54
+ :items="props.machineTypeOptions"
55
+ :disabled="props.isDisabled"
56
+ width="auto"
57
+ test-id="guest-machine-type-select"
58
+ class="guest-machine-type-select"
59
+ size="sm"
60
+ />
61
+ </template>
62
+ </ui-stack-block>
63
+
64
+ <ui-stack-block :has-children="false">
65
+ <template #stackBlockKey>
66
+ <span class="mt-2">{{ localization.common.guestOsFamily }}</span>
67
+ </template>
68
+ <template #stackBlockContent>
69
+ <ui-select
70
+ v-if="guestOsFamily"
71
+ id="guest-os-family-select"
72
+ v-model="guestOsFamily"
73
+ :items="props.osOptions"
74
+ :disabled="props.isDisabled"
75
+ width="auto"
76
+ test-id="guest-os-family-select"
77
+ class="guest-os-family-select"
78
+ size="sm"
79
+ @change="emits('change-os')"
80
+ />
81
+ </template>
82
+ </ui-stack-block>
83
+
84
+ <ui-stack-block :has-children="false">
85
+ <template #stackBlockKey>
86
+ <span class="mt-2">{{ localization.common.guestOsVersion }}</span>
87
+ </template>
88
+ <template #stackBlockContent>
89
+ <ui-select
90
+ v-if="guestOsVersion"
91
+ id="guest-os-version-select"
92
+ v-model="guestOsVersion"
93
+ :items="props.versionsOptions"
94
+ :disabled="props.isDisabled"
95
+ width="auto"
96
+ test-id="guest-os-version-select"
97
+ class="guest-os-version-select"
98
+ size="sm"
99
+ />
100
+ </template>
101
+ </ui-stack-block>
102
+ </template>
103
+ </ui-stack-block>
104
+ </template>
105
+
106
+ <script setup lang="ts">
107
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
108
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
109
+
110
+ const blockIsOpen = defineModel<boolean>('blockIsOpen', { required: true })
111
+ const vmName = defineModel<string>('vmName', { required: true })
112
+ const guestMachineType = defineModel<UI_I_OptionItem | null>(
113
+ 'guestMachineType',
114
+ {
115
+ required: true,
116
+ }
117
+ )
118
+ const guestOsFamily = defineModel<UI_I_OptionItem | null>('guestOsFamily', {
119
+ required: true,
120
+ })
121
+ const guestOsVersion = defineModel<UI_I_OptionItem | null>('guestOsVersion', {
122
+ required: true,
123
+ })
124
+
125
+ const props = defineProps<{
126
+ isDisabled: boolean
127
+ nameLabel: string
128
+ machineTypeOptions: UI_I_OptionItem[]
129
+ osOptions: UI_I_OptionItem[]
130
+ versionsOptions: UI_I_OptionItem[]
131
+ }>()
132
+ const emits = defineEmits<{
133
+ (event: 'change-os'): void
134
+ }>()
135
+
136
+ const localization = computed<UI_I_Localization>(() => useLocal())
137
+ </script>
138
+
139
+ <style scoped lang="scss">
140
+ .vm-name-wrap {
141
+ display: flex;
142
+ align-items: center;
143
+ gap: 4px;
144
+ }
145
+
146
+ .vsphere-icon-vm {
147
+ width: 20px;
148
+ height: 20px;
149
+ }
150
+
151
+ :deep(.guest-os-family-select .ui-main-select-toggle),
152
+ :deep(.guest-machine-type-select .ui-main-select-toggle) {
153
+ width: 108px;
154
+ }
155
+ :deep(.guest-os-version-select .ui-main-select-toggle) {
156
+ width: 196px;
157
+ }
158
+ :deep(.stack-block-label .stack-block-content) {
159
+ flex: unset !important;
160
+ }
161
+ </style>
@@ -1,176 +1,176 @@
1
- <template>
2
- <common-vm-actions-common-select-name-new
3
- v-if="isNewView"
4
- v-model:vm-name="vmName"
5
- v-model:is-show-help="isShowHelp"
6
- :project="props.project"
7
- :errors="errors"
8
- :data-center="props.dataCenter"
9
- @remove-validation-errors="onRemoveValidationErrors"
10
- @select-node="onSelectNode"
11
- />
12
- <common-vm-actions-common-select-name-old
13
- v-else
14
- v-model:vm-name="vmName"
15
- v-model:is-show-help="isShowHelp"
16
- :project="props.project"
17
- :errors="errors"
18
- :data-center="props.dataCenter"
19
- @remove-validation-errors="onRemoveValidationErrors"
20
- @select-node="onSelectNode"
21
- />
22
- </template>
23
-
24
- <script setup lang="ts">
25
- // import { API_UI_I_Error } from '~/lib/models/store/interfaces'
26
- import type { UI_I_Localization } from '~/lib/models/interfaces'
27
- import type { UI_T_Project } from '~/lib/models/types'
28
- import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
29
-
30
- const props = defineProps<{
31
- nameFormSubmit: null | Function
32
- show: boolean
33
- project: UI_T_Project
34
- dataCenter?: UI_I_TreeNode // для сферы
35
- existName?: string
36
- }>()
37
- const emits = defineEmits<{
38
- (event: 'submit', value: [string, UI_I_TreeNode | null]): void
39
- (event: 'loading', value: boolean): void
40
- (
41
- event: 'check-name',
42
- value: [[string, UI_I_TreeNode | null], (error: any) => void]
43
- ): void
44
- (event: 'has-errors', value: boolean): void
45
- }>()
46
-
47
- const { $store }: any = useNuxtApp()
48
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
49
-
50
- const localization = computed<UI_I_Localization>(() => useLocal())
51
-
52
- // TODO 100
53
- const vmName = ref<string>(props.existName || '')
54
-
55
- const selectedNode = ref<UI_I_TreeNode | null>(null)
56
- const onSelectNode = (node: UI_I_TreeNode): void => {
57
- selectedNode.value = node
58
- }
59
-
60
- watch(
61
- () => props.nameFormSubmit,
62
- (newValue) => {
63
- newValue && submit(newValue)
64
- }
65
- )
66
-
67
- const isParentDatacenter = (node: UI_I_TreeNode | null): boolean => {
68
- if (!node) return false
69
-
70
- if (node.parent?.type === 'datacenter') return true
71
- if (node.parent?.type === 'folder') return isParentDatacenter(node.parent)
72
- return false
73
- }
74
- const submit = async (cb: Function): Promise<void> => {
75
- const name = vmName.value
76
-
77
- if (name !== '') {
78
- const isNameValid = await checkNameIsValid(name)
79
- if (!isNameValid) {
80
- cb(false)
81
- return
82
- }
83
- }
84
-
85
- if (props.project === 'sphere') {
86
- // const isDatacenterFolder = isParentDatacenter(selectedNode.value)
87
-
88
- if (
89
- // selectedNode.value?.type !== 'datacenter' &&
90
- // selectedNode.value?.type === 'folder' &&
91
- // !isDatacenterFolder
92
- // TODO рефакторинг, здесь сейчас проверяем является ли выбранный элемент датацентром или папкой(вм)
93
- ![3, 7].includes(selectedNode.value?.kind)
94
- ) {
95
- showValidationErrors([
96
- localization.value.common.enterValidLocationVirtualMachine,
97
- ])
98
- cb(false)
99
- return
100
- }
101
- }
102
-
103
- onRemoveValidationErrors()
104
- emits('submit', [name, selectedNode.value])
105
- cb(true)
106
- }
107
- const checkNameIsValid = async (name: string): Promise<boolean> => {
108
- emits('loading', true)
109
-
110
- return new Promise((resolve) => {
111
- emits('check-name', [
112
- [name, selectedNode.value],
113
- (error) => {
114
- emits('loading', false)
115
-
116
- const status = error?.statusCode || 200
117
- switch (status) {
118
- case 405: // Invalid kind
119
- showValidationErrors([
120
- localization.value.common.kindValidationDescription,
121
- ])
122
- resolve(false)
123
- break
124
- case 406: // Invalid name
125
- showValidationErrors([
126
- localization.value.common.vmNameValidationDescription,
127
- ])
128
- resolve(false)
129
- break
130
- case 409: // Name exist
131
- showValidationErrors([
132
- localization.value.common.vmNameExistInSelectedLocation,
133
- ])
134
- resolve(false)
135
- break
136
- }
137
-
138
- resolve(true)
139
- },
140
- ])
141
- })
142
- }
143
-
144
- const errors = ref<string[]>([])
145
- const showValidationErrors = (data: string[]): void => {
146
- errors.value = data
147
- }
148
- const onRemoveValidationErrors = (): void => {
149
- errors.value = []
150
- }
151
- watch(
152
- errors,
153
- (newValue) => {
154
- emits('has-errors', !newValue.length)
155
- },
156
- { immediate: true, deep: true }
157
- )
158
-
159
- watch(
160
- () => props.show,
161
- (newValue) => {
162
- if (!newValue) return
163
-
164
- const input = document.getElementById('virtual-machine-name')
165
- if (!input) return
166
-
167
- setTimeout(() => {
168
- input.focus()
169
- }, 0)
170
- }
171
- )
172
-
173
- const isShowHelp = ref<boolean>(false)
174
- </script>
175
-
176
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <common-vm-actions-common-select-name-new
3
+ v-if="isNewView"
4
+ v-model:vm-name="vmName"
5
+ v-model:is-show-help="isShowHelp"
6
+ :project="props.project"
7
+ :errors="errors"
8
+ :data-center="props.dataCenter"
9
+ @remove-validation-errors="onRemoveValidationErrors"
10
+ @select-node="onSelectNode"
11
+ />
12
+ <common-vm-actions-common-select-name-old
13
+ v-else
14
+ v-model:vm-name="vmName"
15
+ v-model:is-show-help="isShowHelp"
16
+ :project="props.project"
17
+ :errors="errors"
18
+ :data-center="props.dataCenter"
19
+ @remove-validation-errors="onRemoveValidationErrors"
20
+ @select-node="onSelectNode"
21
+ />
22
+ </template>
23
+
24
+ <script setup lang="ts">
25
+ // import { API_UI_I_Error } from '~/lib/models/store/interfaces'
26
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
27
+ import type { UI_T_Project } from '~/lib/models/types'
28
+ import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
29
+
30
+ const props = defineProps<{
31
+ nameFormSubmit: null | Function
32
+ show: boolean
33
+ project: UI_T_Project
34
+ dataCenter?: UI_I_TreeNode // для сферы
35
+ existName?: string
36
+ }>()
37
+ const emits = defineEmits<{
38
+ (event: 'submit', value: [string, UI_I_TreeNode | null]): void
39
+ (event: 'loading', value: boolean): void
40
+ (
41
+ event: 'check-name',
42
+ value: [[string, UI_I_TreeNode | null], (error: any) => void]
43
+ ): void
44
+ (event: 'has-errors', value: boolean): void
45
+ }>()
46
+
47
+ const { $store }: any = useNuxtApp()
48
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
49
+
50
+ const localization = computed<UI_I_Localization>(() => useLocal())
51
+
52
+ // TODO 100
53
+ const vmName = ref<string>(props.existName || '')
54
+
55
+ const selectedNode = ref<UI_I_TreeNode | null>(null)
56
+ const onSelectNode = (node: UI_I_TreeNode): void => {
57
+ selectedNode.value = node
58
+ }
59
+
60
+ watch(
61
+ () => props.nameFormSubmit,
62
+ (newValue) => {
63
+ newValue && submit(newValue)
64
+ }
65
+ )
66
+
67
+ const isParentDatacenter = (node: UI_I_TreeNode | null): boolean => {
68
+ if (!node) return false
69
+
70
+ if (node.parent?.type === 'datacenter') return true
71
+ if (node.parent?.type === 'folder') return isParentDatacenter(node.parent)
72
+ return false
73
+ }
74
+ const submit = async (cb: Function): Promise<void> => {
75
+ const name = vmName.value
76
+
77
+ if (name !== '') {
78
+ const isNameValid = await checkNameIsValid(name)
79
+ if (!isNameValid) {
80
+ cb(false)
81
+ return
82
+ }
83
+ }
84
+
85
+ if (props.project === 'sphere') {
86
+ // const isDatacenterFolder = isParentDatacenter(selectedNode.value)
87
+
88
+ if (
89
+ // selectedNode.value?.type !== 'datacenter' &&
90
+ // selectedNode.value?.type === 'folder' &&
91
+ // !isDatacenterFolder
92
+ // TODO рефакторинг, здесь сейчас проверяем является ли выбранный элемент датацентром или папкой(вм)
93
+ ![3, 7].includes(selectedNode.value?.kind)
94
+ ) {
95
+ showValidationErrors([
96
+ localization.value.common.enterValidLocationVirtualMachine,
97
+ ])
98
+ cb(false)
99
+ return
100
+ }
101
+ }
102
+
103
+ onRemoveValidationErrors()
104
+ emits('submit', [name, selectedNode.value])
105
+ cb(true)
106
+ }
107
+ const checkNameIsValid = async (name: string): Promise<boolean> => {
108
+ emits('loading', true)
109
+
110
+ return new Promise((resolve) => {
111
+ emits('check-name', [
112
+ [name, selectedNode.value],
113
+ (error) => {
114
+ emits('loading', false)
115
+
116
+ const status = error?.statusCode || 200
117
+ switch (status) {
118
+ case 405: // Invalid kind
119
+ showValidationErrors([
120
+ localization.value.common.kindValidationDescription,
121
+ ])
122
+ resolve(false)
123
+ break
124
+ case 406: // Invalid name
125
+ showValidationErrors([
126
+ localization.value.common.vmNameValidationDescription,
127
+ ])
128
+ resolve(false)
129
+ break
130
+ case 409: // Name exist
131
+ showValidationErrors([
132
+ localization.value.common.vmNameExistInSelectedLocation,
133
+ ])
134
+ resolve(false)
135
+ break
136
+ }
137
+
138
+ resolve(true)
139
+ },
140
+ ])
141
+ })
142
+ }
143
+
144
+ const errors = ref<string[]>([])
145
+ const showValidationErrors = (data: string[]): void => {
146
+ errors.value = data
147
+ }
148
+ const onRemoveValidationErrors = (): void => {
149
+ errors.value = []
150
+ }
151
+ watch(
152
+ errors,
153
+ (newValue) => {
154
+ emits('has-errors', !newValue.length)
155
+ },
156
+ { immediate: true, deep: true }
157
+ )
158
+
159
+ watch(
160
+ () => props.show,
161
+ (newValue) => {
162
+ if (!newValue) return
163
+
164
+ const input = document.getElementById('virtual-machine-name')
165
+ if (!input) return
166
+
167
+ setTimeout(() => {
168
+ input.focus()
169
+ }, 0)
170
+ }
171
+ )
172
+
173
+ const isShowHelp = ref<boolean>(false)
174
+ </script>
175
+
176
+ <style scoped lang="scss"></style>