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