@eclipse-slm/ui 1.5.0-snapshot.870 → 1.5.0-snapshot.883
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/package.json +3 -1
- package/src/api/platform-management/platform-management-client.ts +2 -2
- package/src/app/navigation.ts +7 -0
- package/src/app/routes.ts +6 -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 +76 -0
- package/src/components/capabilities/CapabilityCreateDialog.vue +86 -0
- package/src/components/capabilities/CapabilityCreateForm.vue +275 -0
- package/src/components/capabilities/CapabilityImportDialog.vue +99 -0
- package/src/components/capabilities/capabilityForm.ts +201 -0
- package/src/components/core/Drawer.vue +12 -2
- package/src/components/resources/dialogs/AddItemChooserDialog.vue +68 -0
- package/src/localisation/en.json +3 -0
- package/src/pages/AdminCapabilitiesPage.vue +60 -0
- package/src/pages/ResourceInstancesPage.vue +71 -0
- package/src/stores/capabilitiesStore.ts +45 -2
- package/src/utils/mdiIcons.ts +49 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-slm/ui",
|
|
3
|
-
"version": "1.5.0-snapshot.
|
|
3
|
+
"version": "1.5.0-snapshot.883",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"src",
|
|
21
21
|
"!src/api/*/client",
|
|
22
|
+
"!src/**/*.test.ts",
|
|
22
23
|
"index.html",
|
|
23
24
|
"public",
|
|
24
25
|
"vite/dist",
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
"build": "vite build",
|
|
30
31
|
"serve": "vite preview",
|
|
31
32
|
"lint": "eslint --fix src",
|
|
33
|
+
"test:unit": "vitest run --config vitest.config.ts",
|
|
32
34
|
"test:plugin": "vitest run --config vite/vitest.config.ts",
|
|
33
35
|
"build:plugin": "tsc -p vite/tsconfig.json",
|
|
34
36
|
"prepack": "npm run build:plugin"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
CredentialManagementApi,
|
|
4
4
|
type UserCreateRequest,
|
|
5
5
|
} from "@/api/platform-management/client";
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ class PlatformManagementClient{
|
|
|
16
16
|
|
|
17
17
|
apiUrl = "/platform-management";
|
|
18
18
|
|
|
19
|
-
credentialsApi = new
|
|
19
|
+
credentialsApi = new CredentialManagementApi(undefined, this.apiUrl);
|
|
20
20
|
|
|
21
21
|
async getUsers(): Promise<UserOverviewResponse[]> {
|
|
22
22
|
return axios
|
package/src/app/navigation.ts
CHANGED
|
@@ -177,6 +177,13 @@ export const defaultNavigation: NavItem[] = [
|
|
|
177
177
|
to: 'service-vendors',
|
|
178
178
|
visible: isAdmin,
|
|
179
179
|
},
|
|
180
|
+
{
|
|
181
|
+
id: 'main-menu-button-admin-capabilities',
|
|
182
|
+
titleKey: 'drawer.section.admin.capabilities.title',
|
|
183
|
+
icon: 'mdi-puzzle',
|
|
184
|
+
to: 'capabilities',
|
|
185
|
+
visible: isAdmin,
|
|
186
|
+
},
|
|
180
187
|
{
|
|
181
188
|
id: 'main-menu-button-admin-users',
|
|
182
189
|
// Original used the literal string 'User Management' (no i18n key); kept as-is.
|
package/src/app/routes.ts
CHANGED
|
@@ -181,6 +181,12 @@ export const defaultRoutes: RouteRecordRaw[] = [
|
|
|
181
181
|
component: () => import('@/pages/AdminServiceVendorsPage.vue'),
|
|
182
182
|
meta: { adminPermissionRequired: true },
|
|
183
183
|
},
|
|
184
|
+
{
|
|
185
|
+
name: 'AdminCapabilities',
|
|
186
|
+
path: '/admin/capabilities',
|
|
187
|
+
component: () => import('@/pages/AdminCapabilitiesPage.vue'),
|
|
188
|
+
meta: { adminPermissionRequired: true },
|
|
189
|
+
},
|
|
184
190
|
{
|
|
185
191
|
name: 'AdminUsers',
|
|
186
192
|
path: '/admin/users',
|
|
@@ -10,33 +10,40 @@
|
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
12
|
<template #actions>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
<!-- Three equal columns keep the optional centre action centred regardless of button widths -->
|
|
14
|
+
<div class="confirm-dialog-action justify-start">
|
|
15
|
+
<v-btn
|
|
16
|
+
id="button-confirm-dialog"
|
|
17
|
+
variant="text"
|
|
18
|
+
:disabled="confirmLoading"
|
|
19
|
+
@click="$emit('canceled')"
|
|
20
|
+
>
|
|
21
|
+
{{ cancelButtonLabel }}
|
|
22
|
+
</v-btn>
|
|
23
|
+
</div>
|
|
21
24
|
|
|
22
|
-
<
|
|
25
|
+
<div class="confirm-dialog-action justify-center">
|
|
26
|
+
<slot name="actions-center" />
|
|
27
|
+
</div>
|
|
23
28
|
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
v-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
<div class="confirm-dialog-action justify-end">
|
|
30
|
+
<v-btn
|
|
31
|
+
id="button-confirm-dialog"
|
|
32
|
+
variant="text"
|
|
33
|
+
:color="attention ? 'error' : ''"
|
|
34
|
+
:disabled="confirmButtonDisabled || confirmLoading"
|
|
35
|
+
@click="$emit('confirmed')"
|
|
36
|
+
>
|
|
37
|
+
<v-progress-circular
|
|
38
|
+
v-if="confirmLoading"
|
|
39
|
+
size="16"
|
|
40
|
+
width="2"
|
|
41
|
+
indeterminate
|
|
42
|
+
class="mr-2"
|
|
43
|
+
/>
|
|
44
|
+
{{ confirmButtonLabel }}
|
|
45
|
+
</v-btn>
|
|
46
|
+
</div>
|
|
40
47
|
</template>
|
|
41
48
|
</CustomDialog>
|
|
42
49
|
</template>
|
|
@@ -85,3 +92,10 @@ const props = defineProps({
|
|
|
85
92
|
}
|
|
86
93
|
});
|
|
87
94
|
</script>
|
|
95
|
+
|
|
96
|
+
<style scoped>
|
|
97
|
+
.confirm-dialog-action {
|
|
98
|
+
display: flex;
|
|
99
|
+
flex: 1 1 0;
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
@@ -36,16 +36,26 @@ const showProp = toRef(props,'show'); // react to prop
|
|
|
36
36
|
watch(showProp, (value) => {
|
|
37
37
|
dialogActive.value = Boolean(value);
|
|
38
38
|
}, { immediate: true });
|
|
39
|
+
|
|
40
|
+
// Esc and outside click close the v-dialog by setting its v-model to false; tell the parent
|
|
41
|
+
// (which still has show=true) exactly once. When the parent closes via show=false, no emit.
|
|
42
|
+
watch(dialogActive, (active) => {
|
|
43
|
+
if (!active && props.show) {
|
|
44
|
+
emit('canceled');
|
|
45
|
+
}
|
|
46
|
+
});
|
|
39
47
|
</script>
|
|
40
48
|
|
|
41
49
|
<template>
|
|
42
50
|
<v-dialog
|
|
43
51
|
v-model="dialogActive"
|
|
44
52
|
:width="width"
|
|
45
|
-
@click:outside="emit('canceled')"
|
|
46
53
|
>
|
|
47
54
|
<template #default="{}">
|
|
48
|
-
<v-card
|
|
55
|
+
<v-card
|
|
56
|
+
v-if="dialogActive"
|
|
57
|
+
class="custom-dialog-card"
|
|
58
|
+
>
|
|
49
59
|
<v-toolbar color="primary" theme="dark">
|
|
50
60
|
<slot name="header">
|
|
51
61
|
<div class="dialog-toolbar">
|
|
@@ -61,7 +71,7 @@ watch(showProp, (value) => {
|
|
|
61
71
|
</div>
|
|
62
72
|
</slot>
|
|
63
73
|
</v-toolbar>
|
|
64
|
-
<v-card-text class="mt-8 mx-4">
|
|
74
|
+
<v-card-text class="custom-dialog-content mt-8 mx-4">
|
|
65
75
|
<slot name="content">
|
|
66
76
|
{{ text }}
|
|
67
77
|
</slot>
|
|
@@ -75,6 +85,18 @@ watch(showProp, (value) => {
|
|
|
75
85
|
</template>
|
|
76
86
|
|
|
77
87
|
<style scoped>
|
|
88
|
+
.custom-dialog-card {
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
max-height: min(90vh, calc(100vh - 48px));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.custom-dialog-content {
|
|
95
|
+
flex: 1 1 auto;
|
|
96
|
+
min-height: 0;
|
|
97
|
+
overflow-y: auto;
|
|
98
|
+
}
|
|
99
|
+
|
|
78
100
|
.dialog-toolbar {
|
|
79
101
|
display: flex;
|
|
80
102
|
align-items: center;
|
|
@@ -82,6 +104,12 @@ watch(showProp, (value) => {
|
|
|
82
104
|
position: relative;
|
|
83
105
|
width: 100%;
|
|
84
106
|
}
|
|
107
|
+
|
|
108
|
+
.v-toolbar,
|
|
109
|
+
.v-card-actions {
|
|
110
|
+
flex: 0 0 auto;
|
|
111
|
+
}
|
|
112
|
+
|
|
85
113
|
.close-btn {
|
|
86
114
|
margin-left: auto;
|
|
87
115
|
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
|
3
|
+
import CustomDialog from '@/components/base/CustomDialog.vue'
|
|
4
|
+
import { filterIcons, loadMdiIcons } from '@/utils/mdiIcons'
|
|
5
|
+
import type { MdiIconMeta } from '@/utils/mdiIcons'
|
|
6
|
+
|
|
7
|
+
const ICONS_PER_ROW = 8
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{
|
|
10
|
+
show: boolean
|
|
11
|
+
modelValue?: string
|
|
12
|
+
}>()
|
|
13
|
+
|
|
14
|
+
const emit = defineEmits<{
|
|
15
|
+
(e: 'selected', icon: string): void
|
|
16
|
+
(e: 'canceled'): void
|
|
17
|
+
}>()
|
|
18
|
+
|
|
19
|
+
const icons = ref<MdiIconMeta[]>([])
|
|
20
|
+
const loading = ref(false)
|
|
21
|
+
const loadFailed = ref(false)
|
|
22
|
+
const searchInput = ref<string | null>('')
|
|
23
|
+
const query = ref('')
|
|
24
|
+
const manualName = ref('')
|
|
25
|
+
|
|
26
|
+
let debounceTimer: ReturnType<typeof setTimeout> | undefined
|
|
27
|
+
|
|
28
|
+
watch(searchInput, (value) => {
|
|
29
|
+
clearTimeout(debounceTimer)
|
|
30
|
+
debounceTimer = setTimeout(() => {
|
|
31
|
+
query.value = value ?? ''
|
|
32
|
+
}, 150)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
onBeforeUnmount(() => clearTimeout(debounceTimer))
|
|
36
|
+
|
|
37
|
+
async function load() {
|
|
38
|
+
loading.value = true
|
|
39
|
+
loadFailed.value = false
|
|
40
|
+
try {
|
|
41
|
+
icons.value = await loadMdiIcons()
|
|
42
|
+
} catch {
|
|
43
|
+
loadFailed.value = true
|
|
44
|
+
} finally {
|
|
45
|
+
loading.value = false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
watch(
|
|
50
|
+
() => props.show,
|
|
51
|
+
(visible) => {
|
|
52
|
+
if (!visible) return
|
|
53
|
+
searchInput.value = ''
|
|
54
|
+
query.value = ''
|
|
55
|
+
manualName.value = ''
|
|
56
|
+
if (icons.value.length === 0) load()
|
|
57
|
+
},
|
|
58
|
+
{ immediate: true },
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
const rows = computed(() => {
|
|
62
|
+
const filtered = filterIcons(icons.value, query.value)
|
|
63
|
+
const result: { id: number; icons: MdiIconMeta[] }[] = []
|
|
64
|
+
for (let i = 0; i < filtered.length; i += ICONS_PER_ROW) {
|
|
65
|
+
result.push({ id: i, icons: filtered.slice(i, i + ICONS_PER_ROW) })
|
|
66
|
+
}
|
|
67
|
+
return result
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
function select(name: string) {
|
|
71
|
+
emit('selected', `mdi-${name}`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function useManualName() {
|
|
75
|
+
const name = manualName.value.trim()
|
|
76
|
+
if (!name) return
|
|
77
|
+
emit('selected', name.startsWith('mdi-') ? name : `mdi-${name}`)
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<template>
|
|
82
|
+
<CustomDialog
|
|
83
|
+
:show="show"
|
|
84
|
+
title="Select icon"
|
|
85
|
+
width="720"
|
|
86
|
+
hide-actions
|
|
87
|
+
@canceled="emit('canceled')"
|
|
88
|
+
>
|
|
89
|
+
<template #content>
|
|
90
|
+
<div v-if="loading" class="d-flex justify-center pa-8">
|
|
91
|
+
<v-progress-circular indeterminate color="primary" />
|
|
92
|
+
</div>
|
|
93
|
+
<div v-else-if="loadFailed">
|
|
94
|
+
<v-alert type="warning" variant="tonal" class="mb-4">
|
|
95
|
+
Icon list could not be loaded. Enter an icon name instead.
|
|
96
|
+
</v-alert>
|
|
97
|
+
<div class="d-flex align-center ga-2">
|
|
98
|
+
<v-text-field
|
|
99
|
+
v-model="manualName"
|
|
100
|
+
placeholder="mdi-docker"
|
|
101
|
+
variant="outlined"
|
|
102
|
+
density="compact"
|
|
103
|
+
hide-details
|
|
104
|
+
@keyup.enter="useManualName"
|
|
105
|
+
/>
|
|
106
|
+
<v-btn color="primary" :disabled="!manualName.trim()" @click="useManualName">Use</v-btn>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
<div v-else>
|
|
110
|
+
<v-text-field
|
|
111
|
+
v-model="searchInput"
|
|
112
|
+
placeholder="Search icons"
|
|
113
|
+
aria-label="Search icons"
|
|
114
|
+
prepend-inner-icon="mdi-magnify"
|
|
115
|
+
variant="outlined"
|
|
116
|
+
density="compact"
|
|
117
|
+
clearable
|
|
118
|
+
autofocus
|
|
119
|
+
hide-details
|
|
120
|
+
class="mb-4"
|
|
121
|
+
/>
|
|
122
|
+
<v-virtual-scroll :items="rows" :height="320" :item-height="48" item-key="id">
|
|
123
|
+
<template #default="{ item }">
|
|
124
|
+
<div class="icon-row">
|
|
125
|
+
<v-btn
|
|
126
|
+
v-for="icon in item.icons"
|
|
127
|
+
:key="icon.name"
|
|
128
|
+
:icon="`mdi-${icon.name}`"
|
|
129
|
+
:color="modelValue === `mdi-${icon.name}` ? 'primary' : undefined"
|
|
130
|
+
:variant="modelValue === `mdi-${icon.name}` ? 'flat' : 'text'"
|
|
131
|
+
@click="select(icon.name)"
|
|
132
|
+
>
|
|
133
|
+
<v-icon :icon="`mdi-${icon.name}`" />
|
|
134
|
+
<v-tooltip activator="parent" location="top">mdi-{{ icon.name }}</v-tooltip>
|
|
135
|
+
</v-btn>
|
|
136
|
+
</div>
|
|
137
|
+
</template>
|
|
138
|
+
</v-virtual-scroll>
|
|
139
|
+
<div v-if="rows.length === 0" class="text-center text-medium-emphasis pa-4">
|
|
140
|
+
No icons found
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</template>
|
|
144
|
+
</CustomDialog>
|
|
145
|
+
</template>
|
|
146
|
+
|
|
147
|
+
<style scoped>
|
|
148
|
+
.icon-row {
|
|
149
|
+
display: grid;
|
|
150
|
+
grid-template-columns: repeat(8, 1fr);
|
|
151
|
+
justify-items: center;
|
|
152
|
+
height: 48px;
|
|
153
|
+
align-items: center;
|
|
154
|
+
}
|
|
155
|
+
</style>
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<base-material-card>
|
|
3
|
+
<template #heading>
|
|
4
|
+
<overview-heading text="Capabilities" />
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<no-item-available-note
|
|
8
|
+
v-if="capabilities.length === 0"
|
|
9
|
+
item="Capability"
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
<v-data-table
|
|
13
|
+
v-else
|
|
14
|
+
:headers="headers"
|
|
15
|
+
:items="capabilities"
|
|
16
|
+
item-value="id"
|
|
17
|
+
show-expand
|
|
18
|
+
v-model:expanded="expanded"
|
|
19
|
+
@click:row="onRowClick"
|
|
20
|
+
>
|
|
21
|
+
<template #item.logo="{ item }">
|
|
22
|
+
<v-icon>{{ item.logo }}</v-icon>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<template #item.capabilityClass="{ item }">
|
|
26
|
+
{{ item.capabilityClass === 'DeploymentCapability' ? 'Deployment' : 'Base configuration' }}
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<template #item.type="{ item }">
|
|
30
|
+
<v-chip
|
|
31
|
+
v-for="type in item.type"
|
|
32
|
+
:key="type"
|
|
33
|
+
class="mr-1"
|
|
34
|
+
size="small"
|
|
35
|
+
>
|
|
36
|
+
{{ type }}
|
|
37
|
+
</v-chip>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<template #item.supportedDeploymentTypes="{ item }">
|
|
41
|
+
<template v-if="item.capabilityClass === 'DeploymentCapability' && item.supportedDeploymentTypes?.length">
|
|
42
|
+
<v-chip
|
|
43
|
+
v-for="deploymentType in item.supportedDeploymentTypes"
|
|
44
|
+
:key="deploymentType"
|
|
45
|
+
class="mr-1"
|
|
46
|
+
size="small"
|
|
47
|
+
>
|
|
48
|
+
{{ deploymentType }}
|
|
49
|
+
</v-chip>
|
|
50
|
+
</template>
|
|
51
|
+
<template v-else>
|
|
52
|
+
–
|
|
53
|
+
</template>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<template #item.installCount="{ item }">
|
|
57
|
+
{{ capabilitiesStore.installCountOfCapability(item.id) }} device(s)
|
|
58
|
+
</template>
|
|
59
|
+
|
|
60
|
+
<template #item.deleteAction="{ item }">
|
|
61
|
+
<v-tooltip
|
|
62
|
+
:disabled="capabilitiesStore.installCountOfCapability(item.id) === 0"
|
|
63
|
+
location="top"
|
|
64
|
+
>
|
|
65
|
+
<template #activator="{ props: tooltipProps }">
|
|
66
|
+
<span v-bind="tooltipProps">
|
|
67
|
+
<v-btn
|
|
68
|
+
prepend-icon="mdi-delete"
|
|
69
|
+
size="small"
|
|
70
|
+
color="error"
|
|
71
|
+
:disabled="capabilitiesStore.installCountOfCapability(item.id) > 0"
|
|
72
|
+
@click.stop="capabilityToDelete = item"
|
|
73
|
+
>
|
|
74
|
+
Delete
|
|
75
|
+
</v-btn>
|
|
76
|
+
</span>
|
|
77
|
+
</template>
|
|
78
|
+
Installed on {{ capabilitiesStore.installCountOfCapability(item.id) }} device(s). Uninstall it first.
|
|
79
|
+
</v-tooltip>
|
|
80
|
+
</template>
|
|
81
|
+
|
|
82
|
+
<template #expanded-row="{ columns, item }">
|
|
83
|
+
<tr>
|
|
84
|
+
<td
|
|
85
|
+
:colspan="columns.length"
|
|
86
|
+
class="expanded-actions-cell"
|
|
87
|
+
>
|
|
88
|
+
<table class="action-details-table">
|
|
89
|
+
<thead>
|
|
90
|
+
<tr>
|
|
91
|
+
<th>Action type</th>
|
|
92
|
+
<th>Repository</th>
|
|
93
|
+
<th>Branch</th>
|
|
94
|
+
<th>Playbook</th>
|
|
95
|
+
</tr>
|
|
96
|
+
</thead>
|
|
97
|
+
<tbody>
|
|
98
|
+
<tr
|
|
99
|
+
v-for="[actionType, action] in Object.entries(item.actions ?? {})"
|
|
100
|
+
:key="actionType"
|
|
101
|
+
>
|
|
102
|
+
<td>{{ actionType }}</td>
|
|
103
|
+
<td>{{ action.awxRepo }}</td>
|
|
104
|
+
<td>{{ action.awxBranch }}</td>
|
|
105
|
+
<td>{{ action.playbook }}</td>
|
|
106
|
+
</tr>
|
|
107
|
+
</tbody>
|
|
108
|
+
</table>
|
|
109
|
+
</td>
|
|
110
|
+
</tr>
|
|
111
|
+
</template>
|
|
112
|
+
</v-data-table>
|
|
113
|
+
|
|
114
|
+
<ConfirmDialog
|
|
115
|
+
:show="capabilityToDelete !== null"
|
|
116
|
+
attention
|
|
117
|
+
title="Delete capability"
|
|
118
|
+
:text="`Delete capability '${capabilityToDelete?.name}'? Its AWX job templates and projects are removed too.`"
|
|
119
|
+
confirm-button-label="Delete"
|
|
120
|
+
cancel-button-label="Cancel"
|
|
121
|
+
:confirm-loading="deleting"
|
|
122
|
+
@canceled="capabilityToDelete = null"
|
|
123
|
+
@confirmed="onDeleteConfirmed"
|
|
124
|
+
/>
|
|
125
|
+
</base-material-card>
|
|
126
|
+
</template>
|
|
127
|
+
|
|
128
|
+
<script setup lang="ts">
|
|
129
|
+
import { computed, ref } from 'vue';
|
|
130
|
+
import { useToast } from 'vue-toast-notification';
|
|
131
|
+
import logRequestError from '@/api/restApiHelper';
|
|
132
|
+
import ConfirmDialog from '@/components/base/ConfirmDialog.vue';
|
|
133
|
+
import NoItemAvailableNote from '@/components/base/NoItemAvailableNote.vue';
|
|
134
|
+
import OverviewHeading from '@/components/base/OverviewHeading.vue';
|
|
135
|
+
import { CapabilityInUseError, useCapabilitiesStore } from '@/stores/capabilitiesStore';
|
|
136
|
+
|
|
137
|
+
const $toast = useToast();
|
|
138
|
+
const capabilitiesStore = useCapabilitiesStore();
|
|
139
|
+
|
|
140
|
+
const capabilityToDelete = ref<any>(null);
|
|
141
|
+
const deleting = ref(false);
|
|
142
|
+
const expanded = ref<Array<string | number>>([]);
|
|
143
|
+
|
|
144
|
+
const capabilities = computed(() => capabilitiesStore.capabilities);
|
|
145
|
+
|
|
146
|
+
const headers = [
|
|
147
|
+
{ title: '', key: 'data-table-expand', sortable: false },
|
|
148
|
+
{ title: 'Logo', key: 'logo', sortable: false },
|
|
149
|
+
{ title: 'Name', key: 'name' },
|
|
150
|
+
{ title: 'Class', key: 'capabilityClass' },
|
|
151
|
+
{ title: 'Types', key: 'type', sortable: false },
|
|
152
|
+
{ title: 'Deployment types', key: 'supportedDeploymentTypes', sortable: false },
|
|
153
|
+
{ title: 'In use', key: 'installCount', sortable: false },
|
|
154
|
+
{ title: '', key: 'deleteAction', sortable: false },
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
function onRowClick(_event: MouseEvent, { item }: { item: { id: string | number } }) {
|
|
158
|
+
expanded.value = expanded.value.includes(item.id)
|
|
159
|
+
? expanded.value.filter((id) => id !== item.id)
|
|
160
|
+
: [...expanded.value, item.id];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function onDeleteConfirmed() {
|
|
164
|
+
const capability = capabilityToDelete.value;
|
|
165
|
+
if (!capability) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
deleting.value = true;
|
|
169
|
+
try {
|
|
170
|
+
await capabilitiesStore.deleteCapability(capability.id);
|
|
171
|
+
$toast.success('Capability deleted');
|
|
172
|
+
} catch (e) {
|
|
173
|
+
if (e instanceof CapabilityInUseError) {
|
|
174
|
+
$toast.error(`Capability is installed on ${e.installCount} device(s) and cannot be deleted`);
|
|
175
|
+
} else {
|
|
176
|
+
logRequestError(e);
|
|
177
|
+
$toast.error('Failed to delete capability');
|
|
178
|
+
}
|
|
179
|
+
} finally {
|
|
180
|
+
deleting.value = false;
|
|
181
|
+
capabilityToDelete.value = null;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
</script>
|
|
185
|
+
|
|
186
|
+
<style scoped>
|
|
187
|
+
.action-details-table {
|
|
188
|
+
border-collapse: collapse;
|
|
189
|
+
max-width: 100%;
|
|
190
|
+
margin: 8px 0 8px 48px;
|
|
191
|
+
text-align: left;
|
|
192
|
+
white-space: nowrap;
|
|
193
|
+
width: auto;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.expanded-actions-cell {
|
|
197
|
+
background-color: rgba(var(--v-theme-on-surface), 0.04);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.action-details-table th,
|
|
201
|
+
.action-details-table td {
|
|
202
|
+
border: 0;
|
|
203
|
+
padding: 4px 8px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.action-details-table th {
|
|
207
|
+
font-weight: 700;
|
|
208
|
+
}
|
|
209
|
+
</style>
|
|
@@ -0,0 +1,76 @@
|
|
|
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 'AWX 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: awxRepo, errorMessage: repoError } = useField<string>(`${prefix}.awxRepo`, repoRule, {
|
|
20
|
+
initialValue: props.modelValue.awxRepo,
|
|
21
|
+
});
|
|
22
|
+
const { value: awxBranch, errorMessage: branchError } = useField<string>(
|
|
23
|
+
`${prefix}.awxBranch`, requiredRule('Branch'), { initialValue: props.modelValue.awxBranch });
|
|
24
|
+
const { value: playbook, errorMessage: playbookError } = useField<string>(
|
|
25
|
+
`${prefix}.playbook`, requiredRule('Playbook'), { initialValue: props.modelValue.playbook });
|
|
26
|
+
|
|
27
|
+
watch(() => props.modelValue, (val) => {
|
|
28
|
+
awxRepo.value = val.awxRepo;
|
|
29
|
+
awxBranch.value = val.awxBranch;
|
|
30
|
+
playbook.value = val.playbook;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
watch([awxRepo, awxBranch, playbook], () => {
|
|
34
|
+
const m = props.modelValue;
|
|
35
|
+
if (m.awxRepo === awxRepo.value && m.awxBranch === awxBranch.value && m.playbook === playbook.value) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
emit('update:modelValue', {
|
|
39
|
+
awxRepo: awxRepo.value ?? '',
|
|
40
|
+
awxBranch: awxBranch.value ?? '',
|
|
41
|
+
playbook: playbook.value ?? '',
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
<v-card variant="outlined" class="mt-4 mb-4">
|
|
48
|
+
<v-card-text>
|
|
49
|
+
<v-text-field
|
|
50
|
+
v-model="awxRepo"
|
|
51
|
+
label="AWX repository"
|
|
52
|
+
required
|
|
53
|
+
class="mb-2"
|
|
54
|
+
hide-details="auto"
|
|
55
|
+
:error-messages="repoError"
|
|
56
|
+
@blur="emit('source-changed')"
|
|
57
|
+
/>
|
|
58
|
+
<v-text-field
|
|
59
|
+
v-model="awxBranch"
|
|
60
|
+
label="Branch"
|
|
61
|
+
required
|
|
62
|
+
class="mb-2"
|
|
63
|
+
hide-details="auto"
|
|
64
|
+
:error-messages="branchError"
|
|
65
|
+
@blur="emit('source-changed')"
|
|
66
|
+
/>
|
|
67
|
+
<v-text-field
|
|
68
|
+
v-model="playbook"
|
|
69
|
+
label="Playbook"
|
|
70
|
+
required
|
|
71
|
+
hide-details="auto"
|
|
72
|
+
:error-messages="playbookError"
|
|
73
|
+
/>
|
|
74
|
+
</v-card-text>
|
|
75
|
+
</v-card>
|
|
76
|
+
</template>
|