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