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