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