@kong-ui-public/entities-data-plane-nodes 0.6.73 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,78 +1,26 @@
1
- var ne = Object.defineProperty;
2
- var oe = (n, e, t) => e in n ? ne(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var I = (n, e, t) => oe(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { computed as p, toValue as A, ref as L, watch as ae, defineComponent as O, resolveComponent as S, openBlock as g, createElementBlock as N, createElementVNode as i, toDisplayString as d, unref as l, createBlock as y, Fragment as j, createTextVNode as $, createCommentVNode as q, withCtx as w, createVNode as D, resolveDynamicComponent as Q, useModel as le, renderList as se, mergeModels as re } from "vue";
5
- import { createI18n as ie, i18nTComponent as ce } from "@kong-ui-public/i18n";
6
- import { useErrors as ue } from "@kong-ui-public/entities-shared";
7
- import { EqualIcon as de, ProgressIcon as ge, ClearIcon as ve, CheckCircleIcon as me } from "@kong/icons";
8
- const _e = {
9
- action_button: {
10
- confirm: "Confirm",
11
- submitting: "Submitting...",
12
- ok: "OK"
13
- },
14
- change_log_level: {
15
- title: "Change log level ({summary})",
16
- summary_with_name: "Node {name}",
17
- summary_with_number: "{number} Nodes"
18
- },
19
- dp_list: {
20
- header: {
21
- host: "Host",
22
- action: "Action",
23
- status: "Status"
24
- },
25
- status: {
26
- failed: "Failure",
27
- loading: "Loading",
28
- pending: "Pending",
29
- succeed: "Succeed",
30
- not_supported: "Not supported"
31
- }
32
- },
33
- log_level_disk_space_warning: "If left on for extended periods of time, can result in excess disk space consumption.",
34
- log_level_explanation: {
35
- debug: "Provides debug information about the plugin’s run loop and each individual plugin or other components.",
36
- info: "Provides messages that provide a record of the normal operation of the system.",
37
- notice: "Provides messages that provide a record of the normal operation of the system, but also alerts conditions that may require monitoring. Kong does not make a large difference between info and notice.",
38
- warn: "Is used to log any abnormal behavior that doesn’t result in dropped transactions but requires further investigation.",
39
- error: "Is used for logging errors that result in a request being dropped.",
40
- crit: "Is used when Kong is working under critical conditions and not working properly, thus affecting several clients."
41
- },
42
- revert_to_default_after: {
43
- label: "Revert to default after",
44
- hours: "hour",
45
- minutes: "min",
46
- seconds: "seconds"
47
- },
48
- select_log_level_title: "Select log level"
49
- }, he = {
50
- debug: "Debug",
51
- info: "Info",
52
- notice: "Notice",
53
- warn: "Warn",
54
- error: "Error",
55
- crit: "Critical",
56
- not_applicable: "N/A"
57
- }, pe = {
58
- modal: _e,
59
- log_level: he
1
+ import { computed as h, toValue as $, ref as L, watch as ee, defineComponent as F, resolveComponent as S, openBlock as d, createElementBlock as I, createElementVNode as i, toDisplayString as u, unref as l, createBlock as y, Fragment as Q, createTextVNode as N, createCommentVNode as K, withCtx as w, createVNode as A, resolveDynamicComponent as R, useModel as te, renderList as ne, mergeModels as oe } from "vue";
2
+ import { createI18n as ae, i18nTComponent as le } from "@kong-ui-public/i18n";
3
+ import { useErrors as se } from "@kong-ui-public/entities-shared";
4
+ import { EqualIcon as re, ProgressIcon as ie, ClearIcon as ce, CheckCircleIcon as ue } from "@kong/icons";
5
+ const de = { action_button: { confirm: "Confirm", submitting: "Submitting...", ok: "OK" }, change_log_level: { title: "Change log level ({summary})", summary_with_name: "Node {name}", summary_with_number: "{number} Nodes" }, dp_list: { header: { host: "Host", action: "Action", status: "Status" }, status: { failed: "Failure", loading: "Loading", pending: "Pending", succeed: "Succeed", not_supported: "Not supported" } }, log_level_disk_space_warning: "If left on for extended periods of time, can result in excess disk space consumption.", log_level_explanation: { debug: "Provides debug information about the plugin’s run loop and each individual plugin or other components.", info: "Provides messages that provide a record of the normal operation of the system.", notice: "Provides messages that provide a record of the normal operation of the system, but also alerts conditions that may require monitoring. Kong does not make a large difference between info and notice.", warn: "Is used to log any abnormal behavior that doesn’t result in dropped transactions but requires further investigation.", error: "Is used for logging errors that result in a request being dropped.", crit: "Is used when Kong is working under critical conditions and not working properly, thus affecting several clients." }, revert_to_default_after: { label: "Revert to default after", hours: "hour", minutes: "min", seconds: "seconds" }, select_log_level_title: "Select log level" }, ge = { debug: "Debug", info: "Info", notice: "Notice", warn: "Warn", error: "Error", crit: "Critical", not_applicable: "N/A" }, ve = {
6
+ modal: de,
7
+ log_level: ge
60
8
  };
61
- function E() {
62
- const n = ie("en-us", pe);
9
+ function B() {
10
+ const n = ae("en-us", ve);
63
11
  return {
64
12
  i18n: n,
65
- i18nT: ce(n)
13
+ i18nT: le(n)
66
14
  // Translation component <i18n-t>
67
15
  };
68
16
  }
69
17
  var b = /* @__PURE__ */ ((n) => (n.Debug = "debug", n.Info = "info", n.Notice = "notice", n.Warn = "warn", n.Error = "error", n.Critical = "crit", n))(b || {});
70
- class fe {
18
+ class me {
19
+ concurrentTokenSet = /* @__PURE__ */ new Set();
20
+ concurrentTokenBorrowQueue = [];
71
21
  constructor(e) {
72
- I(this, "concurrentTokenSet", /* @__PURE__ */ new Set());
73
- I(this, "concurrentTokenBorrowQueue", []);
74
22
  for (let t = 0; t < e; ++t)
75
- this.concurrentTokenSet.add(Symbol(`token-${t}`));
23
+ this.concurrentTokenSet.add(/* @__PURE__ */ Symbol(`token-${t}`));
76
24
  }
77
25
  hasAvailableConcurrentToken() {
78
26
  return this.concurrentTokenSet.size > 0;
@@ -105,67 +53,66 @@ class fe {
105
53
  }
106
54
  }
107
55
  }
108
- class V extends Error {
56
+ class q extends Error {
109
57
  constructor(e, t) {
110
58
  super(e, t), this.name = "AsyncAbortException";
111
59
  }
112
60
  }
113
- class B {
61
+ class D {
62
+ tokenBucket = null;
114
63
  constructor(e) {
115
- I(this, "tokenBucket", null);
116
- I(this, "schedule", async (e) => {
117
- let t;
118
- this.tokenBucket && (t = await this.tokenBucket.borrowToken());
119
- try {
120
- const o = await e();
121
- return t == null || t(), o;
122
- } catch (o) {
123
- throw t == null || t(), o;
124
- }
125
- });
126
- I(this, "cancelAll", (e, t) => {
127
- var o;
128
- (o = this.tokenBucket) == null || o.clearWaitingQueue(new V(e, t));
129
- });
130
- e.maxConcurrentAsyncs > 0 && (this.tokenBucket = new fe(e.maxConcurrentAsyncs));
64
+ e.maxConcurrentAsyncs > 0 && (this.tokenBucket = new me(e.maxConcurrentAsyncs));
131
65
  }
66
+ schedule = async (e) => {
67
+ let t;
68
+ this.tokenBucket && (t = await this.tokenBucket.borrowToken());
69
+ try {
70
+ const o = await e();
71
+ return t?.(), o;
72
+ } catch (o) {
73
+ throw t?.(), o;
74
+ }
75
+ };
76
+ cancelAll = (e, t) => {
77
+ this.tokenBucket?.clearWaitingQueue(new q(e, t));
78
+ };
132
79
  }
133
- const be = (n) => n instanceof B ? n : n === null ? new B({ maxConcurrentAsyncs: 0 }) : new B(n), Le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
80
+ const pe = (n) => n instanceof D ? n : n === null ? new D({ maxConcurrentAsyncs: 0 }) : new D(n), _e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
134
81
  __proto__: null,
135
- AsyncAbortException: V,
136
- AsyncScheduler: B,
137
- useAsyncScheduler: be
138
- }, Symbol.toStringTag, { value: "Module" })), W = [
82
+ AsyncAbortException: q,
83
+ AsyncScheduler: D,
84
+ useAsyncScheduler: pe
85
+ }, Symbol.toStringTag, { value: "Module" })), O = [
139
86
  b.Debug,
140
87
  b.Info,
141
88
  b.Notice,
142
89
  b.Warn,
143
90
  b.Error,
144
91
  b.Critical
145
- ], ke = (n) => {
146
- const { i18n: e } = E();
147
- return p(() => {
148
- const t = A(n == null ? void 0 : n.disabled) ?? [];
149
- return W.map((o) => ({
92
+ ], he = (n) => {
93
+ const { i18n: e } = B();
94
+ return h(() => {
95
+ const t = $(n?.disabled) ?? [];
96
+ return O.map((o) => ({
150
97
  label: e.t(`log_level.${o}`),
151
98
  value: o,
152
- selected: (n == null ? void 0 : n.initialSelected) === o,
99
+ selected: n?.initialSelected === o,
153
100
  disabled: t.includes(o)
154
101
  }));
155
102
  });
156
- }, ye = (n) => {
157
- const e = [b.Debug], { i18n: t } = E();
158
- return p(() => {
159
- const o = A(n);
103
+ }, fe = (n) => {
104
+ const e = [b.Debug], { i18n: t } = B();
105
+ return h(() => {
106
+ const o = $(n);
160
107
  return {
161
108
  explanation: t.t(`modal.log_level_explanation.${o}`),
162
109
  warning: e.includes(o) ? t.t("modal.log_level_disk_space_warning") : void 0
163
110
  };
164
111
  });
165
- }, we = (n) => {
166
- const { i18n: e } = E();
167
- return p(() => {
168
- const t = A(n);
112
+ }, be = (n) => {
113
+ const { i18n: e } = B();
114
+ return h(() => {
115
+ const t = $(n);
169
116
  if (isNaN(t) || t <= 0)
170
117
  return "";
171
118
  let o = "";
@@ -176,44 +123,44 @@ const be = (n) => n instanceof B ? n : n === null ? new B({ maxConcurrentAsyncs:
176
123
  const s = Math.floor(t / 3600);
177
124
  return s !== 0 && (o = `${s} ${e.t("modal.revert_to_default_after.hours")} ${o}`), o;
178
125
  });
179
- }, Ce = (n) => {
180
- const e = n.requestExecutor ?? ((s) => s()), { getDataPlaneLogLevel: t, setDataPlaneLogLevel: o } = n, { getMessageFromError: a } = ue();
181
- return { checkDataPlaneLogLevel: (s, c) => {
182
- const u = L(A(c == null ? void 0 : c.currentLogLevelHint) ?? null);
183
- u.value === null && e(async () => {
184
- u.value = await t(s);
185
- }).catch((v) => {
186
- v instanceof V || console.error("Failed to get data plane log level", v);
187
- }), c != null && c.currentLogLevelHint && ae(() => A(c.currentLogLevelHint), (v) => {
188
- v && (u.value = v);
126
+ }, Le = (n) => {
127
+ const e = n.requestExecutor ?? ((s) => s()), { getDataPlaneLogLevel: t, setDataPlaneLogLevel: o } = n, { getMessageFromError: a } = se();
128
+ return { checkDataPlaneLogLevel: (s, m) => {
129
+ const c = L($(m?.currentLogLevelHint) ?? null);
130
+ c.value === null && e(async () => {
131
+ c.value = await t(s);
132
+ }).catch((g) => {
133
+ g instanceof q || console.error("Failed to get data plane log level", g);
134
+ }), m?.currentLogLevelHint && ee(() => $(m.currentLogLevelHint), (g) => {
135
+ g && (c.value = g);
189
136
  });
190
- const m = L("pending"), k = L(null);
137
+ const v = L("pending"), k = L(null);
191
138
  return {
192
- currentLogLevel: u,
193
- updateStatus: m,
139
+ currentLogLevel: c,
140
+ updateStatus: v,
194
141
  updateErrorMessage: k,
195
- updateLogLevel: async (v, C) => {
196
- m.value = "loading", k.value = null;
142
+ updateLogLevel: async (g, C) => {
143
+ v.value = "loading", k.value = null;
197
144
  try {
198
- await e(() => o(s, v, C)), u.value = v, m.value = "success";
145
+ await e(() => o(s, g, C)), c.value = g, v.value = "success";
199
146
  } catch (T) {
200
- k.value = a(T), m.value = "error";
147
+ k.value = a(T), v.value = "error";
201
148
  }
202
149
  }
203
150
  };
204
151
  } };
205
- }, xe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
152
+ }, ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
206
153
  __proto__: null,
207
- supportedLevels: W,
208
- useDataPlaneLogLevelChecker: Ce,
209
- useFriendlyRevertTime: we,
210
- useLogLevelCandidateSelectItems: ke,
211
- useLogLevelExplanation: ye
154
+ supportedLevels: O,
155
+ useDataPlaneLogLevelChecker: Le,
156
+ useFriendlyRevertTime: be,
157
+ useLogLevelCandidateSelectItems: he,
158
+ useLogLevelExplanation: fe
212
159
  }, Symbol.toStringTag, { value: "Module" })), x = {
213
- useI18n: E,
214
- ...xe,
215
- ...Le
216
- }, Se = { "data-testid": "log-change-action" }, Te = { key: 0 }, Ie = { "data-testid": "log-change-action-current-level" }, Ne = { key: 0 }, $e = { "data-testid": "log-change-action-target-level" }, Ae = { "data-testid": "log-change-status" }, De = /* @__PURE__ */ O({
160
+ useI18n: B,
161
+ ...ke,
162
+ ..._e
163
+ }, ye = { "data-testid": "log-change-action" }, we = { key: 0 }, Ce = { "data-testid": "log-change-action-current-level" }, xe = { key: 0 }, Se = { "data-testid": "log-change-action-target-level" }, Te = { "data-testid": "log-change-status" }, Ie = /* @__PURE__ */ F({
217
164
  __name: "CLLModalNodeRow",
218
165
  props: {
219
166
  dataPlaneId: {},
@@ -225,19 +172,19 @@ const be = (n) => n instanceof B ? n : n === null ? new B({ maxConcurrentAsyncs:
225
172
  },
226
173
  setup(n, { expose: e }) {
227
174
  const t = n, { i18n: o } = x.useI18n();
228
- let a = L("not_supported"), r = L("not_supported"), s = L(null), c = async () => {
175
+ let a = L("not_supported"), r = L("not_supported"), s = L(null), m = async () => {
229
176
  };
230
177
  t.hasDllCapability && ({
231
178
  currentLogLevel: a,
232
179
  updateStatus: r,
233
180
  updateErrorMessage: s,
234
- updateLogLevel: c
181
+ updateLogLevel: m
235
182
  } = t.checkLogLevel(t.dataPlaneId, {
236
183
  currentLogLevelHint: () => t.logLevelHint ?? null
237
184
  })), e({
238
- updateLogLevel: c
185
+ updateLogLevel: m
239
186
  });
240
- const u = p(() => {
187
+ const c = h(() => {
241
188
  switch (r.value) {
242
189
  case "success":
243
190
  return "success";
@@ -249,7 +196,7 @@ const be = (n) => n instanceof B ? n : n === null ? new B({ maxConcurrentAsyncs:
249
196
  default:
250
197
  return "neutral";
251
198
  }
252
- }), m = p(() => {
199
+ }), v = h(() => {
253
200
  switch (r.value) {
254
201
  case "success":
255
202
  return o.t("modal.dp_list.status.succeed");
@@ -262,65 +209,65 @@ const be = (n) => n instanceof B ? n : n === null ? new B({ maxConcurrentAsyncs:
262
209
  default:
263
210
  return o.t("modal.dp_list.status.not_supported");
264
211
  }
265
- }), k = p(() => {
212
+ }), k = h(() => {
266
213
  switch (r.value) {
267
214
  case "success":
268
- return me;
215
+ return ue;
269
216
  case "error":
270
217
  case "not_supported":
271
- return ve;
218
+ return ce;
272
219
  case "loading":
273
- return ge;
220
+ return ie;
274
221
  default:
275
- return de;
222
+ return re;
276
223
  }
277
224
  });
278
- return (P, v) => {
279
- const C = S("KSkeleton"), T = S("KBadge"), M = S("KTooltip");
280
- return g(), N("tr", null, [
281
- i("td", null, d(n.hostname), 1),
282
- i("td", Se, [
283
- l(a) === "not_supported" ? (g(), N("span", Te, d(l(o).t("log_level.not_applicable")), 1)) : l(a) ? (g(), N(j, { key: 2 }, [
284
- i("span", Ie, d(l(o).t(`log_level.${l(a)}`)), 1),
285
- l(a) !== n.targetLogLevel ? (g(), N("span", Ne, [
286
- v[0] || (v[0] = $(" → ", -1)),
287
- i("span", $e, d(l(o).t(`log_level.${n.targetLogLevel}`)), 1)
288
- ])) : q("", !0)
289
- ], 64)) : (g(), y(C, {
225
+ return (E, g) => {
226
+ const C = S("KSkeleton"), T = S("KBadge"), P = S("KTooltip");
227
+ return d(), I("tr", null, [
228
+ i("td", null, u(n.hostname), 1),
229
+ i("td", ye, [
230
+ l(a) === "not_supported" ? (d(), I("span", we, u(l(o).t("log_level.not_applicable")), 1)) : l(a) ? (d(), I(Q, { key: 2 }, [
231
+ i("span", Ce, u(l(o).t(`log_level.${l(a)}`)), 1),
232
+ l(a) !== n.targetLogLevel ? (d(), I("span", xe, [
233
+ g[0] || (g[0] = N(" → ", -1)),
234
+ i("span", Se, u(l(o).t(`log_level.${n.targetLogLevel}`)), 1)
235
+ ])) : K("", !0)
236
+ ], 64)) : (d(), y(C, {
290
237
  key: 1,
291
238
  type: "spinner"
292
239
  }))
293
240
  ]),
294
- i("td", Ae, [
295
- l(s) ? (g(), y(M, {
241
+ i("td", Te, [
242
+ l(s) ? (d(), y(P, {
296
243
  key: 0,
297
244
  text: l(s)
298
245
  }, {
299
246
  default: w(() => [
300
- D(T, {
301
- appearance: u.value,
247
+ A(T, {
248
+ appearance: c.value,
302
249
  class: "badge-cell"
303
250
  }, {
304
251
  icon: w(() => [
305
- (g(), y(Q(k.value)))
252
+ (d(), y(R(k.value)))
306
253
  ]),
307
254
  default: w(() => [
308
- $(" " + d(m.value), 1)
255
+ N(" " + u(v.value), 1)
309
256
  ]),
310
257
  _: 1
311
258
  }, 8, ["appearance"])
312
259
  ]),
313
260
  _: 1
314
- }, 8, ["text"])) : (g(), y(T, {
261
+ }, 8, ["text"])) : (d(), y(T, {
315
262
  key: 1,
316
- appearance: u.value,
263
+ appearance: c.value,
317
264
  class: "badge-cell"
318
265
  }, {
319
266
  icon: w(() => [
320
- (g(), y(Q(k.value)))
267
+ (d(), y(R(k.value)))
321
268
  ]),
322
269
  default: w(() => [
323
- $(" " + d(m.value), 1)
270
+ N(" " + u(v.value), 1)
324
271
  ]),
325
272
  _: 1
326
273
  }, 8, ["appearance"]))
@@ -328,25 +275,25 @@ const be = (n) => n instanceof B ? n : n === null ? new B({ maxConcurrentAsyncs:
328
275
  ]);
329
276
  };
330
277
  }
331
- }), z = (n, e) => {
278
+ }), j = (n, e) => {
332
279
  const t = n.__vccOpts || n;
333
280
  for (const [o, a] of e)
334
281
  t[o] = a;
335
282
  return t;
336
- }, Be = /* @__PURE__ */ z(De, [["__scopeId", "data-v-a77ba884"]]), Ee = { class: "explanation-wrapper" }, Pe = {
283
+ }, Ne = /* @__PURE__ */ j(Ie, [["__scopeId", "data-v-a77ba884"]]), $e = { class: "explanation-wrapper" }, Ae = {
337
284
  key: 0,
338
285
  class: "warning-message",
339
286
  "data-testid": "log-level-warning-message"
340
- }, Me = { class: "revert-after-wrapper" }, Ke = { class: "time" }, qe = { class: "seconds" }, Ve = {
287
+ }, De = { class: "revert-after-wrapper" }, Be = { class: "time" }, Ee = { class: "seconds" }, Pe = {
341
288
  class: "formatted-time",
342
289
  "data-testid": "log-level-timeout-formatted"
343
- }, He = {
290
+ }, Me = {
344
291
  class: "data-plane-node-list",
345
292
  "data-testid": "data-plane-node-list"
346
- }, Re = { class: "data-plane-node-col" }, Fe = { class: "data-plane-node-col" }, Qe = /* @__PURE__ */ O({
293
+ }, Ke = { class: "data-plane-node-col" }, qe = { class: "data-plane-node-col" }, Ve = /* @__PURE__ */ F({
347
294
  name: "ChangeLogLevelModal",
348
295
  __name: "ChangeLogLevelModal",
349
- props: /* @__PURE__ */ re({
296
+ props: /* @__PURE__ */ oe({
350
297
  instanceList: {},
351
298
  instanceLogLevel: {},
352
299
  requests: {}
@@ -356,36 +303,36 @@ const be = (n) => n instanceof B ? n : n === null ? new B({ maxConcurrentAsyncs:
356
303
  }),
357
304
  emits: ["update:visible"],
358
305
  setup(n) {
359
- const e = n, t = le(n, "visible"), o = b.Notice, { i18n: a } = x.useI18n(), r = L("edit"), s = L(o), c = L("60"), u = p(() => Math.floor(Number(c.value))), m = p(() => e.instanceList.filter((f) => f.hasDLLCapability !== !1)), k = p(() => {
360
- const f = m.value.length === 1 ? a.t("modal.change_log_level.summary_with_name", { name: m.value[0].hostname }) : a.t("modal.change_log_level.summary_with_number", { number: `${m.value.length}` });
306
+ const e = n, t = te(n, "visible"), o = b.Notice, { i18n: a } = x.useI18n(), r = L("edit"), s = L(o), m = L("60"), c = h(() => Math.floor(Number(m.value))), v = h(() => e.instanceList.filter((f) => f.hasDLLCapability !== !1)), k = h(() => {
307
+ const f = v.value.length === 1 ? a.t("modal.change_log_level.summary_with_name", { name: v.value[0].hostname }) : a.t("modal.change_log_level.summary_with_number", { number: `${v.value.length}` });
361
308
  return a.t("modal.change_log_level.title", { summary: f });
362
- }), P = p(() => r.value === "submitting" || isNaN(u.value) || u.value <= 0 || m.value.length === 0), v = x.useLogLevelCandidateSelectItems({
309
+ }), E = h(() => r.value === "submitting" || isNaN(c.value) || c.value <= 0 || v.value.length === 0), g = x.useLogLevelCandidateSelectItems({
363
310
  initialSelected: o
364
- }), C = x.useLogLevelExplanation(s), T = x.useFriendlyRevertTime(u), M = x.useAsyncScheduler(
311
+ }), C = x.useLogLevelExplanation(s), T = x.useFriendlyRevertTime(c), P = x.useAsyncScheduler(
365
312
  e.requests.scheduler === void 0 ? { maxConcurrentAsyncs: 10 } : e.requests.scheduler
366
- ), { checkDataPlaneLogLevel: U } = x.useDataPlaneLogLevelChecker({
313
+ ), { checkDataPlaneLogLevel: W } = x.useDataPlaneLogLevelChecker({
367
314
  getDataPlaneLogLevel: e.requests.getDataPlaneLogLevel,
368
315
  setDataPlaneLogLevel: e.requests.setDataPlaneLogLevel,
369
- requestExecutor: M.schedule
370
- }), K = /* @__PURE__ */ new Map(), G = (f, _) => {
371
- _ === null ? K.delete(f) : K.set(f, _);
372
- }, J = async () => {
316
+ requestExecutor: P.schedule
317
+ }), M = /* @__PURE__ */ new Map(), z = (f, p) => {
318
+ p === null ? M.delete(f) : M.set(f, p);
319
+ }, U = async () => {
373
320
  if (r.value !== "edit") {
374
- H();
321
+ V();
375
322
  return;
376
323
  }
377
324
  r.value = "submitting";
378
- const f = Array.from(K.values()).map((_) => _.updateLogLevel(s.value, u.value));
325
+ const f = Array.from(M.values()).map((p) => p.updateLogLevel(s.value, c.value));
379
326
  try {
380
327
  await Promise.all(f);
381
- } catch (_) {
382
- console.error("Failed to update log level", _);
328
+ } catch (p) {
329
+ console.error("Failed to update log level", p);
383
330
  } finally {
384
331
  r.value = "submitted";
385
332
  }
386
- }, H = () => {
387
- t.value = !1, c.value = "60", r.value = "edit", s.value = o;
388
- }, X = p(() => {
333
+ }, V = () => {
334
+ t.value = !1, m.value = "60", r.value = "edit", s.value = o;
335
+ }, G = h(() => {
389
336
  switch (r.value) {
390
337
  case "submitting":
391
338
  return a.t("modal.action_button.submitting");
@@ -395,84 +342,81 @@ const be = (n) => n instanceof B ? n : n === null ? new B({ maxConcurrentAsyncs:
395
342
  return a.t("modal.action_button.confirm");
396
343
  }
397
344
  });
398
- return (f, _) => {
399
- const Y = S("KSelect"), R = S("KLabel"), Z = S("KInput"), ee = S("KModal");
400
- return g(), y(ee, {
401
- "action-button-disabled": P.value,
402
- "action-button-text": X.value,
345
+ return (f, p) => {
346
+ const J = S("KSelect"), H = S("KLabel"), X = S("KInput"), Y = S("KModal");
347
+ return d(), y(Y, {
348
+ "action-button-disabled": E.value,
349
+ "action-button-text": G.value,
403
350
  "data-testid": "change-log-level-modal",
404
351
  "hide-cancel-button": !0,
405
352
  "hide-close-icon": r.value === "submitting",
406
353
  "max-width": "640px",
407
354
  title: k.value,
408
355
  visible: t.value,
409
- onCancel: H,
410
- onProceed: J
356
+ onCancel: V,
357
+ onProceed: U
411
358
  }, {
412
359
  default: w(() => [
413
- r.value === "edit" ? (g(), y(Y, {
360
+ r.value === "edit" ? (d(), y(J, {
414
361
  key: 0,
415
362
  modelValue: s.value,
416
- "onUpdate:modelValue": _[0] || (_[0] = (h) => s.value = h),
363
+ "onUpdate:modelValue": p[0] || (p[0] = (_) => s.value = _),
417
364
  class: "log-level-select",
418
365
  "data-testid": "log-level-select",
419
- items: l(v),
366
+ items: l(g),
420
367
  label: l(a).t("modal.select_log_level_title")
421
- }, null, 8, ["modelValue", "items", "label"])) : q("", !0),
422
- i("div", Ee, [
423
- D(R, null, {
368
+ }, null, 8, ["modelValue", "items", "label"])) : K("", !0),
369
+ i("div", $e, [
370
+ A(H, null, {
424
371
  default: w(() => [
425
- $(d(l(a).t(`log_level.${s.value}`)), 1)
372
+ N(u(l(a).t(`log_level.${s.value}`)), 1)
426
373
  ]),
427
374
  _: 1
428
375
  }),
429
- i("div", null, d(l(C).explanation), 1),
430
- l(C).warning ? (g(), N("div", Pe, d(l(C).warning), 1)) : q("", !0)
376
+ i("div", null, u(l(C).explanation), 1),
377
+ l(C).warning ? (d(), I("div", Ae, u(l(C).warning), 1)) : K("", !0)
431
378
  ]),
432
- i("div", Me, [
433
- D(R, null, {
379
+ i("div", De, [
380
+ A(H, null, {
434
381
  default: w(() => [
435
- $(d(l(a).t("modal.revert_to_default_after.label")), 1)
382
+ N(u(l(a).t("modal.revert_to_default_after.label")), 1)
436
383
  ]),
437
384
  _: 1
438
385
  }),
439
- i("div", Ke, [
440
- D(Z, {
441
- modelValue: c.value,
442
- "onUpdate:modelValue": _[1] || (_[1] = (h) => c.value = h),
386
+ i("div", Be, [
387
+ A(X, {
388
+ modelValue: m.value,
389
+ "onUpdate:modelValue": p[1] || (p[1] = (_) => m.value = _),
443
390
  class: "time-input",
444
391
  "data-testid": "log-level-timeout",
445
392
  disabled: r.value !== "edit",
446
- error: u.value <= 0 || isNaN(u.value),
393
+ error: c.value <= 0 || isNaN(c.value),
447
394
  min: "1",
448
395
  type: "number"
449
396
  }, null, 8, ["modelValue", "disabled", "error"]),
450
- i("span", qe, d(l(a).t("modal.revert_to_default_after.seconds")), 1),
451
- i("span", Ve, d(l(T)), 1)
397
+ i("span", Ee, u(l(a).t("modal.revert_to_default_after.seconds")), 1),
398
+ i("span", Pe, u(l(T)), 1)
452
399
  ])
453
400
  ]),
454
- i("table", He, [
401
+ i("table", Me, [
455
402
  i("thead", null, [
456
- i("th", Re, d(l(a).t("modal.dp_list.header.host")), 1),
457
- i("th", Fe, d(l(a).t("modal.dp_list.header.action")), 1),
458
- i("th", null, d(l(a).t("modal.dp_list.header.status")), 1)
403
+ i("th", Ke, u(l(a).t("modal.dp_list.header.host")), 1),
404
+ i("th", qe, u(l(a).t("modal.dp_list.header.action")), 1),
405
+ i("th", null, u(l(a).t("modal.dp_list.header.status")), 1)
459
406
  ]),
460
407
  i("tbody", null, [
461
- (g(!0), N(j, null, se(e.instanceList, (h) => {
462
- var F;
463
- return g(), y(Be, {
464
- key: h.id,
465
- ref_for: !0,
466
- ref: (te) => G(h.id, te),
467
- "check-log-level": l(U),
468
- "data-plane-id": h.id,
469
- "data-testid": `data-plane-node-list-row-${h.id}`,
470
- "has-dll-capability": h.hasDLLCapability ?? !0,
471
- hostname: h.hostname,
472
- "log-level-hint": (F = e.instanceLogLevel) == null ? void 0 : F.get(h.id),
473
- "target-log-level": s.value
474
- }, null, 8, ["check-log-level", "data-plane-id", "data-testid", "has-dll-capability", "hostname", "log-level-hint", "target-log-level"]);
475
- }), 128))
408
+ (d(!0), I(Q, null, ne(e.instanceList, (_) => (d(), y(Ne, {
409
+ key: _.id,
410
+ ref_for: !0,
411
+ ref: (Z) => z(_.id, Z),
412
+ "check-log-level": l(W),
413
+ "data-plane-id": _.id,
414
+ "data-testid": `data-plane-node-list-row-${_.id}`,
415
+ "has-dll-capability": _.hasDLLCapability ?? !0,
416
+ hostname: _.hostname,
417
+ "log-level-hint": e.instanceLogLevel?.get(_.id),
418
+ "target-log-level": s.value
419
+ }, null, 8, ["check-log-level", "data-plane-id", "data-testid", "has-dll-capability", "hostname", "log-level-hint", "target-log-level"]))), 128))
476
420
  ])
477
421
  ])
478
422
  ]),
@@ -480,9 +424,9 @@ const be = (n) => n instanceof B ? n : n === null ? new B({ maxConcurrentAsyncs:
480
424
  }, 8, ["action-button-disabled", "action-button-text", "hide-close-icon", "title", "visible"]);
481
425
  };
482
426
  }
483
- }), Ge = /* @__PURE__ */ z(Qe, [["__scopeId", "data-v-74e820cf"]]);
427
+ }), Oe = /* @__PURE__ */ j(Ve, [["__scopeId", "data-v-74e820cf"]]);
484
428
  export {
485
- Ge as ChangeLogLevelModal,
429
+ Oe as ChangeLogLevelModal,
486
430
  b as LogLevel,
487
431
  x as composables
488
432
  };
@@ -1 +1 @@
1
- (function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@kong-ui-public/i18n"),require("@kong-ui-public/entities-shared"),require("@kong/icons")):typeof define=="function"&&define.amd?define(["exports","vue","@kong-ui-public/i18n","@kong-ui-public/entities-shared","@kong/icons"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s["kong-ui-public-entities-data-plane-nodes"]={},s.Vue,s["kong-ui-public-i18n"],s["kong-ui-public-entities-shared"],s.KongIcons))})(this,function(s,e,b,A,C){"use strict";var ue=Object.defineProperty;var ge=(s,e,b)=>e in s?ue(s,e,{enumerable:!0,configurable:!0,writable:!0,value:b}):s[e]=b;var w=(s,e,b)=>ge(s,typeof e!="symbol"?e+"":e,b);const P={modal:{action_button:{confirm:"Confirm",submitting:"Submitting...",ok:"OK"},change_log_level:{title:"Change log level ({summary})",summary_with_name:"Node {name}",summary_with_number:"{number} Nodes"},dp_list:{header:{host:"Host",action:"Action",status:"Status"},status:{failed:"Failure",loading:"Loading",pending:"Pending",succeed:"Succeed",not_supported:"Not supported"}},log_level_disk_space_warning:"If left on for extended periods of time, can result in excess disk space consumption.",log_level_explanation:{debug:"Provides debug information about the plugin’s run loop and each individual plugin or other components.",info:"Provides messages that provide a record of the normal operation of the system.",notice:"Provides messages that provide a record of the normal operation of the system, but also alerts conditions that may require monitoring. Kong does not make a large difference between info and notice.",warn:"Is used to log any abnormal behavior that doesn’t result in dropped transactions but requires further investigation.",error:"Is used for logging errors that result in a request being dropped.",crit:"Is used when Kong is working under critical conditions and not working properly, thus affecting several clients."},revert_to_default_after:{label:"Revert to default after",hours:"hour",minutes:"min",seconds:"seconds"},select_log_level_title:"Select log level"},log_level:{debug:"Debug",info:"Info",notice:"Notice",warn:"Warn",error:"Error",crit:"Critical",not_applicable:"N/A"}};function S(){const o=b.createI18n("en-us",P);return{i18n:o,i18nT:b.i18nTComponent(o)}}var h=(o=>(o.Debug="debug",o.Info="info",o.Notice="notice",o.Warn="warn",o.Error="error",o.Critical="crit",o))(h||{});class M{constructor(n){w(this,"concurrentTokenSet",new Set);w(this,"concurrentTokenBorrowQueue",[]);for(let t=0;t<n;++t)this.concurrentTokenSet.add(Symbol(`token-${t}`))}hasAvailableConcurrentToken(){return this.concurrentTokenSet.size>0}borrowConcurrentToken(){if(this.concurrentTokenSet.size>0){const n=this.concurrentTokenSet.values().next().value;if(n)return this.concurrentTokenSet.delete(n),()=>{this.returnConcurrentToken(n)}}throw new Error("BUG: No available token to borrow")}returnConcurrentToken(n){if(this.concurrentTokenSet.has(n))throw new Error("Token already returned");const t=this.concurrentTokenBorrowQueue.shift();t?t[0](()=>this.returnConcurrentToken(n)):this.concurrentTokenSet.add(n)}async borrowToken(){return this.hasAvailableConcurrentToken()?this.borrowConcurrentToken():new Promise((n,t)=>{this.concurrentTokenBorrowQueue.push([n,t])})}clearWaitingQueue(n){for(;this.concurrentTokenBorrowQueue.length>0;){const[,t]=this.concurrentTokenBorrowQueue.shift();t(n)}}}class N extends Error{constructor(n,t){super(n,t),this.name="AsyncAbortException"}}class x{constructor(n){w(this,"tokenBucket",null);w(this,"schedule",async n=>{let t;this.tokenBucket&&(t=await this.tokenBucket.borrowToken());try{const a=await n();return t==null||t(),a}catch(a){throw t==null||t(),a}});w(this,"cancelAll",(n,t)=>{var a;(a=this.tokenBucket)==null||a.clearWaitingQueue(new N(n,t))});n.maxConcurrentAsyncs>0&&(this.tokenBucket=new M(n.maxConcurrentAsyncs))}}const K=Object.freeze(Object.defineProperty({__proto__:null,AsyncAbortException:N,AsyncScheduler:x,useAsyncScheduler:o=>o instanceof x?o:o===null?new x({maxConcurrentAsyncs:0}):new x(o)},Symbol.toStringTag,{value:"Module"})),V=[h.Debug,h.Info,h.Notice,h.Warn,h.Error,h.Critical],_={useI18n:S,...Object.freeze(Object.defineProperty({__proto__:null,supportedLevels:V,useDataPlaneLogLevelChecker:o=>{const n=o.requestExecutor??(r=>r()),{getDataPlaneLogLevel:t,setDataPlaneLogLevel:a}=o,{getMessageFromError:l}=A.useErrors();return{checkDataPlaneLogLevel:(r,i)=>{const d=e.ref(e.toValue(i==null?void 0:i.currentLogLevelHint)??null);d.value===null&&n(async()=>{d.value=await t(r)}).catch(u=>{u instanceof N||console.error("Failed to get data plane log level",u)}),i!=null&&i.currentLogLevelHint&&e.watch(()=>e.toValue(i.currentLogLevelHint),u=>{u&&(d.value=u)});const g=e.ref("pending"),k=e.ref(null);return{currentLogLevel:d,updateStatus:g,updateErrorMessage:k,updateLogLevel:async(u,L)=>{g.value="loading",k.value=null;try{await n(()=>a(r,u,L)),d.value=u,g.value="success"}catch(y){k.value=l(y),g.value="error"}}}}}},useFriendlyRevertTime:o=>{const{i18n:n}=S();return e.computed(()=>{const t=e.toValue(o);if(isNaN(t)||t<=0)return"";let a="";const l=t%60;l!==0&&(a+=`${l} ${n.t("modal.revert_to_default_after.seconds")}`);const c=Math.floor(t/60)%60;c!==0&&(a=`${c} ${n.t("modal.revert_to_default_after.minutes")} ${a}`);const r=Math.floor(t/3600);return r!==0&&(a=`${r} ${n.t("modal.revert_to_default_after.hours")} ${a}`),a})},useLogLevelCandidateSelectItems:o=>{const{i18n:n}=S();return e.computed(()=>{const t=e.toValue(o==null?void 0:o.disabled)??[];return V.map(a=>({label:n.t(`log_level.${a}`),value:a,selected:(o==null?void 0:o.initialSelected)===a,disabled:t.includes(a)}))})},useLogLevelExplanation:o=>{const n=[h.Debug],{i18n:t}=S();return e.computed(()=>{const a=e.toValue(o);return{explanation:t.t(`modal.log_level_explanation.${a}`),warning:n.includes(a)?t.t("modal.log_level_disk_space_warning"):void 0}})}},Symbol.toStringTag,{value:"Module"})),...K},q={"data-testid":"log-change-action"},F={key:0},R={"data-testid":"log-change-action-current-level"},H={key:0},j={"data-testid":"log-change-action-target-level"},O={"data-testid":"log-change-status"},Q=e.defineComponent({__name:"CLLModalNodeRow",props:{dataPlaneId:{},hostname:{},hasDllCapability:{type:Boolean},targetLogLevel:{},checkLogLevel:{},logLevelHint:{}},setup(o,{expose:n}){const t=o,{i18n:a}=_.useI18n();let l=e.ref("not_supported"),c=e.ref("not_supported"),r=e.ref(null),i=async()=>{};t.hasDllCapability&&({currentLogLevel:l,updateStatus:c,updateErrorMessage:r,updateLogLevel:i}=t.checkLogLevel(t.dataPlaneId,{currentLogLevelHint:()=>t.logLevelHint??null})),n({updateLogLevel:i});const d=e.computed(()=>{switch(c.value){case"success":return"success";case"error":return"danger";case"loading":case"pending":return"warning";default:return"neutral"}}),g=e.computed(()=>{switch(c.value){case"success":return a.t("modal.dp_list.status.succeed");case"error":return a.t("modal.dp_list.status.failed");case"pending":return a.t("modal.dp_list.status.pending");case"loading":return a.t("modal.dp_list.status.loading");default:return a.t("modal.dp_list.status.not_supported")}}),k=e.computed(()=>{switch(c.value){case"success":return C.CheckCircleIcon;case"error":case"not_supported":return C.ClearIcon;case"loading":return C.ProgressIcon;default:return C.EqualIcon}});return(v,u)=>{const L=e.resolveComponent("KSkeleton"),y=e.resolveComponent("KBadge"),B=e.resolveComponent("KTooltip");return e.openBlock(),e.createElementBlock("tr",null,[e.createElementVNode("td",null,e.toDisplayString(o.hostname),1),e.createElementVNode("td",q,[e.unref(l)==="not_supported"?(e.openBlock(),e.createElementBlock("span",F,e.toDisplayString(e.unref(a).t("log_level.not_applicable")),1)):e.unref(l)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("span",R,e.toDisplayString(e.unref(a).t(`log_level.${e.unref(l)}`)),1),e.unref(l)!==o.targetLogLevel?(e.openBlock(),e.createElementBlock("span",H,[u[0]||(u[0]=e.createTextVNode(" → ",-1)),e.createElementVNode("span",j,e.toDisplayString(e.unref(a).t(`log_level.${o.targetLogLevel}`)),1)])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(L,{key:1,type:"spinner"}))]),e.createElementVNode("td",O,[e.unref(r)?(e.openBlock(),e.createBlock(B,{key:0,text:e.unref(r)},{default:e.withCtx(()=>[e.createVNode(y,{appearance:d.value,class:"badge-cell"},{icon:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.value)))]),default:e.withCtx(()=>[e.createTextVNode(" "+e.toDisplayString(g.value),1)]),_:1},8,["appearance"])]),_:1},8,["text"])):(e.openBlock(),e.createBlock(y,{key:1,appearance:d.value,class:"badge-cell"},{icon:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.value)))]),default:e.withCtx(()=>[e.createTextVNode(" "+e.toDisplayString(g.value),1)]),_:1},8,["appearance"]))])])}}}),T=(o,n)=>{const t=o.__vccOpts||o;for(const[a,l]of n)t[a]=l;return t},W=T(Q,[["__scopeId","data-v-a77ba884"]]),z={class:"explanation-wrapper"},U={key:0,class:"warning-message","data-testid":"log-level-warning-message"},G={class:"revert-after-wrapper"},J={class:"time"},X={class:"seconds"},Y={class:"formatted-time","data-testid":"log-level-timeout-formatted"},Z={class:"data-plane-node-list","data-testid":"data-plane-node-list"},ee={class:"data-plane-node-col"},te={class:"data-plane-node-col"},ne=T(e.defineComponent({name:"ChangeLogLevelModal",__name:"ChangeLogLevelModal",props:e.mergeModels({instanceList:{},instanceLogLevel:{},requests:{}},{visible:{type:Boolean},visibleModifiers:{}}),emits:["update:visible"],setup(o){const n=o,t=e.useModel(o,"visible"),a=h.Notice,{i18n:l}=_.useI18n(),c=e.ref("edit"),r=e.ref(a),i=e.ref("60"),d=e.computed(()=>Math.floor(Number(i.value))),g=e.computed(()=>n.instanceList.filter(f=>f.hasDLLCapability!==!1)),k=e.computed(()=>{const f=g.value.length===1?l.t("modal.change_log_level.summary_with_name",{name:g.value[0].hostname}):l.t("modal.change_log_level.summary_with_number",{number:`${g.value.length}`});return l.t("modal.change_log_level.title",{summary:f})}),v=e.computed(()=>c.value==="submitting"||isNaN(d.value)||d.value<=0||g.value.length===0),u=_.useLogLevelCandidateSelectItems({initialSelected:a}),L=_.useLogLevelExplanation(r),y=_.useFriendlyRevertTime(d),B=_.useAsyncScheduler(n.requests.scheduler===void 0?{maxConcurrentAsyncs:10}:n.requests.scheduler),{checkDataPlaneLogLevel:oe}=_.useDataPlaneLogLevelChecker({getDataPlaneLogLevel:n.requests.getDataPlaneLogLevel,setDataPlaneLogLevel:n.requests.setDataPlaneLogLevel,requestExecutor:B.schedule}),E=new Map,ae=(f,m)=>{m===null?E.delete(f):E.set(f,m)},le=async()=>{if(c.value!=="edit"){D();return}c.value="submitting";const f=Array.from(E.values()).map(m=>m.updateLogLevel(r.value,d.value));try{await Promise.all(f)}catch(m){console.error("Failed to update log level",m)}finally{c.value="submitted"}},D=()=>{t.value=!1,i.value="60",c.value="edit",r.value=a},re=e.computed(()=>{switch(c.value){case"submitting":return l.t("modal.action_button.submitting");case"submitted":return l.t("modal.action_button.ok");default:return l.t("modal.action_button.confirm")}});return(f,m)=>{const se=e.resolveComponent("KSelect"),I=e.resolveComponent("KLabel"),ce=e.resolveComponent("KInput"),ie=e.resolveComponent("KModal");return e.openBlock(),e.createBlock(ie,{"action-button-disabled":v.value,"action-button-text":re.value,"data-testid":"change-log-level-modal","hide-cancel-button":!0,"hide-close-icon":c.value==="submitting","max-width":"640px",title:k.value,visible:t.value,onCancel:D,onProceed:le},{default:e.withCtx(()=>[c.value==="edit"?(e.openBlock(),e.createBlock(se,{key:0,modelValue:r.value,"onUpdate:modelValue":m[0]||(m[0]=p=>r.value=p),class:"log-level-select","data-testid":"log-level-select",items:e.unref(u),label:e.unref(l).t("modal.select_log_level_title")},null,8,["modelValue","items","label"])):e.createCommentVNode("",!0),e.createElementVNode("div",z,[e.createVNode(I,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(l).t(`log_level.${r.value}`)),1)]),_:1}),e.createElementVNode("div",null,e.toDisplayString(e.unref(L).explanation),1),e.unref(L).warning?(e.openBlock(),e.createElementBlock("div",U,e.toDisplayString(e.unref(L).warning),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",G,[e.createVNode(I,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(l).t("modal.revert_to_default_after.label")),1)]),_:1}),e.createElementVNode("div",J,[e.createVNode(ce,{modelValue:i.value,"onUpdate:modelValue":m[1]||(m[1]=p=>i.value=p),class:"time-input","data-testid":"log-level-timeout",disabled:c.value!=="edit",error:d.value<=0||isNaN(d.value),min:"1",type:"number"},null,8,["modelValue","disabled","error"]),e.createElementVNode("span",X,e.toDisplayString(e.unref(l).t("modal.revert_to_default_after.seconds")),1),e.createElementVNode("span",Y,e.toDisplayString(e.unref(y)),1)])]),e.createElementVNode("table",Z,[e.createElementVNode("thead",null,[e.createElementVNode("th",ee,e.toDisplayString(e.unref(l).t("modal.dp_list.header.host")),1),e.createElementVNode("th",te,e.toDisplayString(e.unref(l).t("modal.dp_list.header.action")),1),e.createElementVNode("th",null,e.toDisplayString(e.unref(l).t("modal.dp_list.header.status")),1)]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.instanceList,p=>{var $;return e.openBlock(),e.createBlock(W,{key:p.id,ref_for:!0,ref:de=>ae(p.id,de),"check-log-level":e.unref(oe),"data-plane-id":p.id,"data-testid":`data-plane-node-list-row-${p.id}`,"has-dll-capability":p.hasDLLCapability??!0,hostname:p.hostname,"log-level-hint":($=n.instanceLogLevel)==null?void 0:$.get(p.id),"target-log-level":r.value},null,8,["check-log-level","data-plane-id","data-testid","has-dll-capability","hostname","log-level-hint","target-log-level"])}),128))])])]),_:1},8,["action-button-disabled","action-button-text","hide-close-icon","title","visible"])}}}),[["__scopeId","data-v-74e820cf"]]);s.ChangeLogLevelModal=ne,s.LogLevel=h,s.composables=_,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
1
+ (function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@kong-ui-public/i18n"),require("@kong-ui-public/entities-shared"),require("@kong/icons")):typeof define=="function"&&define.amd?define(["exports","vue","@kong-ui-public/i18n","@kong-ui-public/entities-shared","@kong/icons"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d["kong-ui-public-entities-data-plane-nodes"]={},d.Vue,d["kong-ui-public-i18n"],d["kong-ui-public-entities-shared"],d.KongIcons))})(this,(function(d,e,B,I,y){"use strict";const $={modal:{action_button:{confirm:"Confirm",submitting:"Submitting...",ok:"OK"},change_log_level:{title:"Change log level ({summary})",summary_with_name:"Node {name}",summary_with_number:"{number} Nodes"},dp_list:{header:{host:"Host",action:"Action",status:"Status"},status:{failed:"Failure",loading:"Loading",pending:"Pending",succeed:"Succeed",not_supported:"Not supported"}},log_level_disk_space_warning:"If left on for extended periods of time, can result in excess disk space consumption.",log_level_explanation:{debug:"Provides debug information about the plugin’s run loop and each individual plugin or other components.",info:"Provides messages that provide a record of the normal operation of the system.",notice:"Provides messages that provide a record of the normal operation of the system, but also alerts conditions that may require monitoring. Kong does not make a large difference between info and notice.",warn:"Is used to log any abnormal behavior that doesn’t result in dropped transactions but requires further investigation.",error:"Is used for logging errors that result in a request being dropped.",crit:"Is used when Kong is working under critical conditions and not working properly, thus affecting several clients."},revert_to_default_after:{label:"Revert to default after",hours:"hour",minutes:"min",seconds:"seconds"},select_log_level_title:"Select log level"},log_level:{debug:"Debug",info:"Info",notice:"Notice",warn:"Warn",error:"Error",crit:"Critical",not_applicable:"N/A"}};function w(){const o=B.createI18n("en-us",$);return{i18n:o,i18nT:B.i18nTComponent(o)}}var h=(o=>(o.Debug="debug",o.Info="info",o.Notice="notice",o.Warn="warn",o.Error="error",o.Critical="crit",o))(h||{});class A{concurrentTokenSet=new Set;concurrentTokenBorrowQueue=[];constructor(t){for(let n=0;n<t;++n)this.concurrentTokenSet.add(Symbol(`token-${n}`))}hasAvailableConcurrentToken(){return this.concurrentTokenSet.size>0}borrowConcurrentToken(){if(this.concurrentTokenSet.size>0){const t=this.concurrentTokenSet.values().next().value;if(t)return this.concurrentTokenSet.delete(t),()=>{this.returnConcurrentToken(t)}}throw new Error("BUG: No available token to borrow")}returnConcurrentToken(t){if(this.concurrentTokenSet.has(t))throw new Error("Token already returned");const n=this.concurrentTokenBorrowQueue.shift();n?n[0](()=>this.returnConcurrentToken(t)):this.concurrentTokenSet.add(t)}async borrowToken(){return this.hasAvailableConcurrentToken()?this.borrowConcurrentToken():new Promise((t,n)=>{this.concurrentTokenBorrowQueue.push([t,n])})}clearWaitingQueue(t){for(;this.concurrentTokenBorrowQueue.length>0;){const[,n]=this.concurrentTokenBorrowQueue.shift();n(t)}}}class S extends Error{constructor(t,n){super(t,n),this.name="AsyncAbortException"}}class C{tokenBucket=null;constructor(t){t.maxConcurrentAsyncs>0&&(this.tokenBucket=new A(t.maxConcurrentAsyncs))}schedule=async t=>{let n;this.tokenBucket&&(n=await this.tokenBucket.borrowToken());try{const a=await t();return n?.(),a}catch(a){throw n?.(),a}};cancelAll=(t,n)=>{this.tokenBucket?.clearWaitingQueue(new S(t,n))}}const P=Object.freeze(Object.defineProperty({__proto__:null,AsyncAbortException:S,AsyncScheduler:C,useAsyncScheduler:o=>o instanceof C?o:o===null?new C({maxConcurrentAsyncs:0}):new C(o)},Symbol.toStringTag,{value:"Module"})),T=[h.Debug,h.Info,h.Notice,h.Warn,h.Error,h.Critical],_={useI18n:w,...Object.freeze(Object.defineProperty({__proto__:null,supportedLevels:T,useDataPlaneLogLevelChecker:o=>{const t=o.requestExecutor??(r=>r()),{getDataPlaneLogLevel:n,setDataPlaneLogLevel:a}=o,{getMessageFromError:l}=I.useErrors();return{checkDataPlaneLogLevel:(r,g)=>{const c=e.ref(e.toValue(g?.currentLogLevelHint)??null);c.value===null&&t(async()=>{c.value=await n(r)}).catch(i=>{i instanceof S||console.error("Failed to get data plane log level",i)}),g?.currentLogLevelHint&&e.watch(()=>e.toValue(g.currentLogLevelHint),i=>{i&&(c.value=i)});const u=e.ref("pending"),k=e.ref(null);return{currentLogLevel:c,updateStatus:u,updateErrorMessage:k,updateLogLevel:async(i,b)=>{u.value="loading",k.value=null;try{await t(()=>a(r,i,b)),c.value=i,u.value="success"}catch(L){k.value=l(L),u.value="error"}}}}}},useFriendlyRevertTime:o=>{const{i18n:t}=w();return e.computed(()=>{const n=e.toValue(o);if(isNaN(n)||n<=0)return"";let a="";const l=n%60;l!==0&&(a+=`${l} ${t.t("modal.revert_to_default_after.seconds")}`);const s=Math.floor(n/60)%60;s!==0&&(a=`${s} ${t.t("modal.revert_to_default_after.minutes")} ${a}`);const r=Math.floor(n/3600);return r!==0&&(a=`${r} ${t.t("modal.revert_to_default_after.hours")} ${a}`),a})},useLogLevelCandidateSelectItems:o=>{const{i18n:t}=w();return e.computed(()=>{const n=e.toValue(o?.disabled)??[];return T.map(a=>({label:t.t(`log_level.${a}`),value:a,selected:o?.initialSelected===a,disabled:n.includes(a)}))})},useLogLevelExplanation:o=>{const t=[h.Debug],{i18n:n}=w();return e.computed(()=>{const a=e.toValue(o);return{explanation:n.t(`modal.log_level_explanation.${a}`),warning:t.includes(a)?n.t("modal.log_level_disk_space_warning"):void 0}})}},Symbol.toStringTag,{value:"Module"})),...P},M={"data-testid":"log-change-action"},K={key:0},q={"data-testid":"log-change-action-current-level"},F={key:0},R={"data-testid":"log-change-action-target-level"},H={"data-testid":"log-change-status"},j=e.defineComponent({__name:"CLLModalNodeRow",props:{dataPlaneId:{},hostname:{},hasDllCapability:{type:Boolean},targetLogLevel:{},checkLogLevel:{},logLevelHint:{}},setup(o,{expose:t}){const n=o,{i18n:a}=_.useI18n();let l=e.ref("not_supported"),s=e.ref("not_supported"),r=e.ref(null),g=async()=>{};n.hasDllCapability&&({currentLogLevel:l,updateStatus:s,updateErrorMessage:r,updateLogLevel:g}=n.checkLogLevel(n.dataPlaneId,{currentLogLevelHint:()=>n.logLevelHint??null})),t({updateLogLevel:g});const c=e.computed(()=>{switch(s.value){case"success":return"success";case"error":return"danger";case"loading":case"pending":return"warning";default:return"neutral"}}),u=e.computed(()=>{switch(s.value){case"success":return a.t("modal.dp_list.status.succeed");case"error":return a.t("modal.dp_list.status.failed");case"pending":return a.t("modal.dp_list.status.pending");case"loading":return a.t("modal.dp_list.status.loading");default:return a.t("modal.dp_list.status.not_supported")}}),k=e.computed(()=>{switch(s.value){case"success":return y.CheckCircleIcon;case"error":case"not_supported":return y.ClearIcon;case"loading":return y.ProgressIcon;default:return y.EqualIcon}});return(x,i)=>{const b=e.resolveComponent("KSkeleton"),L=e.resolveComponent("KBadge"),N=e.resolveComponent("KTooltip");return e.openBlock(),e.createElementBlock("tr",null,[e.createElementVNode("td",null,e.toDisplayString(o.hostname),1),e.createElementVNode("td",M,[e.unref(l)==="not_supported"?(e.openBlock(),e.createElementBlock("span",K,e.toDisplayString(e.unref(a).t("log_level.not_applicable")),1)):e.unref(l)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("span",q,e.toDisplayString(e.unref(a).t(`log_level.${e.unref(l)}`)),1),e.unref(l)!==o.targetLogLevel?(e.openBlock(),e.createElementBlock("span",F,[i[0]||(i[0]=e.createTextVNode(" → ",-1)),e.createElementVNode("span",R,e.toDisplayString(e.unref(a).t(`log_level.${o.targetLogLevel}`)),1)])):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createBlock(b,{key:1,type:"spinner"}))]),e.createElementVNode("td",H,[e.unref(r)?(e.openBlock(),e.createBlock(N,{key:0,text:e.unref(r)},{default:e.withCtx(()=>[e.createVNode(L,{appearance:c.value,class:"badge-cell"},{icon:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.value)))]),default:e.withCtx(()=>[e.createTextVNode(" "+e.toDisplayString(u.value),1)]),_:1},8,["appearance"])]),_:1},8,["text"])):(e.openBlock(),e.createBlock(L,{key:1,appearance:c.value,class:"badge-cell"},{icon:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.value)))]),default:e.withCtx(()=>[e.createTextVNode(" "+e.toDisplayString(u.value),1)]),_:1},8,["appearance"]))])])}}}),E=(o,t)=>{const n=o.__vccOpts||o;for(const[a,l]of t)n[a]=l;return n},O=E(j,[["__scopeId","data-v-a77ba884"]]),Q={class:"explanation-wrapper"},W={key:0,class:"warning-message","data-testid":"log-level-warning-message"},z={class:"revert-after-wrapper"},U={class:"time"},G={class:"seconds"},J={class:"formatted-time","data-testid":"log-level-timeout-formatted"},X={class:"data-plane-node-list","data-testid":"data-plane-node-list"},Y={class:"data-plane-node-col"},Z={class:"data-plane-node-col"},ee=E(e.defineComponent({name:"ChangeLogLevelModal",__name:"ChangeLogLevelModal",props:e.mergeModels({instanceList:{},instanceLogLevel:{},requests:{}},{visible:{type:Boolean},visibleModifiers:{}}),emits:["update:visible"],setup(o){const t=o,n=e.useModel(o,"visible"),a=h.Notice,{i18n:l}=_.useI18n(),s=e.ref("edit"),r=e.ref(a),g=e.ref("60"),c=e.computed(()=>Math.floor(Number(g.value))),u=e.computed(()=>t.instanceList.filter(f=>f.hasDLLCapability!==!1)),k=e.computed(()=>{const f=u.value.length===1?l.t("modal.change_log_level.summary_with_name",{name:u.value[0].hostname}):l.t("modal.change_log_level.summary_with_number",{number:`${u.value.length}`});return l.t("modal.change_log_level.title",{summary:f})}),x=e.computed(()=>s.value==="submitting"||isNaN(c.value)||c.value<=0||u.value.length===0),i=_.useLogLevelCandidateSelectItems({initialSelected:a}),b=_.useLogLevelExplanation(r),L=_.useFriendlyRevertTime(c),N=_.useAsyncScheduler(t.requests.scheduler===void 0?{maxConcurrentAsyncs:10}:t.requests.scheduler),{checkDataPlaneLogLevel:te}=_.useDataPlaneLogLevelChecker({getDataPlaneLogLevel:t.requests.getDataPlaneLogLevel,setDataPlaneLogLevel:t.requests.setDataPlaneLogLevel,requestExecutor:N.schedule}),v=new Map,ne=(f,p)=>{p===null?v.delete(f):v.set(f,p)},oe=async()=>{if(s.value!=="edit"){V();return}s.value="submitting";const f=Array.from(v.values()).map(p=>p.updateLogLevel(r.value,c.value));try{await Promise.all(f)}catch(p){console.error("Failed to update log level",p)}finally{s.value="submitted"}},V=()=>{n.value=!1,g.value="60",s.value="edit",r.value=a},ae=e.computed(()=>{switch(s.value){case"submitting":return l.t("modal.action_button.submitting");case"submitted":return l.t("modal.action_button.ok");default:return l.t("modal.action_button.confirm")}});return(f,p)=>{const le=e.resolveComponent("KSelect"),D=e.resolveComponent("KLabel"),re=e.resolveComponent("KInput"),se=e.resolveComponent("KModal");return e.openBlock(),e.createBlock(se,{"action-button-disabled":x.value,"action-button-text":ae.value,"data-testid":"change-log-level-modal","hide-cancel-button":!0,"hide-close-icon":s.value==="submitting","max-width":"640px",title:k.value,visible:n.value,onCancel:V,onProceed:oe},{default:e.withCtx(()=>[s.value==="edit"?(e.openBlock(),e.createBlock(le,{key:0,modelValue:r.value,"onUpdate:modelValue":p[0]||(p[0]=m=>r.value=m),class:"log-level-select","data-testid":"log-level-select",items:e.unref(i),label:e.unref(l).t("modal.select_log_level_title")},null,8,["modelValue","items","label"])):e.createCommentVNode("",!0),e.createElementVNode("div",Q,[e.createVNode(D,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(l).t(`log_level.${r.value}`)),1)]),_:1}),e.createElementVNode("div",null,e.toDisplayString(e.unref(b).explanation),1),e.unref(b).warning?(e.openBlock(),e.createElementBlock("div",W,e.toDisplayString(e.unref(b).warning),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",z,[e.createVNode(D,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(l).t("modal.revert_to_default_after.label")),1)]),_:1}),e.createElementVNode("div",U,[e.createVNode(re,{modelValue:g.value,"onUpdate:modelValue":p[1]||(p[1]=m=>g.value=m),class:"time-input","data-testid":"log-level-timeout",disabled:s.value!=="edit",error:c.value<=0||isNaN(c.value),min:"1",type:"number"},null,8,["modelValue","disabled","error"]),e.createElementVNode("span",G,e.toDisplayString(e.unref(l).t("modal.revert_to_default_after.seconds")),1),e.createElementVNode("span",J,e.toDisplayString(e.unref(L)),1)])]),e.createElementVNode("table",X,[e.createElementVNode("thead",null,[e.createElementVNode("th",Y,e.toDisplayString(e.unref(l).t("modal.dp_list.header.host")),1),e.createElementVNode("th",Z,e.toDisplayString(e.unref(l).t("modal.dp_list.header.action")),1),e.createElementVNode("th",null,e.toDisplayString(e.unref(l).t("modal.dp_list.header.status")),1)]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.instanceList,m=>(e.openBlock(),e.createBlock(O,{key:m.id,ref_for:!0,ref:ce=>ne(m.id,ce),"check-log-level":e.unref(te),"data-plane-id":m.id,"data-testid":`data-plane-node-list-row-${m.id}`,"has-dll-capability":m.hasDLLCapability??!0,hostname:m.hostname,"log-level-hint":t.instanceLogLevel?.get(m.id),"target-log-level":r.value},null,8,["check-log-level","data-plane-id","data-testid","has-dll-capability","hostname","log-level-hint","target-log-level"]))),128))])])]),_:1},8,["action-button-disabled","action-button-text","hide-close-icon","title","visible"])}}}),[["__scopeId","data-v-74e820cf"]]);d.ChangeLogLevelModal=ee,d.LogLevel=h,d.composables=_,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kong-ui-public/entities-data-plane-nodes",
3
- "version": "0.6.73",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "main": "./dist/entities-data-plane-nodes.umd.js",
6
6
  "module": "./dist/entities-data-plane-nodes.es.js",
@@ -26,8 +26,8 @@
26
26
  "axios": "^1.16.1",
27
27
  "vue": ">= 3.3.13 < 4",
28
28
  "vue-router": "^4.6.4 || ^5.0.6",
29
- "@kong-ui-public/entities-shared": "^3.54.1",
30
- "@kong-ui-public/i18n": "^2.4.6"
29
+ "@kong-ui-public/entities-shared": "^3.56.0",
30
+ "@kong-ui-public/i18n": "^2.5.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@kong/design-tokens": "2.0.1",
@@ -36,8 +36,8 @@
36
36
  "axios": "^1.17.0",
37
37
  "vue": "^3.5.35",
38
38
  "vue-router": "^5.1.0",
39
- "@kong-ui-public/i18n": "^2.4.6",
40
- "@kong-ui-public/entities-shared": "^3.54.1"
39
+ "@kong-ui-public/entities-shared": "^3.56.0",
40
+ "@kong-ui-public/i18n": "^2.5.0"
41
41
  },
42
42
  "repository": {
43
43
  "type": "git",