@eclipse-slm/ui 1.5.0-snapshot.883 → 1.5.0-snapshot.956
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/README.md +1 -0
- package/package.json +6 -7
- package/src/api/ansible-service/ansible-service-client.ts +15 -0
- package/src/api/ansible-service/ansible-service-sse.ts +124 -0
- package/src/api/resource-management/resource-management-client.ts +0 -2
- package/src/app/navigation.ts +14 -0
- package/src/app/routes.ts +17 -0
- package/src/components/admin/ansible/AnsibleAdminImages.vue +113 -0
- package/src/components/admin/ansible/AnsibleAdminJobs.vue +179 -0
- package/src/components/admin/ansible/AnsibleAdminOperations.vue +124 -0
- package/src/components/capabilities/CapabilitiesTable.vue +3 -3
- package/src/components/capabilities/CapabilityActionCard.vue +15 -14
- package/src/components/capabilities/CapabilityCreateForm.vue +33 -2
- package/src/components/capabilities/CapabilityImportDialog.vue +16 -7
- package/src/components/capabilities/capabilityForm.ts +65 -22
- package/src/components/jobs/JobDetail.vue +395 -0
- package/src/components/jobs/JobStatusChip.vue +16 -0
- package/src/components/jobs/JobsOverview.vue +59 -72
- package/src/components/profilers/ProfilerDialog.vue +95 -0
- package/src/components/profilers/ProfilerForm.vue +102 -0
- package/src/components/profilers/ProfilersTable.vue +98 -0
- package/src/components/profilers/profilerForm.ts +46 -0
- package/src/docker/entrypoint.sh +2 -2
- package/src/localisation/en.json +90 -0
- package/src/pages/AdminAnsibleServicePage.vue +111 -0
- package/src/pages/AdminProfilersPage.vue +73 -0
- package/src/pages/DashboardPage.vue +28 -56
- package/src/pages/JobDetailPage.vue +7 -0
- package/src/stores/ansibleAdminStore.ts +206 -0
- package/src/stores/environmentStore.ts +3 -3
- package/src/stores/jobsStore.ts +39 -39
- package/src/stores/profilersStore.ts +80 -0
- package/src/stores/resourceDevicesStore.ts +2 -2
- package/src/stores/serviceInstancesStore.ts +0 -1
- package/src/stores/serviceOfferingsStore.ts +1 -1
- package/src/utils/jobStatus.ts +63 -0
- package/vite/dist/apiClients.d.ts +1 -1
- package/vite/dist/apiClients.js +1 -0
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
:key="actionType"
|
|
101
101
|
>
|
|
102
102
|
<td>{{ actionType }}</td>
|
|
103
|
-
<td>{{ action.
|
|
104
|
-
<td>{{ action.
|
|
103
|
+
<td>{{ action.repo }}</td>
|
|
104
|
+
<td>{{ action.ref }}</td>
|
|
105
105
|
<td>{{ action.playbook }}</td>
|
|
106
106
|
</tr>
|
|
107
107
|
</tbody>
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
:show="capabilityToDelete !== null"
|
|
116
116
|
attention
|
|
117
117
|
title="Delete capability"
|
|
118
|
-
:text="`Delete capability '${capabilityToDelete?.name}'
|
|
118
|
+
:text="`Delete capability '${capabilityToDelete?.name}'?`"
|
|
119
119
|
confirm-button-label="Delete"
|
|
120
120
|
cancel-button-label="Cancel"
|
|
121
121
|
:confirm-loading="deleting"
|
|
@@ -10,34 +10,35 @@ const emit = defineEmits<{
|
|
|
10
10
|
}>();
|
|
11
11
|
|
|
12
12
|
const repoRule = (v: string) => {
|
|
13
|
-
if (!v) return '
|
|
13
|
+
if (!v) return 'Repository is required';
|
|
14
14
|
return /^(https?:\/\/|git@)/.test(v) || 'Must start with http://, https:// or git@';
|
|
15
15
|
};
|
|
16
16
|
const requiredRule = (label: string) => (v: string) => !!v || `${label} is required`;
|
|
17
17
|
|
|
18
18
|
const prefix = props.actionType;
|
|
19
|
-
const { value:
|
|
20
|
-
initialValue: props.modelValue.
|
|
19
|
+
const { value: repo, errorMessage: repoError } = useField<string>(`${prefix}.repo`, repoRule, {
|
|
20
|
+
initialValue: props.modelValue.repo,
|
|
21
21
|
});
|
|
22
|
-
const { value:
|
|
23
|
-
`${prefix}.
|
|
22
|
+
const { value: gitRef, errorMessage: branchError } = useField<string>(
|
|
23
|
+
`${prefix}.ref`, requiredRule('Branch'), { initialValue: props.modelValue.ref });
|
|
24
24
|
const { value: playbook, errorMessage: playbookError } = useField<string>(
|
|
25
25
|
`${prefix}.playbook`, requiredRule('Playbook'), { initialValue: props.modelValue.playbook });
|
|
26
26
|
|
|
27
27
|
watch(() => props.modelValue, (val) => {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
repo.value = val.repo;
|
|
29
|
+
gitRef.value = val.ref;
|
|
30
30
|
playbook.value = val.playbook;
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
watch([
|
|
33
|
+
watch([repo, gitRef, playbook], () => {
|
|
34
34
|
const m = props.modelValue;
|
|
35
|
-
if (m.
|
|
35
|
+
if (m.repo === repo.value && m.ref === gitRef.value && m.playbook === playbook.value) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
emit('update:modelValue', {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
...m, // keep imported fields the card does not edit (image, connection types, ...)
|
|
40
|
+
repo: repo.value ?? '',
|
|
41
|
+
ref: gitRef.value ?? '',
|
|
41
42
|
playbook: playbook.value ?? '',
|
|
42
43
|
});
|
|
43
44
|
});
|
|
@@ -47,8 +48,8 @@ watch([awxRepo, awxBranch, playbook], () => {
|
|
|
47
48
|
<v-card variant="outlined" class="mt-4 mb-4">
|
|
48
49
|
<v-card-text>
|
|
49
50
|
<v-text-field
|
|
50
|
-
v-model="
|
|
51
|
-
label="
|
|
51
|
+
v-model="repo"
|
|
52
|
+
label="Repository"
|
|
52
53
|
required
|
|
53
54
|
class="mb-2"
|
|
54
55
|
hide-details="auto"
|
|
@@ -56,7 +57,7 @@ watch([awxRepo, awxBranch, playbook], () => {
|
|
|
56
57
|
@blur="emit('source-changed')"
|
|
57
58
|
/>
|
|
58
59
|
<v-text-field
|
|
59
|
-
v-model="
|
|
60
|
+
v-model="gitRef"
|
|
60
61
|
label="Branch"
|
|
61
62
|
required
|
|
62
63
|
class="mb-2"
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getActionTabColorProps,
|
|
14
14
|
isNameTaken,
|
|
15
15
|
newActionFormData,
|
|
16
|
+
PLAYBOOK_CONTRACT_PATTERN,
|
|
16
17
|
prefillUntouchedActions,
|
|
17
18
|
requiredActions,
|
|
18
19
|
} from './capabilityForm';
|
|
@@ -39,10 +40,25 @@ const deploymentTypeItems = [
|
|
|
39
40
|
|
|
40
41
|
const { errors, validate } = useForm();
|
|
41
42
|
|
|
43
|
+
// Fields of an imported capability the form passes through unchanged (id, other actions, cluster member types, ...)
|
|
44
|
+
const passThrough = ref<Pick<CapabilityFormData, 'id' | 'extraActions' | 'extra'>>(pickPassThrough(props.modelValue.formData));
|
|
45
|
+
|
|
46
|
+
function pickPassThrough(f: CapabilityFormData): Pick<CapabilityFormData, 'id' | 'extraActions' | 'extra'> {
|
|
47
|
+
return {
|
|
48
|
+
...(f.id ? { id: f.id } : {}),
|
|
49
|
+
...(f.extraActions ? { extraActions: f.extraActions } : {}),
|
|
50
|
+
...(f.extra ? { extra: f.extra } : {}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
const { value: name, errorMessage: nameError } = useField<string>('name', (v: string) => {
|
|
43
55
|
if (!v || !v.trim()) return 'Name is required';
|
|
44
|
-
return !isNameTaken(v, capabilitiesStore.capabilities)
|
|
56
|
+
return !isNameTaken(v, capabilitiesStore.capabilities, passThrough.value.id)
|
|
57
|
+
|| 'A capability with this name already exists';
|
|
45
58
|
}, { initialValue: props.modelValue.formData.name });
|
|
59
|
+
const { value: playbookContract, errorMessage: playbookContractError } = useField<string>('playbookContract',
|
|
60
|
+
(v: string) => PLAYBOOK_CONTRACT_PATTERN.test((v ?? '').trim()) || 'Playbook contract must have the form MAJOR.MINOR, e.g. 1.0',
|
|
61
|
+
{ initialValue: props.modelValue.formData.playbookContract });
|
|
46
62
|
const { value: logo } = useField<string>('logo', undefined, { initialValue: props.modelValue.formData.logo });
|
|
47
63
|
const { value: capabilityClass } = useField<CapabilityClass>('capabilityClass', undefined,
|
|
48
64
|
{ initialValue: props.modelValue.formData.capabilityClass });
|
|
@@ -77,6 +93,8 @@ function currentFormData(): CapabilityFormData {
|
|
|
77
93
|
supportedDeploymentTypes: [...(deploymentTypes.value ?? [])],
|
|
78
94
|
types: [...(types.value ?? [])],
|
|
79
95
|
actions: actions.value,
|
|
96
|
+
playbookContract: playbookContract.value ?? '',
|
|
97
|
+
...passThrough.value,
|
|
80
98
|
};
|
|
81
99
|
}
|
|
82
100
|
|
|
@@ -90,6 +108,8 @@ watch(() => props.modelValue, (val) => {
|
|
|
90
108
|
deploymentTypes.value = [...f.supportedDeploymentTypes];
|
|
91
109
|
types.value = [...f.types];
|
|
92
110
|
actions.value = cloneActions(f.actions);
|
|
111
|
+
playbookContract.value = f.playbookContract;
|
|
112
|
+
passThrough.value = pickPassThrough(f);
|
|
93
113
|
});
|
|
94
114
|
|
|
95
115
|
// Create missing action entries when their type appears
|
|
@@ -133,6 +153,8 @@ async function onImported(f: CapabilityFormData) {
|
|
|
133
153
|
deploymentTypes.value = [...f.supportedDeploymentTypes];
|
|
134
154
|
types.value = [...f.types];
|
|
135
155
|
actions.value = cloneActions(f.actions);
|
|
156
|
+
playbookContract.value = f.playbookContract;
|
|
157
|
+
passThrough.value = pickPassThrough(f);
|
|
136
158
|
// Show errors of the imported values right away; wait until new action cards registered their fields
|
|
137
159
|
await nextTick();
|
|
138
160
|
await nextTick();
|
|
@@ -152,7 +174,7 @@ function onIconSelected(icon: string) {
|
|
|
152
174
|
|
|
153
175
|
// Emit changes to parent
|
|
154
176
|
let validationRun = 0;
|
|
155
|
-
watch([name, logo, capabilityClass, deploymentTypes, types, actions], async () => {
|
|
177
|
+
watch([name, logo, capabilityClass, deploymentTypes, types, actions, playbookContract, passThrough], async () => {
|
|
156
178
|
const run = ++validationRun;
|
|
157
179
|
await nextTick(); // let newly mounted action cards register their fields
|
|
158
180
|
const result = await validate({ mode: 'silent' }); // silent: do not flag untouched fields as errors
|
|
@@ -261,6 +283,15 @@ watch([name, logo, capabilityClass, deploymentTypes, types, actions], async () =
|
|
|
261
283
|
</v-window>
|
|
262
284
|
</div>
|
|
263
285
|
|
|
286
|
+
<v-text-field
|
|
287
|
+
v-model="playbookContract"
|
|
288
|
+
label="Playbook contract"
|
|
289
|
+
hint="Version (MAJOR.MINOR) of the playbook contract the playbooks were written for"
|
|
290
|
+
persistent-hint
|
|
291
|
+
class="mb-4"
|
|
292
|
+
:error-messages="playbookContractError"
|
|
293
|
+
/>
|
|
294
|
+
|
|
264
295
|
<div v-if="isDeployTypeSelected" class="mb-2">
|
|
265
296
|
<div class="text-subtitle-2 mb-2">Supported deployment types</div>
|
|
266
297
|
<v-select
|
|
@@ -47,7 +47,7 @@ async function importCapability() {
|
|
|
47
47
|
const response = await ResourceManagementClient.capabilityApi.importCapabilityFromGit({
|
|
48
48
|
repositoryUrl: repositoryUrl.value.trim(),
|
|
49
49
|
branch: branch.value.trim(),
|
|
50
|
-
filePath: filePath.value.trim(),
|
|
50
|
+
filePath: filePath.value.trim() || DEFAULT_FILE_PATH,
|
|
51
51
|
});
|
|
52
52
|
if (id !== requestId) return;
|
|
53
53
|
if (!response.data || typeof response.data !== 'object') {
|
|
@@ -86,14 +86,23 @@ async function importCapability() {
|
|
|
86
86
|
/>
|
|
87
87
|
<v-text-field
|
|
88
88
|
v-model="branch"
|
|
89
|
-
label="
|
|
90
|
-
|
|
91
|
-
<v-text-field
|
|
92
|
-
v-model="filePath"
|
|
93
|
-
label="File path"
|
|
94
|
-
hint="Path inside the repository"
|
|
89
|
+
label="Tag or branch"
|
|
90
|
+
hint="Version of the capability, e.g. 1.1.0"
|
|
95
91
|
persistent-hint
|
|
96
92
|
/>
|
|
93
|
+
<v-expansion-panels variant="accordion" class="mt-4">
|
|
94
|
+
<v-expansion-panel title="Advanced">
|
|
95
|
+
<v-expansion-panel-text>
|
|
96
|
+
<v-text-field
|
|
97
|
+
v-model="filePath"
|
|
98
|
+
label="File path"
|
|
99
|
+
:placeholder="DEFAULT_FILE_PATH"
|
|
100
|
+
hint="Path of the capability definition inside the repository"
|
|
101
|
+
persistent-hint
|
|
102
|
+
/>
|
|
103
|
+
</v-expansion-panel-text>
|
|
104
|
+
</v-expansion-panel>
|
|
105
|
+
</v-expansion-panels>
|
|
97
106
|
</template>
|
|
98
107
|
</ConfirmDialog>
|
|
99
108
|
</template>
|
|
@@ -5,9 +5,11 @@ export type FormCapabilityType = 'SETUP' | 'DEPLOY'
|
|
|
5
5
|
export type FormActionType = 'INSTALL' | 'UNINSTALL' | 'DEPLOY' | 'UNDEPLOY'
|
|
6
6
|
|
|
7
7
|
export interface ActionFormData {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
repo: string
|
|
9
|
+
ref: string
|
|
10
10
|
playbook: string
|
|
11
|
+
// Imported action fields the form does not edit (image, connectionTypes, timeoutMinutes, ...); sent unchanged
|
|
12
|
+
extra?: Record<string, unknown>
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export interface CapabilityFormData {
|
|
@@ -17,6 +19,14 @@ export interface CapabilityFormData {
|
|
|
17
19
|
supportedDeploymentTypes: string[] // DeploymentType values
|
|
18
20
|
types: FormCapabilityType[]
|
|
19
21
|
actions: Partial<Record<FormActionType, ActionFormData>>
|
|
22
|
+
// Playbook contract (MAJOR.MINOR) the Ansible actions were written for
|
|
23
|
+
playbookContract: string
|
|
24
|
+
// Set by an import: the fixed id of the imported capability, so that importing it again updates it
|
|
25
|
+
id?: string
|
|
26
|
+
// Imported actions the form cannot edit (e.g. UPDATE, SCALE_UP); sent unchanged
|
|
27
|
+
extraActions?: Record<string, unknown>
|
|
28
|
+
// Imported capability fields the form does not edit (e.g. clusterMemberTypes); sent unchanged
|
|
29
|
+
extra?: Record<string, unknown>
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
export interface CapabilityForm {
|
|
@@ -26,6 +36,11 @@ export interface CapabilityForm {
|
|
|
26
36
|
|
|
27
37
|
export const DEFAULT_BRANCH = 'main'
|
|
28
38
|
|
|
39
|
+
// Playbook contract supported by this SLM version (see PlaybookContract of the ansible_service)
|
|
40
|
+
export const DEFAULT_PLAYBOOK_CONTRACT = '1.0'
|
|
41
|
+
|
|
42
|
+
export const PLAYBOOK_CONTRACT_PATTERN = /^\d+\.\d+$/
|
|
43
|
+
|
|
29
44
|
const DEFAULT_PLAYBOOKS: Record<FormActionType, string> = {
|
|
30
45
|
INSTALL: 'install.yml',
|
|
31
46
|
UNINSTALL: 'uninstall.yml',
|
|
@@ -41,7 +56,7 @@ export const ACTIONS_BY_TYPE: Record<FormCapabilityType, FormActionType[]> = {
|
|
|
41
56
|
}
|
|
42
57
|
|
|
43
58
|
export function newActionFormData(actionType?: FormActionType): ActionFormData {
|
|
44
|
-
return {
|
|
59
|
+
return { repo: '', ref: DEFAULT_BRANCH, playbook: actionType ? DEFAULT_PLAYBOOKS[actionType] : '' }
|
|
45
60
|
}
|
|
46
61
|
|
|
47
62
|
export function newCapabilityFormData(): CapabilityFormData {
|
|
@@ -52,6 +67,7 @@ export function newCapabilityFormData(): CapabilityFormData {
|
|
|
52
67
|
supportedDeploymentTypes: [],
|
|
53
68
|
types: [],
|
|
54
69
|
actions: {},
|
|
70
|
+
playbookContract: DEFAULT_PLAYBOOK_CONTRACT,
|
|
55
71
|
}
|
|
56
72
|
}
|
|
57
73
|
|
|
@@ -97,14 +113,15 @@ export function fallbackLogo(name: string): string {
|
|
|
97
113
|
return 'mdi-puzzle'
|
|
98
114
|
}
|
|
99
115
|
|
|
100
|
-
|
|
116
|
+
// ownId: id of the capability being edited (an imported capability that may already exist), not counted as a clash
|
|
117
|
+
export function isNameTaken(name: string, existing: { name: string; id?: string }[], ownId?: string): boolean {
|
|
101
118
|
const wanted = name.trim().toLowerCase()
|
|
102
|
-
return existing.some(c => c.name.trim().toLowerCase() === wanted)
|
|
119
|
+
return existing.some(c => c.name.trim().toLowerCase() === wanted && (ownId === undefined || c.id !== ownId))
|
|
103
120
|
}
|
|
104
121
|
|
|
105
122
|
function isUntouched(action: ActionFormData, actionType: FormActionType): boolean {
|
|
106
|
-
return action.
|
|
107
|
-
&& action.
|
|
123
|
+
return action.repo === '' && action.playbook === DEFAULT_PLAYBOOKS[actionType]
|
|
124
|
+
&& action.ref === DEFAULT_BRANCH
|
|
108
125
|
}
|
|
109
126
|
|
|
110
127
|
// Plain-object copy; structuredClone throws on Vue reactive proxies
|
|
@@ -113,7 +130,7 @@ export function cloneActions(
|
|
|
113
130
|
): Partial<Record<FormActionType, ActionFormData>> {
|
|
114
131
|
const result: Partial<Record<FormActionType, ActionFormData>> = {}
|
|
115
132
|
for (const [key, value] of Object.entries(actions) as [FormActionType, ActionFormData][]) {
|
|
116
|
-
result[key] = { ...value }
|
|
133
|
+
result[key] = { ...value, ...(value.extra ? { extra: { ...value.extra } } : {}) }
|
|
117
134
|
}
|
|
118
135
|
return result
|
|
119
136
|
}
|
|
@@ -126,22 +143,31 @@ export function prefillUntouchedActions(
|
|
|
126
143
|
const result: Partial<Record<FormActionType, ActionFormData>> = {}
|
|
127
144
|
for (const [key, value] of Object.entries(actions) as [FormActionType, ActionFormData][]) {
|
|
128
145
|
result[key] = src && key !== source && isUntouched(value, key)
|
|
129
|
-
? { ...value,
|
|
146
|
+
? { ...value, repo: src.repo, ref: src.ref }
|
|
130
147
|
: { ...value }
|
|
131
148
|
}
|
|
132
149
|
return result
|
|
133
150
|
}
|
|
134
151
|
|
|
135
|
-
// Capability definition as returned by the git import endpoint
|
|
152
|
+
// Capability definition as returned by the git import endpoint
|
|
136
153
|
export interface ImportedCapability {
|
|
154
|
+
id?: string
|
|
137
155
|
capabilityClass?: string
|
|
138
156
|
name?: string
|
|
139
157
|
logo?: string
|
|
140
158
|
type?: string[]
|
|
141
159
|
supportedDeploymentTypes?: string[]
|
|
142
|
-
|
|
160
|
+
playbookContract?: string
|
|
161
|
+
actions?: Record<string, ({ repo?: string; ref?: string; playbook?: string } & Record<string, unknown>) | undefined>
|
|
162
|
+
[field: string]: unknown
|
|
143
163
|
}
|
|
144
164
|
|
|
165
|
+
// Capability fields the form edits itself; every other imported field is passed through in `extra`
|
|
166
|
+
const FORM_CAPABILITY_FIELDS = new Set(['id', 'capabilityClass', 'name', 'logo', 'type', 'supportedDeploymentTypes',
|
|
167
|
+
'playbookContract', 'actions'])
|
|
168
|
+
// Action fields the form edits or sets itself
|
|
169
|
+
const FORM_ACTION_FIELDS = new Set(['repo', 'ref', 'playbook', 'actionClass', 'actionType'])
|
|
170
|
+
|
|
145
171
|
const FORM_ACTION_TYPES: FormActionType[] = ['INSTALL', 'UNINSTALL', 'DEPLOY', 'UNDEPLOY']
|
|
146
172
|
|
|
147
173
|
export function capabilityToFormData(c: ImportedCapability): CapabilityFormData {
|
|
@@ -149,12 +175,20 @@ export function capabilityToFormData(c: ImportedCapability): CapabilityFormData
|
|
|
149
175
|
? 'BaseConfigurationCapability'
|
|
150
176
|
: 'DeploymentCapability'
|
|
151
177
|
const actions: Partial<Record<FormActionType, ActionFormData>> = {}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (a)
|
|
155
|
-
|
|
178
|
+
const extraActions: Record<string, unknown> = {}
|
|
179
|
+
for (const [t, a] of Object.entries(c.actions ?? {})) {
|
|
180
|
+
if (!a) continue
|
|
181
|
+
if (!(FORM_ACTION_TYPES as string[]).includes(t)) {
|
|
182
|
+
extraActions[t] = a
|
|
183
|
+
continue
|
|
184
|
+
}
|
|
185
|
+
const extra = Object.fromEntries(Object.entries(a).filter(([k]) => !FORM_ACTION_FIELDS.has(k)))
|
|
186
|
+
actions[t as FormActionType] = {
|
|
187
|
+
repo: a.repo ?? '', ref: a.ref ?? DEFAULT_BRANCH, playbook: a.playbook ?? '',
|
|
188
|
+
...(Object.keys(extra).length ? { extra } : {}),
|
|
156
189
|
}
|
|
157
190
|
}
|
|
191
|
+
const extra = Object.fromEntries(Object.entries(c).filter(([k]) => !FORM_CAPABILITY_FIELDS.has(k)))
|
|
158
192
|
return {
|
|
159
193
|
name: c.name ?? '',
|
|
160
194
|
logo: c.logo ?? '',
|
|
@@ -162,6 +196,10 @@ export function capabilityToFormData(c: ImportedCapability): CapabilityFormData
|
|
|
162
196
|
supportedDeploymentTypes: capabilityClass === 'DeploymentCapability' ? [...(c.supportedDeploymentTypes ?? [])] : [],
|
|
163
197
|
types: TYPE_ORDER.filter(t => (c.type ?? []).includes(t)),
|
|
164
198
|
actions,
|
|
199
|
+
playbookContract: c.playbookContract ?? '',
|
|
200
|
+
...(c.id ? { id: c.id } : {}),
|
|
201
|
+
...(Object.keys(extraActions).length ? { extraActions } : {}),
|
|
202
|
+
...(Object.keys(extra).length ? { extra } : {}),
|
|
165
203
|
}
|
|
166
204
|
}
|
|
167
205
|
|
|
@@ -170,28 +208,33 @@ export function importErrorMessage(e: unknown): string {
|
|
|
170
208
|
return typeof message === 'string' && message ? message : 'Failed to import capability'
|
|
171
209
|
}
|
|
172
210
|
|
|
211
|
+
// id: used when the form has no id of its own (i.e. the capability was not imported)
|
|
173
212
|
export function buildCapabilityRequest(form: CapabilityFormData, id?: string): GetCapabilities200ResponseInner {
|
|
174
213
|
const name = form.name.trim()
|
|
175
|
-
const actions: Record<string, unknown> = {}
|
|
214
|
+
const actions: Record<string, unknown> = { ...(form.extraActions ?? {}) }
|
|
176
215
|
for (const actionType of requiredActions(form)) {
|
|
177
216
|
const a = form.actions[actionType] ?? newActionFormData()
|
|
178
217
|
actions[actionType] = {
|
|
179
|
-
actionClass: 'AwxAction',
|
|
180
|
-
actionType,
|
|
181
|
-
awxRepo: a.awxRepo.trim(),
|
|
182
|
-
awxBranch: a.awxBranch.trim(),
|
|
183
|
-
playbook: a.playbook.trim(),
|
|
184
218
|
connectionTypes: ['ssh'],
|
|
185
219
|
skipable: false,
|
|
186
220
|
configParameters: [],
|
|
221
|
+
...(a.extra ?? {}),
|
|
222
|
+
actionClass: 'AnsibleAction',
|
|
223
|
+
actionType,
|
|
224
|
+
repo: a.repo.trim(),
|
|
225
|
+
ref: a.ref.trim(),
|
|
226
|
+
playbook: a.playbook.trim(),
|
|
187
227
|
}
|
|
188
228
|
}
|
|
229
|
+
const effectiveId = form.id ?? id
|
|
189
230
|
const body: Record<string, unknown> = {
|
|
190
|
-
...(
|
|
231
|
+
...(form.extra ?? {}),
|
|
232
|
+
...(effectiveId !== undefined ? { id: effectiveId } : {}),
|
|
191
233
|
capabilityClass: form.capabilityClass,
|
|
192
234
|
name,
|
|
193
235
|
logo: form.logo.trim() || fallbackLogo(name),
|
|
194
236
|
type: effectiveTypes(form),
|
|
237
|
+
playbookContract: form.playbookContract.trim(),
|
|
195
238
|
actions,
|
|
196
239
|
}
|
|
197
240
|
if (form.capabilityClass === 'DeploymentCapability') {
|