@kong-ui-public/entities-consumers 4.8.2-pr.3869.e876c8c8a.0 → 4.8.2
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/dist/entities-consumers.es.js +926 -0
- package/dist/entities-consumers.umd.js +1 -0
- package/dist/style.css +1 -0
- package/dist/types/components/AddConsumerModal.vue.d.ts +38 -0
- package/dist/types/components/AddConsumerModal.vue.d.ts.map +1 -0
- package/dist/types/components/ConsumerConfigCard.vue.d.ts +63 -0
- package/dist/types/components/ConsumerConfigCard.vue.d.ts.map +1 -0
- package/dist/types/components/ConsumerForm.vue.d.ts +44 -0
- package/dist/types/components/ConsumerForm.vue.d.ts.map +1 -0
- package/dist/types/components/ConsumerList.vue.d.ts +123 -0
- package/dist/types/components/ConsumerList.vue.d.ts.map +1 -0
- package/dist/types/composables/index.d.ts +6 -0
- package/dist/types/composables/index.d.ts.map +1 -0
- package/dist/types/composables/useI18n.d.ts +9 -0
- package/dist/types/composables/useI18n.d.ts.map +1 -0
- package/dist/types/consumers-endpoints.d.ts +27 -0
- package/dist/types/consumers-endpoints.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types/consumer-config-card.d.ts +18 -0
- package/dist/types/types/consumer-config-card.d.ts.map +1 -0
- package/dist/types/types/consumer-form.d.ts +28 -0
- package/dist/types/types/consumer-form.d.ts.map +1 -0
- package/dist/types/types/consumer-list.d.ts +39 -0
- package/dist/types/types/consumer-list.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +4 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,926 @@
|
|
|
1
|
+
import { defineComponent as ae, ref as y, computed as h, watch as ve, resolveComponent as R, openBlock as E, createBlock as W, unref as t, withCtx as a, createElementVNode as b, toDisplayString as p, createVNode as i, createElementBlock as O, createCommentVNode as j, Fragment as Qe, renderList as We, onBeforeMount as ze, createSlots as ge, createTextVNode as K, Teleport as Ye, renderSlot as Ee, reactive as Se } from "vue";
|
|
2
|
+
import { useRouter as Fe } from "vue-router";
|
|
3
|
+
import { BookIcon as Me, AddIcon as Ge, TeamIcon as Xe } from "@kong/icons";
|
|
4
|
+
import { createI18n as Ze, i18nTComponent as et } from "@kong-ui-public/i18n";
|
|
5
|
+
import { useAxios as ye, useDebouncedFilter as tt, useManagedByColumn as ot, useTableState as st, useFetcher as nt, useDeleteUrlBuilder as rt, FetcherStatus as at, EntityBaseTable as it, PermissionsWrapper as re, getManagedByLabel as lt, TableTags as ct, EntityFilter as ut, EntityDeleteModal as dt, EntityTypes as mt, useErrors as pt, EntityBaseFormType as xe, EntityBaseForm as ft, SupportedEntityType as De, EntityFormSection as gt, ConfigurationSchemaSection as Ae, EntityBaseConfigCard as vt } from "@kong-ui-public/entities-shared";
|
|
6
|
+
const yt = { list: { table_headers: { username: "Username", custom_id: "Custom ID", tags: "Tags", id: "ID" }, empty_state: { title: "Configure a new consumer", description: "Consumers are the end users of a service.", title_for_consumer_group: "Configure a new consumer" }, empty_state_v2: { title: "Configure your first consumer", group: "Consumers created in gateways within this group will automatically appear here.", description: "Consumers represent users or apps accessing your APIs, allowing for tailored authentication and individual access control.", learn_more: "Learn more" }, toolbar_actions: { new_consumer: "New consumer" } }, title: "Consumers", search: { placeholder: { konnect: "Filter by name", kongManager: "Filter by exact username or ID" } }, actions: { add_consumer: "Add consumer", create: "New consumer", copy_id: "Copy ID", copy_json: "Copy JSON", edit: "Edit", delete: "Delete", remove: "Remove", view: "View details" }, delete: { title: "Delete a consumer", description: "Deleting this consumer will also remove this consumer from any associated consumer group and delete all its plugins. This action cannot be reversed." }, consumer_groups: { add: { title: "Add consumers", ctaText: "Add consumers to this group", consumers_label: "Consumers", consumer_placeholder: "Add consumer", footer: "Search by exact name or ID to find consumers not included in the list" }, remove: { title: "Remove a consumer", confirmation: "Are you sure you want to remove this consumer {consumer} from consumer group {consumerGroup}?", confirmationNoCG: "Are you sure you want to remove this consumer {consumer} from this consumer group?", description: "Removing this consumer from the group could change the rate limit policy applied to this consumer." } }, errors: { general: "Consumers could not be retrieved", delete: "The consumer could not be deleted at this time.", copy: "Failed to copy to clipboard", add: "Some consumers could not be added at this time.", already_added: "This consumer has already been added to the consumer group" }, copy: { success: "Copied {val} to clipboard", success_brief: "Successfully copied to clipboard" }, form: { title: "Consumer identification", info: { title: "General information", description: "General information will help identify and manage added consumer." }, consumer_identification: { title: "Consumer identification", description: "A consumer can have both unique username and unique custom ID or one of them." } }, fields: { username: { label: "Username", placeholder: "Enter a unique username", tooltip: "The unique username of the consumer. You must send either this field or {custom_id} with the request.", custom_id: "custom_id" }, custom_id: { label: "Custom ID", placeholder: "Enter a unique custom ID", tooltip: "Field for storing an existing unique ID for the consumer - useful for mapping Kong with users in your existing database. You must send either this field or {username} with the request.", username: "username" }, tags: { label: "Tags", placeholder: "Enter a list of tags separated by comma", help: "e.g. tag1, tag2, tag3", tooltip: "An optional set of strings associated with the consumer for grouping and filtering." } } }, ht = {
|
|
7
|
+
consumers: yt
|
|
8
|
+
};
|
|
9
|
+
function bt() {
|
|
10
|
+
const e = Ze("en-us", ht);
|
|
11
|
+
return {
|
|
12
|
+
i18n: e,
|
|
13
|
+
i18nT: et(e)
|
|
14
|
+
// Translation component <i18n-t>
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const ie = {
|
|
18
|
+
useI18n: bt
|
|
19
|
+
}, Z = "/v2/control-planes/{controlPlaneId}/core-entities/{workspace}", oe = "/{workspace}", L = {
|
|
20
|
+
list: {
|
|
21
|
+
konnect: {
|
|
22
|
+
all: `${Z}/consumers`,
|
|
23
|
+
forConsumerGroup: `${Z}/consumer_groups/{consumerGroupId}/consumers`,
|
|
24
|
+
oneForConsumerGroup: `${Z}/consumer_groups/{consumerGroupId}/consumers/{consumerId}`,
|
|
25
|
+
search: `${Z}/consumers/search`
|
|
26
|
+
},
|
|
27
|
+
kongManager: {
|
|
28
|
+
all: `${oe}/consumers`,
|
|
29
|
+
forConsumerGroup: `${oe}/consumer_groups/{consumerGroupId}/consumers`,
|
|
30
|
+
oneForConsumerGroup: `${oe}/consumer_groups/{consumerGroupId}/consumers/{consumerId}`
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
form: {
|
|
34
|
+
konnect: {
|
|
35
|
+
create: `${Z}/consumers`,
|
|
36
|
+
edit: `${Z}/consumers/{id}`
|
|
37
|
+
},
|
|
38
|
+
kongManager: {
|
|
39
|
+
create: `${oe}/consumers`,
|
|
40
|
+
edit: `${oe}/consumers/{id}`
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}, _t = { class: "add-consumer-form-container" }, Ct = { class: "add-consumer-form-cta" }, kt = { class: "select-item-label" }, It = {
|
|
44
|
+
key: 0,
|
|
45
|
+
class: "select-item-desc"
|
|
46
|
+
}, wt = {
|
|
47
|
+
key: 0,
|
|
48
|
+
class: "kong-ui-entity-add-consumers-error"
|
|
49
|
+
}, $t = { key: 0 }, Et = /* @__PURE__ */ ae({
|
|
50
|
+
__name: "AddConsumerModal",
|
|
51
|
+
props: {
|
|
52
|
+
/** The base konnect or kongManger config. Pass additional config props in the shared entity component as needed. */
|
|
53
|
+
config: {
|
|
54
|
+
type: Object,
|
|
55
|
+
required: !0,
|
|
56
|
+
validator: (e) => !(!e || !["konnect", "kongManager"].includes(e?.app) || !e.consumerGroupId)
|
|
57
|
+
},
|
|
58
|
+
visible: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
required: !0
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
emits: ["cancel", "add:success", "add:partial-success", "error"],
|
|
64
|
+
setup(e, { emit: c }) {
|
|
65
|
+
const { i18n: { t: r } } = ie.useI18n(), o = e, S = c, { axiosInstance: n } = ye(o.config?.axiosRequestConfig), _ = y([]), {
|
|
66
|
+
debouncedQueryChange: w,
|
|
67
|
+
loading: A,
|
|
68
|
+
allRecords: T,
|
|
69
|
+
error: u,
|
|
70
|
+
loadItems: z,
|
|
71
|
+
results: Y
|
|
72
|
+
} = tt(
|
|
73
|
+
o.config,
|
|
74
|
+
L.list[o.config.app].all,
|
|
75
|
+
"",
|
|
76
|
+
{
|
|
77
|
+
fetchedItemsKey: "data",
|
|
78
|
+
searchKeys: ["username", "id"]
|
|
79
|
+
}
|
|
80
|
+
), U = (d) => d, H = h(() => u.value ? r("consumers.errors.general") : ""), X = y(0), J = h(() => T.value === void 0), M = h(() => Y.value.map((d) => ({
|
|
81
|
+
label: d.username || d.customId,
|
|
82
|
+
value: d.id,
|
|
83
|
+
selected: _.value.includes(d.id),
|
|
84
|
+
data: d
|
|
85
|
+
// we need this to determine whether or not to show the description text
|
|
86
|
+
}))), q = (d) => {
|
|
87
|
+
const $ = J.value ? Y.value.find((I) => I.id === d) : T.value?.find((I) => I.id === d);
|
|
88
|
+
return $ ? $.username || $.custom_id : d;
|
|
89
|
+
}, ee = () => {
|
|
90
|
+
g.value = "", D.value = [], x.value = [], S("cancel");
|
|
91
|
+
}, D = y([]), F = y(!1), g = y(""), l = async () => {
|
|
92
|
+
if (!_.value.length) {
|
|
93
|
+
g.value = "", x.value = [], S("cancel");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
F.value = !0, g.value = "", D.value = [], x.value = [];
|
|
97
|
+
try {
|
|
98
|
+
const d = _.value.map((G) => Q(G)), $ = await Promise.allSettled(d);
|
|
99
|
+
let I = !0;
|
|
100
|
+
$.forEach((G) => {
|
|
101
|
+
G.status !== "fulfilled" && (I = !1);
|
|
102
|
+
}), I ? (D.value = [], x.value = [], S("add:success", _.value), _.value = []) : (D.value.length && S("add:partial-success", D.value), _.value = [], C($));
|
|
103
|
+
} catch {
|
|
104
|
+
g.value = r("consumers.errors.add"), S("error", g.value);
|
|
105
|
+
} finally {
|
|
106
|
+
F.value = !1;
|
|
107
|
+
}
|
|
108
|
+
}, v = h(() => {
|
|
109
|
+
let d = `${o.config.apiBaseUrl}${L.list[o.config.app].forConsumerGroup}`;
|
|
110
|
+
return o.config.app === "konnect" && (d = d.replace(/{controlPlaneId}/gi, o.config?.controlPlaneId || "")), d.replace(/\/{workspace}/gi, o.config?.workspace ? `/${o.config.workspace}` : "").replace(/{consumerGroupId}/gi, o.config?.consumerGroupId || "");
|
|
111
|
+
}), Q = async (d) => {
|
|
112
|
+
const $ = {
|
|
113
|
+
consumer: d
|
|
114
|
+
};
|
|
115
|
+
try {
|
|
116
|
+
const I = await n.post(v.value, $);
|
|
117
|
+
return D.value.push(d), I;
|
|
118
|
+
} catch (I) {
|
|
119
|
+
let G = `${q(d)} - ${I.message}`;
|
|
120
|
+
return I.response.status === 409 && (G = `${q(d)} - ${r("consumers.errors.already_added")}`), Promise.reject(Error(G));
|
|
121
|
+
}
|
|
122
|
+
}, x = y([]), C = (d) => {
|
|
123
|
+
x.value = d.map(($) => $.reason?.message).filter(Boolean);
|
|
124
|
+
};
|
|
125
|
+
return ve(M, () => {
|
|
126
|
+
X.value++;
|
|
127
|
+
}, { immediate: !0, deep: !0 }), ve(() => o.visible, () => {
|
|
128
|
+
o.visible && z();
|
|
129
|
+
}, { immediate: !0 }), (d, $) => {
|
|
130
|
+
const I = R("KMultiselect"), G = R("KAlert"), le = R("KPrompt");
|
|
131
|
+
return E(), W(le, {
|
|
132
|
+
"action-button-disabled": F.value,
|
|
133
|
+
class: "kong-ui-entities-add-consumers-modal",
|
|
134
|
+
"data-testid": "add-consumer-modal",
|
|
135
|
+
title: t(r)("consumers.consumer_groups.add.title"),
|
|
136
|
+
visible: e.visible,
|
|
137
|
+
onCancel: ee,
|
|
138
|
+
onProceed: l
|
|
139
|
+
}, {
|
|
140
|
+
default: a(() => [
|
|
141
|
+
b("div", _t, [
|
|
142
|
+
b("p", Ct, p(t(r)("consumers.consumer_groups.add.ctaText")), 1),
|
|
143
|
+
i(I, {
|
|
144
|
+
modelValue: _.value,
|
|
145
|
+
"onUpdate:modelValue": $[0] || ($[0] = (P) => _.value = P),
|
|
146
|
+
autosuggest: "",
|
|
147
|
+
"data-testid": "add-consumers-multiselect",
|
|
148
|
+
"dropdown-footer-text": J.value ? t(r)("consumers.consumer_groups.add.footer") : void 0,
|
|
149
|
+
items: M.value,
|
|
150
|
+
label: t(r)("consumers.consumer_groups.add.consumers_label"),
|
|
151
|
+
loading: t(A),
|
|
152
|
+
placeholder: t(r)("consumers.consumer_groups.add.consumer_placeholder"),
|
|
153
|
+
readonly: F.value,
|
|
154
|
+
required: "",
|
|
155
|
+
width: "100%",
|
|
156
|
+
onQueryChange: t(w)
|
|
157
|
+
}, {
|
|
158
|
+
"item-template": a(({ item: P }) => [
|
|
159
|
+
b("div", kt, p(P.label), 1),
|
|
160
|
+
U(P).data.username && U(P).data.custom_id ? (E(), O("div", It, p(U(P).data.custom_id), 1)) : j("", !0)
|
|
161
|
+
]),
|
|
162
|
+
_: 1
|
|
163
|
+
}, 8, ["modelValue", "dropdown-footer-text", "items", "label", "loading", "placeholder", "readonly", "onQueryChange"]),
|
|
164
|
+
g.value || H.value || x.value.length ? (E(), O("div", wt, [
|
|
165
|
+
i(G, { appearance: "danger" }, {
|
|
166
|
+
default: a(() => [
|
|
167
|
+
b("p", null, p(t(r)("consumers.errors.add")), 1),
|
|
168
|
+
x.value.length ? (E(), O("ul", $t, [
|
|
169
|
+
(E(!0), O(Qe, null, We(x.value, (P, ce) => (E(), O("li", { key: ce }, p(P), 1))), 128))
|
|
170
|
+
])) : j("", !0),
|
|
171
|
+
b("div", null, p(g.value || H.value), 1)
|
|
172
|
+
]),
|
|
173
|
+
_: 1
|
|
174
|
+
})
|
|
175
|
+
])) : j("", !0)
|
|
176
|
+
])
|
|
177
|
+
]),
|
|
178
|
+
_: 1
|
|
179
|
+
}, 8, ["action-button-disabled", "title", "visible"]);
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}), he = (e, c) => {
|
|
183
|
+
const r = e.__vccOpts || e;
|
|
184
|
+
for (const [o, S] of c)
|
|
185
|
+
r[o] = S;
|
|
186
|
+
return r;
|
|
187
|
+
}, St = /* @__PURE__ */ he(Et, [["__scopeId", "data-v-ee085540"]]), Mt = { class: "kong-ui-entities-consumers-list" }, Gt = { class: "button-row" }, xt = { class: "empty-state-wrapper" }, At = /* @__PURE__ */ ae({
|
|
188
|
+
__name: "ConsumerList",
|
|
189
|
+
props: {
|
|
190
|
+
/** The base konnect or kongManger config. Pass additional config props in the shared entity component as needed. */
|
|
191
|
+
config: {
|
|
192
|
+
type: Object,
|
|
193
|
+
required: !0,
|
|
194
|
+
validator: (e) => !(!e || !["konnect", "kongManager"].includes(e?.app) || !e.createRoute || !e.getViewRoute || !e.getEditRoute || e.app === "kongManager" && !e.isExactMatch && !e.filterSchema)
|
|
195
|
+
},
|
|
196
|
+
// used to override the default identifier for the cache entry
|
|
197
|
+
cacheIdentifier: {
|
|
198
|
+
type: String,
|
|
199
|
+
default: ""
|
|
200
|
+
},
|
|
201
|
+
/** A synchronous or asynchronous function, that returns a boolean, that evaluates if the user can create a new entity */
|
|
202
|
+
canCreate: {
|
|
203
|
+
type: Function,
|
|
204
|
+
required: !1,
|
|
205
|
+
default: async () => !0
|
|
206
|
+
},
|
|
207
|
+
/** A synchronous or asynchronous function, that returns a boolean, that evaluates if the user can delete a given entity */
|
|
208
|
+
canDelete: {
|
|
209
|
+
type: Function,
|
|
210
|
+
required: !1,
|
|
211
|
+
default: async () => !0
|
|
212
|
+
},
|
|
213
|
+
/** A synchronous or asynchronous function, that returns a boolean, that evaluates if the user can edit a given entity */
|
|
214
|
+
canEdit: {
|
|
215
|
+
type: Function,
|
|
216
|
+
required: !1,
|
|
217
|
+
default: async () => !0
|
|
218
|
+
},
|
|
219
|
+
/** A synchronous or asynchronous function, that returns a boolean, that evaluates if the user can retrieve (view details) a given entity */
|
|
220
|
+
canRetrieve: {
|
|
221
|
+
type: Function,
|
|
222
|
+
required: !1,
|
|
223
|
+
default: async () => !0
|
|
224
|
+
},
|
|
225
|
+
/** default to false, setting to true will teleport the toolbar button to the destination in the consuming app */
|
|
226
|
+
useActionOutside: {
|
|
227
|
+
type: Boolean,
|
|
228
|
+
default: !1
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
emits: ["error", "click:learn-more", "copy:success", "copy:error", "delete:success", "add:success", "remove:success"],
|
|
232
|
+
setup(e, { emit: c }) {
|
|
233
|
+
const r = c, o = e, { i18nT: S, i18n: { t: n } } = ie.useI18n(), _ = Fe(), { axiosInstance: w } = ye(o.config?.axiosRequestConfig), A = h(() => o.config.app !== "kongManager" || !!o.config.disableSorting), T = {
|
|
234
|
+
// the Username column is non-hidable
|
|
235
|
+
username: { label: n("consumers.list.table_headers.username"), searchable: !0, sortable: !0, hidable: !1 },
|
|
236
|
+
custom_id: { label: n("consumers.list.table_headers.custom_id"), searchable: !0, sortable: !0 },
|
|
237
|
+
tags: { label: n("consumers.list.table_headers.tags"), sortable: !1 }
|
|
238
|
+
}, { defaultTablePreferences: u, tableHeaders: z } = ot(T), Y = (s) => ({
|
|
239
|
+
"data-testid": s.username ?? s.custom_id ?? s.id
|
|
240
|
+
}), U = () => {
|
|
241
|
+
o.config.consumerGroupId ? _e() : _.push(o.config.createRoute);
|
|
242
|
+
}, H = (s) => {
|
|
243
|
+
let f = `${o.config.apiBaseUrl}${s}`;
|
|
244
|
+
return o.config.app === "konnect" && (f = f.replace(/{controlPlaneId}/gi, o.config?.controlPlaneId || "")), f.replace(/\/{workspace}/gi, o.config?.workspace ? `/${o.config.workspace}` : "").replace(/{consumerGroupId}/gi, o.config?.consumerGroupId || "");
|
|
245
|
+
}, X = h(() => H(
|
|
246
|
+
L.list[o.config.app][g.value ? "forConsumerGroup" : "all"]
|
|
247
|
+
)), J = h(() => o.config.app === "konnect" && o.config.workspace && M.value ? H(L.list.konnect.search) : X.value), M = y(""), q = h(() => {
|
|
248
|
+
const s = o.config.app === "konnect" || o.config.isExactMatch;
|
|
249
|
+
return s ? {
|
|
250
|
+
isExactMatch: s,
|
|
251
|
+
placeholder: n(`consumers.search.placeholder.${o.config.app}`)
|
|
252
|
+
} : {
|
|
253
|
+
isExactMatch: s,
|
|
254
|
+
fields: {
|
|
255
|
+
username: T.username,
|
|
256
|
+
custom_id: T.custom_id
|
|
257
|
+
},
|
|
258
|
+
schema: o.config.filterSchema
|
|
259
|
+
};
|
|
260
|
+
}), { hasRecords: ee, handleStateChange: D } = st(M), F = h(() => ee.value && o.config.app === "konnect"), g = h(() => !!o.config.consumerGroupId), l = h(
|
|
261
|
+
() => g.value ? "kong-ui-entities-consumers-list-in-group-page" : "kong-ui-entities-consumers-list"
|
|
262
|
+
), v = h(() => g.value && !o.config.paginatedEndpoint ? "consumers" : void 0), {
|
|
263
|
+
fetcher: Q,
|
|
264
|
+
fetcherState: x,
|
|
265
|
+
fetcherCacheKey: C
|
|
266
|
+
} = nt(h(() => ({ ...o.config, cacheIdentifier: o.cacheIdentifier })), J, v), d = () => {
|
|
267
|
+
M.value = "";
|
|
268
|
+
}, $ = () => {
|
|
269
|
+
C.value++;
|
|
270
|
+
}, I = (s) => s ?? "-", G = y(null), le = async (s, f) => {
|
|
271
|
+
const V = s.id;
|
|
272
|
+
if (!await f(V)) {
|
|
273
|
+
r("copy:error", {
|
|
274
|
+
entity: s,
|
|
275
|
+
field: "id",
|
|
276
|
+
message: n("consumers.errors.copy")
|
|
277
|
+
});
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
r("copy:success", {
|
|
281
|
+
entity: s,
|
|
282
|
+
field: "id",
|
|
283
|
+
message: n("consumers.copy.success", { val: V })
|
|
284
|
+
});
|
|
285
|
+
}, P = (s, f) => {
|
|
286
|
+
const V = JSON.stringify(s);
|
|
287
|
+
if (!f(V)) {
|
|
288
|
+
r("copy:error", {
|
|
289
|
+
entity: s,
|
|
290
|
+
message: n("consumers.errors.copy")
|
|
291
|
+
});
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
r("copy:success", {
|
|
295
|
+
entity: s,
|
|
296
|
+
message: n("consumers.copy.success_brief")
|
|
297
|
+
});
|
|
298
|
+
}, ce = async (s) => {
|
|
299
|
+
await o.canRetrieve?.(s) && _.push(o.config.getViewRoute(s.id));
|
|
300
|
+
}, Pe = (s) => ({
|
|
301
|
+
label: n("consumers.actions.view"),
|
|
302
|
+
to: o.config.getViewRoute(s)
|
|
303
|
+
}), Re = (s) => ({
|
|
304
|
+
label: n("consumers.actions.edit"),
|
|
305
|
+
to: o.config.getEditRoute(s)
|
|
306
|
+
}), N = y(void 0), se = y(!1), ne = y(!1), be = y(""), Te = rt(o.config, X.value), Be = (s) => {
|
|
307
|
+
N.value = s, se.value = !0;
|
|
308
|
+
}, Ve = () => {
|
|
309
|
+
se.value = !1;
|
|
310
|
+
}, Ke = async () => {
|
|
311
|
+
if (N.value?.id) {
|
|
312
|
+
ne.value = !0;
|
|
313
|
+
try {
|
|
314
|
+
await w.delete(Te(N.value.id)), ne.value = !1, se.value = !1, C.value++, r("delete:success", N.value);
|
|
315
|
+
} catch (s) {
|
|
316
|
+
be.value = s.response?.data?.message || s.message || n("consumers.errors.delete"), r("error", s);
|
|
317
|
+
} finally {
|
|
318
|
+
ne.value = !1;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}, ue = y(!1), _e = () => {
|
|
322
|
+
ue.value = !0;
|
|
323
|
+
}, Ce = () => {
|
|
324
|
+
ue.value = !1;
|
|
325
|
+
}, ke = (s, f) => {
|
|
326
|
+
f || Ce(), C.value++, r("add:success", s);
|
|
327
|
+
}, Ue = () => {
|
|
328
|
+
g.value && _e();
|
|
329
|
+
}, B = y(void 0), de = y(!1), qe = y(""), Ne = (s) => {
|
|
330
|
+
B.value = s, de.value = !0;
|
|
331
|
+
}, Ie = () => {
|
|
332
|
+
de.value = !1, B.value = void 0;
|
|
333
|
+
}, Oe = h(() => {
|
|
334
|
+
let s = `${o.config.apiBaseUrl}${L.list[o.config.app].oneForConsumerGroup}`;
|
|
335
|
+
return o.config.app === "konnect" && (s = s.replace(/{controlPlaneId}/gi, o.config?.controlPlaneId || "")), s.replace(/\/{workspace}/gi, o.config?.workspace ? `/${o.config.workspace}` : "").replace(/{consumerGroupId}/gi, o.config?.consumerGroupId || "");
|
|
336
|
+
}), we = y(!1), je = async () => {
|
|
337
|
+
if (B.value) {
|
|
338
|
+
we.value = !0;
|
|
339
|
+
try {
|
|
340
|
+
const s = Oe.value.replace(/{consumerId}/gi, B.value.id);
|
|
341
|
+
await w.delete(s), r("remove:success", B.value), Ie(), C.value++;
|
|
342
|
+
} catch (s) {
|
|
343
|
+
qe.value = s.message || n("consumers.errors.delete"), r("error", s);
|
|
344
|
+
} finally {
|
|
345
|
+
we.value = !1;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
ve(x, (s) => {
|
|
350
|
+
if (s.status === at.Error) {
|
|
351
|
+
G.value = {
|
|
352
|
+
title: n("consumers.errors.general")
|
|
353
|
+
}, s.error?.response?.data?.message && (G.value.message = s.error.response.data.message), r("error", s.error);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
G.value = null;
|
|
357
|
+
});
|
|
358
|
+
const me = y({
|
|
359
|
+
ctaPath: g.value ? void 0 : o.config.createRoute,
|
|
360
|
+
ctaText: void 0,
|
|
361
|
+
message: `${n("consumers.list.empty_state.description")}${o.config.additionMessageForEmptyState ? ` ${o.config.additionMessageForEmptyState}` : ""}`,
|
|
362
|
+
title: n("consumers.title")
|
|
363
|
+
}), pe = y(!1);
|
|
364
|
+
return ze(async () => {
|
|
365
|
+
pe.value = await o.canCreate(), pe.value && (me.value.title = g.value ? n("consumers.list.empty_state.title_for_consumer_group") : n("consumers.list.empty_state.title"), me.value.ctaText = g.value ? n("consumers.actions.add_consumer") : n("consumers.actions.create"));
|
|
366
|
+
}), (s, f) => {
|
|
367
|
+
const V = R("KButton"), Le = R("KEmptyState"), te = R("KDropdownItem"), $e = R("KClipboardProvider"), He = R("KPrompt");
|
|
368
|
+
return E(), O("div", Mt, [
|
|
369
|
+
i(t(it), {
|
|
370
|
+
"cache-identifier": e.cacheIdentifier,
|
|
371
|
+
"default-table-preferences": t(u),
|
|
372
|
+
"disable-sorting": A.value,
|
|
373
|
+
"empty-state-options": me.value,
|
|
374
|
+
"enable-entity-actions": "",
|
|
375
|
+
"error-message": G.value,
|
|
376
|
+
fetcher: t(Q),
|
|
377
|
+
"fetcher-cache-key": t(C),
|
|
378
|
+
"hide-pagination": g.value && !e.config.paginatedEndpoint,
|
|
379
|
+
"pagination-type": "offset",
|
|
380
|
+
"preferences-storage-key": l.value,
|
|
381
|
+
query: M.value,
|
|
382
|
+
"row-attributes": Y,
|
|
383
|
+
"table-headers": t(z),
|
|
384
|
+
onClearSearchInput: d,
|
|
385
|
+
"onClick:row": f[3] || (f[3] = (m) => ce(m)),
|
|
386
|
+
onEmptyStateCtaClicked: Ue,
|
|
387
|
+
onSort: $,
|
|
388
|
+
onState: t(D)
|
|
389
|
+
}, ge({
|
|
390
|
+
"toolbar-filter": a(() => [
|
|
391
|
+
Ee(s.$slots, "toolbar-filter", {}, void 0, !0),
|
|
392
|
+
g.value ? j("", !0) : (E(), W(t(ut), {
|
|
393
|
+
key: 0,
|
|
394
|
+
modelValue: M.value,
|
|
395
|
+
"onUpdate:modelValue": f[0] || (f[0] = (m) => M.value = m),
|
|
396
|
+
config: q.value
|
|
397
|
+
}, null, 8, ["modelValue", "config"]))
|
|
398
|
+
]),
|
|
399
|
+
"toolbar-button": a(() => [
|
|
400
|
+
(E(), W(Ye, {
|
|
401
|
+
disabled: !e.useActionOutside,
|
|
402
|
+
to: "#kong-ui-app-page-header-action-button"
|
|
403
|
+
}, [
|
|
404
|
+
b("div", Gt, [
|
|
405
|
+
!g.value && F.value ? (E(), W(V, {
|
|
406
|
+
key: 0,
|
|
407
|
+
appearance: "secondary",
|
|
408
|
+
class: "open-learning-hub",
|
|
409
|
+
"data-testid": "consumers-learn-more-button",
|
|
410
|
+
icon: "",
|
|
411
|
+
onClick: f[1] || (f[1] = (m) => s.$emit("click:learn-more"))
|
|
412
|
+
}, {
|
|
413
|
+
default: a(() => [
|
|
414
|
+
i(t(Me), { decorative: "" })
|
|
415
|
+
]),
|
|
416
|
+
_: 1
|
|
417
|
+
})) : j("", !0),
|
|
418
|
+
i(t(re), {
|
|
419
|
+
"auth-function": () => e.canCreate()
|
|
420
|
+
}, {
|
|
421
|
+
default: a(() => [
|
|
422
|
+
i(V, {
|
|
423
|
+
appearance: "primary",
|
|
424
|
+
"data-testid": "toolbar-add-consumer",
|
|
425
|
+
size: e.useActionOutside ? "medium" : "large",
|
|
426
|
+
onClick: U
|
|
427
|
+
}, {
|
|
428
|
+
default: a(() => [
|
|
429
|
+
i(t(Ge)),
|
|
430
|
+
K(" " + p(e.config.consumerGroupId ? t(n)("consumers.actions.add_consumer") : t(n)("consumers.list.toolbar_actions.new_consumer")), 1)
|
|
431
|
+
]),
|
|
432
|
+
_: 1
|
|
433
|
+
}, 8, ["size"])
|
|
434
|
+
]),
|
|
435
|
+
_: 1
|
|
436
|
+
}, 8, ["auth-function"])
|
|
437
|
+
])
|
|
438
|
+
], 8, ["disabled"]))
|
|
439
|
+
]),
|
|
440
|
+
username: a(({ rowValue: m }) => [
|
|
441
|
+
b("b", null, p(I(m)), 1)
|
|
442
|
+
]),
|
|
443
|
+
custom_id: a(({ rowValue: m }) => [
|
|
444
|
+
K(p(I(m)), 1)
|
|
445
|
+
]),
|
|
446
|
+
tags: a(({ rowValue: m }) => [
|
|
447
|
+
i(t(ct), { tags: m }, null, 8, ["tags"])
|
|
448
|
+
]),
|
|
449
|
+
managed_by: a(({ rowValue: m }) => [
|
|
450
|
+
K(p(t(lt)(m) ?? "-"), 1)
|
|
451
|
+
]),
|
|
452
|
+
actions: a(({ row: m }) => [
|
|
453
|
+
i($e, null, {
|
|
454
|
+
default: a(({ copyToClipboard: fe }) => [
|
|
455
|
+
i(te, {
|
|
456
|
+
"data-testid": "action-entity-copy-id",
|
|
457
|
+
onClick: (Je) => le(m, fe)
|
|
458
|
+
}, {
|
|
459
|
+
default: a(() => [
|
|
460
|
+
K(p(t(n)("consumers.actions.copy_id")), 1)
|
|
461
|
+
]),
|
|
462
|
+
_: 1
|
|
463
|
+
}, 8, ["onClick"])
|
|
464
|
+
]),
|
|
465
|
+
_: 2
|
|
466
|
+
}, 1024),
|
|
467
|
+
i($e, null, {
|
|
468
|
+
default: a(({ copyToClipboard: fe }) => [
|
|
469
|
+
i(te, {
|
|
470
|
+
"data-testid": "action-entity-copy-json",
|
|
471
|
+
onClick: (Je) => P(m, fe)
|
|
472
|
+
}, {
|
|
473
|
+
default: a(() => [
|
|
474
|
+
K(p(t(n)("consumers.actions.copy_json")), 1)
|
|
475
|
+
]),
|
|
476
|
+
_: 1
|
|
477
|
+
}, 8, ["onClick"])
|
|
478
|
+
]),
|
|
479
|
+
_: 2
|
|
480
|
+
}, 1024),
|
|
481
|
+
i(t(re), {
|
|
482
|
+
"auth-function": () => e.canRetrieve(m)
|
|
483
|
+
}, {
|
|
484
|
+
default: a(() => [
|
|
485
|
+
i(te, {
|
|
486
|
+
"data-testid": "action-entity-view",
|
|
487
|
+
"has-divider": "",
|
|
488
|
+
item: Pe(m.id)
|
|
489
|
+
}, null, 8, ["item"])
|
|
490
|
+
]),
|
|
491
|
+
_: 2
|
|
492
|
+
}, 1032, ["auth-function"]),
|
|
493
|
+
i(t(re), {
|
|
494
|
+
"auth-function": () => e.canEdit(m)
|
|
495
|
+
}, {
|
|
496
|
+
default: a(() => [
|
|
497
|
+
i(te, {
|
|
498
|
+
"data-testid": "action-entity-edit",
|
|
499
|
+
item: Re(m.id)
|
|
500
|
+
}, null, 8, ["item"])
|
|
501
|
+
]),
|
|
502
|
+
_: 2
|
|
503
|
+
}, 1032, ["auth-function"]),
|
|
504
|
+
i(t(re), {
|
|
505
|
+
"auth-function": () => e.canDelete(m)
|
|
506
|
+
}, {
|
|
507
|
+
default: a(() => [
|
|
508
|
+
i(te, {
|
|
509
|
+
danger: "",
|
|
510
|
+
"data-testid": "action-entity-delete",
|
|
511
|
+
"has-divider": "",
|
|
512
|
+
onClick: () => e.config.consumerGroupId ? Ne(m) : Be(m)
|
|
513
|
+
}, {
|
|
514
|
+
default: a(() => [
|
|
515
|
+
K(p(e.config.consumerGroupId ? t(n)("consumers.actions.remove") : t(n)("consumers.actions.delete")), 1)
|
|
516
|
+
]),
|
|
517
|
+
_: 1
|
|
518
|
+
}, 8, ["onClick"])
|
|
519
|
+
]),
|
|
520
|
+
_: 2
|
|
521
|
+
}, 1032, ["auth-function"])
|
|
522
|
+
]),
|
|
523
|
+
_: 2
|
|
524
|
+
}, [
|
|
525
|
+
!M.value && e.config.app === "konnect" ? {
|
|
526
|
+
name: "empty-state",
|
|
527
|
+
fn: a(() => [
|
|
528
|
+
b("div", xt, [
|
|
529
|
+
Ee(s.$slots, "empty-state-toolbar", {}, void 0, !0),
|
|
530
|
+
i(Le, {
|
|
531
|
+
"data-testid": e.config.consumerGroupId ? "nested-consumers-entity-empty-state" : "consumers-entity-empty-state",
|
|
532
|
+
"icon-background": "",
|
|
533
|
+
message: t(n)("consumers.list.empty_state_v2.description"),
|
|
534
|
+
title: t(n)("consumers.list.empty_state_v2.title")
|
|
535
|
+
}, ge({
|
|
536
|
+
icon: a(() => [
|
|
537
|
+
i(t(Xe), { decorative: "" })
|
|
538
|
+
]),
|
|
539
|
+
action: a(() => [
|
|
540
|
+
pe.value ? (E(), W(V, {
|
|
541
|
+
key: 0,
|
|
542
|
+
"data-testid": "entity-create-button",
|
|
543
|
+
onClick: U
|
|
544
|
+
}, {
|
|
545
|
+
default: a(() => [
|
|
546
|
+
i(t(Ge), { decorative: "" }),
|
|
547
|
+
K(" " + p(t(n)("consumers.list.toolbar_actions.new_consumer")), 1)
|
|
548
|
+
]),
|
|
549
|
+
_: 1
|
|
550
|
+
})) : j("", !0),
|
|
551
|
+
i(V, {
|
|
552
|
+
appearance: "secondary",
|
|
553
|
+
"data-testid": "entity-learn-more-button",
|
|
554
|
+
onClick: f[2] || (f[2] = (m) => s.$emit("click:learn-more"))
|
|
555
|
+
}, {
|
|
556
|
+
default: a(() => [
|
|
557
|
+
i(t(Me), { decorative: "" }),
|
|
558
|
+
K(" " + p(t(n)("consumers.list.empty_state_v2.learn_more")), 1)
|
|
559
|
+
]),
|
|
560
|
+
_: 1
|
|
561
|
+
})
|
|
562
|
+
]),
|
|
563
|
+
_: 2
|
|
564
|
+
}, [
|
|
565
|
+
e.config?.isControlPlaneGroup ? {
|
|
566
|
+
name: "default",
|
|
567
|
+
fn: a(() => [
|
|
568
|
+
K(p(t(n)("consumers.list.empty_state_v2.group")), 1)
|
|
569
|
+
]),
|
|
570
|
+
key: "0"
|
|
571
|
+
} : void 0
|
|
572
|
+
]), 1032, ["data-testid", "message", "title"])
|
|
573
|
+
])
|
|
574
|
+
]),
|
|
575
|
+
key: "0"
|
|
576
|
+
} : void 0
|
|
577
|
+
]), 1032, ["cache-identifier", "default-table-preferences", "disable-sorting", "empty-state-options", "error-message", "fetcher", "fetcher-cache-key", "hide-pagination", "preferences-storage-key", "query", "table-headers", "onState"]),
|
|
578
|
+
i(t(dt), {
|
|
579
|
+
"action-button-disabled": ne.value,
|
|
580
|
+
"data-testid": "delete-consumer-modal",
|
|
581
|
+
description: t(n)("consumers.delete.description"),
|
|
582
|
+
"entity-name": N.value && (N.value.username || N.value.custom_id || N.value.id),
|
|
583
|
+
"entity-type": t(mt).Consumer,
|
|
584
|
+
error: be.value,
|
|
585
|
+
title: t(n)("consumers.delete.title"),
|
|
586
|
+
visible: se.value,
|
|
587
|
+
onCancel: Ve,
|
|
588
|
+
onProceed: Ke
|
|
589
|
+
}, null, 8, ["action-button-disabled", "description", "entity-name", "entity-type", "error", "title", "visible"]),
|
|
590
|
+
e.config.consumerGroupId ? (E(), W(St, {
|
|
591
|
+
key: 0,
|
|
592
|
+
config: e.config,
|
|
593
|
+
"data-testid": "add-consumer-modal",
|
|
594
|
+
visible: ue.value,
|
|
595
|
+
"onAdd:partialSuccess": f[4] || (f[4] = (m) => ke(m, !0)),
|
|
596
|
+
"onAdd:success": f[5] || (f[5] = (m) => ke(m)),
|
|
597
|
+
onCancel: Ce
|
|
598
|
+
}, null, 8, ["config", "visible"])) : j("", !0),
|
|
599
|
+
e.config.consumerGroupId && B.value ? (E(), W(He, {
|
|
600
|
+
key: 1,
|
|
601
|
+
"action-button-appearance": "danger",
|
|
602
|
+
"data-testid": "remove-consumer-modal",
|
|
603
|
+
title: t(n)("consumers.consumer_groups.remove.title"),
|
|
604
|
+
visible: de.value,
|
|
605
|
+
onCancel: Ie,
|
|
606
|
+
onProceed: je
|
|
607
|
+
}, {
|
|
608
|
+
default: a(() => [
|
|
609
|
+
i(t(S), {
|
|
610
|
+
class: "message",
|
|
611
|
+
keypath: e.config.consumerGroupName ? "consumers.consumer_groups.remove.confirmation" : "consumers.consumer_groups.remove.confirmationNoCG",
|
|
612
|
+
tag: "p"
|
|
613
|
+
}, ge({
|
|
614
|
+
consumer: a(() => [
|
|
615
|
+
b("strong", null, p(B.value.username || B.value.custom_id || B.value.id), 1)
|
|
616
|
+
]),
|
|
617
|
+
_: 2
|
|
618
|
+
}, [
|
|
619
|
+
e.config.consumerGroupName ? {
|
|
620
|
+
name: "consumerGroup",
|
|
621
|
+
fn: a(() => [
|
|
622
|
+
b("strong", null, p(e.config.consumerGroupName), 1)
|
|
623
|
+
]),
|
|
624
|
+
key: "0"
|
|
625
|
+
} : void 0
|
|
626
|
+
]), 1032, ["keypath"]),
|
|
627
|
+
b("p", null, p(t(n)("consumers.consumer_groups.remove.description")), 1)
|
|
628
|
+
]),
|
|
629
|
+
_: 1
|
|
630
|
+
}, 8, ["title", "visible"])) : j("", !0)
|
|
631
|
+
]);
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
}), Qt = /* @__PURE__ */ he(At, [["__scopeId", "data-v-20e920ea"]]), k = [];
|
|
635
|
+
for (let e = 0; e < 256; ++e)
|
|
636
|
+
k.push((e + 256).toString(16).slice(1));
|
|
637
|
+
function Ft(e, c = 0) {
|
|
638
|
+
return (k[e[c + 0]] + k[e[c + 1]] + k[e[c + 2]] + k[e[c + 3]] + "-" + k[e[c + 4]] + k[e[c + 5]] + "-" + k[e[c + 6]] + k[e[c + 7]] + "-" + k[e[c + 8]] + k[e[c + 9]] + "-" + k[e[c + 10]] + k[e[c + 11]] + k[e[c + 12]] + k[e[c + 13]] + k[e[c + 14]] + k[e[c + 15]]).toLowerCase();
|
|
639
|
+
}
|
|
640
|
+
const Dt = new Uint8Array(16);
|
|
641
|
+
function Pt() {
|
|
642
|
+
return crypto.getRandomValues(Dt);
|
|
643
|
+
}
|
|
644
|
+
function Rt(e, c, r) {
|
|
645
|
+
return crypto.randomUUID ? crypto.randomUUID() : Tt(e);
|
|
646
|
+
}
|
|
647
|
+
function Tt(e, c, r) {
|
|
648
|
+
e = e || {};
|
|
649
|
+
const o = e.random ?? e.rng?.() ?? Pt();
|
|
650
|
+
if (o.length < 16)
|
|
651
|
+
throw new Error("Random bytes length must be >= 16");
|
|
652
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Ft(o);
|
|
653
|
+
}
|
|
654
|
+
const Bt = { class: "kong-ui-entities-consumer-form" }, Vt = ["id"], Kt = { class: "fields-group-text" }, Ut = ["aria-labelledby"], qt = /* @__PURE__ */ ae({
|
|
655
|
+
__name: "ConsumerForm",
|
|
656
|
+
props: {
|
|
657
|
+
/** The base konnect or kongManger config. Pass additional config props in the shared entity component as needed. */
|
|
658
|
+
config: {
|
|
659
|
+
type: Object,
|
|
660
|
+
required: !0,
|
|
661
|
+
validator: (e) => !(!e || !["konnect", "kongManager"].includes(e?.app) || e?.app === "konnect" && !e?.controlPlaneId || e?.app === "kongManager" && typeof e?.workspace != "string" || !e?.cancelRoute)
|
|
662
|
+
},
|
|
663
|
+
/** If a valid consumerId is provided, it will put the form in Edit mode instead of Create */
|
|
664
|
+
consumerId: {
|
|
665
|
+
type: String,
|
|
666
|
+
required: !1,
|
|
667
|
+
default: null
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
emits: ["update", "error", "loading"],
|
|
671
|
+
setup(e, { emit: c }) {
|
|
672
|
+
const r = e, o = c, { i18nT: S, i18n: { t: n } } = ie.useI18n(), _ = Fe(), { axiosInstance: w } = ye(r.config?.axiosRequestConfig), { getMessageFromError: A } = pt(), T = Rt(), u = Se({
|
|
673
|
+
fields: {
|
|
674
|
+
username: "",
|
|
675
|
+
customId: "",
|
|
676
|
+
tags: ""
|
|
677
|
+
},
|
|
678
|
+
readonly: !1,
|
|
679
|
+
errorMessage: ""
|
|
680
|
+
}), z = Se({
|
|
681
|
+
username: "",
|
|
682
|
+
customId: "",
|
|
683
|
+
tags: ""
|
|
684
|
+
}), Y = h(() => L.form[r.config?.app]?.edit), U = () => {
|
|
685
|
+
_.push(r.config?.cancelRoute || { name: "consumer-list" });
|
|
686
|
+
}, H = (l) => {
|
|
687
|
+
o("loading", l);
|
|
688
|
+
}, X = (l) => {
|
|
689
|
+
o("error", l);
|
|
690
|
+
}, J = (l) => {
|
|
691
|
+
u.fields.username = l?.item?.username || l?.username || "", u.fields.customId = l?.item?.custom_id || l?.custom_id || "";
|
|
692
|
+
const v = l?.item?.tags || l?.tags || [];
|
|
693
|
+
u.fields.tags = v?.join(", ") || "", Object.assign(z, u.fields);
|
|
694
|
+
}, M = h(() => r.consumerId ? xe.Edit : xe.Create), q = (l) => {
|
|
695
|
+
let v = `${r.config?.apiBaseUrl}${L.form[r.config?.app][l]}`;
|
|
696
|
+
return r.config?.app === "konnect" && (v = v.replace(/{controlPlaneId}/gi, r.config?.controlPlaneId || "")), v.replace(/\/{workspace}/gi, r.config?.workspace ? `/${r.config.workspace}` : "").replace(/{id}/gi, r.consumerId ?? "");
|
|
697
|
+
}, ee = h(() => !!u.fields.username || !!u.fields.customId), D = h(() => JSON.stringify(u.fields) !== JSON.stringify(z)), F = h(() => ({
|
|
698
|
+
username: u.fields.username || null,
|
|
699
|
+
custom_id: u.fields.customId || null,
|
|
700
|
+
tags: u.fields.tags.split(",")?.map((l) => String(l || "").trim())?.filter((l) => l !== "")
|
|
701
|
+
})), g = async () => {
|
|
702
|
+
try {
|
|
703
|
+
u.readonly = !0;
|
|
704
|
+
let l;
|
|
705
|
+
M.value === "create" ? l = await w.post(q("create"), F.value) : M.value === "edit" && (l = r.config?.app === "konnect" ? await w.put(q("edit"), F.value) : await w.patch(q("edit"), F.value)), J(l?.data), o("update", l?.data);
|
|
706
|
+
} catch (l) {
|
|
707
|
+
u.errorMessage = A(l), o("error", l);
|
|
708
|
+
} finally {
|
|
709
|
+
u.readonly = !1;
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
return (l, v) => {
|
|
713
|
+
const Q = R("KInput"), x = R("KCard");
|
|
714
|
+
return E(), O("div", Bt, [
|
|
715
|
+
i(t(ft), {
|
|
716
|
+
"can-submit": ee.value && D.value,
|
|
717
|
+
config: e.config,
|
|
718
|
+
"edit-id": e.consumerId,
|
|
719
|
+
"entity-type": t(De).Consumer,
|
|
720
|
+
"error-message": u.errorMessage,
|
|
721
|
+
"fetch-url": Y.value,
|
|
722
|
+
"form-fields": F.value,
|
|
723
|
+
"is-readonly": u.readonly,
|
|
724
|
+
onCancel: U,
|
|
725
|
+
"onFetch:error": v[3] || (v[3] = (C) => X(C)),
|
|
726
|
+
"onFetch:success": J,
|
|
727
|
+
onLoading: v[4] || (v[4] = (C) => H(C)),
|
|
728
|
+
onSubmit: g
|
|
729
|
+
}, {
|
|
730
|
+
default: a(() => [
|
|
731
|
+
b("div", null, [
|
|
732
|
+
i(t(gt), {
|
|
733
|
+
description: t(n)("consumers.form.info.description"),
|
|
734
|
+
"has-divider": "",
|
|
735
|
+
title: t(n)("consumers.form.info.title")
|
|
736
|
+
}, {
|
|
737
|
+
default: a(() => [
|
|
738
|
+
b("div", null, [
|
|
739
|
+
b("h3", {
|
|
740
|
+
id: `fields-group-title-${t(T)}`,
|
|
741
|
+
class: "fields-group-title"
|
|
742
|
+
}, p(t(n)("consumers.form.consumer_identification.title")) + "* ", 9, Vt),
|
|
743
|
+
b("p", Kt, p(t(n)("consumers.form.consumer_identification.description")), 1)
|
|
744
|
+
]),
|
|
745
|
+
i(x, null, {
|
|
746
|
+
default: a(() => [
|
|
747
|
+
b("fieldset", {
|
|
748
|
+
"aria-labelledby": `fields-group-title-${t(T)}`
|
|
749
|
+
}, [
|
|
750
|
+
i(Q, {
|
|
751
|
+
modelValue: u.fields.username,
|
|
752
|
+
"onUpdate:modelValue": v[0] || (v[0] = (C) => u.fields.username = C),
|
|
753
|
+
modelModifiers: { trim: !0 },
|
|
754
|
+
autocomplete: "off",
|
|
755
|
+
class: "username-field",
|
|
756
|
+
"data-testid": "consumer-form-username",
|
|
757
|
+
label: t(n)("consumers.fields.username.label"),
|
|
758
|
+
"label-attributes": { tooltipAttributes: { maxWidth: "400" } },
|
|
759
|
+
placeholder: t(n)("consumers.fields.username.placeholder"),
|
|
760
|
+
readonly: u.readonly,
|
|
761
|
+
type: "text"
|
|
762
|
+
}, {
|
|
763
|
+
"label-tooltip": a(() => [
|
|
764
|
+
i(t(S), {
|
|
765
|
+
keypath: "consumers.fields.username.tooltip",
|
|
766
|
+
scope: "global"
|
|
767
|
+
}, {
|
|
768
|
+
custom_id: a(() => [
|
|
769
|
+
b("code", null, p(t(n)("consumers.fields.username.custom_id")), 1)
|
|
770
|
+
]),
|
|
771
|
+
_: 1
|
|
772
|
+
})
|
|
773
|
+
]),
|
|
774
|
+
_: 1
|
|
775
|
+
}, 8, ["modelValue", "label", "placeholder", "readonly"]),
|
|
776
|
+
i(Q, {
|
|
777
|
+
modelValue: u.fields.customId,
|
|
778
|
+
"onUpdate:modelValue": v[1] || (v[1] = (C) => u.fields.customId = C),
|
|
779
|
+
modelModifiers: { trim: !0 },
|
|
780
|
+
autocomplete: "off",
|
|
781
|
+
"data-testid": "consumer-form-custom-id",
|
|
782
|
+
label: t(n)("consumers.fields.custom_id.label"),
|
|
783
|
+
"label-attributes": { tooltipAttributes: { maxWidth: "400" } },
|
|
784
|
+
placeholder: t(n)("consumers.fields.custom_id.placeholder"),
|
|
785
|
+
readonly: u.readonly,
|
|
786
|
+
type: "text"
|
|
787
|
+
}, {
|
|
788
|
+
"label-tooltip": a(() => [
|
|
789
|
+
i(t(S), {
|
|
790
|
+
keypath: "consumers.fields.custom_id.tooltip",
|
|
791
|
+
scope: "global"
|
|
792
|
+
}, {
|
|
793
|
+
username: a(() => [
|
|
794
|
+
b("code", null, p(t(n)("consumers.fields.custom_id.username")), 1)
|
|
795
|
+
]),
|
|
796
|
+
_: 1
|
|
797
|
+
})
|
|
798
|
+
]),
|
|
799
|
+
_: 1
|
|
800
|
+
}, 8, ["modelValue", "label", "placeholder", "readonly"])
|
|
801
|
+
], 8, Ut)
|
|
802
|
+
]),
|
|
803
|
+
_: 1
|
|
804
|
+
}),
|
|
805
|
+
i(Q, {
|
|
806
|
+
modelValue: u.fields.tags,
|
|
807
|
+
"onUpdate:modelValue": v[2] || (v[2] = (C) => u.fields.tags = C),
|
|
808
|
+
modelModifiers: { trim: !0 },
|
|
809
|
+
autocomplete: "off",
|
|
810
|
+
"data-testid": "consumer-form-tags",
|
|
811
|
+
help: t(n)("consumers.fields.tags.help"),
|
|
812
|
+
label: t(n)("consumers.fields.tags.label"),
|
|
813
|
+
"label-attributes": {
|
|
814
|
+
info: t(n)("consumers.fields.tags.tooltip"),
|
|
815
|
+
tooltipAttributes: { maxWidth: "400" }
|
|
816
|
+
},
|
|
817
|
+
placeholder: t(n)("consumers.fields.tags.placeholder"),
|
|
818
|
+
readonly: u.readonly,
|
|
819
|
+
type: "text"
|
|
820
|
+
}, null, 8, ["modelValue", "help", "label", "label-attributes", "placeholder", "readonly"])
|
|
821
|
+
]),
|
|
822
|
+
_: 1
|
|
823
|
+
}, 8, ["description", "title"])
|
|
824
|
+
])
|
|
825
|
+
]),
|
|
826
|
+
_: 1
|
|
827
|
+
}, 8, ["can-submit", "config", "edit-id", "entity-type", "error-message", "fetch-url", "form-fields", "is-readonly"])
|
|
828
|
+
]);
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
}), Wt = /* @__PURE__ */ he(qt, [["__scopeId", "data-v-a0873f95"]]), Nt = { class: "kong-ui-consumer-entity-config-card" }, zt = /* @__PURE__ */ ae({
|
|
832
|
+
__name: "ConsumerConfigCard",
|
|
833
|
+
props: {
|
|
834
|
+
/** The base konnect or kongManger config. Pass additional config props in the shared entity component as needed. */
|
|
835
|
+
config: {
|
|
836
|
+
type: Object,
|
|
837
|
+
required: !0,
|
|
838
|
+
validator: (e) => !(!e || !["konnect", "kongManager"].includes(e?.app) || e.app === "konnect" && !e.controlPlaneId || e.app === "kongManager" && typeof e.workspace != "string" || !e.entityId)
|
|
839
|
+
},
|
|
840
|
+
/**
|
|
841
|
+
* External link for documentation that determines visibility of Documentation button
|
|
842
|
+
*/
|
|
843
|
+
configCardDoc: {
|
|
844
|
+
type: String,
|
|
845
|
+
default: "",
|
|
846
|
+
required: !1
|
|
847
|
+
},
|
|
848
|
+
/**
|
|
849
|
+
* Control visibility of card title content
|
|
850
|
+
*/
|
|
851
|
+
hideTitle: {
|
|
852
|
+
type: Boolean,
|
|
853
|
+
default: !1
|
|
854
|
+
}
|
|
855
|
+
},
|
|
856
|
+
emits: ["loading", "fetch:error", "fetch:success"],
|
|
857
|
+
setup(e) {
|
|
858
|
+
const c = e, { i18n: { t: r }, i18nT: o } = ie.useI18n(), S = h(() => L.form[c.config.app].edit), n = y({
|
|
859
|
+
id: {},
|
|
860
|
+
username: {
|
|
861
|
+
section: Ae.Basic,
|
|
862
|
+
tooltip: r("consumers.fields.username.tooltip"),
|
|
863
|
+
order: 1
|
|
864
|
+
},
|
|
865
|
+
custom_id: {
|
|
866
|
+
section: Ae.Basic,
|
|
867
|
+
tooltip: r("consumers.fields.custom_id.tooltip"),
|
|
868
|
+
label: r("consumers.fields.custom_id.label"),
|
|
869
|
+
order: 2
|
|
870
|
+
},
|
|
871
|
+
updated_at: {},
|
|
872
|
+
created_at: {},
|
|
873
|
+
tags: {
|
|
874
|
+
tooltip: r("consumers.fields.tags.tooltip")
|
|
875
|
+
},
|
|
876
|
+
username_lower: {
|
|
877
|
+
hidden: !0
|
|
878
|
+
},
|
|
879
|
+
type: {
|
|
880
|
+
hidden: !0
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
return (_, w) => (E(), O("div", Nt, [
|
|
884
|
+
i(t(vt), {
|
|
885
|
+
config: e.config,
|
|
886
|
+
"config-card-doc": e.configCardDoc,
|
|
887
|
+
"config-schema": n.value,
|
|
888
|
+
"entity-type": t(De).Consumer,
|
|
889
|
+
"fetch-url": S.value,
|
|
890
|
+
"hide-title": e.hideTitle,
|
|
891
|
+
"onFetch:error": w[0] || (w[0] = (A) => _.$emit("fetch:error", A)),
|
|
892
|
+
"onFetch:success": w[1] || (w[1] = (A) => _.$emit("fetch:success", A)),
|
|
893
|
+
onLoading: w[2] || (w[2] = (A) => _.$emit("loading", A))
|
|
894
|
+
}, {
|
|
895
|
+
"username-label-tooltip": a(() => [
|
|
896
|
+
i(t(o), {
|
|
897
|
+
keypath: "consumers.fields.username.tooltip",
|
|
898
|
+
scope: "global"
|
|
899
|
+
}, {
|
|
900
|
+
custom_id: a(() => [
|
|
901
|
+
b("code", null, p(t(r)("consumers.fields.username.custom_id")), 1)
|
|
902
|
+
]),
|
|
903
|
+
_: 1
|
|
904
|
+
})
|
|
905
|
+
]),
|
|
906
|
+
"custom_id-label-tooltip": a(() => [
|
|
907
|
+
i(t(o), {
|
|
908
|
+
keypath: "consumers.fields.custom_id.tooltip",
|
|
909
|
+
scope: "global"
|
|
910
|
+
}, {
|
|
911
|
+
username: a(() => [
|
|
912
|
+
b("code", null, p(t(r)("consumers.fields.custom_id.username")), 1)
|
|
913
|
+
]),
|
|
914
|
+
_: 1
|
|
915
|
+
})
|
|
916
|
+
]),
|
|
917
|
+
_: 1
|
|
918
|
+
}, 8, ["config", "config-card-doc", "config-schema", "entity-type", "fetch-url", "hide-title"])
|
|
919
|
+
]));
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
export {
|
|
923
|
+
zt as ConsumerConfigCard,
|
|
924
|
+
Wt as ConsumerForm,
|
|
925
|
+
Qt as ConsumerList
|
|
926
|
+
};
|