@eclipse-slm/ui 0.0.0-stage → 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.
Files changed (298) hide show
  1. package/README.md +278 -2
  2. package/index.html +19 -0
  3. package/package.json +105 -4
  4. package/public/favicon.ico +0 -0
  5. package/public/favicon.png +0 -0
  6. package/public/favicon_white.png +0 -0
  7. package/public/sidebar-image.jpg +0 -0
  8. package/src/App.vue +40 -0
  9. package/src/api/ansible-service/ansible-service-client.ts +15 -0
  10. package/src/api/ansible-service/ansible-service-sse.ts +124 -0
  11. package/src/api/apiState.js +7 -0
  12. package/src/api/catalog/catalogRestApi.js +17 -0
  13. package/src/api/notification-service/notification-service-client.ts +7 -0
  14. package/src/api/notification-service/notificationServiceActuatorRestApi.js +26 -0
  15. package/src/api/notification-service/notificationServiceWebsocketClient.js +60 -0
  16. package/src/api/platform-management/platform-management-client.ts +46 -0
  17. package/src/api/platform-management/platformManagementActuatorRestApi.js +26 -0
  18. package/src/api/resource-management/resource-management-client.ts +37 -0
  19. package/src/api/resource-management/resourceManagementActuatorRestApi.js +26 -0
  20. package/src/api/restApiHelper.js +11 -0
  21. package/src/api/service-management/service-management-client.ts +31 -0
  22. package/src/api/service-management/serviceManagementActuatorRestApi.ts +26 -0
  23. package/src/app/appInstance.ts +8 -0
  24. package/src/app/navigation.ts +224 -0
  25. package/src/app/routes.ts +215 -0
  26. package/src/assets/clint-mckoy.jpg +0 -0
  27. package/src/assets/img/avatarImg.jpg +0 -0
  28. package/src/assets/img/fabos_logo.png +0 -0
  29. package/src/assets/img/fabos_logo_fabweiss.png +0 -0
  30. package/src/assets/img/fraunhofer-logo.png +0 -0
  31. package/src/assets/img/sidebar-1.jpg +0 -0
  32. package/src/assets/img/sidebar-2.jpg +0 -0
  33. package/src/assets/img/sidebar-3.jpg +0 -0
  34. package/src/assets/img/sidebar-4.jpg +0 -0
  35. package/src/assets/img/sidebar-5.jpg +0 -0
  36. package/src/assets/img/sidebar-image.jpg +0 -0
  37. package/src/assets/img/vue-logo.png +0 -0
  38. package/src/assets/lock.jpg +0 -0
  39. package/src/assets/login.jpg +0 -0
  40. package/src/assets/logo.png +0 -0
  41. package/src/assets/pricing.jpg +0 -0
  42. package/src/assets/register.jpg +0 -0
  43. package/src/assets/vuetify.svg +1 -0
  44. package/src/components/admin/VersionsOverview.vue +149 -0
  45. package/src/components/admin/ansible/AnsibleAdminImages.vue +113 -0
  46. package/src/components/admin/ansible/AnsibleAdminJobs.vue +179 -0
  47. package/src/components/admin/ansible/AnsibleAdminOperations.vue +124 -0
  48. package/src/components/base/ActionButton.vue +63 -0
  49. package/src/components/base/ActionButtonType.ts +5 -0
  50. package/src/components/base/Card.vue +17 -0
  51. package/src/components/base/ConfirmDialog.vue +101 -0
  52. package/src/components/base/CustomDialog.vue +116 -0
  53. package/src/components/base/IconPickerDialog.vue +155 -0
  54. package/src/components/base/Item.vue +79 -0
  55. package/src/components/base/ItemGroup.vue +131 -0
  56. package/src/components/base/ItemSubGroup.vue +25 -0
  57. package/src/components/base/MaterialAlert.vue +56 -0
  58. package/src/components/base/MaterialCard.vue +166 -0
  59. package/src/components/base/MaterialChartCard.vue +95 -0
  60. package/src/components/base/MaterialSnackbar.vue +71 -0
  61. package/src/components/base/MaterialStatsCard.vue +115 -0
  62. package/src/components/base/MaterialTabs.vue +43 -0
  63. package/src/components/base/MaterialTestimony.vue +79 -0
  64. package/src/components/base/NoItemAvailableNote.vue +22 -0
  65. package/src/components/base/OverviewHeading.vue +25 -0
  66. package/src/components/base/ProgressCircular.vue +68 -0
  67. package/src/components/base/RowWithLabel.vue +228 -0
  68. package/src/components/base/Subheading.vue +35 -0
  69. package/src/components/base/TextWithLabel.vue +41 -0
  70. package/src/components/base/VComponent.vue +40 -0
  71. package/src/components/capabilities/CapabilitiesTable.vue +209 -0
  72. package/src/components/capabilities/CapabilityActionCard.vue +77 -0
  73. package/src/components/capabilities/CapabilityCreateDialog.vue +86 -0
  74. package/src/components/capabilities/CapabilityCreateForm.vue +306 -0
  75. package/src/components/capabilities/CapabilityImportDialog.vue +108 -0
  76. package/src/components/capabilities/capabilityForm.ts +244 -0
  77. package/src/components/charts/AasCircularChart.vue +170 -0
  78. package/src/components/charts/AasCircularChartFilterBar.vue +72 -0
  79. package/src/components/charts/LineChart.js +14 -0
  80. package/src/components/clusters/ClustersOverview.vue +76 -0
  81. package/src/components/clusters/dialogs/ClusterDeleteDialog.vue +125 -0
  82. package/src/components/clusters/dialogs/ClusterScaleDialog.vue +272 -0
  83. package/src/components/clusters/dialogs/ClustersCreateDialog.vue +112 -0
  84. package/src/components/clusters/dialogs/ClustersCreateDialogPage.ts +7 -0
  85. package/src/components/clusters/dialogs/ClustersCreateDialogPageAddExistingCluster.vue +261 -0
  86. package/src/components/clusters/dialogs/ClustersCreateDialogPageCreateNewCluster.vue +244 -0
  87. package/src/components/clusters/dialogs/ClustersCreateDialogPageStart.vue +75 -0
  88. package/src/components/core/AppBar.vue +301 -0
  89. package/src/components/core/Drawer.vue +217 -0
  90. package/src/components/core/Footer.vue +43 -0
  91. package/src/components/core/View.vue +32 -0
  92. package/src/components/credentials/CredentialCreateDialog.vue +121 -0
  93. package/src/components/credentials/CredentialDisplay.vue +105 -0
  94. package/src/components/credentials/CredentialForm.vue +394 -0
  95. package/src/components/credentials/CredentialTypes.ts +26 -0
  96. package/src/components/dashboard/Buttons.vue +431 -0
  97. package/src/components/dashboard/DashboardResourceStatistics.vue +53 -0
  98. package/src/components/dashboard/Grid.vue +300 -0
  99. package/src/components/dashboard/Icons.vue +300 -0
  100. package/src/components/dashboard/Notifications.vue +402 -0
  101. package/src/components/dashboard/Tabs.vue +418 -0
  102. package/src/components/dashboard/Typography.vue +120 -0
  103. package/src/components/discovery/DiscoverDialog.vue +186 -0
  104. package/src/components/discovery/DiscoveredResourcesTable.vue +176 -0
  105. package/src/components/discovery/DiscoveryJobDetailsDialog.vue +65 -0
  106. package/src/components/discovery/DiscoveryJobsDeleteDialog.vue +88 -0
  107. package/src/components/discovery/DiscoveryJobsTable.vue +131 -0
  108. package/src/components/discovery/DiscoveryOverview.vue +99 -0
  109. package/src/components/discovery/DriversTable.vue +70 -0
  110. package/src/components/discovery/OnboardingDialog.vue +82 -0
  111. package/src/components/jobs/JobDetail.vue +413 -0
  112. package/src/components/jobs/JobStatusChip.vue +16 -0
  113. package/src/components/jobs/JobsOverview.vue +160 -0
  114. package/src/components/notifications/NotificationsOverview.vue +154 -0
  115. package/src/components/profilers/ProfilerDialog.vue +95 -0
  116. package/src/components/profilers/ProfilerForm.vue +102 -0
  117. package/src/components/profilers/ProfilersTable.vue +98 -0
  118. package/src/components/profilers/profilerForm.ts +61 -0
  119. package/src/components/provider/ProviderOverview.vue +64 -0
  120. package/src/components/provider/ServiceHosterTable.vue +47 -0
  121. package/src/components/provider/VirtualResourceProviderTable.vue +73 -0
  122. package/src/components/provider/dialogs/VmCreateDialog.vue +99 -0
  123. package/src/components/provider/dialogs/VmCreateDialogForm.vue +59 -0
  124. package/src/components/resources/ResourceConnectionIcon.vue +40 -0
  125. package/src/components/resources/ResourcesDeleteDialog.vue +102 -0
  126. package/src/components/resources/ResourcesTableClusters.vue +192 -0
  127. package/src/components/resources/ResourcesTableDevices.vue +338 -0
  128. package/src/components/resources/ResourcesTableTypes.vue +106 -0
  129. package/src/components/resources/capabilities/CapabilitiesButton.vue +164 -0
  130. package/src/components/resources/capabilities/CapabilityIcon.vue +44 -0
  131. package/src/components/resources/capabilities/CapabilityParamsDialog.vue +119 -0
  132. package/src/components/resources/capabilities/CapabilityParamsDialogInputField.vue +51 -0
  133. package/src/components/resources/deviceinfo/DeviceInfoCapabilitiesView.vue +239 -0
  134. package/src/components/resources/deviceinfo/DeviceInfoCredentialsView.vue +205 -0
  135. package/src/components/resources/deviceinfo/DeviceInfoHardwareView.vue +162 -0
  136. package/src/components/resources/deviceinfo/DeviceInfoNameplateView.vue +201 -0
  137. package/src/components/resources/deviceinfo/DeviceInfoSubmodelsView.vue +173 -0
  138. package/src/components/resources/deviceinfo/DeviceInfoView.vue +207 -0
  139. package/src/components/resources/deviceinfo/common/DeviceInfoCommonBasicsSection.vue +101 -0
  140. package/src/components/resources/deviceinfo/common/DeviceInfoCommonRemoteAccessSection.vue +224 -0
  141. package/src/components/resources/deviceinfo/common/DeviceInfoCommonView.vue +43 -0
  142. package/src/components/resources/deviceinfo/firmware/DeviceInfoFirmwareView.vue +113 -0
  143. package/src/components/resources/deviceinfo/firmware/FirmwareAvailableVersionsSection.vue +193 -0
  144. package/src/components/resources/deviceinfo/firmware/FirmwareCredentialsSection.vue +250 -0
  145. package/src/components/resources/deviceinfo/firmware/FirmwareUpdateJobsSection.vue +149 -0
  146. package/src/components/resources/deviceinfo/firmware/FirmwareUpdateStatusSection.vue +117 -0
  147. package/src/components/resources/deviceinfo/firmware/sectionState.ts +12 -0
  148. package/src/components/resources/devicetypeinfo/DeviceTypeInfoCommonView.vue +58 -0
  149. package/src/components/resources/devicetypeinfo/DeviceTypeInfoFirmwareView.vue +270 -0
  150. package/src/components/resources/devicetypeinfo/DeviceTypeInfoView.vue +110 -0
  151. package/src/components/resources/dialogs/AddItemChooserDialog.vue +68 -0
  152. package/src/components/resources/dialogs/DeviceCreateDeviceDetailsForm.vue +109 -0
  153. package/src/components/resources/dialogs/DeviceCreateDialog.vue +224 -0
  154. package/src/components/resources/dialogs/DeviceDialogCreateTypes.ts +11 -0
  155. package/src/components/resources/remoteaccess/RemoteAccessDialog.vue +82 -0
  156. package/src/components/resources/remoteaccess/RemoteAccessForm.vue +149 -0
  157. package/src/components/resources/remoteaccess/RemoteAccessHandler.ts +73 -0
  158. package/src/components/resources/remoteaccess/RemoteAccessTypes.ts +11 -0
  159. package/src/components/service_offerings/ServiceCategoriesTable.vue +154 -0
  160. package/src/components/service_offerings/ServiceCategoryCreateOrEditDialog.vue +117 -0
  161. package/src/components/service_offerings/ServiceOfferingCardGrid.vue +173 -0
  162. package/src/components/service_offerings/ServiceOfferingCardList.vue +117 -0
  163. package/src/components/service_offerings/ServiceOfferingDetailsOverview.vue +89 -0
  164. package/src/components/service_offerings/ServiceOfferingDetailsRequirements.vue +89 -0
  165. package/src/components/service_offerings/ServiceOfferingTable.vue +291 -0
  166. package/src/components/service_offerings/ServiceOfferingToolbar.vue +133 -0
  167. package/src/components/service_offerings/ServiceOptionValue.vue +213 -0
  168. package/src/components/service_offerings/dialogs/ServiceOfferingCreateDialog.vue +70 -0
  169. package/src/components/service_offerings/wizard_service_offering/ServiceOfferingWizardGitStep1Common.vue +214 -0
  170. package/src/components/service_offerings/wizard_service_offering/ServiceOfferingWizardManualStep1Common.vue +196 -0
  171. package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerContainerImageName.vue +112 -0
  172. package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerContainerLabels.vue +158 -0
  173. package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerContainerPortMappings.vue +177 -0
  174. package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerContainerRestartPolicy.vue +63 -0
  175. package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerContainerVolumes.vue +157 -0
  176. package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerEnvironmentVariables.vue +163 -0
  177. package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep1Common.vue +154 -0
  178. package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionCodesys.vue +139 -0
  179. package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionDockerCompose.vue +423 -0
  180. package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionDockerContainer.vue +293 -0
  181. package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionKubernetes.vue +382 -0
  182. package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep3ServiceOptions.vue +193 -0
  183. package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep4Requirements.vue +238 -0
  184. package/src/components/service_offerings/wizard_service_offering_version/ServiceRepositorySelect.vue +90 -0
  185. package/src/components/service_offerings/wizard_service_offering_version/serviceOptions/serviceOptionsDefinitionTable.vue +210 -0
  186. package/src/components/service_vendors/ServiceRepositoryCreateDialog.vue +165 -0
  187. package/src/components/service_vendors/ServiceVendorCreateOrEditDialog.vue +171 -0
  188. package/src/components/service_vendors/ServiceVendorDevelopersTable.vue +201 -0
  189. package/src/components/service_vendors/ServiceVendorTable.vue +158 -0
  190. package/src/components/services/ServiceInstanceDeleteDialog.vue +29 -0
  191. package/src/components/services/ServiceInstancesOverview.vue +63 -0
  192. package/src/components/services/ServiceInstancesTable.vue +379 -0
  193. package/src/components/services/dialog/ServiceInstanceDetailsDialog.vue +369 -0
  194. package/src/components/services/serviceInstanceMixin.js +29 -0
  195. package/src/components/tables/RegularTables.vue +186 -0
  196. package/src/components/updates/FirmwareUpdateStatusIcon.vue +54 -0
  197. package/src/components/updates/FirmwareUpdateVersion.vue +65 -0
  198. package/src/components/user/UserCredentials.vue +278 -0
  199. package/src/components/user/UserProfileDetails.vue +89 -0
  200. package/src/customization/customizeApp.ts +6 -0
  201. package/src/customization/customizeMessages.ts +6 -0
  202. package/src/customization/customizeNavigation.ts +6 -0
  203. package/src/customization/customizeRoutes.ts +6 -0
  204. package/src/customization/deepMerge.ts +28 -0
  205. package/src/customization/theme.ts +15 -0
  206. package/src/design/overrides.sass +62 -0
  207. package/src/design/serviceOfferingCard.scss +38 -0
  208. package/src/design/variables.scss +34 -0
  209. package/src/design/vuetify-material/_appbar.sass +54 -0
  210. package/src/design/vuetify-material/_buttons.sass +67 -0
  211. package/src/design/vuetify-material/_card.sass +107 -0
  212. package/src/design/vuetify-material/_chip.sass +9 -0
  213. package/src/design/vuetify-material/_footer.sass +29 -0
  214. package/src/design/vuetify-material/_map.sass +3 -0
  215. package/src/design/vuetify-material/_modal.sass +25 -0
  216. package/src/design/vuetify-material/_notification.sass +12 -0
  217. package/src/design/vuetify-material/_pagination.sass +5 -0
  218. package/src/design/vuetify-material/_settings.sass +36 -0
  219. package/src/design/vuetify-material/_sidebar.sass +69 -0
  220. package/src/design/vuetify-material/_tab.sass +12 -0
  221. package/src/design/vuetify-material/_table.sass +22 -0
  222. package/src/design/vuetify-material/_view.sass +23 -0
  223. package/src/docker/entrypoint.sh +85 -0
  224. package/src/docker/nginx.conf +35 -0
  225. package/src/docker/slm.conf +15 -0
  226. package/src/localisation/de.json +91 -0
  227. package/src/localisation/en.json +387 -0
  228. package/src/main.ts +167 -0
  229. package/src/pages/AccessDeniedPage.vue +10 -0
  230. package/src/pages/AdminAnsibleServicePage.vue +111 -0
  231. package/src/pages/AdminCapabilitiesPage.vue +60 -0
  232. package/src/pages/AdminComponentsPage.vue +34 -0
  233. package/src/pages/AdminPage.vue +68 -0
  234. package/src/pages/AdminProfilersPage.vue +73 -0
  235. package/src/pages/AdminServiceCategoriesPage.vue +34 -0
  236. package/src/pages/AdminServiceVendorsPage.vue +53 -0
  237. package/src/pages/AdminUsersPage.vue +367 -0
  238. package/src/pages/ClustersPage.vue +64 -0
  239. package/src/pages/DashboardPage.vue +351 -0
  240. package/src/pages/DiscoveryDriversPage.vue +35 -0
  241. package/src/pages/DiscoveryInboxPage.vue +31 -0
  242. package/src/pages/DiscoveryJobsPage.vue +34 -0
  243. package/src/pages/IndexPage.vue +29 -0
  244. package/src/pages/JobDetailPage.vue +7 -0
  245. package/src/pages/JobsPage.vue +18 -0
  246. package/src/pages/NotificationsPage.vue +13 -0
  247. package/src/pages/ProviderPage.vue +18 -0
  248. package/src/pages/ResourceInstancesPage.vue +177 -0
  249. package/src/pages/ResourceTypesPage.vue +102 -0
  250. package/src/pages/ServiceInstancesPage.vue +33 -0
  251. package/src/pages/ServiceOfferingCreateOrEditPage.vue +197 -0
  252. package/src/pages/ServiceOfferingDetailsPage.vue +180 -0
  253. package/src/pages/ServiceOfferingOrderPage.vue +300 -0
  254. package/src/pages/ServiceOfferingVersionCreateOrEditPage.vue +431 -0
  255. package/src/pages/ServiceOfferingsPage.vue +149 -0
  256. package/src/pages/ServiceVendorPage.vue +431 -0
  257. package/src/pages/UserProfilePage.vue +64 -0
  258. package/src/pages/router.js +34 -0
  259. package/src/shims-vue.d.ts +5 -0
  260. package/src/stores/ansibleAdminStore.ts +206 -0
  261. package/src/stores/capabilitiesStore.ts +159 -0
  262. package/src/stores/catalogStore.ts +50 -0
  263. package/src/stores/discoveryStore.ts +88 -0
  264. package/src/stores/environmentStore.ts +61 -0
  265. package/src/stores/jobsStore.ts +73 -0
  266. package/src/stores/notificationStore.ts +169 -0
  267. package/src/stores/profilersStore.ts +80 -0
  268. package/src/stores/providerStore.ts +52 -0
  269. package/src/stores/resourceClustersStore.ts +98 -0
  270. package/src/stores/resourceDevicesStore.ts +294 -0
  271. package/src/stores/serviceInstancesStore.ts +92 -0
  272. package/src/stores/serviceOfferingsStore.ts +208 -0
  273. package/src/stores/store.ts +66 -0
  274. package/src/stores/userStore.ts +126 -0
  275. package/src/utils/capabilityUtils.js +114 -0
  276. package/src/utils/dateUtils.js +21 -0
  277. package/src/utils/deviceUtils.js +74 -0
  278. package/src/utils/firmwareUtils.ts +35 -0
  279. package/src/utils/i18n.ts +28 -0
  280. package/src/utils/imageUtil.js +37 -0
  281. package/src/utils/jobStatus.ts +76 -0
  282. package/src/utils/mdiIcons.ts +49 -0
  283. package/src/utils/notificationTextGenerator.ts +108 -0
  284. package/src/utils/serviceOptionUtil.js +106 -0
  285. package/src/utils/tokenInterceptor.js +59 -0
  286. package/src/utils/updateToken.js +18 -0
  287. package/src/utils/yup.custom.js +11 -0
  288. package/vite/dist/apiClients.d.ts +5 -0
  289. package/vite/dist/apiClients.js +59 -0
  290. package/vite/dist/drift.d.ts +9 -0
  291. package/vite/dist/drift.js +57 -0
  292. package/vite/dist/index.d.ts +4 -0
  293. package/vite/dist/index.js +94 -0
  294. package/vite/dist/overrides.d.ts +3 -0
  295. package/vite/dist/overrides.js +71 -0
  296. package/vite/dist/paths.d.ts +18 -0
  297. package/vite/dist/paths.js +22 -0
  298. package/vite/package.json +1 -0
