@cobaltcore-dev/aurora 0.20.3 → 0.22.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.
Files changed (91) hide show
  1. package/dist/client/AuthProvider-p1e1DuKU.mjs +69 -0
  2. package/dist/client/AuthProvider-p1e1DuKU.mjs.map +1 -0
  3. package/dist/client/{ContentHeader-CIAzorGI.mjs → ContentHeader-BIScbvb4.mjs} +3 -2
  4. package/dist/client/{ContentHeader-CIAzorGI.mjs.map → ContentHeader-BIScbvb4.mjs.map} +1 -1
  5. package/dist/client/DeleteFlavorModal-lFMExcq_.mjs +713 -0
  6. package/dist/client/DeleteFlavorModal-lFMExcq_.mjs.map +1 -0
  7. package/dist/client/{DeletePcaModal-YUlNw8cw.mjs → DeletePcaModal-Dg9dej-H.mjs} +2 -2
  8. package/dist/client/{DeletePcaModal-YUlNw8cw.mjs.map → DeletePcaModal-Dg9dej-H.mjs.map} +1 -1
  9. package/dist/client/{DetailsInfo-Cv3oke-R.mjs → DetailsInfo-DwCo9P1o.mjs} +2 -2
  10. package/dist/client/{DetailsInfo-Cv3oke-R.mjs.map → DetailsInfo-DwCo9P1o.mjs.map} +1 -1
  11. package/dist/client/{FloatingIpActionModals-PLN6CWZ9.mjs → FloatingIpActionModals-CDF8LVtX.mjs} +2 -2
  12. package/dist/client/{FloatingIpActionModals-PLN6CWZ9.mjs.map → FloatingIpActionModals-CDF8LVtX.mjs.map} +1 -1
  13. package/dist/client/{ImageToastNotifications-BQM7HOyE.mjs → ImageToastNotifications-Dzq6jNTm.mjs} +2 -2
  14. package/dist/client/{ImageToastNotifications-BQM7HOyE.mjs.map → ImageToastNotifications-Dzq6jNTm.mjs.map} +1 -1
  15. package/dist/client/Slot-CWb612-_.mjs +28 -0
  16. package/dist/client/Slot-CWb612-_.mjs.map +1 -0
  17. package/dist/client/{_auth-BtRCgHQe.mjs → _auth-Dut7CaMR.mjs} +2 -2
  18. package/dist/client/{_auth-BtRCgHQe.mjs.map → _auth-Dut7CaMR.mjs.map} +1 -1
  19. package/dist/client/{_flavorId-BaNJ1CDY.mjs → _flavorId-BMJcnI7H.mjs} +2 -2
  20. package/dist/client/{_flavorId-BaNJ1CDY.mjs.map → _flavorId-BMJcnI7H.mjs.map} +1 -1
  21. package/dist/client/{_flavorId-BMX239RH.mjs → _flavorId-DUWdFEMH.mjs} +13 -14
  22. package/dist/client/{_flavorId-BMX239RH.mjs.map → _flavorId-DUWdFEMH.mjs.map} +1 -1
  23. package/dist/client/{_floatingIpId-DQFtZNeg.mjs → _floatingIpId-CjQLzpC5.mjs} +2 -2
  24. package/dist/client/{_floatingIpId-DQFtZNeg.mjs.map → _floatingIpId-CjQLzpC5.mjs.map} +1 -1
  25. package/dist/client/{_floatingIpId-E6x99cmW.mjs → _floatingIpId-KcWWq9ZW2.mjs} +4 -4
  26. package/dist/client/_floatingIpId-KcWWq9ZW2.mjs.map +1 -0
  27. package/dist/client/{_imageId-C2662dZr.mjs → _imageId-BkEpwbCr.mjs} +3 -3
  28. package/dist/client/{_imageId-C2662dZr.mjs.map → _imageId-BkEpwbCr.mjs.map} +1 -1
  29. package/dist/client/{_pcaId-CNbmhUF8.mjs → _pcaId-BcwGho7g.mjs} +4 -4
  30. package/dist/client/{_pcaId-CNbmhUF8.mjs.map → _pcaId-BcwGho7g.mjs.map} +1 -1
  31. package/dist/client/{_projectId-B4ScifQf.mjs → _projectId-CoMD6nq6.mjs} +3 -3
  32. package/dist/client/{_projectId-B4ScifQf.mjs.map → _projectId-CoMD6nq6.mjs.map} +1 -1
  33. package/dist/client/{_projectId-CYq4KZXB.mjs → _projectId-D8FHe0gr.mjs} +3 -3
  34. package/dist/client/{_projectId-CYq4KZXB.mjs.map → _projectId-D8FHe0gr.mjs.map} +1 -1
  35. package/dist/client/{_projectId-DxgPaiA7.mjs → _projectId-MjFv839t.mjs} +2 -2
  36. package/dist/client/{_projectId-DxgPaiA7.mjs.map → _projectId-MjFv839t.mjs.map} +1 -1
  37. package/dist/client/{_projectId-DJLjspKf.mjs → _projectId-hMtrqW6m.mjs} +24 -23
  38. package/dist/client/{_projectId-DJLjspKf.mjs.map → _projectId-hMtrqW6m.mjs.map} +1 -1
  39. package/dist/client/{_securityGroupId-ju2ZSIYe.mjs → _securityGroupId-B5-gJe1u.mjs} +3 -3
  40. package/dist/client/{_securityGroupId-ju2ZSIYe.mjs.map → _securityGroupId-B5-gJe1u.mjs.map} +1 -1
  41. package/dist/client/{_securityGroupId-a46ExjsA.mjs → _securityGroupId-fPJWtDPU.mjs} +2 -2
  42. package/dist/client/{_securityGroupId-a46ExjsA.mjs.map → _securityGroupId-fPJWtDPU.mjs.map} +1 -1
  43. package/dist/client/{_storageType-BkhbKG_G.mjs → _storageType-CI5f4CsI.mjs} +2 -2
  44. package/dist/client/{_storageType-BkhbKG_G.mjs.map → _storageType-CI5f4CsI.mjs.map} +1 -1
  45. package/dist/client/{_storageType-ByLL106s.mjs → _storageType-DePX1Aah.mjs} +3 -3
  46. package/dist/client/{_storageType-ByLL106s.mjs.map → _storageType-DePX1Aah.mjs.map} +1 -1
  47. package/dist/client/{aurora-Owys0YMN.mjs → aurora-Dp_NPGe8.mjs} +2 -2
  48. package/dist/client/{aurora-Owys0YMN.mjs.map → aurora-Dp_NPGe8.mjs.map} +1 -1
  49. package/dist/client/components/Auth/LoginForm.d.ts +1 -0
  50. package/dist/client/{flavors-C7PVJUqZ.mjs → flavors-DLxUiBhE.mjs} +2 -2
  51. package/dist/client/{flavors-C7PVJUqZ.mjs.map → flavors-DLxUiBhE.mjs.map} +1 -1
  52. package/dist/client/{flavors-Bwjig3k2.mjs → flavors-DkGuWvge.mjs} +11 -12
  53. package/dist/client/{flavors-Bwjig3k2.mjs.map → flavors-DkGuWvge.mjs.map} +1 -1
  54. package/dist/client/{floatingips-D98DrjA0.mjs → floatingips-DC5OrR8h.mjs} +3 -3
  55. package/dist/client/{floatingips-D98DrjA0.mjs.map → floatingips-DC5OrR8h.mjs.map} +1 -1
  56. package/dist/client/{hooks-BsbKkpZc.mjs → hooks-D0wGUhRF.mjs} +2 -2
  57. package/dist/client/{hooks-BsbKkpZc.mjs.map → hooks-D0wGUhRF.mjs.map} +1 -1
  58. package/dist/client/{images-CfBrglGJ.mjs → images-D9nfOtSC.mjs} +5 -5
  59. package/dist/client/{images-CfBrglGJ.mjs.map → images-D9nfOtSC.mjs.map} +1 -1
  60. package/dist/client/{images-CD7DNwru.mjs → images-h9i7S4LN.mjs} +2 -2
  61. package/dist/client/{images-CD7DNwru.mjs.map → images-h9i7S4LN.mjs.map} +1 -1
  62. package/dist/client/index.js +302 -502
  63. package/dist/client/index.js.map +1 -1
  64. package/dist/client/{objects-CEBrL7k-.mjs → objects-B3Z8h4RU.mjs} +2 -2
  65. package/dist/client/{objects-CEBrL7k-.mjs.map → objects-B3Z8h4RU.mjs.map} +1 -1
  66. package/dist/client/{objects-DvIxpzGI.mjs → objects-CGOfO00N.mjs} +3 -3
  67. package/dist/client/{objects-DvIxpzGI.mjs.map → objects-CGOfO00N.mjs.map} +1 -1
  68. package/dist/client/{pca-ZgGU0UPF.mjs → pca-C7cMT8fW.mjs} +2 -2
  69. package/dist/client/{pca-ZgGU0UPF.mjs.map → pca-C7cMT8fW.mjs.map} +1 -1
  70. package/dist/client/{pca-CpMqoF00.mjs → pca-Nppb8aVa.mjs} +5 -5
  71. package/dist/client/{pca-CpMqoF00.mjs.map → pca-Nppb8aVa.mjs.map} +1 -1
  72. package/dist/client/routeInfo-CdTRlSxv.mjs +32 -0
  73. package/dist/client/routeInfo-CdTRlSxv.mjs.map +1 -0
  74. package/dist/client/routes-Bz4zb2H4.mjs +10 -0
  75. package/dist/client/routes-Bz4zb2H4.mjs.map +1 -0
  76. package/dist/client/routes-CaqfgBYu.mjs +112 -0
  77. package/dist/client/routes-CaqfgBYu.mjs.map +1 -0
  78. package/dist/client/{securitygroups-BwhVyNmZ.mjs → securitygroups-JMvcJLpb.mjs} +2 -2
  79. package/dist/client/{securitygroups-BwhVyNmZ.mjs.map → securitygroups-JMvcJLpb.mjs.map} +1 -1
  80. package/dist/client/store/AuthProvider.d.ts +10 -11
  81. package/dist/server/index.js +1 -10
  82. package/package.json +1 -2
  83. package/dist/client/AuthProvider-Cj_Btfnc.mjs +0 -56
  84. package/dist/client/AuthProvider-Cj_Btfnc.mjs.map +0 -1
  85. package/dist/client/DeleteFlavorModal-Dwm0Hh84.mjs +0 -638
  86. package/dist/client/DeleteFlavorModal-Dwm0Hh84.mjs.map +0 -1
  87. package/dist/client/_floatingIpId-E6x99cmW.mjs.map +0 -1
  88. package/dist/client/routeInfo-Ct5r4Gen.mjs +0 -56
  89. package/dist/client/routeInfo-Ct5r4Gen.mjs.map +0 -1
  90. package/dist/client/useErrorTranslation-Dc0eE8Zt.mjs +0 -83
  91. package/dist/client/useErrorTranslation-Dc0eE8Zt.mjs.map +0 -1
