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