@@ -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 &amp; 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>
@@ -0,0 +1,244 @@
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
+ repo: string
9
+ ref: string
10
+ playbook: string
11
+ // Imported action fields the form does not edit (image, connectionTypes, timeoutMinutes, ...); sent unchanged
12
+ extra?: Record<string, unknown>
13
+ }
14
+
15
+ export interface CapabilityFormData {
16
+ name: string
17
+ logo: string // '' = use fallback
18
+ capabilityClass: CapabilityClass
19
+ supportedDeploymentTypes: string[] // DeploymentType values
20
+ types: FormCapabilityType[]
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>
30
+ }
31
+
32
+ export interface CapabilityForm {
33
+ isFormValid: boolean
34
+ formData: CapabilityFormData
35
+ }
36
+
37
+ export const DEFAULT_BRANCH = 'main'
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
+
44
+ const DEFAULT_PLAYBOOKS: Record<FormActionType, string> = {
45
+ INSTALL: 'install.yml',
46
+ UNINSTALL: 'uninstall.yml',
47
+ DEPLOY: 'deploy.yml',
48
+ UNDEPLOY: 'undeploy.yml',
49
+ }
50
+
51
+ const TYPE_ORDER: FormCapabilityType[] = ['SETUP', 'DEPLOY']
52
+
53
+ export const ACTIONS_BY_TYPE: Record<FormCapabilityType, FormActionType[]> = {
54
+ SETUP: ['INSTALL', 'UNINSTALL'],
55
+ DEPLOY: ['DEPLOY', 'UNDEPLOY'],
56
+ }
57
+
58
+ export function newActionFormData(actionType?: FormActionType): ActionFormData {
59
+ return { repo: '', ref: DEFAULT_BRANCH, playbook: actionType ? DEFAULT_PLAYBOOKS[actionType] : '' }
60
+ }
61
+
62
+ export function newCapabilityFormData(): CapabilityFormData {
63
+ return {
64
+ name: '',
65
+ logo: '',
66
+ capabilityClass: 'DeploymentCapability',
67
+ supportedDeploymentTypes: [],
68
+ types: [],
69
+ actions: {},
70
+ playbookContract: DEFAULT_PLAYBOOK_CONTRACT,
71
+ }
72
+ }
73
+
74
+ export function allowedTypes(cls: CapabilityClass): FormCapabilityType[] {
75
+ return cls === 'BaseConfigurationCapability' ? ['SETUP'] : ['SETUP', 'DEPLOY']
76
+ }
77
+
78
+ export function effectiveTypes(form: CapabilityFormData): FormCapabilityType[] {
79
+ if (form.capabilityClass === 'BaseConfigurationCapability') {
80
+ return ['SETUP']
81
+ }
82
+ const allowed = allowedTypes(form.capabilityClass)
83
+ return TYPE_ORDER.filter(t => allowed.includes(t) && form.types.includes(t))
84
+ }
85
+
86
+ export function requiredActions(form: CapabilityFormData): FormActionType[] {
87
+ return effectiveTypes(form).flatMap(t => ACTIONS_BY_TYPE[t])
88
+ }
89
+
90
+ export function hasActionErrors(
91
+ actionType: FormActionType,
92
+ errors: Record<string, string | undefined>,
93
+ ): boolean {
94
+ const prefix = `${actionType}.`
95
+ return Object.entries(errors).some(([field, message]) => field.startsWith(prefix) && !!message)
96
+ }
97
+
98
+ export function getActionTabColorProps(
99
+ actionType: FormActionType,
100
+ errors: Record<string, string | undefined>,
101
+ ): { color?: 'error'; baseColor?: 'error' } {
102
+ return hasActionErrors(actionType, errors) ? { color: 'error', baseColor: 'error' } : {}
103
+ }
104
+
105
+ export function fallbackLogo(name: string): string {
106
+ const first = name.trim().charAt(0).toLowerCase()
107
+ if (/^[a-z]$/.test(first)) {
108
+ return `mdi-alpha-${first}-box`
109
+ }
110
+ if (/^[0-9]$/.test(first)) {
111
+ return `mdi-numeric-${first}-box`
112
+ }
113
+ return 'mdi-puzzle'
114
+ }
115
+
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 {
118
+ const wanted = name.trim().toLowerCase()
119
+ return existing.some(c => c.name.trim().toLowerCase() === wanted && (ownId === undefined || c.id !== ownId))
120
+ }
121
+
122
+ function isUntouched(action: ActionFormData, actionType: FormActionType): boolean {
123
+ return action.repo === '' && action.playbook === DEFAULT_PLAYBOOKS[actionType]
124
+ && action.ref === DEFAULT_BRANCH
125
+ }
126
+
127
+ // Plain-object copy; structuredClone throws on Vue reactive proxies
128
+ export function cloneActions(
129
+ actions: Partial<Record<FormActionType, ActionFormData>>,
130
+ ): Partial<Record<FormActionType, ActionFormData>> {
131
+ const result: Partial<Record<FormActionType, ActionFormData>> = {}
132
+ for (const [key, value] of Object.entries(actions) as [FormActionType, ActionFormData][]) {
133
+ result[key] = { ...value, ...(value.extra ? { extra: { ...value.extra } } : {}) }
134
+ }
135
+ return result
136
+ }
137
+
138
+ export function prefillUntouchedActions(
139
+ actions: Partial<Record<FormActionType, ActionFormData>>,
140
+ source: FormActionType,
141
+ ): Partial<Record<FormActionType, ActionFormData>> {
142
+ const src = actions[source]
143
+ const result: Partial<Record<FormActionType, ActionFormData>> = {}
144
+ for (const [key, value] of Object.entries(actions) as [FormActionType, ActionFormData][]) {
145
+ result[key] = src && key !== source && isUntouched(value, key)
146
+ ? { ...value, repo: src.repo, ref: src.ref }
147
+ : { ...value }
148
+ }
149
+ return result
150
+ }
151
+
152
+ // Capability definition as returned by the git import endpoint
153
+ export interface ImportedCapability {
154
+ id?: string
155
+ capabilityClass?: string
156
+ name?: string
157
+ logo?: string
158
+ type?: string[]
159
+ supportedDeploymentTypes?: string[]
160
+ playbookContract?: string
161
+ actions?: Record<string, ({ repo?: string; ref?: string; playbook?: string } & Record<string, unknown>) | undefined>
162
+ [field: string]: unknown
163
+ }
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
+
171
+ const FORM_ACTION_TYPES: FormActionType[] = ['INSTALL', 'UNINSTALL', 'DEPLOY', 'UNDEPLOY']
172
+
173
+ export function capabilityToFormData(c: ImportedCapability): CapabilityFormData {
174
+ const capabilityClass: CapabilityClass = c.capabilityClass === 'BaseConfigurationCapability'
175
+ ? 'BaseConfigurationCapability'
176
+ : 'DeploymentCapability'
177
+ const actions: Partial<Record<FormActionType, ActionFormData>> = {}
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 } : {}),
189
+ }
190
+ }
191
+ const extra = Object.fromEntries(Object.entries(c).filter(([k]) => !FORM_CAPABILITY_FIELDS.has(k)))
192
+ return {
193
+ name: c.name ?? '',
194
+ logo: c.logo ?? '',
195
+ capabilityClass,
196
+ supportedDeploymentTypes: capabilityClass === 'DeploymentCapability' ? [...(c.supportedDeploymentTypes ?? [])] : [],
197
+ types: TYPE_ORDER.filter(t => (c.type ?? []).includes(t)),
198
+ actions,
199
+ playbookContract: c.playbookContract ?? '',
200
+ ...(c.id ? { id: c.id } : {}),
201
+ ...(Object.keys(extraActions).length ? { extraActions } : {}),
202
+ ...(Object.keys(extra).length ? { extra } : {}),
203
+ }
204
+ }
205
+
206
+ export function importErrorMessage(e: unknown): string {
207
+ const message = (e as { response?: { data?: { message?: unknown } } })?.response?.data?.message
208
+ return typeof message === 'string' && message ? message : 'Failed to import capability'
209
+ }
210
+
211
+ // id: used when the form has no id of its own (i.e. the capability was not imported)
212
+ export function buildCapabilityRequest(form: CapabilityFormData, id?: string): GetCapabilities200ResponseInner {
213
+ const name = form.name.trim()
214
+ const actions: Record<string, unknown> = { ...(form.extraActions ?? {}) }
215
+ for (const actionType of requiredActions(form)) {
216
+ const a = form.actions[actionType] ?? newActionFormData()
217
+ actions[actionType] = {
218
+ connectionTypes: ['ssh'],
219
+ skipable: false,
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(),
227
+ }
228
+ }
229
+ const effectiveId = form.id ?? id
230
+ const body: Record<string, unknown> = {
231
+ ...(form.extra ?? {}),
232
+ ...(effectiveId !== undefined ? { id: effectiveId } : {}),
233
+ capabilityClass: form.capabilityClass,
234
+ name,
235
+ logo: form.logo.trim() || fallbackLogo(name),
236
+ type: effectiveTypes(form),
237
+ playbookContract: form.playbookContract.trim(),
238
+ actions,
239
+ }
240
+ if (form.capabilityClass === 'DeploymentCapability') {
241
+ body.supportedDeploymentTypes = form.supportedDeploymentTypes
242
+ }
243
+ return body as unknown as GetCapabilities200ResponseInner
244
+ }