@eclipse-slm/ui 1.5.0-snapshot.868 → 1.5.0-snapshot.877

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.
@@ -0,0 +1,86 @@
1
+ <script setup lang="ts">
2
+ import { ref, toRef } from 'vue';
3
+ import { useToast } from 'vue-toast-notification';
4
+ import logRequestError from '@/api/restApiHelper';
5
+ import ConfirmDialog from '@/components/base/ConfirmDialog.vue';
6
+ import CapabilityCreateForm from '@/components/capabilities/CapabilityCreateForm.vue';
7
+ import { buildCapabilityRequest, newCapabilityFormData } from '@/components/capabilities/capabilityForm';
8
+ import type { CapabilityForm } from '@/components/capabilities/capabilityForm';
9
+ import { useCapabilitiesStore } from '@/stores/capabilitiesStore';
10
+
11
+ const props = defineProps({
12
+ show: {
13
+ type: Boolean,
14
+ default: false,
15
+ },
16
+ });
17
+ const emit = defineEmits(['canceled', 'confirmed']);
18
+
19
+ const $toast = useToast();
20
+ const capabilitiesStore = useCapabilitiesStore();
21
+
22
+ const active = toRef(props, 'show');
23
+ const loading = ref(false);
24
+ const formKey = ref(0);
25
+ const formRef = ref<InstanceType<typeof CapabilityCreateForm> | null>(null);
26
+ const form = ref<CapabilityForm>({ isFormValid: false, formData: newCapabilityFormData() });
27
+
28
+ function clearDialog() {
29
+ formKey.value++; // remount the form to reset vee-validate state
30
+ form.value = { isFormValid: false, formData: newCapabilityFormData() };
31
+ }
32
+
33
+ function closeDialog() {
34
+ clearDialog();
35
+ emit('canceled');
36
+ }
37
+
38
+ async function createCapability() {
39
+ if (!form.value.isFormValid) {
40
+ $toast.error('Please fill in all required fields correctly');
41
+ return;
42
+ }
43
+ loading.value = true;
44
+ try {
45
+ await capabilitiesStore.createCapability(
46
+ buildCapabilityRequest(form.value.formData, globalThis.crypto?.randomUUID?.()),
47
+ );
48
+ $toast.info('Capability created successfully');
49
+ clearDialog();
50
+ emit('confirmed');
51
+ } catch (e) {
52
+ logRequestError(e);
53
+ $toast.error('Failed to create capability');
54
+ } finally {
55
+ loading.value = false;
56
+ }
57
+ }
58
+ </script>
59
+
60
+ <template>
61
+ <ConfirmDialog
62
+ :show="active"
63
+ title="Add capability"
64
+ width="800px"
65
+ cancel-button-label="Cancel"
66
+ confirm-button-label="Create capability"
67
+ :confirm-button-disabled="!form.isFormValid"
68
+ :confirm-loading="loading"
69
+ @canceled="closeDialog"
70
+ @confirmed="createCapability"
71
+ >
72
+ <template #content>
73
+ <CapabilityCreateForm ref="formRef" :key="formKey" v-model="form" />
74
+ </template>
75
+ <template #actions-center>
76
+ <v-btn
77
+ variant="text"
78
+ prepend-icon="mdi-import"
79
+ :disabled="loading"
80
+ @click="formRef?.openImport()"
81
+ >
82
+ Import
83
+ </v-btn>
84
+ </template>
85
+ </ConfirmDialog>
86
+ </template>
@@ -0,0 +1,275 @@
1
+ <script setup lang="ts">
2
+ import { computed, nextTick, ref, watch } from 'vue';
3
+ import { useField, useForm } from 'vee-validate';
4
+ import { useCapabilitiesStore } from '@/stores/capabilitiesStore';
5
+ import IconPickerDialog from '@/components/base/IconPickerDialog.vue';
6
+ import CapabilityActionCard from './CapabilityActionCard.vue';
7
+ import CapabilityImportDialog from './CapabilityImportDialog.vue';
8
+ import {
9
+ allowedTypes,
10
+ cloneActions,
11
+ effectiveTypes,
12
+ fallbackLogo,
13
+ getActionTabColorProps,
14
+ isNameTaken,
15
+ newActionFormData,
16
+ prefillUntouchedActions,
17
+ requiredActions,
18
+ } from './capabilityForm';
19
+ import type {
20
+ ActionFormData,
21
+ CapabilityClass,
22
+ CapabilityForm,
23
+ CapabilityFormData,
24
+ FormActionType,
25
+ FormCapabilityType,
26
+ } from './capabilityForm';
27
+
28
+ const props = defineProps<{ modelValue: CapabilityForm }>();
29
+ const emit = defineEmits<{ (e: 'update:modelValue', value: CapabilityForm): void }>();
30
+
31
+ const capabilitiesStore = useCapabilitiesStore();
32
+
33
+ const deploymentTypeItems = [
34
+ { title: 'Docker container', value: 'DOCKER_CONTAINER' },
35
+ { title: 'Docker compose', value: 'DOCKER_COMPOSE' },
36
+ { title: 'Kubernetes', value: 'KUBERNETES' },
37
+ { title: 'CODESYS', value: 'CODESYS' },
38
+ ];
39
+
40
+ const { errors, validate } = useForm();
41
+
42
+ const { value: name, errorMessage: nameError } = useField<string>('name', (v: string) => {
43
+ if (!v || !v.trim()) return 'Name is required';
44
+ return !isNameTaken(v, capabilitiesStore.capabilities) || 'A capability with this name already exists';
45
+ }, { initialValue: props.modelValue.formData.name });
46
+ const { value: logo } = useField<string>('logo', undefined, { initialValue: props.modelValue.formData.logo });
47
+ const { value: capabilityClass } = useField<CapabilityClass>('capabilityClass', undefined,
48
+ { initialValue: props.modelValue.formData.capabilityClass });
49
+ const { value: deploymentTypes, errorMessage: deploymentTypesError } = useField<string[]>(
50
+ 'supportedDeploymentTypes',
51
+ (v: string[]) => !isDeployTypeSelected.value || (v && v.length > 0)
52
+ || 'Select at least one deployment type',
53
+ { initialValue: props.modelValue.formData.supportedDeploymentTypes });
54
+ const { value: types, errorMessage: typesError } = useField<FormCapabilityType[]>('types',
55
+ () => effectiveTypes(currentFormData()).length > 0 || 'Select at least one capability type',
56
+ { initialValue: props.modelValue.formData.types });
57
+ const actions = ref<Partial<Record<FormActionType, ActionFormData>>>(
58
+ cloneActions(props.modelValue.formData.actions));
59
+
60
+ const showIconPicker = ref(false);
61
+ const showImportDialog = ref(false);
62
+ const activeActionTab = ref<FormActionType | null>(null);
63
+
64
+ const isDeployment = computed(() => capabilityClass.value === 'DeploymentCapability');
65
+ const isDeployTypeSelected = computed(
66
+ () => isDeployment.value && (types.value ?? []).includes('DEPLOY')
67
+ );
68
+ const typeChoices = computed(() => allowedTypes(capabilityClass.value));
69
+ const displayedLogo = computed(() => logo.value || fallbackLogo(name.value ?? ''));
70
+ const actionTypes = computed(() => requiredActions(currentFormData()));
71
+
72
+ function currentFormData(): CapabilityFormData {
73
+ return {
74
+ name: name.value ?? '',
75
+ logo: logo.value ?? '',
76
+ capabilityClass: capabilityClass.value,
77
+ supportedDeploymentTypes: [...(deploymentTypes.value ?? [])],
78
+ types: [...(types.value ?? [])],
79
+ actions: actions.value,
80
+ };
81
+ }
82
+
83
+ // Sync incoming modelValue (e.g. dialog reset) to fields
84
+ watch(() => props.modelValue, (val) => {
85
+ if (JSON.stringify(val.formData) === JSON.stringify(currentFormData())) return;
86
+ const f = val.formData;
87
+ name.value = f.name;
88
+ logo.value = f.logo;
89
+ capabilityClass.value = f.capabilityClass;
90
+ deploymentTypes.value = [...f.supportedDeploymentTypes];
91
+ types.value = [...f.types];
92
+ actions.value = cloneActions(f.actions);
93
+ });
94
+
95
+ // Create missing action entries when their type appears
96
+ watch(actionTypes, (needed) => {
97
+ for (const t of needed) {
98
+ if (!actions.value[t]) {
99
+ actions.value = { ...actions.value, [t]: newActionFormData(t) };
100
+ }
101
+ }
102
+
103
+ if (!needed.length) {
104
+ activeActionTab.value = null;
105
+ return;
106
+ }
107
+
108
+ if (!activeActionTab.value || !needed.includes(activeActionTab.value)) {
109
+ activeActionTab.value = needed[0];
110
+ }
111
+ }, { immediate: true });
112
+
113
+ watch(isDeployTypeSelected, (selected) => {
114
+ if (!selected) {
115
+ deploymentTypes.value = [];
116
+ }
117
+ }, { immediate: true });
118
+
119
+ function setAction(t: FormActionType, value: ActionFormData) {
120
+ actions.value = { ...actions.value, [t]: value };
121
+ }
122
+
123
+ function onSourceChanged(t: FormActionType) {
124
+ if (t !== actionTypes.value[0]) return;
125
+ actions.value = prefillUntouchedActions(actions.value, t);
126
+ }
127
+
128
+ async function onImported(f: CapabilityFormData) {
129
+ showImportDialog.value = false;
130
+ name.value = f.name;
131
+ logo.value = f.logo;
132
+ capabilityClass.value = f.capabilityClass;
133
+ deploymentTypes.value = [...f.supportedDeploymentTypes];
134
+ types.value = [...f.types];
135
+ actions.value = cloneActions(f.actions);
136
+ // Show errors of the imported values right away; wait until new action cards registered their fields
137
+ await nextTick();
138
+ await nextTick();
139
+ await validate();
140
+ }
141
+
142
+ function openImport() {
143
+ showImportDialog.value = true;
144
+ }
145
+
146
+ defineExpose({ openImport });
147
+
148
+ function onIconSelected(icon: string) {
149
+ logo.value = icon;
150
+ showIconPicker.value = false;
151
+ }
152
+
153
+ // Emit changes to parent
154
+ let validationRun = 0;
155
+ watch([name, logo, capabilityClass, deploymentTypes, types, actions], async () => {
156
+ const run = ++validationRun;
157
+ await nextTick(); // let newly mounted action cards register their fields
158
+ const result = await validate({ mode: 'silent' }); // silent: do not flag untouched fields as errors
159
+ if (run !== validationRun) return; // a newer change superseded this run
160
+ emit('update:modelValue', { isFormValid: result.valid, formData: currentFormData() });
161
+ }, { deep: true, immediate: true });
162
+ </script>
163
+
164
+ <template>
165
+ <form @submit.prevent>
166
+ <CapabilityImportDialog
167
+ :show="showImportDialog"
168
+ @imported="onImported"
169
+ @canceled="showImportDialog = false"
170
+ />
171
+
172
+ <div class="text-subtitle-2 mb-2">Icon &amp; Capability Name</div>
173
+ <v-text-field
174
+ v-model="name"
175
+ label="Name"
176
+ required
177
+ :prepend-icon="displayedLogo"
178
+ :error-messages="nameError"
179
+ @click:prepend="showIconPicker = true"
180
+ />
181
+
182
+ <IconPickerDialog
183
+ :show="showIconPicker"
184
+ :model-value="logo"
185
+ @selected="onIconSelected"
186
+ @canceled="showIconPicker = false"
187
+ />
188
+
189
+ <div class="mb-4">
190
+ <div class="text-subtitle-2">Capability class</div>
191
+ <v-radio-group v-model="capabilityClass" inline hide-details>
192
+ <v-radio label="Deployment" value="DeploymentCapability" />
193
+ <v-radio label="Base configuration" value="BaseConfigurationCapability" />
194
+ </v-radio-group>
195
+ </div>
196
+
197
+ <div class="mb-4">
198
+ <div class="text-subtitle-2">Capability types</div>
199
+ <div class="d-flex align-center flex-wrap">
200
+ <template v-if="isDeployment">
201
+ <v-checkbox
202
+ v-for="t in typeChoices"
203
+ :key="t"
204
+ v-model="types"
205
+ :label="t"
206
+ :value="t"
207
+ multiple
208
+ hide-details
209
+ density="compact"
210
+ class="mr-4"
211
+ inline
212
+ />
213
+ </template>
214
+ <v-checkbox
215
+ v-else
216
+ :model-value="true"
217
+ label="SETUP"
218
+ disabled
219
+ hide-details
220
+ density="compact"
221
+ inline
222
+ />
223
+ </div>
224
+ <div v-if="typesError" class="text-caption text-error">{{ typesError }}</div>
225
+ </div>
226
+
227
+ <div v-if="actionTypes.length" class="mt-2">
228
+ <div class="text-subtitle-2 mb-2">Action types</div>
229
+
230
+ <v-tabs
231
+ v-model="activeActionTab"
232
+ color="primary"
233
+ density="compact"
234
+ class="mb-2"
235
+ >
236
+ <v-tab
237
+ v-for="t in actionTypes"
238
+ :key="`tab-${t}`"
239
+ :value="t"
240
+ v-bind="getActionTabColorProps(t, errors)"
241
+ >
242
+ {{ t }}
243
+ </v-tab>
244
+ </v-tabs>
245
+
246
+ <v-window v-model="activeActionTab">
247
+ <v-window-item
248
+ v-for="t in actionTypes"
249
+ :key="`panel-${t}`"
250
+ :value="t"
251
+ eager
252
+ >
253
+ <CapabilityActionCard
254
+ v-if="actions[t]"
255
+ :action-type="t"
256
+ :model-value="actions[t]!"
257
+ @update:model-value="setAction(t, $event)"
258
+ @source-changed="onSourceChanged(t)"
259
+ />
260
+ </v-window-item>
261
+ </v-window>
262
+ </div>
263
+
264
+ <div v-if="isDeployTypeSelected" class="mb-2">
265
+ <div class="text-subtitle-2 mb-2">Supported deployment types</div>
266
+ <v-select
267
+ v-model="deploymentTypes"
268
+ multiple
269
+ chips
270
+ :items="deploymentTypeItems"
271
+ :error-messages="deploymentTypesError"
272
+ />
273
+ </div>
274
+ </form>
275
+ </template>
@@ -0,0 +1,99 @@
1
+ <script setup lang="ts">
2
+ import { computed, ref, watch } from 'vue';
3
+ import { useToast } from 'vue-toast-notification';
4
+ import ResourceManagementClient from '@/api/resource-management/resource-management-client';
5
+ import logRequestError from '@/api/restApiHelper';
6
+ import ConfirmDialog from '@/components/base/ConfirmDialog.vue';
7
+ import { capabilityToFormData, DEFAULT_BRANCH, importErrorMessage } from './capabilityForm';
8
+ import type { CapabilityFormData, ImportedCapability } from './capabilityForm';
9
+
10
+ const DEFAULT_FILE_PATH = 'capability.json';
11
+
12
+ const props = defineProps<{ show: boolean }>();
13
+ const emit = defineEmits<{
14
+ (e: 'imported', value: CapabilityFormData): void;
15
+ (e: 'canceled'): void;
16
+ }>();
17
+
18
+ const $toast = useToast();
19
+
20
+ const repositoryUrl = ref('');
21
+ const branch = ref(DEFAULT_BRANCH);
22
+ const filePath = ref(DEFAULT_FILE_PATH);
23
+ const loading = ref(false);
24
+ // Bumped whenever the dialog closes, so a response that arrives after cancel is ignored
25
+ let requestId = 0;
26
+
27
+ const urlRule = (v: string) => /^https?:\/\/\S+$/i.test((v ?? '').trim()) || 'Must start with http:// or https://';
28
+ const isUrlValid = computed(() => urlRule(repositoryUrl.value) === true);
29
+
30
+ // Start from the defaults each time the dialog opens
31
+ watch(() => props.show, (open) => {
32
+ if (!open) {
33
+ requestId++;
34
+ loading.value = false;
35
+ return;
36
+ }
37
+ repositoryUrl.value = '';
38
+ branch.value = DEFAULT_BRANCH;
39
+ filePath.value = DEFAULT_FILE_PATH;
40
+ });
41
+
42
+ async function importCapability() {
43
+ if (!isUrlValid.value) return;
44
+ const id = ++requestId;
45
+ loading.value = true;
46
+ try {
47
+ const response = await ResourceManagementClient.capabilityApi.importCapabilityFromGit({
48
+ repositoryUrl: repositoryUrl.value.trim(),
49
+ branch: branch.value.trim(),
50
+ filePath: filePath.value.trim(),
51
+ });
52
+ if (id !== requestId) return;
53
+ if (!response.data || typeof response.data !== 'object') {
54
+ $toast.error('Failed to import capability');
55
+ return;
56
+ }
57
+ emit('imported', capabilityToFormData(response.data as ImportedCapability));
58
+ } catch (e) {
59
+ if (id !== requestId) return;
60
+ logRequestError(e);
61
+ $toast.error(importErrorMessage(e));
62
+ } finally {
63
+ if (id === requestId) loading.value = false;
64
+ }
65
+ }
66
+ </script>
67
+
68
+ <template>
69
+ <ConfirmDialog
70
+ :show="show"
71
+ title="Import capability"
72
+ width="600px"
73
+ cancel-button-label="Cancel"
74
+ confirm-button-label="Import"
75
+ :confirm-button-disabled="!isUrlValid"
76
+ :confirm-loading="loading"
77
+ @canceled="emit('canceled')"
78
+ @confirmed="importCapability"
79
+ >
80
+ <template #content>
81
+ <v-text-field
82
+ v-model="repositoryUrl"
83
+ label="Repository URL"
84
+ required
85
+ :rules="[urlRule]"
86
+ />
87
+ <v-text-field
88
+ v-model="branch"
89
+ label="Branch or tag"
90
+ />
91
+ <v-text-field
92
+ v-model="filePath"
93
+ label="File path"
94
+ hint="Path inside the repository"
95
+ persistent-hint
96
+ />
97
+ </template>
98
+ </ConfirmDialog>
99
+ </template>
@@ -0,0 +1,201 @@
1
+ import type { GetCapabilities200ResponseInner } from '@/api/resource-management/client'
2
+
3
+ export type CapabilityClass = 'DeploymentCapability' | 'BaseConfigurationCapability'
4
+ export type FormCapabilityType = 'SETUP' | 'DEPLOY'
5
+ export type FormActionType = 'INSTALL' | 'UNINSTALL' | 'DEPLOY' | 'UNDEPLOY'
6
+
7
+ export interface ActionFormData {
8
+ awxRepo: string
9
+ awxBranch: string
10
+ playbook: string
11
+ }
12
+
13
+ export interface CapabilityFormData {
14
+ name: string
15
+ logo: string // '' = use fallback
16
+ capabilityClass: CapabilityClass
17
+ supportedDeploymentTypes: string[] // DeploymentType values
18
+ types: FormCapabilityType[]
19
+ actions: Partial<Record<FormActionType, ActionFormData>>
20
+ }
21
+
22
+ export interface CapabilityForm {
23
+ isFormValid: boolean
24
+ formData: CapabilityFormData
25
+ }
26
+
27
+ export const DEFAULT_BRANCH = 'main'
28
+
29
+ const DEFAULT_PLAYBOOKS: Record<FormActionType, string> = {
30
+ INSTALL: 'install.yml',
31
+ UNINSTALL: 'uninstall.yml',
32
+ DEPLOY: 'deploy.yml',
33
+ UNDEPLOY: 'undeploy.yml',
34
+ }
35
+
36
+ const TYPE_ORDER: FormCapabilityType[] = ['SETUP', 'DEPLOY']
37
+
38
+ export const ACTIONS_BY_TYPE: Record<FormCapabilityType, FormActionType[]> = {
39
+ SETUP: ['INSTALL', 'UNINSTALL'],
40
+ DEPLOY: ['DEPLOY', 'UNDEPLOY'],
41
+ }
42
+
43
+ export function newActionFormData(actionType?: FormActionType): ActionFormData {
44
+ return { awxRepo: '', awxBranch: DEFAULT_BRANCH, playbook: actionType ? DEFAULT_PLAYBOOKS[actionType] : '' }
45
+ }
46
+
47
+ export function newCapabilityFormData(): CapabilityFormData {
48
+ return {
49
+ name: '',
50
+ logo: '',
51
+ capabilityClass: 'DeploymentCapability',
52
+ supportedDeploymentTypes: [],
53
+ types: [],
54
+ actions: {},
55
+ }
56
+ }
57
+
58
+ export function allowedTypes(cls: CapabilityClass): FormCapabilityType[] {
59
+ return cls === 'BaseConfigurationCapability' ? ['SETUP'] : ['SETUP', 'DEPLOY']
60
+ }
61
+
62
+ export function effectiveTypes(form: CapabilityFormData): FormCapabilityType[] {
63
+ if (form.capabilityClass === 'BaseConfigurationCapability') {
64
+ return ['SETUP']
65
+ }
66
+ const allowed = allowedTypes(form.capabilityClass)
67
+ return TYPE_ORDER.filter(t => allowed.includes(t) && form.types.includes(t))
68
+ }
69
+
70
+ export function requiredActions(form: CapabilityFormData): FormActionType[] {
71
+ return effectiveTypes(form).flatMap(t => ACTIONS_BY_TYPE[t])
72
+ }
73
+
74
+ export function hasActionErrors(
75
+ actionType: FormActionType,
76
+ errors: Record<string, string | undefined>,
77
+ ): boolean {
78
+ const prefix = `${actionType}.`
79
+ return Object.entries(errors).some(([field, message]) => field.startsWith(prefix) && !!message)
80
+ }
81
+
82
+ export function getActionTabColorProps(
83
+ actionType: FormActionType,
84
+ errors: Record<string, string | undefined>,
85
+ ): { color?: 'error'; baseColor?: 'error' } {
86
+ return hasActionErrors(actionType, errors) ? { color: 'error', baseColor: 'error' } : {}
87
+ }
88
+
89
+ export function fallbackLogo(name: string): string {
90
+ const first = name.trim().charAt(0).toLowerCase()
91
+ if (/^[a-z]$/.test(first)) {
92
+ return `mdi-alpha-${first}-box`
93
+ }
94
+ if (/^[0-9]$/.test(first)) {
95
+ return `mdi-numeric-${first}-box`
96
+ }
97
+ return 'mdi-puzzle'
98
+ }
99
+
100
+ export function isNameTaken(name: string, existing: { name: string }[]): boolean {
101
+ const wanted = name.trim().toLowerCase()
102
+ return existing.some(c => c.name.trim().toLowerCase() === wanted)
103
+ }
104
+
105
+ function isUntouched(action: ActionFormData, actionType: FormActionType): boolean {
106
+ return action.awxRepo === '' && action.playbook === DEFAULT_PLAYBOOKS[actionType]
107
+ && action.awxBranch === DEFAULT_BRANCH
108
+ }
109
+
110
+ // Plain-object copy; structuredClone throws on Vue reactive proxies
111
+ export function cloneActions(
112
+ actions: Partial<Record<FormActionType, ActionFormData>>,
113
+ ): Partial<Record<FormActionType, ActionFormData>> {
114
+ const result: Partial<Record<FormActionType, ActionFormData>> = {}
115
+ for (const [key, value] of Object.entries(actions) as [FormActionType, ActionFormData][]) {
116
+ result[key] = { ...value }
117
+ }
118
+ return result
119
+ }
120
+
121
+ export function prefillUntouchedActions(
122
+ actions: Partial<Record<FormActionType, ActionFormData>>,
123
+ source: FormActionType,
124
+ ): Partial<Record<FormActionType, ActionFormData>> {
125
+ const src = actions[source]
126
+ const result: Partial<Record<FormActionType, ActionFormData>> = {}
127
+ for (const [key, value] of Object.entries(actions) as [FormActionType, ActionFormData][]) {
128
+ result[key] = src && key !== source && isUntouched(value, key)
129
+ ? { ...value, awxRepo: src.awxRepo, awxBranch: src.awxBranch }
130
+ : { ...value }
131
+ }
132
+ return result
133
+ }
134
+
135
+ // Capability definition as returned by the git import endpoint; only the fields the form can show
136
+ export interface ImportedCapability {
137
+ capabilityClass?: string
138
+ name?: string
139
+ logo?: string
140
+ type?: string[]
141
+ supportedDeploymentTypes?: string[]
142
+ actions?: Record<string, { awxRepo?: string; awxBranch?: string; playbook?: string } | undefined>
143
+ }
144
+
145
+ const FORM_ACTION_TYPES: FormActionType[] = ['INSTALL', 'UNINSTALL', 'DEPLOY', 'UNDEPLOY']
146
+
147
+ export function capabilityToFormData(c: ImportedCapability): CapabilityFormData {
148
+ const capabilityClass: CapabilityClass = c.capabilityClass === 'BaseConfigurationCapability'
149
+ ? 'BaseConfigurationCapability'
150
+ : 'DeploymentCapability'
151
+ const actions: Partial<Record<FormActionType, ActionFormData>> = {}
152
+ for (const t of FORM_ACTION_TYPES) {
153
+ const a = c.actions?.[t]
154
+ if (a) {
155
+ actions[t] = { awxRepo: a.awxRepo ?? '', awxBranch: a.awxBranch ?? DEFAULT_BRANCH, playbook: a.playbook ?? '' }
156
+ }
157
+ }
158
+ return {
159
+ name: c.name ?? '',
160
+ logo: c.logo ?? '',
161
+ capabilityClass,
162
+ supportedDeploymentTypes: capabilityClass === 'DeploymentCapability' ? [...(c.supportedDeploymentTypes ?? [])] : [],
163
+ types: TYPE_ORDER.filter(t => (c.type ?? []).includes(t)),
164
+ actions,
165
+ }
166
+ }
167
+
168
+ export function importErrorMessage(e: unknown): string {
169
+ const message = (e as { response?: { data?: { message?: unknown } } })?.response?.data?.message
170
+ return typeof message === 'string' && message ? message : 'Failed to import capability'
171
+ }
172
+
173
+ export function buildCapabilityRequest(form: CapabilityFormData, id?: string): GetCapabilities200ResponseInner {
174
+ const name = form.name.trim()
175
+ const actions: Record<string, unknown> = {}
176
+ for (const actionType of requiredActions(form)) {
177
+ const a = form.actions[actionType] ?? newActionFormData()
178
+ actions[actionType] = {
179
+ actionClass: 'AwxAction',
180
+ actionType,
181
+ awxRepo: a.awxRepo.trim(),
182
+ awxBranch: a.awxBranch.trim(),
183
+ playbook: a.playbook.trim(),
184
+ connectionTypes: ['ssh'],
185
+ skipable: false,
186
+ configParameters: [],
187
+ }
188
+ }
189
+ const body: Record<string, unknown> = {
190
+ ...(id !== undefined ? { id } : {}),
191
+ capabilityClass: form.capabilityClass,
192
+ name,
193
+ logo: form.logo.trim() || fallbackLogo(name),
194
+ type: effectiveTypes(form),
195
+ actions,
196
+ }
197
+ if (form.capabilityClass === 'DeploymentCapability') {
198
+ body.supportedDeploymentTypes = form.supportedDeploymentTypes
199
+ }
200
+ return body as unknown as GetCapabilities200ResponseInner
201
+ }
@@ -153,6 +153,16 @@ export default {
153
153
  @use 'vuetify/lib/styles/tools/_rtl.sass' as *
154
154
 
155
155
  #core-navigation-drawer
156
+ // Vuetify adds the group's prepend width (40px) to the child indent. Set it through Vuetify's own
157
+ // variable: overriding --prepend-width directly only works when our CSS happens to load after Vuetify's.
158
+ --v-list-group-prepend: 0px
159
+
160
+ .v-list-group
161
+ --list-indent-size: 8px
162
+
163
+ .v-list-group--sub-group .v-list-group__items
164
+ --indent-padding: 24px
165
+
156
166
  .v-list-group__header.v-list-item--active:before
157
167
  opacity: .24
158
168
 
@@ -180,10 +190,10 @@ export default {
180
190
  .v-list-group--sub-group
181
191
  .v-list-item
182
192
  +ltr()
183
- padding-left: 8px
193
+ padding-left: 4px
184
194
 
185
195
  +rtl()
186
- padding-right: 8px
196
+ padding-right: 4px
187
197
 
188
198
  .v-list-group__header
189
199
  +ltr()