@rancher/shell 0.3.17 → 0.3.19
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.
- package/assets/translations/en-us.yaml +8 -4
- package/assets/translations/zh-hans.yaml +64 -8
- package/components/AsyncButton.vue +1 -1
- package/components/Inactivity.vue +10 -0
- package/components/LazyImage.vue +2 -2
- package/components/PromptRestore.vue +8 -6
- package/components/ResourceDetail/Masthead.vue +1 -1
- package/components/ResourceDetail/index.vue +4 -2
- package/components/__tests__/PromptRestore.test.ts +142 -0
- package/components/auth/AzureWarning.vue +1 -1
- package/components/auth/RoleDetailEdit.vue +2 -0
- package/components/fleet/FleetResources.vue +3 -64
- package/components/form/FileImageSelector.vue +9 -0
- package/components/form/FileSelector.vue +2 -1
- package/components/form/MatchExpressions.vue +1 -3
- package/components/form/__tests__/FileImageSelector.test.ts +42 -0
- package/components/form/__tests__/FileSelector.test.ts +76 -0
- package/components/formatter/ClusterProvider.vue +3 -1
- package/components/formatter/__tests__/ClusterProvider.test.ts +24 -0
- package/components/nav/WindowManager/ContainerShell.vue +60 -36
- package/components/nav/WindowManager/__tests__/ContainerShell.test.ts +561 -0
- package/config/labels-annotations.js +2 -1
- package/config/persistentVolume.ts +108 -0
- package/config/product/manager.js +5 -1
- package/config/types.js +2 -0
- package/core/plugin-helpers.js +19 -3
- package/core/types.ts +4 -0
- package/detail/fleet.cattle.io.gitrepo.vue +10 -2
- package/detail/pod.vue +36 -3
- package/detail/workload/index.vue +40 -9
- package/dialog/DiagnosticTimingsDialog.vue +1 -0
- package/edit/__tests__/ui.cattle.io.navlink.test.ts +110 -0
- package/edit/fleet.cattle.io.clustergroup.vue +14 -3
- package/edit/persistentvolume/__tests__/persistentvolume.test.ts +82 -0
- package/edit/persistentvolume/index.vue +2 -1
- package/edit/persistentvolume/plugins/csi.vue +3 -1
- package/edit/persistentvolume/plugins/longhorn.vue +12 -12
- package/edit/provisioning.cattle.io.cluster/RegistryConfigs.vue +15 -11
- package/edit/provisioning.cattle.io.cluster/index.vue +1 -1
- package/edit/provisioning.cattle.io.cluster/rke2.vue +5 -1
- package/edit/storage.k8s.io.storageclass/index.vue +1 -2
- package/edit/ui.cattle.io.navlink.vue +213 -186
- package/layouts/default.vue +1 -1
- package/list/group.principal.vue +1 -1
- package/middleware/authenticated.js +12 -4
- package/mixins/create-edit-view/impl.js +2 -2
- package/models/chart.js +1 -1
- package/models/etcdbackup.js +2 -1
- package/models/fleet.cattle.io.cluster.js +33 -4
- package/models/fleet.cattle.io.gitrepo.js +112 -38
- package/models/management.cattle.io.cluster.js +13 -3
- package/models/management.cattle.io.kontainerdriver.js +14 -0
- package/models/persistentvolume.js +2 -111
- package/models/pod.js +30 -0
- package/models/rke.cattle.io.etcdsnapshot.js +10 -7
- package/package.json +1 -1
- package/pages/c/_cluster/apps/charts/install.vue +74 -25
- package/pages/c/_cluster/auth/group.principal/assign-edit.vue +1 -1
- package/pages/c/_cluster/auth/roles/index.vue +1 -1
- package/pages/c/_cluster/explorer/index.vue +1 -1
- package/pages/c/_cluster/manager/cloudCredential/_id.vue +0 -1
- package/pages/c/_cluster/manager/cloudCredential/create.vue +0 -1
- package/pages/c/_cluster/settings/brand.vue +11 -8
- package/pages/c/_cluster/uiplugins/index.vue +9 -4
- package/pages/diagnostic.vue +5 -3
- package/pages/home.vue +1 -1
- package/plugins/dashboard-store/__tests__/actions.spec.ts +165 -0
- package/plugins/dashboard-store/__tests__/getters.spec.ts +100 -0
- package/plugins/dashboard-store/__tests__/{mutations.spec.js → mutations.spec.ts} +2 -2
- package/plugins/dashboard-store/actions.js +1 -1
- package/plugins/dashboard-store/resource-class.js +4 -0
- package/plugins/steve/__tests__/getters.spec.ts +93 -0
- package/plugins/steve/getters.js +21 -1
- package/plugins/steve/subscribe.js +1 -3
- package/rancher-components/components/BadgeState/BadgeState.spec.ts +12 -0
- package/rancher-components/components/BadgeState/BadgeState.vue +111 -0
- package/rancher-components/components/BadgeState/index.ts +1 -0
- package/rancher-components/components/Banner/Banner.test.ts +63 -0
- package/rancher-components/components/Banner/Banner.vue +244 -0
- package/rancher-components/components/Banner/index.ts +1 -0
- package/rancher-components/components/Card/Card.test.ts +37 -0
- package/rancher-components/components/Card/Card.vue +167 -0
- package/rancher-components/components/Card/index.ts +1 -0
- package/rancher-components/components/Form/Checkbox/Checkbox.test.ts +68 -0
- package/rancher-components/components/Form/Checkbox/Checkbox.vue +420 -0
- package/rancher-components/components/Form/Checkbox/index.ts +1 -0
- package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +23 -0
- package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +355 -0
- package/rancher-components/components/Form/LabeledInput/index.ts +1 -0
- package/rancher-components/components/Form/Radio/RadioButton.test.ts +31 -0
- package/rancher-components/components/Form/Radio/RadioButton.vue +287 -0
- package/rancher-components/components/Form/Radio/RadioGroup.vue +254 -0
- package/rancher-components/components/Form/Radio/index.ts +2 -0
- package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +170 -0
- package/rancher-components/components/Form/TextArea/index.ts +1 -0
- package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.test.ts +94 -0
- package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.vue +149 -0
- package/rancher-components/components/Form/ToggleSwitch/index.ts +1 -0
- package/rancher-components/components/Form/index.ts +5 -0
- package/rancher-components/components/LabeledTooltip/LabeledTooltip.vue +151 -0
- package/rancher-components/components/LabeledTooltip/index.ts +1 -0
- package/rancher-components/components/StringList/StringList.test.ts +484 -0
- package/rancher-components/components/StringList/StringList.vue +611 -0
- package/rancher-components/components/StringList/index.ts +1 -0
- package/scripts/extension/publish +54 -14
- package/scripts/typegen.sh +10 -2
- package/store/index.js +1 -3
- package/store/store-types.js +2 -0
- package/types/api.d.ts +1 -0
- package/types/fleet.d.ts +1 -0
- package/types/shell/index.d.ts +696 -2
- package/types/userPreferences.d.ts +1 -1
- package/utils/__mocks__/socket.js +21 -0
- package/utils/grafana.js +23 -11
- package/utils/selector.js +2 -1
- package/utils/socket.js +1 -0
- package/utils/validators/formRules/index.ts +3 -3
- package/plugins/steve/urloptions.js +0 -47
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Vue, { PropType } from 'vue';
|
|
3
|
+
|
|
4
|
+
import LabeledInput from '@components/Form/LabeledInput/LabeledInput.vue';
|
|
5
|
+
import { findStringIndex, hasDuplicatedStrings } from '@shell/utils/array';
|
|
6
|
+
|
|
7
|
+
type Error = 'duplicate';
|
|
8
|
+
type ErrorMessages = Record<Error, string>;
|
|
9
|
+
|
|
10
|
+
type Arrow = 'up' | 'down';
|
|
11
|
+
|
|
12
|
+
const DIRECTION: Record<Arrow, number> = {
|
|
13
|
+
up: -1,
|
|
14
|
+
down: 1,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const INPUT = {
|
|
18
|
+
create: 'item-create',
|
|
19
|
+
edit: 'item-edit',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const BOX = 'box';
|
|
23
|
+
|
|
24
|
+
const CLASS = {
|
|
25
|
+
item: 'item',
|
|
26
|
+
error: 'error',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Manage a list of strings
|
|
31
|
+
*/
|
|
32
|
+
export default Vue.extend({
|
|
33
|
+
|
|
34
|
+
name: 'StringList',
|
|
35
|
+
components: { LabeledInput },
|
|
36
|
+
|
|
37
|
+
props: {
|
|
38
|
+
/**
|
|
39
|
+
* The items source
|
|
40
|
+
*/
|
|
41
|
+
items: {
|
|
42
|
+
type: Array as PropType<string[]>,
|
|
43
|
+
default() {
|
|
44
|
+
return [];
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Determines if items with same text will be treated differently, depending on the letters case
|
|
49
|
+
* It is used to compare items during create/edit actions and detect duplicates.
|
|
50
|
+
*/
|
|
51
|
+
caseSensitive: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: false,
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Determines if the list of items is editable or view-only
|
|
57
|
+
*/
|
|
58
|
+
readonly: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: false,
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* The placeholder to show in input field when create or edit items
|
|
64
|
+
*/
|
|
65
|
+
placeholder: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: null,
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* Determines the action buttons position at the bottom of the main box
|
|
71
|
+
*/
|
|
72
|
+
actionsPosition: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: 'right',
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* Custom Error messages
|
|
78
|
+
*/
|
|
79
|
+
errorMessages: {
|
|
80
|
+
type: Object as PropType<ErrorMessages>,
|
|
81
|
+
default() {
|
|
82
|
+
return {} as ErrorMessages;
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
data() {
|
|
87
|
+
return {
|
|
88
|
+
value: null as string | null,
|
|
89
|
+
selected: null as string | null,
|
|
90
|
+
editedItem: null as string | null,
|
|
91
|
+
isCreateItem: false,
|
|
92
|
+
errors: { duplicate: false } as Record<Error, boolean>
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
computed: {
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Create an array of error messages, one for each current error
|
|
100
|
+
*/
|
|
101
|
+
errorMessagesArray(): string[] {
|
|
102
|
+
return (Object.keys(this.errors) as Error[])
|
|
103
|
+
.filter((f) => this.errors[f] && this.errorMessages[f])
|
|
104
|
+
.map((k) => this.errorMessages[k]);
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
watch: {
|
|
109
|
+
/**
|
|
110
|
+
* Shutdown any user actions on the component when it becomes readonly
|
|
111
|
+
*/
|
|
112
|
+
readonly() {
|
|
113
|
+
this.toggleEditMode(false);
|
|
114
|
+
this.toggleCreateMode(false);
|
|
115
|
+
},
|
|
116
|
+
value(val) {
|
|
117
|
+
this.$emit('type:item', val);
|
|
118
|
+
},
|
|
119
|
+
errors: {
|
|
120
|
+
handler(val) {
|
|
121
|
+
this.$emit('errors', val);
|
|
122
|
+
},
|
|
123
|
+
deep: true
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
methods: {
|
|
128
|
+
onChange(value: string) {
|
|
129
|
+
this.value = value;
|
|
130
|
+
|
|
131
|
+
const items = [
|
|
132
|
+
...this.items,
|
|
133
|
+
this.value
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
this.toggleError(
|
|
137
|
+
'duplicate',
|
|
138
|
+
hasDuplicatedStrings(items, this.caseSensitive),
|
|
139
|
+
this.isCreateItem ? INPUT.create : INPUT.edit
|
|
140
|
+
);
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
onSelect(item: string) {
|
|
144
|
+
if (this.readonly || this.isCreateItem || this.editedItem === item) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
this.selected = item;
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
onSelectNext(arrow: Arrow) {
|
|
151
|
+
const index = findStringIndex(
|
|
152
|
+
this.items,
|
|
153
|
+
this.selected as string,
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
if (index !== -1) {
|
|
157
|
+
/**
|
|
158
|
+
* Select next item in the arrow's direction if it exists,
|
|
159
|
+
* else select again this.selected (do nothing)
|
|
160
|
+
*/
|
|
161
|
+
const item = (this.items[index + DIRECTION[arrow]] || this.selected) as string;
|
|
162
|
+
|
|
163
|
+
this.onSelect(item);
|
|
164
|
+
this.moveScrollbar(arrow);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
onSelectLeave(item?: string) {
|
|
169
|
+
if (item === this.selected) {
|
|
170
|
+
this.selected = null;
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
onClickEmptyBody() {
|
|
175
|
+
if (!this.isCreateItem && !this.editedItem) {
|
|
176
|
+
this.toggleCreateMode(true);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
onClickPlusButton() {
|
|
181
|
+
this.onSelectLeave();
|
|
182
|
+
this.toggleCreateMode(true);
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
onClickMinusButton() {
|
|
186
|
+
if (this.isCreateItem) {
|
|
187
|
+
this.toggleCreateMode(false);
|
|
188
|
+
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (this.editedItem) {
|
|
192
|
+
this.deleteAndSelectNext(this.editedItem);
|
|
193
|
+
this.toggleEditMode(false);
|
|
194
|
+
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (this.selected) {
|
|
198
|
+
this.deleteAndSelectNext(this.selected);
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
deleteAndSelectNext(currItem: string) {
|
|
203
|
+
const index = findStringIndex(this.items, currItem, false);
|
|
204
|
+
|
|
205
|
+
if (index !== -1) {
|
|
206
|
+
/**
|
|
207
|
+
* Select the next item in the list.
|
|
208
|
+
*/
|
|
209
|
+
const item = (this.items[index + 1] || this.items[index - 1]);
|
|
210
|
+
|
|
211
|
+
this.onSelect(item);
|
|
212
|
+
this.setFocus(item);
|
|
213
|
+
|
|
214
|
+
this.deleteItem(this.items[index]);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
setFocus(refId: string) {
|
|
219
|
+
this.$nextTick(() => (this.getElemByRef(refId) as Vue & HTMLElement)?.focus());
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Move scrollbar when the selected item is over the top or bottom side of the box
|
|
224
|
+
*/
|
|
225
|
+
moveScrollbar(arrow: Arrow, value?: number) {
|
|
226
|
+
const box = this.getElemByRef(BOX) as HTMLElement;
|
|
227
|
+
const item = this.getElemByRef(this.selected || '') as HTMLElement;
|
|
228
|
+
|
|
229
|
+
if (box && item && item.className.includes(CLASS.item)) {
|
|
230
|
+
const boxRect = box.getClientRects()[0];
|
|
231
|
+
const itemRect = item.getClientRects()[0];
|
|
232
|
+
|
|
233
|
+
if (
|
|
234
|
+
(arrow === 'down' && itemRect.bottom > boxRect.bottom) ||
|
|
235
|
+
(arrow === 'up' && itemRect.top < boxRect.top)
|
|
236
|
+
) {
|
|
237
|
+
const top = (value ?? itemRect.height) * DIRECTION[arrow];
|
|
238
|
+
|
|
239
|
+
box.scrollBy({ top });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Set an error and eventually assign an error class to the element
|
|
246
|
+
*/
|
|
247
|
+
toggleError(type: Error, val: boolean, refId?: string) {
|
|
248
|
+
this.errors[type] = val;
|
|
249
|
+
|
|
250
|
+
if (refId) {
|
|
251
|
+
this.toggleErrorClass(refId, val);
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
toggleErrorClass(refId: string, val: boolean) {
|
|
256
|
+
const input = (this.getElemByRef(refId) as Vue)?.$el;
|
|
257
|
+
|
|
258
|
+
if (input) {
|
|
259
|
+
if (val) {
|
|
260
|
+
input.classList.add(CLASS.error);
|
|
261
|
+
} else {
|
|
262
|
+
input.classList.remove(CLASS.error);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Show/Hide the input line to create new item
|
|
269
|
+
*/
|
|
270
|
+
toggleCreateMode(show: boolean) {
|
|
271
|
+
if (this.readonly) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (show) {
|
|
275
|
+
this.toggleEditMode(false);
|
|
276
|
+
this.value = '';
|
|
277
|
+
|
|
278
|
+
this.isCreateItem = true;
|
|
279
|
+
this.setFocus(INPUT.create);
|
|
280
|
+
} else {
|
|
281
|
+
this.value = null;
|
|
282
|
+
this.toggleError('duplicate', false);
|
|
283
|
+
this.onSelectLeave();
|
|
284
|
+
|
|
285
|
+
this.isCreateItem = false;
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Show/Hide the in-line editing to edit an existing item
|
|
291
|
+
*/
|
|
292
|
+
toggleEditMode(show: boolean, item?: string) {
|
|
293
|
+
if (this.readonly) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (show) {
|
|
297
|
+
this.toggleCreateMode(false);
|
|
298
|
+
this.value = this.editedItem;
|
|
299
|
+
|
|
300
|
+
this.editedItem = item || '';
|
|
301
|
+
this.setFocus(INPUT.edit);
|
|
302
|
+
} else {
|
|
303
|
+
this.value = null;
|
|
304
|
+
this.toggleError('duplicate', false);
|
|
305
|
+
this.onSelectLeave();
|
|
306
|
+
|
|
307
|
+
this.editedItem = null;
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
|
|
311
|
+
getElemByRef(id: string) {
|
|
312
|
+
const ref = this.$refs[id];
|
|
313
|
+
|
|
314
|
+
return Array.isArray(ref) ? ref[0] : ref;
|
|
315
|
+
},
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Create a new item and insert in the items list
|
|
319
|
+
*/
|
|
320
|
+
saveItem(closeInput = true) {
|
|
321
|
+
const value = this.value?.trim();
|
|
322
|
+
|
|
323
|
+
if (value) {
|
|
324
|
+
const items = [
|
|
325
|
+
...this.items,
|
|
326
|
+
value,
|
|
327
|
+
];
|
|
328
|
+
|
|
329
|
+
if (!hasDuplicatedStrings(items, this.caseSensitive)) {
|
|
330
|
+
this.updateItems(items);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (closeInput) {
|
|
335
|
+
this.toggleCreateMode(false);
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Update an existing item in the items list
|
|
341
|
+
*/
|
|
342
|
+
updateItem(item: string, closeInput = true) {
|
|
343
|
+
const value = this.value?.trim();
|
|
344
|
+
|
|
345
|
+
if (value) {
|
|
346
|
+
const items = [...this.items];
|
|
347
|
+
const index = findStringIndex(items, item, false);
|
|
348
|
+
|
|
349
|
+
if (index !== -1) {
|
|
350
|
+
items[index] = value;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (!hasDuplicatedStrings(items, this.caseSensitive)) {
|
|
354
|
+
this.updateItems(items);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (closeInput) {
|
|
359
|
+
this.toggleEditMode(false);
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Remove an item from items list
|
|
365
|
+
*/
|
|
366
|
+
deleteItem(item?: string) {
|
|
367
|
+
const items = this.items.filter((f) => f !== item);
|
|
368
|
+
|
|
369
|
+
this.updateItems(items);
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Update items list and emit to parent component
|
|
374
|
+
*/
|
|
375
|
+
updateItems(items: string[]) {
|
|
376
|
+
this.$emit('change', items);
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
|
|
380
|
+
});
|
|
381
|
+
</script>
|
|
382
|
+
|
|
383
|
+
<template>
|
|
384
|
+
<div
|
|
385
|
+
class="string-list"
|
|
386
|
+
:class="{ readonly }"
|
|
387
|
+
>
|
|
388
|
+
<div
|
|
389
|
+
ref="box"
|
|
390
|
+
data-testid="div-string-list-box"
|
|
391
|
+
class="string-list-box"
|
|
392
|
+
tabindex="0"
|
|
393
|
+
@dblclick="onClickEmptyBody()"
|
|
394
|
+
>
|
|
395
|
+
<div
|
|
396
|
+
v-for="item in items"
|
|
397
|
+
:key="item"
|
|
398
|
+
:ref="item"
|
|
399
|
+
:class="{
|
|
400
|
+
selected: selected === item,
|
|
401
|
+
readonly
|
|
402
|
+
}"
|
|
403
|
+
:data-testid="`div-item-${item}`"
|
|
404
|
+
class="item static"
|
|
405
|
+
tabindex="0"
|
|
406
|
+
@mousedown="onSelect(item)"
|
|
407
|
+
@dblclick.stop="toggleEditMode(true, item)"
|
|
408
|
+
@keydown.down.prevent="onSelectNext('down')"
|
|
409
|
+
@keydown.up.prevent="onSelectNext('up')"
|
|
410
|
+
@blur="onSelectLeave(item)"
|
|
411
|
+
>
|
|
412
|
+
<span
|
|
413
|
+
v-if="!editedItem || editedItem !== item"
|
|
414
|
+
class="label static"
|
|
415
|
+
>
|
|
416
|
+
{{ item }}
|
|
417
|
+
</span>
|
|
418
|
+
<LabeledInput
|
|
419
|
+
v-if="editedItem && editedItem === item"
|
|
420
|
+
ref="item-edit"
|
|
421
|
+
:data-testid="`item-edit-${item}`"
|
|
422
|
+
class="edit-input static"
|
|
423
|
+
:value="value != null ? value : item"
|
|
424
|
+
@input="onChange($event)"
|
|
425
|
+
@blur.prevent="updateItem(item)"
|
|
426
|
+
@keydown.native.enter="updateItem(item, !errors.duplicate)"
|
|
427
|
+
/>
|
|
428
|
+
</div>
|
|
429
|
+
<div
|
|
430
|
+
v-if="isCreateItem"
|
|
431
|
+
class="create-field static"
|
|
432
|
+
>
|
|
433
|
+
<LabeledInput
|
|
434
|
+
ref="item-create"
|
|
435
|
+
data-testid="item-create"
|
|
436
|
+
class="create-input static"
|
|
437
|
+
type="text"
|
|
438
|
+
:value="value"
|
|
439
|
+
:placeholder="placeholder"
|
|
440
|
+
@input="onChange($event)"
|
|
441
|
+
@blur.prevent="saveItem"
|
|
442
|
+
@keydown.native.enter="saveItem(!errors.duplicate)"
|
|
443
|
+
/>
|
|
444
|
+
</div>
|
|
445
|
+
</div>
|
|
446
|
+
<div
|
|
447
|
+
v-if="!readonly"
|
|
448
|
+
class="string-list-footer"
|
|
449
|
+
:class="{[actionsPosition]: true }"
|
|
450
|
+
>
|
|
451
|
+
<div
|
|
452
|
+
data-testid="div-action-buttons"
|
|
453
|
+
class="action-buttons"
|
|
454
|
+
>
|
|
455
|
+
<button
|
|
456
|
+
data-testid="button-remove"
|
|
457
|
+
class="btn btn-sm role-tertiary remove-button"
|
|
458
|
+
:disabled="!selected && !isCreateItem && !editedItem"
|
|
459
|
+
@mousedown.prevent="onClickMinusButton"
|
|
460
|
+
>
|
|
461
|
+
<span class="icon icon-minus icon-sm" />
|
|
462
|
+
</button>
|
|
463
|
+
<button
|
|
464
|
+
data-testid="button-add"
|
|
465
|
+
class="btn btn-sm role-tertiary add-button"
|
|
466
|
+
:disabled="isCreateItem || editedItem"
|
|
467
|
+
@click.prevent="onClickPlusButton"
|
|
468
|
+
>
|
|
469
|
+
<span class="icon icon-plus icon-sm" />
|
|
470
|
+
</button>
|
|
471
|
+
</div>
|
|
472
|
+
<div class="messages">
|
|
473
|
+
<i
|
|
474
|
+
v-if="errorMessagesArray.length > 0"
|
|
475
|
+
data-testid="i-warning-icon"
|
|
476
|
+
class="icon icon-warning icon-lg"
|
|
477
|
+
/>
|
|
478
|
+
<span
|
|
479
|
+
v-for="(msg, idx) in errorMessagesArray"
|
|
480
|
+
:key="idx"
|
|
481
|
+
:data-testid="`span-error-message-${msg}`"
|
|
482
|
+
class="error"
|
|
483
|
+
>
|
|
484
|
+
{{ idx > 0 ? '; ' : '' }}
|
|
485
|
+
{{ msg }}
|
|
486
|
+
</span>
|
|
487
|
+
</div>
|
|
488
|
+
</div>
|
|
489
|
+
</div>
|
|
490
|
+
</template>
|
|
491
|
+
|
|
492
|
+
<style lang="scss" scoped>
|
|
493
|
+
|
|
494
|
+
.string-list {
|
|
495
|
+
display: flex;
|
|
496
|
+
flex-direction: column;
|
|
497
|
+
width: auto;
|
|
498
|
+
|
|
499
|
+
&.readonly {
|
|
500
|
+
cursor: default;
|
|
501
|
+
opacity: 0.4;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.string-list-box {
|
|
505
|
+
min-height: 200px;
|
|
506
|
+
height: 100%;
|
|
507
|
+
outline: none;
|
|
508
|
+
overflow-y: auto;
|
|
509
|
+
overflow-x: hidden;
|
|
510
|
+
border: solid var(--border-width) var(--input-border);
|
|
511
|
+
padding-top: 3px;
|
|
512
|
+
|
|
513
|
+
.static {
|
|
514
|
+
height: 25px;
|
|
515
|
+
padding: 3px;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
.item {
|
|
519
|
+
outline: none;
|
|
520
|
+
|
|
521
|
+
&.selected {
|
|
522
|
+
background: var(--primary);
|
|
523
|
+
color: var(--primary-hover-text);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
&.readonly {
|
|
527
|
+
pointer-events: none;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.label {
|
|
531
|
+
display: block;
|
|
532
|
+
width: auto;
|
|
533
|
+
user-select: none;
|
|
534
|
+
overflow: hidden;
|
|
535
|
+
white-space: no-wrap;
|
|
536
|
+
text-overflow: ellipsis;
|
|
537
|
+
padding-top: 1px;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.create-field {
|
|
542
|
+
padding-top: 1px;
|
|
543
|
+
margin-bottom: 7px;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
.labeled-input {
|
|
547
|
+
padding-top: 0;
|
|
548
|
+
padding-bottom: 0;
|
|
549
|
+
border-radius: 0;
|
|
550
|
+
&.error {
|
|
551
|
+
border: none;
|
|
552
|
+
box-shadow: 0 0 0 var(--outline-width) var(--error);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.string-list-footer {
|
|
558
|
+
--footer-height: 28px;
|
|
559
|
+
height: var(--footer-height);
|
|
560
|
+
margin-top: 5px;
|
|
561
|
+
display: flex;
|
|
562
|
+
justify-content: space-between;
|
|
563
|
+
gap: 0.5rem;
|
|
564
|
+
|
|
565
|
+
&.left {
|
|
566
|
+
flex-direction: row;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
&.right {
|
|
570
|
+
flex-direction: row-reverse;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
.action-buttons {
|
|
574
|
+
display: flex;
|
|
575
|
+
flex-direction: row-reverse;
|
|
576
|
+
gap: 0.5rem;
|
|
577
|
+
|
|
578
|
+
.btn {
|
|
579
|
+
min-height: var(--footer-height);
|
|
580
|
+
line-height: 0;
|
|
581
|
+
border-radius: 2px;
|
|
582
|
+
|
|
583
|
+
&:disabled {
|
|
584
|
+
cursor: default;
|
|
585
|
+
pointer-events: none;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.messages {
|
|
591
|
+
line-height: var(--footer-height);
|
|
592
|
+
|
|
593
|
+
.error, .icon-warning {
|
|
594
|
+
color: var(--error);
|
|
595
|
+
line-height: inherit;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
::v-deep {
|
|
602
|
+
.labeled-input INPUT.no-label,
|
|
603
|
+
.labeled-input INPUT:hover.no-label,
|
|
604
|
+
.labeled-input INPUT:focus.no-label {
|
|
605
|
+
padding: 1px 0px 0px 0px;
|
|
606
|
+
}
|
|
607
|
+
.labeled-input.compact-input {
|
|
608
|
+
min-height: 0;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as StringList } from './StringList.vue';
|