@eclipse-slm/ui 1.5.0-snapshot.1 → 1.5.0-snapshot.1017
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 +8 -0
- package/package.json +9 -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/notification-service/notificationServiceWebsocketClient.js +5 -5
- package/src/api/platform-management/platform-management-client.ts +2 -2
- package/src/api/resource-management/resource-management-client.ts +0 -2
- package/src/app/appInstance.ts +8 -0
- package/src/app/navigation.ts +21 -0
- package/src/app/routes.ts +23 -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/base/ConfirmDialog.vue +39 -25
- package/src/components/base/CustomDialog.vue +31 -3
- package/src/components/base/IconPickerDialog.vue +155 -0
- package/src/components/capabilities/CapabilitiesTable.vue +209 -0
- package/src/components/capabilities/CapabilityActionCard.vue +77 -0
- package/src/components/capabilities/CapabilityCreateDialog.vue +86 -0
- package/src/components/capabilities/CapabilityCreateForm.vue +306 -0
- package/src/components/capabilities/CapabilityImportDialog.vue +108 -0
- package/src/components/capabilities/capabilityForm.ts +244 -0
- package/src/components/core/AppBar.vue +1 -1
- package/src/components/core/Drawer.vue +12 -2
- package/src/components/jobs/JobDetail.vue +413 -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 +61 -0
- package/src/components/resources/deviceinfo/DeviceInfoView.vue +9 -1
- package/src/components/resources/dialogs/AddItemChooserDialog.vue +68 -0
- package/src/components/service_offerings/ServiceOfferingCardGrid.vue +1 -1
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionDockerCompose.vue +1 -2
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionKubernetes.vue +1 -2
- package/src/components/service_vendors/ServiceVendorDevelopersTable.vue +1 -1
- package/src/docker/entrypoint.sh +2 -2
- package/src/localisation/en.json +93 -0
- package/src/main.ts +3 -6
- package/src/pages/AdminAnsibleServicePage.vue +111 -0
- package/src/pages/AdminCapabilitiesPage.vue +60 -0
- package/src/pages/AdminProfilersPage.vue +73 -0
- package/src/pages/DashboardPage.vue +28 -56
- package/src/pages/JobDetailPage.vue +7 -0
- package/src/pages/ResourceInstancesPage.vue +71 -0
- package/src/pages/ServiceOfferingCreateOrEditPage.vue +2 -2
- package/src/stores/ansibleAdminStore.ts +206 -0
- package/src/stores/capabilitiesStore.ts +45 -2
- package/src/stores/environmentStore.ts +3 -3
- package/src/stores/jobsStore.ts +39 -39
- package/src/stores/notificationStore.ts +15 -1
- 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/stores/userStore.ts +1 -1
- package/src/utils/i18n.ts +4 -2
- package/src/utils/imageUtil.js +1 -1
- package/src/utils/jobStatus.ts +76 -0
- package/src/utils/mdiIcons.ts +49 -0
- package/src/utils/notificationTextGenerator.ts +27 -1
- package/src/utils/tokenInterceptor.js +1 -1
- package/src/utils/updateToken.js +1 -1
- package/vite/dist/apiClients.d.ts +1 -1
- package/vite/dist/apiClients.js +1 -0
- package/vite/dist/index.js +25 -4
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { watch } from 'vue';
|
|
3
|
+
import { useField } from 'vee-validate';
|
|
4
|
+
import type { ActionFormData, FormActionType } from './capabilityForm';
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{ actionType: FormActionType; modelValue: ActionFormData }>();
|
|
7
|
+
const emit = defineEmits<{
|
|
8
|
+
(e: 'update:modelValue', value: ActionFormData): void;
|
|
9
|
+
(e: 'source-changed'): void;
|
|
10
|
+
}>();
|
|
11
|
+
|
|
12
|
+
const repoRule = (v: string) => {
|
|
13
|
+
if (!v) return 'Repository is required';
|
|
14
|
+
return /^(https?:\/\/|git@)/.test(v) || 'Must start with http://, https:// or git@';
|
|
15
|
+
};
|
|
16
|
+
const requiredRule = (label: string) => (v: string) => !!v || `${label} is required`;
|
|
17
|
+
|
|
18
|
+
const prefix = props.actionType;
|
|
19
|
+
const { value: repo, errorMessage: repoError } = useField<string>(`${prefix}.repo`, repoRule, {
|
|
20
|
+
initialValue: props.modelValue.repo,
|
|
21
|
+
});
|
|
22
|
+
const { value: gitRef, errorMessage: branchError } = useField<string>(
|
|
23
|
+
`${prefix}.ref`, requiredRule('Branch'), { initialValue: props.modelValue.ref });
|
|
24
|
+
const { value: playbook, errorMessage: playbookError } = useField<string>(
|
|
25
|
+
`${prefix}.playbook`, requiredRule('Playbook'), { initialValue: props.modelValue.playbook });
|
|
26
|
+
|
|
27
|
+
watch(() => props.modelValue, (val) => {
|
|
28
|
+
repo.value = val.repo;
|
|
29
|
+
gitRef.value = val.ref;
|
|
30
|
+
playbook.value = val.playbook;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
watch([repo, gitRef, playbook], () => {
|
|
34
|
+
const m = props.modelValue;
|
|
35
|
+
if (m.repo === repo.value && m.ref === gitRef.value && m.playbook === playbook.value) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
emit('update:modelValue', {
|
|
39
|
+
...m, // keep imported fields the card does not edit (image, connection types, ...)
|
|
40
|
+
repo: repo.value ?? '',
|
|
41
|
+
ref: gitRef.value ?? '',
|
|
42
|
+
playbook: playbook.value ?? '',
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<v-card variant="outlined" class="mt-4 mb-4">
|
|
49
|
+
<v-card-text>
|
|
50
|
+
<v-text-field
|
|
51
|
+
v-model="repo"
|
|
52
|
+
label="Repository"
|
|
53
|
+
required
|
|
54
|
+
class="mb-2"
|
|
55
|
+
hide-details="auto"
|
|
56
|
+
:error-messages="repoError"
|
|
57
|
+
@blur="emit('source-changed')"
|
|
58
|
+
/>
|
|
59
|
+
<v-text-field
|
|
60
|
+
v-model="gitRef"
|
|
61
|
+
label="Branch"
|
|
62
|
+
required
|
|
63
|
+
class="mb-2"
|
|
64
|
+
hide-details="auto"
|
|
65
|
+
:error-messages="branchError"
|
|
66
|
+
@blur="emit('source-changed')"
|
|
67
|
+
/>
|
|
68
|
+
<v-text-field
|
|
69
|
+
v-model="playbook"
|
|
70
|
+
label="Playbook"
|
|
71
|
+
required
|
|
72
|
+
hide-details="auto"
|
|
73
|
+
:error-messages="playbookError"
|
|
74
|
+
/>
|
|
75
|
+
</v-card-text>
|
|
76
|
+
</v-card>
|
|
77
|
+
</template>
|
|
@@ -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,306 @@
|
|
|
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
|
+
PLAYBOOK_CONTRACT_PATTERN,
|
|
17
|
+
prefillUntouchedActions,
|
|
18
|
+
requiredActions,
|
|
19
|
+
} from './capabilityForm';
|
|
20
|
+
import type {
|
|
21
|
+
ActionFormData,
|
|
22
|
+
CapabilityClass,
|
|
23
|
+
CapabilityForm,
|
|
24
|
+
CapabilityFormData,
|
|
25
|
+
FormActionType,
|
|
26
|
+
FormCapabilityType,
|
|
27
|
+
} from './capabilityForm';
|
|
28
|
+
|
|
29
|
+
const props = defineProps<{ modelValue: CapabilityForm }>();
|
|
30
|
+
const emit = defineEmits<{ (e: 'update:modelValue', value: CapabilityForm): void }>();
|
|
31
|
+
|
|
32
|
+
const capabilitiesStore = useCapabilitiesStore();
|
|
33
|
+
|
|
34
|
+
const deploymentTypeItems = [
|
|
35
|
+
{ title: 'Docker container', value: 'DOCKER_CONTAINER' },
|
|
36
|
+
{ title: 'Docker compose', value: 'DOCKER_COMPOSE' },
|
|
37
|
+
{ title: 'Kubernetes', value: 'KUBERNETES' },
|
|
38
|
+
{ title: 'CODESYS', value: 'CODESYS' },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const { errors, validate } = useForm();
|
|
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
|
+
|
|
54
|
+
const { value: name, errorMessage: nameError } = useField<string>('name', (v: string) => {
|
|
55
|
+
if (!v || !v.trim()) return 'Name is required';
|
|
56
|
+
return !isNameTaken(v, capabilitiesStore.capabilities, passThrough.value.id)
|
|
57
|
+
|| 'A capability with this name already exists';
|
|
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 });
|
|
62
|
+
const { value: logo } = useField<string>('logo', undefined, { initialValue: props.modelValue.formData.logo });
|
|
63
|
+
const { value: capabilityClass } = useField<CapabilityClass>('capabilityClass', undefined,
|
|
64
|
+
{ initialValue: props.modelValue.formData.capabilityClass });
|
|
65
|
+
const { value: deploymentTypes, errorMessage: deploymentTypesError } = useField<string[]>(
|
|
66
|
+
'supportedDeploymentTypes',
|
|
67
|
+
(v: string[]) => !isDeployTypeSelected.value || (v && v.length > 0)
|
|
68
|
+
|| 'Select at least one deployment type',
|
|
69
|
+
{ initialValue: props.modelValue.formData.supportedDeploymentTypes });
|
|
70
|
+
const { value: types, errorMessage: typesError } = useField<FormCapabilityType[]>('types',
|
|
71
|
+
() => effectiveTypes(currentFormData()).length > 0 || 'Select at least one capability type',
|
|
72
|
+
{ initialValue: props.modelValue.formData.types });
|
|
73
|
+
const actions = ref<Partial<Record<FormActionType, ActionFormData>>>(
|
|
74
|
+
cloneActions(props.modelValue.formData.actions));
|
|
75
|
+
|
|
76
|
+
const showIconPicker = ref(false);
|
|
77
|
+
const showImportDialog = ref(false);
|
|
78
|
+
const activeActionTab = ref<FormActionType | null>(null);
|
|
79
|
+
|
|
80
|
+
const isDeployment = computed(() => capabilityClass.value === 'DeploymentCapability');
|
|
81
|
+
const isDeployTypeSelected = computed(
|
|
82
|
+
() => isDeployment.value && (types.value ?? []).includes('DEPLOY')
|
|
83
|
+
);
|
|
84
|
+
const typeChoices = computed(() => allowedTypes(capabilityClass.value));
|
|
85
|
+
const displayedLogo = computed(() => logo.value || fallbackLogo(name.value ?? ''));
|
|
86
|
+
const actionTypes = computed(() => requiredActions(currentFormData()));
|
|
87
|
+
|
|
88
|
+
function currentFormData(): CapabilityFormData {
|
|
89
|
+
return {
|
|
90
|
+
name: name.value ?? '',
|
|
91
|
+
logo: logo.value ?? '',
|
|
92
|
+
capabilityClass: capabilityClass.value,
|
|
93
|
+
supportedDeploymentTypes: [...(deploymentTypes.value ?? [])],
|
|
94
|
+
types: [...(types.value ?? [])],
|
|
95
|
+
actions: actions.value,
|
|
96
|
+
playbookContract: playbookContract.value ?? '',
|
|
97
|
+
...passThrough.value,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Sync incoming modelValue (e.g. dialog reset) to fields
|
|
102
|
+
watch(() => props.modelValue, (val) => {
|
|
103
|
+
if (JSON.stringify(val.formData) === JSON.stringify(currentFormData())) return;
|
|
104
|
+
const f = val.formData;
|
|
105
|
+
name.value = f.name;
|
|
106
|
+
logo.value = f.logo;
|
|
107
|
+
capabilityClass.value = f.capabilityClass;
|
|
108
|
+
deploymentTypes.value = [...f.supportedDeploymentTypes];
|
|
109
|
+
types.value = [...f.types];
|
|
110
|
+
actions.value = cloneActions(f.actions);
|
|
111
|
+
playbookContract.value = f.playbookContract;
|
|
112
|
+
passThrough.value = pickPassThrough(f);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Create missing action entries when their type appears
|
|
116
|
+
watch(actionTypes, (needed) => {
|
|
117
|
+
for (const t of needed) {
|
|
118
|
+
if (!actions.value[t]) {
|
|
119
|
+
actions.value = { ...actions.value, [t]: newActionFormData(t) };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (!needed.length) {
|
|
124
|
+
activeActionTab.value = null;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!activeActionTab.value || !needed.includes(activeActionTab.value)) {
|
|
129
|
+
activeActionTab.value = needed[0];
|
|
130
|
+
}
|
|
131
|
+
}, { immediate: true });
|
|
132
|
+
|
|
133
|
+
watch(isDeployTypeSelected, (selected) => {
|
|
134
|
+
if (!selected) {
|
|
135
|
+
deploymentTypes.value = [];
|
|
136
|
+
}
|
|
137
|
+
}, { immediate: true });
|
|
138
|
+
|
|
139
|
+
function setAction(t: FormActionType, value: ActionFormData) {
|
|
140
|
+
actions.value = { ...actions.value, [t]: value };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function onSourceChanged(t: FormActionType) {
|
|
144
|
+
if (t !== actionTypes.value[0]) return;
|
|
145
|
+
actions.value = prefillUntouchedActions(actions.value, t);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function onImported(f: CapabilityFormData) {
|
|
149
|
+
showImportDialog.value = false;
|
|
150
|
+
name.value = f.name;
|
|
151
|
+
logo.value = f.logo;
|
|
152
|
+
capabilityClass.value = f.capabilityClass;
|
|
153
|
+
deploymentTypes.value = [...f.supportedDeploymentTypes];
|
|
154
|
+
types.value = [...f.types];
|
|
155
|
+
actions.value = cloneActions(f.actions);
|
|
156
|
+
playbookContract.value = f.playbookContract;
|
|
157
|
+
passThrough.value = pickPassThrough(f);
|
|
158
|
+
// Show errors of the imported values right away; wait until new action cards registered their fields
|
|
159
|
+
await nextTick();
|
|
160
|
+
await nextTick();
|
|
161
|
+
await validate();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function openImport() {
|
|
165
|
+
showImportDialog.value = true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
defineExpose({ openImport });
|
|
169
|
+
|
|
170
|
+
function onIconSelected(icon: string) {
|
|
171
|
+
logo.value = icon;
|
|
172
|
+
showIconPicker.value = false;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Emit changes to parent
|
|
176
|
+
let validationRun = 0;
|
|
177
|
+
watch([name, logo, capabilityClass, deploymentTypes, types, actions, playbookContract, passThrough], async () => {
|
|
178
|
+
const run = ++validationRun;
|
|
179
|
+
await nextTick(); // let newly mounted action cards register their fields
|
|
180
|
+
const result = await validate({ mode: 'silent' }); // silent: do not flag untouched fields as errors
|
|
181
|
+
if (run !== validationRun) return; // a newer change superseded this run
|
|
182
|
+
emit('update:modelValue', { isFormValid: result.valid, formData: currentFormData() });
|
|
183
|
+
}, { deep: true, immediate: true });
|
|
184
|
+
</script>
|
|
185
|
+
|
|
186
|
+
<template>
|
|
187
|
+
<form @submit.prevent>
|
|
188
|
+
<CapabilityImportDialog
|
|
189
|
+
:show="showImportDialog"
|
|
190
|
+
@imported="onImported"
|
|
191
|
+
@canceled="showImportDialog = false"
|
|
192
|
+
/>
|
|
193
|
+
|
|
194
|
+
<div class="text-subtitle-2 mb-2">Icon & Capability Name</div>
|
|
195
|
+
<v-text-field
|
|
196
|
+
v-model="name"
|
|
197
|
+
label="Name"
|
|
198
|
+
required
|
|
199
|
+
:prepend-icon="displayedLogo"
|
|
200
|
+
:error-messages="nameError"
|
|
201
|
+
@click:prepend="showIconPicker = true"
|
|
202
|
+
/>
|
|
203
|
+
|
|
204
|
+
<IconPickerDialog
|
|
205
|
+
:show="showIconPicker"
|
|
206
|
+
:model-value="logo"
|
|
207
|
+
@selected="onIconSelected"
|
|
208
|
+
@canceled="showIconPicker = false"
|
|
209
|
+
/>
|
|
210
|
+
|
|
211
|
+
<div class="mb-4">
|
|
212
|
+
<div class="text-subtitle-2">Capability class</div>
|
|
213
|
+
<v-radio-group v-model="capabilityClass" inline hide-details>
|
|
214
|
+
<v-radio label="Deployment" value="DeploymentCapability" />
|
|
215
|
+
<v-radio label="Base configuration" value="BaseConfigurationCapability" />
|
|
216
|
+
</v-radio-group>
|
|
217
|
+
</div>
|
|
218
|
+
|
|
219
|
+
<div class="mb-4">
|
|
220
|
+
<div class="text-subtitle-2">Capability types</div>
|
|
221
|
+
<div class="d-flex align-center flex-wrap">
|
|
222
|
+
<template v-if="isDeployment">
|
|
223
|
+
<v-checkbox
|
|
224
|
+
v-for="t in typeChoices"
|
|
225
|
+
:key="t"
|
|
226
|
+
v-model="types"
|
|
227
|
+
:label="t"
|
|
228
|
+
:value="t"
|
|
229
|
+
multiple
|
|
230
|
+
hide-details
|
|
231
|
+
density="compact"
|
|
232
|
+
class="mr-4"
|
|
233
|
+
inline
|
|
234
|
+
/>
|
|
235
|
+
</template>
|
|
236
|
+
<v-checkbox
|
|
237
|
+
v-else
|
|
238
|
+
:model-value="true"
|
|
239
|
+
label="SETUP"
|
|
240
|
+
disabled
|
|
241
|
+
hide-details
|
|
242
|
+
density="compact"
|
|
243
|
+
inline
|
|
244
|
+
/>
|
|
245
|
+
</div>
|
|
246
|
+
<div v-if="typesError" class="text-caption text-error">{{ typesError }}</div>
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
<div v-if="actionTypes.length" class="mt-2">
|
|
250
|
+
<div class="text-subtitle-2 mb-2">Action types</div>
|
|
251
|
+
|
|
252
|
+
<v-tabs
|
|
253
|
+
v-model="activeActionTab"
|
|
254
|
+
color="primary"
|
|
255
|
+
density="compact"
|
|
256
|
+
class="mb-2"
|
|
257
|
+
>
|
|
258
|
+
<v-tab
|
|
259
|
+
v-for="t in actionTypes"
|
|
260
|
+
:key="`tab-${t}`"
|
|
261
|
+
:value="t"
|
|
262
|
+
v-bind="getActionTabColorProps(t, errors)"
|
|
263
|
+
>
|
|
264
|
+
{{ t }}
|
|
265
|
+
</v-tab>
|
|
266
|
+
</v-tabs>
|
|
267
|
+
|
|
268
|
+
<v-window v-model="activeActionTab">
|
|
269
|
+
<v-window-item
|
|
270
|
+
v-for="t in actionTypes"
|
|
271
|
+
:key="`panel-${t}`"
|
|
272
|
+
:value="t"
|
|
273
|
+
eager
|
|
274
|
+
>
|
|
275
|
+
<CapabilityActionCard
|
|
276
|
+
v-if="actions[t]"
|
|
277
|
+
:action-type="t"
|
|
278
|
+
:model-value="actions[t]!"
|
|
279
|
+
@update:model-value="setAction(t, $event)"
|
|
280
|
+
@source-changed="onSourceChanged(t)"
|
|
281
|
+
/>
|
|
282
|
+
</v-window-item>
|
|
283
|
+
</v-window>
|
|
284
|
+
</div>
|
|
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
|
+
|
|
295
|
+
<div v-if="isDeployTypeSelected" class="mb-2">
|
|
296
|
+
<div class="text-subtitle-2 mb-2">Supported deployment types</div>
|
|
297
|
+
<v-select
|
|
298
|
+
v-model="deploymentTypes"
|
|
299
|
+
multiple
|
|
300
|
+
chips
|
|
301
|
+
:items="deploymentTypeItems"
|
|
302
|
+
:error-messages="deploymentTypesError"
|
|
303
|
+
/>
|
|
304
|
+
</div>
|
|
305
|
+
</form>
|
|
306
|
+
</template>
|
|
@@ -0,0 +1,108 @@
|
|
|
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() || DEFAULT_FILE_PATH,
|
|
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="Tag or branch"
|
|
90
|
+
hint="Version of the capability, e.g. 1.1.0"
|
|
91
|
+
persistent-hint
|
|
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>
|
|
106
|
+
</template>
|
|
107
|
+
</ConfirmDialog>
|
|
108
|
+
</template>
|