@@ -1,638 +0,0 @@
1
- import { B as e, E as t, G as n, K as r, P as i, R as a, U as o, g as s, r as c, tt as l, ut as u, y as d } from "./build-DgeVmENN.mjs";
2
- import { t as f } from "./useErrorTranslation-Dc0eE8Zt.mjs";
3
- import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
4
- import g, { Suspense as _, startTransition as v, use as y, useEffect as b, useMemo as x, useState as S } from "react";
5
- import { Trans as C, useLingui as w } from "@lingui/react";
6
- import { ErrorBoundary as T } from "react-error-boundary";
7
- //#region src/client/routes/_auth/projects/$projectId/compute/-components/Flavors/-components/SpecFormRow.tsx
8
- var E = ({ specKey: e, value: r, errors: i, isLoading: a, onKeyChange: s, onValueChange: c, onSave: l, onCancel: f }) => {
9
- let { i18n: p, _: g } = w();
10
- return /*#__PURE__*/ h(t, { children: [
11
- /*#__PURE__*/ m(n, {
12
- className: "pl-0",
13
- children: /*#__PURE__*/ m(o, {
14
- value: e,
15
- onChange: (e) => s(e.target.value),
16
- placeholder: p._({ id: "wPrtGF" }),
17
- errortext: i.key,
18
- required: !0
19
- })
20
- }),
21
- /*#__PURE__*/ m(n, {
22
- className: "pl-0",
23
- children: /*#__PURE__*/ m(o, {
24
- value: r,
25
- onChange: (e) => c(e.target.value),
26
- placeholder: p._({ id: "pubQie" }),
27
- errortext: i.value,
28
- required: !0
29
- })
30
- }),
31
- /*#__PURE__*/ m(n, { children: /*#__PURE__*/ h(u, { children: [/*#__PURE__*/ m(d, {
32
- icon: "check",
33
- onClick: l,
34
- variant: "primary",
35
- title: p._({ id: "TyODHt" }),
36
- disabled: a
37
- }), /*#__PURE__*/ m(d, {
38
- icon: "cancel",
39
- onClick: f,
40
- title: p._({ id: "dEgA5A" }),
41
- disabled: a
42
- })] }) })
43
- ] });
44
- }, D = ({ specKey: e, value: i, isDeleting: a, onDelete: o, canDelete: s }) => {
45
- let { i18n: c, _: u } = w(), [f, g] = S(!1);
46
- return b(() => {
47
- if (f) {
48
- let e = setTimeout(() => {
49
- g(!1);
50
- }, 3e3);
51
- return () => clearTimeout(e);
52
- }
53
- }, [f]), /*#__PURE__*/ h(t, { children: [
54
- /*#__PURE__*/ m(n, { children: e }),
55
- /*#__PURE__*/ m(n, {
56
- className: "break-all",
57
- children: i
58
- }),
59
- /*#__PURE__*/ m(n, { children: a ? /*#__PURE__*/ m(l, {
60
- distribution: "center",
61
- alignment: "center",
62
- children: /*#__PURE__*/ m(r, { variant: "primary" })
63
- }) : /*#__PURE__*/ m(l, {
64
- distribution: "end",
65
- alignment: "end",
66
- children: s ? f ? /*#__PURE__*/ m(d, {
67
- variant: "primary-danger",
68
- onClick: () => {
69
- g(!1), o();
70
- },
71
- title: c._({ id: "cnGeoo" }),
72
- "aria-label": c._({ id: "cnGeoo" }),
73
- "data-testid": "confirm-deletion",
74
- disabled: a,
75
- children: c._({ id: "cnGeoo" })
76
- }) : /*#__PURE__*/ m(d, {
77
- icon: "deleteForever",
78
- onClick: () => g(!0),
79
- title: c._({
80
- id: "2G6hLq",
81
- values: { specKey: e }
82
- }),
83
- "aria-label": c._({
84
- id: "2G6hLq",
85
- values: { specKey: e }
86
- }),
87
- "data-testid": `delete-${e}`,
88
- disabled: a
89
- }) : /*#__PURE__*/ m(p, {})
90
- }) })
91
- ] });
92
- }, O = (e, t) => e.compute.canUser.query({
93
- project_id: t,
94
- permission: ["flavor_specs:create", "flavor_specs:delete"]
95
- }).then(([e, t]) => ({
96
- canCreate: e,
97
- canDelete: t
98
- })), k = (e, t, n) => e.compute.getExtraSpecs.query({
99
- project_id: t,
100
- flavorId: n
101
- });
102
- function A() {
103
- return /*#__PURE__*/ m(t, { children: /*#__PURE__*/ m(n, {
104
- colSpan: 3,
105
- children: /*#__PURE__*/ m(l, {
106
- distribution: "center",
107
- alignment: "center",
108
- children: /*#__PURE__*/ m(r, { variant: "primary" })
109
- })
110
- }) });
111
- }
112
- function j({ error: t }) {
113
- let { i18n: n, _: r } = w(), { translateError: i } = f();
114
- return /*#__PURE__*/ m(e, {
115
- variant: "error",
116
- text: t instanceof Error ? i(t.message) : n._({ id: "W5A0Ly" })
117
- });
118
- }
119
- function M({ permissionsPromise: e, extraSpecsPromise: r, client: o, project: s, flavor: c, onSpecsUpdate: u, isAddingSpec: g, setIsAddingSpec: _, setMessage: v }) {
120
- let { i18n: b, _: x } = w(), { translateError: C } = f(), T = y(e), [O, k] = S(y(r)), [A, j] = S(""), [M, N] = S(""), [P, F] = S({}), [I, L] = S(null), R = () => {
121
- let e = A.trim(), t = M.trim(), n = {};
122
- return e ? Object.keys(O).includes(e) && (n.key = "Key already exists.") : n.key = "Key is required.", t || (n.value = "Value is required."), F(n), Object.keys(n).length === 0;
123
- }, z = () => {
124
- j(""), N(""), F({});
125
- }, B = async () => {
126
- if (!R()) {
127
- v({
128
- text: b._({ id: "CBFSfX" }),
129
- type: "error"
130
- });
131
- return;
132
- }
133
- try {
134
- let e = A.trim(), t = M.trim();
135
- await o.compute.createExtraSpecs.mutate({
136
- project_id: s,
137
- flavorId: c.id,
138
- extra_specs: { [e]: t }
139
- });
140
- let n = {
141
- [e]: t,
142
- ...O
143
- };
144
- k(n), u(n), v({
145
- text: b._({
146
- id: "2mbisJ",
147
- values: { trimmedKey: e }
148
- }),
149
- type: "info"
150
- }), z(), _(!1);
151
- } catch (e) {
152
- v({
153
- text: C(e instanceof Error ? e.message : "Failed to create extra spec"),
154
- type: "error"
155
- });
156
- }
157
- }, V = async (e) => {
158
- try {
159
- L(e), await o.compute.deleteExtraSpec.mutate({
160
- project_id: s,
161
- flavorId: c.id,
162
- key: e
163
- });
164
- let t = { ...O };
165
- delete t[e], k(t), u(t), v({
166
- text: b._({
167
- id: "7UlHhT",
168
- values: { keyToDelete: e }
169
- }),
170
- type: "info"
171
- });
172
- } catch (t) {
173
- v({
174
- text: C(t instanceof Error ? t.message : `Failed to delete extra spec "${e}"`),
175
- type: "error"
176
- });
177
- } finally {
178
- L(null);
179
- }
180
- }, H = (e) => {
181
- j(e), P.key && F((e) => ({
182
- ...e,
183
- key: void 0
184
- }));
185
- }, U = (e) => {
186
- N(e), P.value && F((e) => ({
187
- ...e,
188
- value: void 0
189
- }));
190
- }, W = Object.keys(O).length === 0 && !g;
191
- return /*#__PURE__*/ h(p, { children: [T.canCreate && /*#__PURE__*/ m(l, {
192
- direction: "horizontal",
193
- className: "bg-theme-background-lvl-1 justify-end p-2",
194
- children: /*#__PURE__*/ m(d, {
195
- label: b._({ id: "u7En0V" }),
196
- "data-testid": "addExtraButton",
197
- onClick: () => _(!0),
198
- variant: "primary",
199
- disabled: g
200
- })
201
- }), /*#__PURE__*/ h(i, {
202
- columns: 3,
203
- children: [
204
- /*#__PURE__*/ h(t, { children: [
205
- /*#__PURE__*/ m(a, { children: b._({ id: "7sMeHQ" }) }),
206
- /*#__PURE__*/ m(a, { children: b._({ id: "wMHvYH" }) }),
207
- /*#__PURE__*/ m(a, {})
208
- ] }),
209
- g && /*#__PURE__*/ m(E, {
210
- specKey: A,
211
- value: M,
212
- errors: P,
213
- isLoading: !1,
214
- onKeyChange: H,
215
- onValueChange: U,
216
- onSave: B,
217
- onCancel: () => {
218
- z(), _(!1), v(null);
219
- }
220
- }),
221
- Object.entries(O).map(([e, t]) => /*#__PURE__*/ m(D, {
222
- specKey: e,
223
- value: t,
224
- isDeleting: I === e,
225
- onDelete: () => V(e),
226
- canDelete: T.canDelete
227
- }, e)),
228
- W && /*#__PURE__*/ m(t, { children: /*#__PURE__*/ m(n, {
229
- colSpan: 3,
230
- className: "text-theme-default py-4 text-center",
231
- children: b._({ id: "S3olSf" })
232
- }) })
233
- ]
234
- })] });
235
- }
236
- var N = ({ client: t, isOpen: n, onClose: r, project: i, flavor: a, canEdit: o }) => {
237
- let { i18n: s, _: l } = w(), [u, d] = S(null), [f, p] = S(!1), [y, b] = S(null), [x, C] = S(o), E = g.useMemo(() => n ? o === void 0 ? O(t, i) : Promise.resolve({
238
- canCreate: o,
239
- canDelete: o
240
- }) : null, [
241
- t,
242
- i,
243
- n,
244
- o
245
- ]);
246
- g.useEffect(() => {
247
- if (o !== void 0) {
248
- C(o);
249
- return;
250
- }
251
- E?.then(({ canCreate: e, canDelete: t }) => C(e || t));
252
- }, [E, o]);
253
- let D = x ? s._({ id: "SIfYq6" }) : s._({ id: "6GBt0m" });
254
- return g.useEffect(() => {
255
- n && a?.id && v(() => {
256
- b(k(t, i, a.id));
257
- });
258
- }, [
259
- n,
260
- a?.id,
261
- t,
262
- i
263
- ]), !n || !a || !E || !y ? null : /*#__PURE__*/ m(c, {
264
- onCancel: () => {
265
- d(null), p(!1), b(null), r();
266
- },
267
- title: D,
268
- open: n,
269
- size: "xl",
270
- children: /*#__PURE__*/ h("div", { children: [u && /*#__PURE__*/ m(e, {
271
- onDismiss: () => d(null),
272
- text: u.text,
273
- variant: u.type,
274
- className: "mb-4"
275
- }), /*#__PURE__*/ m(T, {
276
- fallbackRender: ({ error: e }) => /*#__PURE__*/ m(j, { error: e }),
277
- children: /*#__PURE__*/ m(_, {
278
- fallback: /*#__PURE__*/ m(A, {}),
279
- children: /*#__PURE__*/ m(M, {
280
- permissionsPromise: E,
281
- extraSpecsPromise: y,
282
- client: t,
283
- project: i,
284
- flavor: a,
285
- onSpecsUpdate: (e) => {
286
- v(() => {
287
- b(Promise.resolve(e));
288
- });
289
- },
290
- isAddingSpec: f,
291
- setIsAddingSpec: p,
292
- message: u,
293
- setMessage: d
294
- })
295
- })
296
- })] })
297
- });
298
- }, P = ({ tenantId: e, errors: r, isLoading: i, onTenantIdChange: a, onSave: s, onCancel: c }) => {
299
- let { i18n: l, _: f } = w();
300
- return /*#__PURE__*/ h(t, { children: [/*#__PURE__*/ m(n, {
301
- className: "pl-0",
302
- children: /*#__PURE__*/ m(o, {
303
- value: e,
304
- onChange: (e) => a(e.target.value),
305
- placeholder: l._({ id: "wa1Bcq" }),
306
- errortext: r.tenantId,
307
- required: !0
308
- })
309
- }), /*#__PURE__*/ m(n, { children: /*#__PURE__*/ h(u, { children: [/*#__PURE__*/ m(d, {
310
- icon: "check",
311
- onClick: s,
312
- variant: "primary",
313
- title: l._({ id: "q0Rla3" }),
314
- disabled: i
315
- }), /*#__PURE__*/ m(d, {
316
- icon: "cancel",
317
- onClick: c,
318
- title: l._({ id: "dEgA5A" }),
319
- disabled: i
320
- })] }) })] });
321
- }, F = ({ access: e, isDeleting: i, onDelete: a, canDelete: o }) => {
322
- let { i18n: s, _: c } = w(), [u, f] = S(!1);
323
- b(() => {
324
- if (u) {
325
- let e = setTimeout(() => {
326
- f(!1);
327
- }, 3e3);
328
- return () => clearTimeout(e);
329
- }
330
- }, [u]);
331
- let g = () => {
332
- f(!1), a();
333
- };
334
- return /*#__PURE__*/ h(t, { children: [/*#__PURE__*/ m(n, {
335
- className: "break-all",
336
- children: e.tenant_id
337
- }), /*#__PURE__*/ m(n, { children: i ? /*#__PURE__*/ m(l, {
338
- distribution: "center",
339
- alignment: "center",
340
- children: /*#__PURE__*/ m(r, { variant: "primary" })
341
- }) : /*#__PURE__*/ m(l, {
342
- distribution: "end",
343
- alignment: "end",
344
- children: (() => {
345
- if (!o) return /*#__PURE__*/ m(p, {});
346
- if (u) return /*#__PURE__*/ m(d, {
347
- variant: "primary-danger",
348
- onClick: g,
349
- title: s._({ id: "w9+8d7" }),
350
- "aria-label": s._({ id: "w9+8d7" }),
351
- "data-testid": "confirm-removal",
352
- disabled: i,
353
- children: s._({ id: "t/YqKh" })
354
- });
355
- {
356
- let t = e.tenant_id;
357
- return /*#__PURE__*/ m(d, {
358
- icon: "deleteForever",
359
- onClick: () => f(!0),
360
- title: s._({
361
- id: "tfxu04",
362
- values: { tenantId: t }
363
- }),
364
- "aria-label": s._({
365
- id: "tfxu04",
366
- values: { tenantId: t }
367
- }),
368
- "data-testid": `remove-${t}`,
369
- disabled: i
370
- });
371
- }
372
- })()
373
- }) })] });
374
- }, I = (e, t) => e.compute.canUser.query({
375
- project_id: t,
376
- permission: ["flavors:add_project", "flavors:remove_project"]
377
- }).then(([e, t]) => ({
378
- canAdd: e,
379
- canRemove: t
380
- })), L = (e, t, n) => e.compute.getFlavorAccess.query({
381
- project_id: t,
382
- flavorId: n
383
- });
384
- function R() {
385
- return /*#__PURE__*/ m(t, { children: /*#__PURE__*/ m(n, {
386
- colSpan: 2,
387
- children: /*#__PURE__*/ m(l, {
388
- distribution: "center",
389
- alignment: "center",
390
- children: /*#__PURE__*/ m(r, { variant: "primary" })
391
- })
392
- }) });
393
- }
394
- function z({ permissionsPromise: e, flavorAccessPromise: r, client: o, project: s, flavor: c, onAccessUpdate: u, isAddingAccess: g, setIsAddingAccess: _, setMessage: v }) {
395
- let { i18n: b, _: x } = w(), { translateError: C } = f(), T = y(e), E = y(r), [D, O] = S(""), [k, A] = S({}), [j, M] = S(/* @__PURE__ */ new Set()), [N, I] = S(!1), L = c["os-flavor-access:is_public"] !== !1, R = E.length === 0 && !g, z = () => {
396
- let e = D.trim(), t = {};
397
- return e ? E.some((t) => t.tenant_id === e) && (t.tenantId = "This tenant already has access to this flavor.") : t.tenantId = "Tenant ID is required.", A(t), Object.keys(t).length === 0;
398
- }, B = () => {
399
- O(""), A({});
400
- }, V = async () => {
401
- if (!z()) {
402
- v({
403
- text: b._({ id: "CBFSfX" }),
404
- type: "error"
405
- });
406
- return;
407
- }
408
- I(!0);
409
- try {
410
- let e = D.trim();
411
- u(await o.compute.addTenantAccess.mutate({
412
- project_id: s,
413
- flavorId: c.id,
414
- targetProjectId: e
415
- })), v({
416
- text: b._({
417
- id: "7flw0l",
418
- values: { trimmedTenantId: e }
419
- }),
420
- type: "info"
421
- }), B(), _(!1);
422
- } catch (e) {
423
- v({
424
- text: C(e?.message || "Failed to add tenant access"),
425
- type: "error"
426
- });
427
- } finally {
428
- I(!1);
429
- }
430
- }, H = async (e) => {
431
- M((t) => new Set(t).add(e));
432
- try {
433
- u(await o.compute.removeTenantAccess.mutate({
434
- project_id: s,
435
- flavorId: c.id,
436
- targetProjectId: e
437
- })), v({
438
- text: b._({
439
- id: "rvXsSb",
440
- values: { tenantIdToRemove: e }
441
- }),
442
- type: "info"
443
- });
444
- } catch (e) {
445
- v({
446
- text: C(e?.message || "Failed to remove tenant access"),
447
- type: "error"
448
- });
449
- } finally {
450
- M((t) => {
451
- let n = new Set(t);
452
- return n.delete(e), n;
453
- });
454
- }
455
- };
456
- return L ? /*#__PURE__*/ h(i, {
457
- columns: 2,
458
- children: [/*#__PURE__*/ h(t, { children: [/*#__PURE__*/ m(a, { children: b._({ id: "T9Mtpi" }) }), /*#__PURE__*/ m(a, { children: " " })] }), /*#__PURE__*/ m(t, { children: /*#__PURE__*/ m(n, {
459
- colSpan: 2,
460
- className: "text-theme-default py-4 text-center",
461
- children: b._({ id: "9x6EkK" })
462
- }) })]
463
- }) : /*#__PURE__*/ h(p, { children: [T.canAdd && /*#__PURE__*/ m(l, {
464
- direction: "horizontal",
465
- className: "bg-theme-background-lvl-1 justify-end p-2",
466
- children: /*#__PURE__*/ m(d, {
467
- label: b._({ id: "q0Rla3" }),
468
- "data-testid": "addTenantButton",
469
- onClick: () => _(!0),
470
- variant: "primary",
471
- disabled: g
472
- })
473
- }), /*#__PURE__*/ h(i, {
474
- columns: 2,
475
- children: [
476
- /*#__PURE__*/ h(t, { children: [/*#__PURE__*/ m(a, { children: b._({ id: "T9Mtpi" }) }), /*#__PURE__*/ m(a, {})] }),
477
- g && /*#__PURE__*/ m(P, {
478
- tenantId: D,
479
- errors: k,
480
- isLoading: N,
481
- onTenantIdChange: (e) => {
482
- O(e), k.tenantId && A((e) => ({
483
- ...e,
484
- tenantId: void 0
485
- }));
486
- },
487
- onSave: V,
488
- onCancel: () => {
489
- B(), _(!1), v(null);
490
- }
491
- }),
492
- E.map((e) => /*#__PURE__*/ m(F, {
493
- access: e,
494
- isDeleting: j.has(e.tenant_id),
495
- onDelete: () => H(e.tenant_id),
496
- canDelete: T.canRemove
497
- }, e.tenant_id)),
498
- R && /*#__PURE__*/ m(t, { children: /*#__PURE__*/ m(n, {
499
- colSpan: 2,
500
- className: "text-theme-default py-4 text-center",
501
- children: b._({ id: "Gyd3No" })
502
- }) })
503
- ]
504
- })] });
505
- }
506
- var B = ({ client: t, isOpen: n, onClose: r, project: i, flavor: a }) => {
507
- let { i18n: o, _: s } = w(), { translateError: l } = f(), [u, d] = S(null), [p, g] = S(!1), y = x(() => n ? I(t, i) : null, [
508
- t,
509
- i,
510
- n
511
- ]), C = x(() => !n || !a?.id ? null : L(t, i, a.id).then((e) => e.filter((e, t, n) => n.findIndex((t) => t.tenant_id === e.tenant_id) === t)).catch((e) => (d({
512
- text: l(e?.message || "GET_FLAVOR_ACCESS_FAILED"),
513
- type: "error"
514
- }), [])), [
515
- n,
516
- a?.id,
517
- t,
518
- i
519
- ]);
520
- b(() => {
521
- n && d(null);
522
- }, [n, a?.id]);
523
- let [T, E] = S(null), D = `${n}-${a?.id}`, O = T?.key === D ? T.promise : C, k = () => {
524
- d(null), g(!1), E(null), r();
525
- }, A = (e) => {
526
- let t = e.filter((e, t, n) => n.findIndex((t) => t.tenant_id === e.tenant_id) === t);
527
- v(() => {
528
- E({
529
- key: D,
530
- promise: Promise.resolve(t)
531
- });
532
- });
533
- };
534
- if (!n || !a || !y || !O) return null;
535
- let j = a.name;
536
- return /*#__PURE__*/ m(c, {
537
- onCancel: k,
538
- title: o._({
539
- id: "6Rnrsz",
540
- values: { flavorName: j }
541
- }),
542
- open: n,
543
- size: "xl",
544
- children: /*#__PURE__*/ h("div", { children: [u && /*#__PURE__*/ m(e, {
545
- onDismiss: () => d(null),
546
- text: u.text,
547
- variant: u.type,
548
- className: "mb-4",
549
- dismissible: !0
550
- }), /*#__PURE__*/ m(_, {
551
- fallback: /*#__PURE__*/ m(R, {}),
552
- children: /*#__PURE__*/ m(z, {
553
- permissionsPromise: y,
554
- flavorAccessPromise: O,
555
- client: t,
556
- project: i,
557
- flavor: a,
558
- onAccessUpdate: A,
559
- isAddingAccess: p,
560
- setIsAddingAccess: g,
561
- setMessage: d
562
- })
563
- })] })
564
- });
565
- }, V = ({ client: o, isOpen: p, onClose: g, project: _, flavor: v, onSuccess: y }) => {
566
- let { i18n: b, _: x } = w(), { translateError: T } = f(), [E, D] = S(!1), [O, k] = S(null), A = async () => {
567
- if (!v?.id) {
568
- k(b._({ id: "NlcF/v" }));
569
- return;
570
- }
571
- k(null);
572
- try {
573
- D(!0), await o.compute.deleteFlavor.mutate({
574
- project_id: _,
575
- flavorId: v.id
576
- }), y(), j();
577
- } catch (e) {
578
- k(e?.message ? T(e.message) : b._({ id: "8zAn1f" }));
579
- } finally {
580
- D(!1);
581
- }
582
- }, j = () => {
583
- k(null), g();
584
- };
585
- return /*#__PURE__*/ h(c, {
586
- onCancel: j,
587
- title: b._({ id: "JT3I1g" }),
588
- open: p,
589
- onConfirm: A,
590
- modalFooter: /*#__PURE__*/ m(s, {
591
- className: "flex justify-end",
592
- children: /*#__PURE__*/ h(u, { children: [/*#__PURE__*/ m(d, {
593
- variant: "primary-danger",
594
- onClick: A,
595
- disabled: E,
596
- children: E ? /*#__PURE__*/ m(r, { size: "small" }) : /*#__PURE__*/ m(C, { id: "cnGeoo" })
597
- }), /*#__PURE__*/ m(d, {
598
- variant: "default",
599
- onClick: j,
600
- children: /*#__PURE__*/ m(C, { id: "dEgA5A" })
601
- })] })
602
- }),
603
- children: [E && /*#__PURE__*/ m(l, {
604
- distribution: "center",
605
- alignment: "center",
606
- children: /*#__PURE__*/ m(r, { variant: "primary" })
607
- }), !E && /*#__PURE__*/ h("div", { children: [
608
- O && /*#__PURE__*/ m(e, {
609
- onDismiss: () => {
610
- k(null);
611
- },
612
- text: O,
613
- variant: "error",
614
- className: "mb-4"
615
- }),
616
- /*#__PURE__*/ m(e, {
617
- text: b._({ id: "QQ8wUG" }),
618
- variant: "danger",
619
- className: "mb-4"
620
- }),
621
- v && /*#__PURE__*/ h(i, {
622
- columns: 2,
623
- children: [
624
- /*#__PURE__*/ h(t, { children: [/*#__PURE__*/ m(a, { children: b._({ id: "6YtxFj" }) }), /*#__PURE__*/ m(n, { children: v.name })] }),
625
- /*#__PURE__*/ h(t, { children: [/*#__PURE__*/ m(a, { children: b._({ id: "S0kLOH" }) }), /*#__PURE__*/ m(n, { children: v.id })] }),
626
- /*#__PURE__*/ h(t, { children: [/*#__PURE__*/ m(a, { children: b._({ id: "MZGbkp" }) }), /*#__PURE__*/ m(n, { children: v.vcpus })] }),
627
- /*#__PURE__*/ h(t, { children: [/*#__PURE__*/ m(a, { children: b._({ id: "RGhYAo" }) }), /*#__PURE__*/ h(n, { children: [v.ram, " MiB"] })] }),
628
- /*#__PURE__*/ h(t, { children: [/*#__PURE__*/ m(a, { children: b._({ id: "sPFHpI" }) }), /*#__PURE__*/ h(n, { children: [v.disk, " GiB"] })] }),
629
- v.swap && /*#__PURE__*/ h(t, { children: [/*#__PURE__*/ m(a, { children: b._({ id: "vH2C/2" }) }), /*#__PURE__*/ h(n, { children: [v.swap, " MiB"] })] })
630
- ]
631
- })
632
- ] })]
633
- });
634
- };
635
- //#endregion
636
- export { B as n, N as r, V as t };
637
-
638
- //# sourceMappingURL=DeleteFlavorModal-Dwm0Hh84.mjs.map