@cobaltcore-dev/aurora 0.7.0 → 0.8.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 (101) hide show
  1. package/README.md +101 -7
  2. package/dist/client/AuroraApp.d.ts +38 -0
  3. package/dist/client/{ContentHeader-kx1Th5Sq.mjs → ContentHeader-DqsGNvtD.mjs} +17 -17
  4. package/dist/client/{ContentHeader-kx1Th5Sq.mjs.map → ContentHeader-DqsGNvtD.mjs.map} +1 -1
  5. package/dist/client/{DeleteFlavorModal-C3cb7YiJ.mjs → DeleteFlavorModal-C3m7bQJu.mjs} +163 -163
  6. package/dist/client/{DeleteFlavorModal-C3cb7YiJ.mjs.map → DeleteFlavorModal-C3m7bQJu.mjs.map} +1 -1
  7. package/dist/client/{EditSecurityGroupModal-CpP54WIK.mjs → EditSecurityGroupModal-DKusxfta.mjs} +18 -18
  8. package/dist/client/{EditSecurityGroupModal-CpP54WIK.mjs.map → EditSecurityGroupModal-DKusxfta.mjs.map} +1 -1
  9. package/dist/client/{FiltersInput-DxcyR6Bp.mjs → FiltersInput-GzR4D0q6.mjs} +21 -21
  10. package/dist/client/{FiltersInput-DxcyR6Bp.mjs.map → FiltersInput-GzR4D0q6.mjs.map} +1 -1
  11. package/dist/client/{FloatingIpActionModals-BP8RWHbu.mjs → FloatingIpActionModals-CRvROJ3H.mjs} +51 -51
  12. package/dist/client/{FloatingIpActionModals-BP8RWHbu.mjs.map → FloatingIpActionModals-CRvROJ3H.mjs.map} +1 -1
  13. package/dist/client/{ImageToastNotifications-TZ3EfQg-.mjs → ImageToastNotifications-BuDXpTkl.mjs} +344 -344
  14. package/dist/client/{ImageToastNotifications-TZ3EfQg-.mjs.map → ImageToastNotifications-BuDXpTkl.mjs.map} +1 -1
  15. package/dist/client/{RouteError-QSV7qOoJ.mjs → RouteError-DVAiT0mT.mjs} +2 -2
  16. package/dist/client/{RouteError-QSV7qOoJ.mjs.map → RouteError-DVAiT0mT.mjs.map} +1 -1
  17. package/dist/client/{SortInput-CYv2_Pur.mjs → SortInput-VK7IYqQv.mjs} +6 -6
  18. package/dist/client/{SortInput-CYv2_Pur.mjs.map → SortInput-VK7IYqQv.mjs.map} +1 -1
  19. package/dist/client/{_flavorId-C2x43-6S.mjs → _flavorId-B9Vqkraj.mjs} +8 -8
  20. package/dist/client/{_flavorId-C2x43-6S.mjs.map → _flavorId-B9Vqkraj.mjs.map} +1 -1
  21. package/dist/client/{_flavorId-CR8ZUI-P.mjs → _flavorId-CFpNGz52.mjs} +62 -62
  22. package/dist/client/{_flavorId-CR8ZUI-P.mjs.map → _flavorId-CFpNGz52.mjs.map} +1 -1
  23. package/dist/client/{_floatingIpId-BCk41_Lb.mjs → _floatingIpId-B5GMSLeQ.mjs} +2 -2
  24. package/dist/client/{_floatingIpId-BCk41_Lb.mjs.map → _floatingIpId-B5GMSLeQ.mjs.map} +1 -1
  25. package/dist/client/{_floatingIpId-BGrOAmPT.mjs → _floatingIpId-C2-BeRmF.mjs} +27 -27
  26. package/dist/client/{_floatingIpId-BGrOAmPT.mjs.map → _floatingIpId-C2-BeRmF.mjs.map} +1 -1
  27. package/dist/client/_imageId-9NZytfNs.mjs +534 -0
  28. package/dist/client/{_imageId-CvfD832b.mjs.map → _imageId-9NZytfNs.mjs.map} +1 -1
  29. package/dist/client/_pcaId-BwTvJJgh.mjs +479 -0
  30. package/dist/client/_pcaId-BwTvJJgh.mjs.map +1 -0
  31. package/dist/client/{_pcaId-DOHycvCf.mjs → _pcaId-DUHQd0rB.mjs} +2 -2
  32. package/dist/client/{_pcaId-DOHycvCf.mjs.map → _pcaId-DUHQd0rB.mjs.map} +1 -1
  33. package/dist/client/{_projectId-DOgwFiqD.mjs → _projectId-B_2sZKk-.mjs} +2 -2
  34. package/dist/client/{_projectId-DOgwFiqD.mjs.map → _projectId-B_2sZKk-.mjs.map} +1 -1
  35. package/dist/client/{_projectId-MxcHrXW4.mjs → _projectId-CLgClx24.mjs} +3 -3
  36. package/dist/client/{_projectId-MxcHrXW4.mjs.map → _projectId-CLgClx24.mjs.map} +1 -1
  37. package/dist/client/_projectId-cW9aQ4Ag.mjs +271 -0
  38. package/dist/client/_projectId-cW9aQ4Ag.mjs.map +1 -0
  39. package/dist/client/{_securityGroupId-KKw4RPdH.mjs → _securityGroupId-DYxmXUOP.mjs} +319 -319
  40. package/dist/client/{_securityGroupId-KKw4RPdH.mjs.map → _securityGroupId-DYxmXUOP.mjs.map} +1 -1
  41. package/dist/client/{_securityGroupId-CJJanWiY.mjs → _securityGroupId-fhK1CuZh.mjs} +2 -2
  42. package/dist/client/{_securityGroupId-CJJanWiY.mjs.map → _securityGroupId-fhK1CuZh.mjs.map} +1 -1
  43. package/dist/client/{_storageType-DYjo-6ej.mjs → _storageType-2_fau4B5.mjs} +698 -698
  44. package/dist/client/{_storageType-DYjo-6ej.mjs.map → _storageType-2_fau4B5.mjs.map} +1 -1
  45. package/dist/client/{_storageType-4wSxI__0.mjs → _storageType-dRTFMKG3.mjs} +2 -2
  46. package/dist/client/{_storageType-4wSxI__0.mjs.map → _storageType-dRTFMKG3.mjs.map} +1 -1
  47. package/dist/client/{about-Bo9vxGHy.mjs → about-Nsxkyh9U.mjs} +2 -2
  48. package/dist/client/{about-Bo9vxGHy.mjs.map → about-Nsxkyh9U.mjs.map} +1 -1
  49. package/dist/client/{build-DeJcDjPi.mjs → build-BdRRmNf5.mjs} +3290 -3274
  50. package/dist/client/{build-DeJcDjPi.mjs.map → build-BdRRmNf5.mjs.map} +1 -1
  51. package/dist/client/{constants-BmcGYeR-.mjs → constants-J5nm9hbP.mjs} +15 -15
  52. package/dist/client/{constants-BmcGYeR-.mjs.map → constants-J5nm9hbP.mjs.map} +1 -1
  53. package/dist/client/{flavors-BxFVqgnb.mjs → flavors-_P7R-CeT.mjs} +2 -2
  54. package/dist/client/{flavors-BxFVqgnb.mjs.map → flavors-_P7R-CeT.mjs.map} +1 -1
  55. package/dist/client/{flavors-CfdgjsZY.mjs → flavors-m1qDHzeS.mjs} +238 -221
  56. package/dist/client/flavors-m1qDHzeS.mjs.map +1 -0
  57. package/dist/client/{floatingips-ByRb82wS.mjs → floatingips-Dq4DXQYb.mjs} +90 -90
  58. package/dist/client/{floatingips-ByRb82wS.mjs.map → floatingips-Dq4DXQYb.mjs.map} +1 -1
  59. package/dist/client/{images-CenluYV8.mjs → images-CpM-T_jM.mjs} +2 -2
  60. package/dist/client/{images-CenluYV8.mjs.map → images-CpM-T_jM.mjs.map} +1 -1
  61. package/dist/client/images-DHmVgQAh2.mjs +1890 -0
  62. package/dist/client/images-DHmVgQAh2.mjs.map +1 -0
  63. package/dist/client/{images-C_dX7nY6.mjs → images-Dbjo4yKn.mjs} +2 -2
  64. package/dist/client/{images-C_dX7nY6.mjs.map → images-Dbjo4yKn.mjs.map} +1 -1
  65. package/dist/client/index.d.ts +1 -1
  66. package/dist/client/index.js +382 -351
  67. package/dist/client/index.js.map +1 -1
  68. package/dist/client/{objects-gxSjvbvF.mjs → objects-DKWp9RtR.mjs} +2 -2
  69. package/dist/client/{objects-gxSjvbvF.mjs.map → objects-DKWp9RtR.mjs.map} +1 -1
  70. package/dist/client/{objects-BJM6YeuF.mjs → objects-DaCuy_CB.mjs} +1156 -1156
  71. package/dist/client/{objects-BJM6YeuF.mjs.map → objects-DaCuy_CB.mjs.map} +1 -1
  72. package/dist/client/{pca-Bl8NmoVZ.mjs → pca-C8zWTSSt.mjs} +2 -2
  73. package/dist/client/{pca-Bl8NmoVZ.mjs.map → pca-C8zWTSSt.mjs.map} +1 -1
  74. package/dist/client/pca-CK5-j7Kk.mjs +202 -0
  75. package/dist/client/pca-CK5-j7Kk.mjs.map +1 -0
  76. package/dist/client/{projects-pe2_dCnV.mjs → projects-CHYn7L5e.mjs} +2 -2
  77. package/dist/client/{projects-pe2_dCnV.mjs.map → projects-CHYn7L5e.mjs.map} +1 -1
  78. package/dist/client/{projects-D2iewAzu.mjs → projects-CeLhtLvf.mjs} +2 -2
  79. package/dist/client/{projects-D2iewAzu.mjs.map → projects-CeLhtLvf.mjs.map} +1 -1
  80. package/dist/client/{projects-CgclWI16.mjs → projects-ClViaUuv.mjs} +11 -11
  81. package/dist/client/{projects-CgclWI16.mjs.map → projects-ClViaUuv.mjs.map} +1 -1
  82. package/dist/client/{_projectId-BDSWnMGj.mjs → routeInfo-DlDJZnpg.mjs} +34 -8
  83. package/dist/client/routeInfo-DlDJZnpg.mjs.map +1 -0
  84. package/dist/client/{securitygroups-DahZkVYQ.mjs → securitygroups-CNFLu9zS.mjs} +112 -112
  85. package/dist/client/{securitygroups-DahZkVYQ.mjs.map → securitygroups-CNFLu9zS.mjs.map} +1 -1
  86. package/dist/client/{useListWithFiltering-DaYcu5AB.mjs → useListWithFiltering-v2A0-SZb.mjs} +9 -9
  87. package/dist/client/{useListWithFiltering-DaYcu5AB.mjs.map → useListWithFiltering-v2A0-SZb.mjs.map} +1 -1
  88. package/dist/server/index.d.ts +6 -1
  89. package/dist/server/index.js +37 -12
  90. package/package.json +4 -4
  91. package/dist/client/_imageId-CvfD832b.mjs +0 -534
  92. package/dist/client/_pcaId-BxBt5DXi.mjs +0 -459
  93. package/dist/client/_pcaId-BxBt5DXi.mjs.map +0 -1
  94. package/dist/client/_projectId-BDSWnMGj.mjs.map +0 -1
  95. package/dist/client/_projectId-DS4nR59B.mjs +0 -299
  96. package/dist/client/_projectId-DS4nR59B.mjs.map +0 -1
  97. package/dist/client/flavors-CfdgjsZY.mjs.map +0 -1
  98. package/dist/client/images-CKqIXUq52.mjs +0 -1873
  99. package/dist/client/images-CKqIXUq52.mjs.map +0 -1
  100. package/dist/client/pca-RSiWpJs9.mjs +0 -182
  101. package/dist/client/pca-RSiWpJs9.mjs.map +0 -1
@@ -1,1873 +0,0 @@
1
- import { B as e, C as t, F as n, G as r, H as i, J as a, N as o, P as s, Q as c, R as l, U as u, X as d, a as f, at as p, ct as m, f as h, i as g, it as _, j as ee, k as v, lt as y, n as b, ot as te, q as ne, r as x, s as S, tt as C, u as w, w as T, x as re } from "./build-DeJcDjPi.mjs";
2
- import { n as E, r as D } from "./trpcClient-BzPUgiM2.mjs";
3
- import { t as ie } from "./cn-DM4Cy3jv.mjs";
4
- import { t as O } from "./images-CenluYV8.mjs";
5
- import { t as k } from "./ContentHeader-kx1Th5Sq.mjs";
6
- import { t as A } from "./SortInput-CYv2_Pur.mjs";
7
- import { A as j, C as ae, D as oe, E as se, F as M, I as N, M as P, N as F, O as I, P as L, S as R, T as z, _ as B, a as ce, b as le, c as V, d as H, f as ue, g as U, h as de, i as fe, j as pe, k as me, l as he, m as ge, n as _e, o as ve, p as ye, r as be, s as xe, t as Se, u as Ce, v as we, w as Te, x as Ee, y as De } from "./ImageToastNotifications-TZ3EfQg-.mjs";
8
- import { t as Oe } from "./useProjectId-DBc5lpoU.mjs";
9
- import "./hooks-dSArr2Ca.mjs";
10
- import { n as ke, t as Ae } from "./FiltersInput-DxcyR6Bp.mjs";
11
- import { Fragment as W, jsx as G, jsxs as K } from "react/jsx-runtime";
12
- import { Suspense as je, startTransition as Me, use as Ne, useCallback as Pe, useEffect as Fe, useMemo as Ie, useRef as Le, useState as q } from "react";
13
- import { useNavigate as Re, useParams as J, useSearch as Y } from "@tanstack/react-router";
14
- import { TRPCClientError as ze } from "@trpc/client";
15
- import { Trans as X, useLingui as Z } from "@lingui/react";
16
- import { i18n as Be } from "@lingui/core";
17
- import { ErrorBoundary as Ve } from "react-error-boundary";
18
- import "@trpc/server";
19
- //#region src/client/routes/_auth/projects/$projectId/compute/-components/Images/-components/ImageTableRow.tsx
20
- function He({ image: e, isSelected: t, isPending: n, isAccepted: i, permissions: a, onEditDetails: o, onEditMetadata: c, onDelete: u, onSelect: d, onActivationStatusChange: f, onManageAccess: p, onUpdateVisibility: m, setToastData: h, uploadId: g, uploadProgressPercent: ee, onMemberStatusChanged: v, showSelectColumn: y = !1 }) {
21
- let { i18n: b, _: ne } = Z(), { id: x, name: S, status: w, visibility: re, size: E, disk_format: ie, created_at: O, owner: k } = e, A = S || b._({ id: "MEIAzV" }), { projectId: j } = J({ from: "/_auth/projects/$projectId/compute/images/" }), ae = Re(), oe = D.useUtils(), se = D.compute.updateImageMember.useMutation({ onSuccess: () => {
22
- oe.compute.listImagesWithPagination.invalidate(), oe.compute.listSharedImagesByMemberStatus.invalidate();
23
- } }), P = async (e) => {
24
- try {
25
- await se.mutateAsync({
26
- project_id: j,
27
- imageId: x,
28
- memberId: j,
29
- status: e
30
- }), h(H(e, { onDismiss: () => h(null) })), v?.();
31
- } catch (e) {
32
- let t = e?.message;
33
- h(Ce(t, { onDismiss: () => h(null) }));
34
- }
35
- }, I = j === k, R = n || i, z = se.isPending;
36
- return /*#__PURE__*/ K(T, {
37
- "data-testid": `image-row-${x}`,
38
- onClick: () => ae({
39
- to: "/projects/$projectId/compute/images/$imageId",
40
- params: {
41
- projectId: j,
42
- imageId: x
43
- }
44
- }),
45
- children: [
46
- y && /*#__PURE__*/ G(r, {
47
- onClick: (e) => e.stopPropagation(),
48
- children: /*#__PURE__*/ G(te, {
49
- checked: t,
50
- onChange: () => d(e)
51
- })
52
- }),
53
- /*#__PURE__*/ G(r, { children: w }),
54
- /*#__PURE__*/ G(r, { children: A }),
55
- /*#__PURE__*/ G(r, { children: re }),
56
- /*#__PURE__*/ G(r, { children: e.protected ? b._({ id: "l75CjT" }) : b._({ id: "1UzENP" }) }),
57
- /*#__PURE__*/ G(r, { children: g && g === x ? `${ee}%` : /*#__PURE__*/ G(N, { size: E }) }),
58
- /*#__PURE__*/ G(r, { children: ie || b._({ id: "fj5byd" }) }),
59
- /*#__PURE__*/ G(r, { children: O ? new Date(O).toLocaleDateString() : b._({ id: "fj5byd" }) }),
60
- /*#__PURE__*/ G(r, {
61
- onClick: (e) => e.stopPropagation(),
62
- children: z ? /*#__PURE__*/ G(l, {
63
- variant: "primary",
64
- size: "small"
65
- }) : /*#__PURE__*/ G(s, { children: /*#__PURE__*/ K(C, { children: [
66
- /*#__PURE__*/ G(_, {
67
- label: b._({ id: "v0hPHE" }),
68
- onClick: () => ae({
69
- to: "/projects/$projectId/compute/images/$imageId",
70
- params: {
71
- projectId: j,
72
- imageId: x
73
- }
74
- })
75
- }),
76
- R && a.canUpdateMember && /*#__PURE__*/ K(W, { children: [n && /*#__PURE__*/ G(_, {
77
- label: b._({ id: "g3UF2V" }),
78
- onClick: () => P(M.ACCEPTED)
79
- }), /*#__PURE__*/ G(_, {
80
- label: b._({ id: "1t/NnN" }),
81
- onClick: () => P(M.REJECTED)
82
- })] }),
83
- !R && a.canUpdate && /*#__PURE__*/ K(W, { children: [
84
- /*#__PURE__*/ G(_, {
85
- label: b._({ id: "Y1YKad" }),
86
- onClick: () => o(e)
87
- }),
88
- /*#__PURE__*/ G(_, {
89
- label: b._({ id: "SIfYq6" }),
90
- onClick: () => c(e)
91
- }),
92
- /*#__PURE__*/ G(_, {
93
- label: e.status === F.DEACTIVATED ? b._({ id: "FQBaXG" }) : b._({ id: "5y3O+A" }),
94
- onClick: () => f(e)
95
- }),
96
- e.visibility === L.SHARED && I && (a.canCreateMember || a.canDeleteMember) && /*#__PURE__*/ G(_, {
97
- label: b._({ id: "cWbW6w" }),
98
- onClick: () => p(e)
99
- }),
100
- e.visibility === L.PRIVATE && /*#__PURE__*/ G(_, {
101
- label: b._({ id: "gMYsdZ" }),
102
- onClick: () => m(e.id, L.SHARED, A)
103
- })
104
- ] }),
105
- !R && a.canDelete && !e.protected && /*#__PURE__*/ G(_, {
106
- label: b._({ id: "cnGeoo" }),
107
- onClick: () => u(e)
108
- })
109
- ] }) })
110
- })
111
- ]
112
- }, x);
113
- }
114
- //#endregion
115
- //#region src/server/Compute/helpers/imageHelpers.ts
116
- var Ue = {
117
- qcow2: [
118
- "bare",
119
- "ova",
120
- "docker"
121
- ],
122
- raw: [
123
- "bare",
124
- "ova",
125
- "docker"
126
- ],
127
- vmdk: ["bare", "ova"],
128
- vhd: ["bare", "ova"],
129
- vhdx: ["bare", "ova"],
130
- vdi: ["bare", "ova"],
131
- iso: ["bare"],
132
- ami: ["ami"],
133
- aki: ["aki"],
134
- ari: ["ari"],
135
- ploop: ["bare"]
136
- }, We = {
137
- qcow2: "bare",
138
- raw: "bare",
139
- vmdk: "bare",
140
- vhd: "bare",
141
- vhdx: "bare",
142
- vdi: "bare",
143
- iso: "bare",
144
- ami: "ami",
145
- aki: "aki",
146
- ari: "ari",
147
- ploop: "bare"
148
- };
149
- function Ge(e) {
150
- return Ue[e] || [];
151
- }
152
- function Ke(e) {
153
- return We[e] || "";
154
- }
155
- function Q(e, t) {
156
- return Ge(e).includes(t);
157
- }
158
- //#endregion
159
- //#region src/client/routes/_auth/projects/$projectId/compute/-components/Images/-components/CreateImageModal.tsx
160
- var qe = {
161
- name: "",
162
- tags: [],
163
- visibility: L.PRIVATE,
164
- disk_format: void 0,
165
- container_format: void 0,
166
- protected: !1,
167
- min_disk: 0,
168
- min_ram: 0
169
- }, Je = ({ isOpen: t, onClose: n, onCreate: r, isLoading: a = !1, isUploadPending: o = !1, uploadProgressPercent: s }) => {
170
- let { i18n: d, _: p } = Z(), [h, g] = q({ ...qe }), [_, v] = q(""), [b, ne] = q(null), [C, T] = q({}), [re, E] = q(!1), [D, O] = q(null), k = h.name.trim() !== "" && b !== null && h.disk_format !== void 0 && h.disk_format.trim() !== "" && h.container_format !== void 0 && h.container_format.trim() !== "" && h.min_disk >= 0 && h.min_ram >= 0, A = Ie(() => h.disk_format ? Ge(h.disk_format) : [], [h.disk_format]), j = [
171
- ".qcow2",
172
- ".raw",
173
- ".vmdk",
174
- ".vhd",
175
- ".vhdx",
176
- ".vdi",
177
- ".ami",
178
- ".ari",
179
- ".aki",
180
- ".iso",
181
- ".ploop",
182
- ".img"
183
- ], ae = j.join(", "), oe = (e) => {
184
- let { name: t, value: n, type: r, checked: i } = e.target;
185
- g((e) => ({
186
- ...e,
187
- [t]: r === "checkbox" ? i : n
188
- })), C[t] && T((e) => {
189
- let n = { ...e };
190
- return delete n[t], n;
191
- });
192
- }, se = (e) => {
193
- let { name: t, value: n } = e.target;
194
- t === "name" && (!n || n.trim() === "") && T((e) => ({
195
- ...e,
196
- name: d._({ id: "wyIOMP" })
197
- }));
198
- }, M = (e, t) => {
199
- if (e === "disk_format") {
200
- let e = t, n = Ke(e);
201
- g((t) => ({
202
- ...t,
203
- disk_format: e,
204
- container_format: n
205
- }));
206
- } else g((n) => ({
207
- ...n,
208
- [e]: t
209
- }));
210
- C[e] && T((t) => {
211
- let n = { ...t };
212
- return delete n[e], n;
213
- });
214
- }, N = (e, t) => {
215
- let n = t === "" ? 0 : parseInt(t, 10);
216
- isNaN(n) || (g((t) => ({
217
- ...t,
218
- [e]: n
219
- })), C[e] && T((t) => {
220
- let n = { ...t };
221
- return delete n[e], n;
222
- }));
223
- }, F = (e, t) => {
224
- t < 0 && (e === "min_disk" ? T((e) => ({
225
- ...e,
226
- min_disk: d._({ id: "K3bUTE" })
227
- })) : e === "min_ram" && T((e) => ({
228
- ...e,
229
- min_ram: d._({ id: "PEGvy+" })
230
- })));
231
- }, I = (e) => {
232
- let t = e.name.toLowerCase();
233
- j.some((e) => t.endsWith(e)) ? (ne(e), C.file && T((e) => {
234
- let t = { ...e };
235
- return delete t.file, t;
236
- })) : T((e) => ({
237
- ...e,
238
- file: d._({
239
- id: "qzIZOL",
240
- values: { supportedFileFormats: ae }
241
- })
242
- }));
243
- }, R = (e) => {
244
- let t = e.target.files?.[0];
245
- t && I(t);
246
- }, z = (e) => {
247
- e.preventDefault(), e.stopPropagation(), E(!0);
248
- }, B = (e) => {
249
- e.preventDefault(), e.stopPropagation(), E(!1);
250
- }, ce = (e) => {
251
- e.preventDefault(), e.stopPropagation(), E(!1);
252
- let t = e.dataTransfer.files;
253
- t && t.length > 0 && I(t[0]);
254
- }, le = (e) => {
255
- v(e.target.value);
256
- }, V = () => {
257
- let e = _.trim();
258
- if (e !== "") {
259
- if (h.tags.includes(e)) {
260
- v("");
261
- return;
262
- }
263
- g((t) => ({
264
- ...t,
265
- tags: [...t.tags, e]
266
- })), v("");
267
- }
268
- }, H = (e) => {
269
- e.key === "Enter" && (e.preventDefault(), V());
270
- }, ue = (e) => {
271
- g((t) => ({
272
- ...t,
273
- tags: t.tags.filter((t) => t !== e)
274
- }));
275
- }, U = () => {
276
- let e = {};
277
- return (!h.name || h.name.trim() === "") && (e.name = d._({ id: "wyIOMP" })), b || (e.file = d._({ id: "aTqCTq" })), (!h.disk_format || h.disk_format.trim() === "") && (e.disk_format = d._({ id: "LK0pQN" })), (!h.container_format || h.container_format.trim() === "") && (e.container_format = d._({ id: "J4DKSM" })), h.disk_format && h.container_format && (Q(h.disk_format, h.container_format) || (e.container_format = d._({ id: "BgMp/T" }))), h.min_disk < 0 && (e.min_disk = d._({ id: "K3bUTE" })), h.min_ram < 0 && (e.min_ram = d._({ id: "PEGvy+" })), T(e), Object.keys(e).length === 0;
278
- }, de = async (e) => {
279
- if (e.preventDefault(), O(null), !U()) {
280
- O(d._({ id: "CBFSfX" }));
281
- return;
282
- }
283
- try {
284
- await r({
285
- name: h.name.trim(),
286
- tags: h.tags,
287
- visibility: h.visibility,
288
- disk_format: h.disk_format,
289
- container_format: h.container_format,
290
- protected: h.protected,
291
- min_disk: h.min_disk,
292
- min_ram: h.min_ram
293
- }, b), fe();
294
- } catch (e) {
295
- O(e instanceof Error ? e.message : d._({ id: "TQn3hH" }));
296
- }
297
- }, fe = () => {
298
- g({ ...qe }), v(""), ne(null), T({}), O(null), n();
299
- };
300
- return /*#__PURE__*/ K(x, {
301
- open: t,
302
- onCancel: a ? void 0 : fe,
303
- size: "large",
304
- title: d._({ id: "xw2UtT" }),
305
- onConfirm: de,
306
- confirmButtonLabel: d._({ id: "a/nTb8" }),
307
- cancelButtonLabel: d._({ id: "dEgA5A" }),
308
- disableConfirmButton: a || !k,
309
- closeable: !a,
310
- closeOnEsc: !a,
311
- children: [
312
- a && !s && /*#__PURE__*/ K(c, {
313
- distribution: "center",
314
- alignment: "center",
315
- className: "mt-4",
316
- children: [
317
- /*#__PURE__*/ G(l, { variant: "primary" }),
318
- !o && /*#__PURE__*/ G(X, { id: "98Fs4G" }),
319
- o && /*#__PURE__*/ G(X, { id: "3q1GLx" })
320
- ]
321
- }),
322
- a && !!s && /*#__PURE__*/ G("div", {
323
- className: "bg-neutral-quaternary mt-4 w-full rounded-full",
324
- children: /*#__PURE__*/ K("div", {
325
- className: "bg-theme-info flex h-4 items-center justify-center rounded-full p-0.5 text-center text-xs leading-none font-medium text-white",
326
- style: { width: `${s}%` },
327
- children: [s, "%"]
328
- })
329
- }),
330
- !a && /*#__PURE__*/ K(f, {
331
- className: "mb-6",
332
- children: [
333
- D && /*#__PURE__*/ G(e, {
334
- variant: "error",
335
- className: "mb-6",
336
- children: D
337
- }),
338
- /*#__PURE__*/ G(i, {
339
- className: "mb-6",
340
- children: /*#__PURE__*/ G(S, { children: /*#__PURE__*/ K("div", {
341
- className: "w-full",
342
- children: [
343
- /*#__PURE__*/ K("label", {
344
- htmlFor: "image-file",
345
- className: "mb-2 block text-sm font-medium text-gray-900",
346
- children: [d._({ id: "UKwOYH" }), /*#__PURE__*/ G("span", {
347
- className: "ml-1 text-red-500",
348
- children: "*"
349
- })]
350
- }),
351
- /*#__PURE__*/ G("div", {
352
- className: "flex w-full items-center justify-center",
353
- children: /*#__PURE__*/ K("label", {
354
- htmlFor: "image-file",
355
- onDragOver: z,
356
- onDragLeave: B,
357
- onDrop: ce,
358
- className: ie("flex h-24 w-full cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed transition-all", re ? "border-blue-500 bg-blue-50" : "border-gray-300 bg-gray-50 hover:bg-gray-100"),
359
- children: [/*#__PURE__*/ K("div", {
360
- className: "flex flex-col items-center justify-center pt-3 pb-3",
361
- children: [
362
- /*#__PURE__*/ G("svg", {
363
- className: ie("mb-1 h-6 w-6 transition-colors", re ? "text-blue-500" : "text-gray-500"),
364
- "aria-hidden": "true",
365
- xmlns: "http://www.w3.org/2000/svg",
366
- fill: "none",
367
- viewBox: "0 0 20 16",
368
- children: /*#__PURE__*/ G("path", {
369
- stroke: "currentColor",
370
- strokeLinecap: "round",
371
- strokeLinejoin: "round",
372
- strokeWidth: "2",
373
- d: "M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 5.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"
374
- })
375
- }),
376
- /*#__PURE__*/ G("p", {
377
- className: ie("text-xs transition-colors", re ? "font-semibold text-blue-600" : "text-gray-500"),
378
- children: re ? /*#__PURE__*/ G("span", { children: d._({ id: "vXmL4D" }) }) : /*#__PURE__*/ K(W, { children: [
379
- /*#__PURE__*/ G("span", {
380
- className: "font-semibold",
381
- children: d._({ id: "gYe+hC" })
382
- }),
383
- " ",
384
- d._({ id: "Np28ib" })
385
- ] })
386
- }),
387
- /*#__PURE__*/ G("p", {
388
- className: "text-xs text-gray-400",
389
- children: d._({ id: "jBIkmi" })
390
- })
391
- ]
392
- }), /*#__PURE__*/ G("input", {
393
- id: "image-file",
394
- type: "file",
395
- className: "hidden",
396
- onChange: R,
397
- accept: ae,
398
- disabled: a
399
- })]
400
- })
401
- }),
402
- b && /*#__PURE__*/ K("div", {
403
- className: "mt-2 flex items-center justify-between rounded-lg border border-green-200 bg-green-50 p-2 text-xs",
404
- children: [/*#__PURE__*/ K("div", {
405
- className: "flex items-center",
406
- children: [/*#__PURE__*/ G("svg", {
407
- className: "mr-2 h-4 w-4 text-green-600",
408
- fill: "currentColor",
409
- viewBox: "0 0 20 20",
410
- children: /*#__PURE__*/ G("path", {
411
- fillRule: "evenodd",
412
- d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
413
- clipRule: "evenodd"
414
- })
415
- }), /*#__PURE__*/ G("span", {
416
- className: "text-gray-700",
417
- children: b.name
418
- })]
419
- }), /*#__PURE__*/ G("button", {
420
- type: "button",
421
- onClick: () => {
422
- ne(null), C.file && T((e) => {
423
- let t = { ...e };
424
- return delete t.file, t;
425
- });
426
- },
427
- className: "font-medium text-red-600 hover:text-red-800",
428
- disabled: a,
429
- children: d._({ id: "t/YqKh" })
430
- })]
431
- }),
432
- C.file && /*#__PURE__*/ G("p", {
433
- className: "text-theme-error mt-1 text-xs text-red-600",
434
- children: C.file
435
- })
436
- ]
437
- }) })
438
- }),
439
- /*#__PURE__*/ K(i, {
440
- className: "mb-6",
441
- children: [
442
- /*#__PURE__*/ G(S, {
443
- className: "mb-6",
444
- children: /*#__PURE__*/ G(u, {
445
- id: "name",
446
- name: "name",
447
- label: d._({ id: "ExLULX" }),
448
- value: h.name,
449
- onChange: oe,
450
- onBlur: se,
451
- required: !0,
452
- errortext: C.name,
453
- placeholder: d._({ id: "PsEGri" }),
454
- disabled: a
455
- })
456
- }),
457
- /*#__PURE__*/ G(S, {
458
- className: "mb-6",
459
- children: /*#__PURE__*/ K("div", {
460
- className: "w-full",
461
- children: [/*#__PURE__*/ K(c, {
462
- gap: "1",
463
- direction: "horizontal",
464
- alignment: "start",
465
- children: [/*#__PURE__*/ G("div", {
466
- className: "flex-1",
467
- children: /*#__PURE__*/ G(u, {
468
- id: "tags",
469
- name: "tags",
470
- label: d._({ id: "OYHzN1" }),
471
- value: _,
472
- onChange: le,
473
- onKeyDown: H,
474
- helptext: d._({ id: "AN0DBJ" }),
475
- placeholder: d._({ id: "tmpGvt" }),
476
- disabled: a
477
- })
478
- }), /*#__PURE__*/ G(m, {
479
- variant: "primary",
480
- onClick: V,
481
- disabled: a || _.trim() === "",
482
- children: /*#__PURE__*/ G(X, { id: "m16xKo" })
483
- })]
484
- }), h.tags.length > 0 && /*#__PURE__*/ G(c, {
485
- gap: "1",
486
- wrap: !0,
487
- alignment: "center",
488
- className: "mt-1",
489
- children: h.tags.map((e) => /*#__PURE__*/ G(ee, {
490
- closeable: !0,
491
- pillKey: "",
492
- pillValue: e,
493
- onClose: () => ue(e)
494
- }, e))
495
- })]
496
- })
497
- }),
498
- /*#__PURE__*/ G(S, {
499
- className: "mb-6",
500
- children: /*#__PURE__*/ K(y, {
501
- id: "visibility",
502
- name: "visibility",
503
- label: d._({ id: "2q/Q7x" }),
504
- value: h.visibility,
505
- onChange: (e) => M("visibility", e),
506
- disabled: a,
507
- loading: a,
508
- children: [
509
- /*#__PURE__*/ G(w, {
510
- value: L.PUBLIC,
511
- label: d._({ id: "7d1a0d" })
512
- }),
513
- /*#__PURE__*/ G(w, {
514
- value: L.PRIVATE,
515
- label: d._({ id: "zwBp5t" })
516
- }),
517
- /*#__PURE__*/ G(w, {
518
- value: L.SHARED,
519
- label: d._({ id: "0Gd0NU" })
520
- }),
521
- /*#__PURE__*/ G(w, {
522
- value: L.COMMUNITY,
523
- label: d._({ id: "chL5IG" })
524
- })
525
- ]
526
- })
527
- }),
528
- /*#__PURE__*/ G(S, {
529
- className: "mb-6",
530
- children: /*#__PURE__*/ K(c, {
531
- direction: "horizontal",
532
- gap: "3",
533
- distribution: "evenly",
534
- className: "w-full",
535
- children: [/*#__PURE__*/ G("div", {
536
- className: "flex-1",
537
- children: /*#__PURE__*/ K(y, {
538
- id: "disk_format",
539
- name: "disk_format",
540
- label: d._({ id: "NopYGU" }),
541
- value: h.disk_format,
542
- onChange: (e) => M("disk_format", e),
543
- disabled: a,
544
- loading: a,
545
- required: !0,
546
- errortext: C.disk_format,
547
- children: [
548
- /*#__PURE__*/ G(w, {
549
- value: P.QCOW2,
550
- label: "QCOW2 - QEMU Emulator"
551
- }),
552
- /*#__PURE__*/ G(w, {
553
- value: P.RAW,
554
- label: "Raw"
555
- }),
556
- /*#__PURE__*/ G(w, {
557
- value: P.VMDK,
558
- label: "VMDK - Virtual Machine Disk"
559
- }),
560
- /*#__PURE__*/ G(w, {
561
- value: P.VHD,
562
- label: "VHD - Virtual Hard Disk"
563
- }),
564
- /*#__PURE__*/ G(w, {
565
- value: P.VHDX,
566
- label: "VHDX - Virtual Hard Disk Extended"
567
- }),
568
- /*#__PURE__*/ G(w, {
569
- value: P.VDI,
570
- label: "VDI - Virtual Disk Image"
571
- }),
572
- /*#__PURE__*/ G(w, {
573
- value: P.AMI,
574
- label: "AMI - Amazon Machine Image"
575
- }),
576
- /*#__PURE__*/ G(w, {
577
- value: P.ARI,
578
- label: "ARI - Amazon Ramdisk Image"
579
- }),
580
- /*#__PURE__*/ G(w, {
581
- value: P.AKI,
582
- label: "AKI - Amazon Kernel Image"
583
- }),
584
- /*#__PURE__*/ G(w, {
585
- value: P.ISO,
586
- label: "ISO - Optical Disk Image"
587
- }),
588
- /*#__PURE__*/ G(w, {
589
- value: P.PLOOP,
590
- label: "PLOOP - Virtuozzo/Parallels Loopback Disk"
591
- })
592
- ]
593
- })
594
- }), /*#__PURE__*/ G("div", {
595
- className: "flex-1",
596
- children: /*#__PURE__*/ G(y, {
597
- id: "container_format",
598
- name: "container_format",
599
- label: d._({ id: "6/xipy" }),
600
- value: h.container_format,
601
- onChange: (e) => M("container_format", e),
602
- disabled: a || !h.disk_format || !A.length,
603
- required: !0,
604
- errortext: C.container_format,
605
- helptext: !A.length && d._({ id: "A7CVME" }),
606
- children: A.map((e) => /*#__PURE__*/ G(w, {
607
- value: e,
608
- label: e.toUpperCase()
609
- }, e))
610
- })
611
- })]
612
- })
613
- }),
614
- /*#__PURE__*/ G(S, {
615
- className: "mb-0",
616
- children: /*#__PURE__*/ G(te, {
617
- id: "protected",
618
- name: "protected",
619
- label: d._({ id: "644xgx" }),
620
- checked: h.protected,
621
- onChange: oe,
622
- helptext: d._({ id: "aV6KPH" }),
623
- disabled: a
624
- })
625
- })
626
- ]
627
- }),
628
- /*#__PURE__*/ G(i, {
629
- className: "mb-6",
630
- children: /*#__PURE__*/ G(S, {
631
- className: "mb-0",
632
- children: /*#__PURE__*/ K(c, {
633
- direction: "horizontal",
634
- gap: "3",
635
- distribution: "evenly",
636
- className: "w-full",
637
- children: [/*#__PURE__*/ G("div", {
638
- className: "flex-1",
639
- children: /*#__PURE__*/ G(u, {
640
- id: "min_disk",
641
- name: "min_disk",
642
- label: d._({ id: "NixRmA" }),
643
- type: "number",
644
- value: String(h.min_disk),
645
- onChange: (e) => N("min_disk", e.target.value),
646
- onBlur: () => F("min_disk", h.min_disk),
647
- helptext: d._({ id: "4fh0Wj" }),
648
- errortext: C.min_disk,
649
- disabled: a
650
- })
651
- }), /*#__PURE__*/ G("div", {
652
- className: "flex-1",
653
- children: /*#__PURE__*/ G(u, {
654
- id: "min_ram",
655
- name: "min_ram",
656
- label: d._({ id: "CgZxr7" }),
657
- type: "number",
658
- value: String(h.min_ram),
659
- onChange: (e) => N("min_ram", e.target.value),
660
- onBlur: () => F("min_ram", h.min_ram),
661
- helptext: d._({ id: "KsIM0b" }),
662
- errortext: C.min_ram,
663
- disabled: a
664
- })
665
- })]
666
- })
667
- })
668
- })
669
- ]
670
- })
671
- ]
672
- });
673
- }, Ye = ({ deletableImages: t, protectedImages: n, isOpen: r, isLoading: i, onClose: a, onDelete: o }) => {
674
- let { i18n: s, _: u } = Z(), d = t.length, f = n.length;
675
- return /*#__PURE__*/ K(x, {
676
- onCancel: a,
677
- size: "small",
678
- title: s._({ id: "JtHgVz" }),
679
- open: r,
680
- modalFooter: /*#__PURE__*/ G(h, {
681
- className: "flex justify-end",
682
- children: /*#__PURE__*/ K(g, { children: [/*#__PURE__*/ G(m, {
683
- variant: "default",
684
- onClick: a,
685
- children: /*#__PURE__*/ G(X, { id: "dEgA5A" })
686
- }), /*#__PURE__*/ G(m, {
687
- variant: "primary-danger",
688
- onClick: (e) => {
689
- e.preventDefault(), o(t);
690
- },
691
- disabled: i,
692
- "data-testid": "delete-image-button",
693
- children: /*#__PURE__*/ G(X, { id: "cnGeoo" })
694
- })] })
695
- }),
696
- children: [i && /*#__PURE__*/ G(c, {
697
- distribution: "center",
698
- alignment: "center",
699
- children: /*#__PURE__*/ G(l, { variant: "primary" })
700
- }), !i && /*#__PURE__*/ K("div", {
701
- className: "my-6",
702
- children: [
703
- d > 0 && /*#__PURE__*/ K(W, { children: [/*#__PURE__*/ G(e, {
704
- text: s._({
705
- id: "Dh1qvV",
706
- values: { deletableCount: d }
707
- }),
708
- variant: "danger",
709
- className: "mb-6"
710
- }), /*#__PURE__*/ K("div", {
711
- className: "mb-6",
712
- children: [/*#__PURE__*/ G("h3", {
713
- className: "jn:text-theme-high mb-3 font-semibold",
714
- children: /*#__PURE__*/ G(X, {
715
- id: "rwBVXS",
716
- values: { deletableCount: d }
717
- })
718
- }), /*#__PURE__*/ G("div", {
719
- className: "jn:bg-theme-background-lvl-1 max-h-24 overflow-y-auto rounded p-4",
720
- children: /*#__PURE__*/ G("ul", {
721
- className: "space-y-2",
722
- children: t.map((e) => /*#__PURE__*/ G("li", {
723
- className: "jn:text-theme-default font-mono",
724
- children: e
725
- }, e))
726
- })
727
- })]
728
- })] }),
729
- f > 0 && /*#__PURE__*/ K("div", {
730
- className: "mb-6",
731
- children: [/*#__PURE__*/ G("h3", {
732
- className: "jn:text-theme-high mb-3 font-semibold",
733
- children: /*#__PURE__*/ G(X, { id: "jtnAf8" })
734
- }), /*#__PURE__*/ G("div", {
735
- className: "jn:bg-theme-warning/10 max-h-24 overflow-y-auto rounded border border-yellow-500/20 p-4",
736
- children: /*#__PURE__*/ G("ul", {
737
- className: "space-y-2",
738
- children: n.map((e) => /*#__PURE__*/ G("li", {
739
- className: "jn:text-theme-default font-mono",
740
- children: e
741
- }, e))
742
- })
743
- })]
744
- }),
745
- /*#__PURE__*/ K("div", {
746
- className: "jn:bg-theme-background-lvl-2 mb-6 rounded p-4",
747
- children: [d > 0 && /*#__PURE__*/ K("div", {
748
- className: "mb-2 flex justify-between",
749
- children: [/*#__PURE__*/ G("span", {
750
- className: "jn:text-theme-default",
751
- children: /*#__PURE__*/ G(X, { id: "MJtNLd" })
752
- }), /*#__PURE__*/ G("span", {
753
- className: "jn:text-theme-highest font-semibold",
754
- children: d
755
- })]
756
- }), f > 0 && /*#__PURE__*/ K("div", {
757
- className: "flex justify-between",
758
- children: [/*#__PURE__*/ G("span", {
759
- className: "jn:text-theme-default",
760
- children: /*#__PURE__*/ G(X, { id: "QxBGbh" })
761
- }), /*#__PURE__*/ G("span", {
762
- className: "jn:text-theme-warning font-semibold",
763
- children: f
764
- })]
765
- })]
766
- })
767
- ]
768
- })]
769
- });
770
- }, Xe = ({ activeImages: e, deactivatedImages: t, isOpen: n, isLoading: r, onClose: i, onDeactivate: a }) => {
771
- let { i18n: o, _: s } = Z(), u = e.length, d = t.length, f = (t) => {
772
- t.preventDefault(), a(e);
773
- };
774
- return /*#__PURE__*/ K(x, {
775
- onCancel: i,
776
- size: "small",
777
- title: o._({ id: "+9CXS9" }),
778
- open: n,
779
- onConfirm: (e) => {
780
- f(e), i();
781
- },
782
- confirmButtonLabel: o._({ id: "5y3O+A" }),
783
- cancelButtonLabel: o._({ id: "dEgA5A" }),
784
- disableConfirmButton: r,
785
- children: [r && /*#__PURE__*/ G(c, {
786
- distribution: "center",
787
- alignment: "center",
788
- children: /*#__PURE__*/ G(l, { variant: "primary" })
789
- }), !r && /*#__PURE__*/ K("div", {
790
- className: "my-6",
791
- children: [
792
- u > 0 && /*#__PURE__*/ K(W, { children: [/*#__PURE__*/ G("p", {
793
- className: "mb-6",
794
- children: /*#__PURE__*/ G(X, {
795
- id: "zm7+/D",
796
- values: { activeCount: u },
797
- components: { 0: /*#__PURE__*/ G("strong", {}) }
798
- })
799
- }), /*#__PURE__*/ K("div", {
800
- className: "mb-6",
801
- children: [/*#__PURE__*/ G("h3", {
802
- className: "jn:text-theme-high mb-3 font-semibold",
803
- children: /*#__PURE__*/ G(X, {
804
- id: "ryxYVo",
805
- values: { activeCount: u }
806
- })
807
- }), /*#__PURE__*/ G("div", {
808
- className: "jn:bg-theme-background-lvl-1 max-h-24 overflow-y-auto rounded p-4",
809
- children: /*#__PURE__*/ G("ul", {
810
- className: "space-y-2",
811
- children: e.map((e) => /*#__PURE__*/ G("li", {
812
- className: "jn:text-theme-default font-mono",
813
- children: e
814
- }, e))
815
- })
816
- })]
817
- })] }),
818
- d > 0 && /*#__PURE__*/ K("div", {
819
- className: "mb-6",
820
- children: [/*#__PURE__*/ G("h3", {
821
- className: "jn:text-theme-high mb-3 font-semibold",
822
- children: /*#__PURE__*/ G(X, { id: "JpZn1L" })
823
- }), /*#__PURE__*/ G("div", {
824
- className: "jn:bg-theme-background-lvl-1 max-h-24 overflow-y-auto rounded p-4",
825
- children: /*#__PURE__*/ G("ul", {
826
- className: "space-y-2",
827
- children: t.map((e) => /*#__PURE__*/ G("li", {
828
- className: "jn:text-theme-default font-mono",
829
- children: e
830
- }, e))
831
- })
832
- })]
833
- }),
834
- /*#__PURE__*/ K("div", {
835
- className: "jn:bg-theme-background-lvl-2 mb-6 rounded p-4",
836
- children: [u > 0 && /*#__PURE__*/ K("div", {
837
- className: "mb-2 flex justify-between",
838
- children: [/*#__PURE__*/ G("span", {
839
- className: "jn:text-theme-default",
840
- children: /*#__PURE__*/ G(X, { id: "rD9yV1" })
841
- }), /*#__PURE__*/ G("span", {
842
- className: "jn:text-theme-highest font-semibold",
843
- children: u
844
- })]
845
- }), d > 0 && /*#__PURE__*/ K("div", {
846
- className: "flex justify-between",
847
- children: [/*#__PURE__*/ G("span", {
848
- className: "jn:text-theme-default",
849
- children: /*#__PURE__*/ G(X, { id: "NH2fsP" })
850
- }), /*#__PURE__*/ G("span", {
851
- className: "jn:text-theme-warning font-semibold",
852
- children: d
853
- })]
854
- })]
855
- })
856
- ]
857
- })]
858
- });
859
- }, Ze = ({ deactivatedImages: e, activeImages: t, isOpen: n, isLoading: r, onClose: i, onActivate: a }) => {
860
- let { i18n: o, _: s } = Z(), u = e.length, d = t.length;
861
- return /*#__PURE__*/ K(x, {
862
- onCancel: i,
863
- size: "small",
864
- title: o._({ id: "UdcGJu" }),
865
- open: n,
866
- onConfirm: (t) => {
867
- t.preventDefault(), a(e);
868
- },
869
- confirmButtonLabel: o._({ id: "FQBaXG" }),
870
- cancelButtonLabel: o._({ id: "dEgA5A" }),
871
- disableConfirmButton: r,
872
- children: [r && /*#__PURE__*/ G(c, {
873
- distribution: "center",
874
- alignment: "center",
875
- children: /*#__PURE__*/ G(l, { variant: "primary" })
876
- }), !r && /*#__PURE__*/ K("div", {
877
- className: "my-6",
878
- children: [
879
- u > 0 && /*#__PURE__*/ K(W, { children: [/*#__PURE__*/ G("p", {
880
- className: "mb-6",
881
- children: /*#__PURE__*/ G(X, {
882
- id: "MgZyuJ",
883
- values: { deactivatedCount: u },
884
- components: { 0: /*#__PURE__*/ G("strong", {}) }
885
- })
886
- }), /*#__PURE__*/ K("div", {
887
- className: "mb-6",
888
- children: [/*#__PURE__*/ G("h3", {
889
- className: "jn:text-theme-high mb-3 font-semibold",
890
- children: /*#__PURE__*/ G(X, {
891
- id: "shKIZu",
892
- values: { deactivatedCount: u }
893
- })
894
- }), /*#__PURE__*/ G("div", {
895
- className: "jn:bg-theme-background-lvl-1 max-h-24 overflow-y-auto rounded p-4",
896
- children: /*#__PURE__*/ G("ul", {
897
- className: "space-y-2",
898
- children: e.map((e) => /*#__PURE__*/ G("li", {
899
- className: "jn:text-theme-default font-mono",
900
- children: e
901
- }, e))
902
- })
903
- })]
904
- })] }),
905
- d > 0 && /*#__PURE__*/ K("div", {
906
- className: "mb-6",
907
- children: [/*#__PURE__*/ G("h3", {
908
- className: "jn:text-theme-high mb-3 font-semibold",
909
- children: /*#__PURE__*/ G(X, { id: "pOPvlj" })
910
- }), /*#__PURE__*/ G("div", {
911
- className: "jn:bg-theme-warning/10 max-h-24 overflow-y-auto rounded border border-yellow-500/20 p-4",
912
- children: /*#__PURE__*/ G("ul", {
913
- className: "space-y-2",
914
- children: t.map((e) => /*#__PURE__*/ G("li", {
915
- className: "jn:text-theme-default font-mono",
916
- children: e
917
- }, e))
918
- })
919
- })]
920
- }),
921
- /*#__PURE__*/ K("div", {
922
- className: "jn:bg-theme-background-lvl-2 mb-6 rounded p-4",
923
- children: [u > 0 && /*#__PURE__*/ K("div", {
924
- className: "mb-2 flex justify-between",
925
- children: [/*#__PURE__*/ G("span", {
926
- className: "jn:text-theme-default",
927
- children: /*#__PURE__*/ G(X, { id: "4fvDRe" })
928
- }), /*#__PURE__*/ G("span", {
929
- className: "jn:text-theme-highest font-semibold",
930
- children: u
931
- })]
932
- }), d > 0 && /*#__PURE__*/ K("div", {
933
- className: "flex justify-between",
934
- children: [/*#__PURE__*/ G("span", {
935
- className: "jn:text-theme-default",
936
- children: /*#__PURE__*/ G(X, { id: "x5l/TK" })
937
- }), /*#__PURE__*/ G("span", {
938
- className: "jn:text-theme-warning font-semibold",
939
- children: d
940
- })]
941
- })]
942
- })
943
- ]
944
- })]
945
- });
946
- }, Qe = ({ isOpen: t, onClose: n, image: r, permissions: { canCreateMember: i, canDeleteMember: a } }) => {
947
- let { i18n: o, _: s } = Z(), c = Oe(), [l, u] = q(null), [d, f] = q(!1), { data: p, isLoading: m } = D.compute.listImageMembers.useQuery({
948
- project_id: c,
949
- imageId: r?.id || ""
950
- }, { enabled: t && !!r?.id }), h = () => {
951
- u(null), f(!1), n();
952
- };
953
- if (!t || !r) return null;
954
- let g = r.name || r.id;
955
- return /*#__PURE__*/ G(x, {
956
- onCancel: h,
957
- title: o._({
958
- id: "UQ7Wyv",
959
- values: { imageName: g }
960
- }),
961
- open: t,
962
- size: "xl",
963
- children: /*#__PURE__*/ K("div", { children: [l && /*#__PURE__*/ G(e, {
964
- onDismiss: () => u(null),
965
- text: l.text,
966
- variant: l.type,
967
- className: "mb-4"
968
- }), /*#__PURE__*/ G(j, {
969
- projectId: c,
970
- image: r,
971
- imageMembers: p,
972
- isMembersLoading: m,
973
- canAdd: i,
974
- canRemove: a,
975
- isAddingMember: d,
976
- setIsAddingMember: f,
977
- setMessage: u
978
- })] })
979
- });
980
- };
981
- //#endregion
982
- //#region src/client/routes/_auth/projects/$projectId/compute/-components/Images/-components/ImageListView.tsx
983
- function $e({ images: e, suggestedImages: t, acceptedImages: i, permissions: o, isFetching: s, currentPage: u = 1, totalPages: d = 1, onPageChange: f, children: p, selectedImages: m, setSelectedImages: h, deleteAllModalOpen: g, setDeleteAllModalOpen: _, deactivateAllModalOpen: ee, setDeactivateAllModalOpen: y, activateAllModalOpen: b, setActivateAllModalOpen: x, createModalOpen: S, setCreateModalOpen: C, deletableImages: w, protectedImages: ie, activeImages: O, deactivatedImages: k, onImageUpdated: A, onImageDeleted: j, onMemberStatusChanged: M, hasAnyBulkAction: N }) {
984
- let P = Oe(), [L, H] = q(null), [pe, Ce] = q(!1), [ke, Ae] = q(!1), [je, Me] = q(!1), [Ne, Pe] = q(!1), [Fe, Ie] = q(!1), [Le, Re] = q(!1), [J, Y] = q(null), [Z, Ve] = q(!1), [Ue, We] = q(null), [Ge, Ke] = q(!1), Q = D.useUtils(), qe = D.compute.deleteImage.useMutation({ onSuccess: () => {
985
- Q.compute.listImagesWithPagination.invalidate();
986
- } }), $e = D.compute.deactivateImage.useMutation({ onSuccess: () => {
987
- Q.compute.listImagesWithPagination.invalidate(), Q.compute.getImageById.invalidate();
988
- } }), et = D.compute.reactivateImage.useMutation({ onSuccess: () => {
989
- Q.compute.listImagesWithPagination.invalidate(), Q.compute.getImageById.invalidate();
990
- } }), tt = D.compute.deleteImages.useMutation({ onSuccess: () => {
991
- Q.compute.listImagesWithPagination.invalidate(), h([]);
992
- } }), nt = D.compute.activateImages.useMutation({ onSuccess: () => {
993
- Q.compute.listImagesWithPagination.invalidate(), h([]);
994
- } }), rt = D.compute.deactivateImages.useMutation({ onSuccess: () => {
995
- Q.compute.listImagesWithPagination.invalidate(), h([]);
996
- } }), it = D.compute.updateImage.useMutation({ onSuccess: (e) => {
997
- Q.compute.listImagesWithPagination.invalidate(), Q.compute.getImageById.setData({
998
- project_id: P,
999
- imageId: e.id
1000
- }, e);
1001
- } }), at = D.compute.createImage.useMutation({ onSuccess: () => {
1002
- Q.compute.listImagesWithPagination.invalidate();
1003
- } }), ot = D.compute.updateImageVisibility.useMutation({ onSuccess: (e) => {
1004
- A(e);
1005
- } }), { data: st } = D.compute.watchUploadProgress.useSubscription({
1006
- project_id: P,
1007
- uploadId: Ue || ""
1008
- }, { enabled: !!Ue && Ge }), ct = qe.isPending || $e.isPending || et.isPending || tt.isPending || nt.isPending || rt.isPending || it.isPending, $ = () => H(null), lt = async (e, t, n) => {
1009
- try {
1010
- await ot.mutateAsync({
1011
- project_id: P,
1012
- imageId: e,
1013
- visibility: t
1014
- }), H(Te(n, t, { onDismiss: $ }));
1015
- } catch (e) {
1016
- H(ae(n, e?.message || Be._({
1017
- id: "J9cmxx",
1018
- values: { newVisibility: t }
1019
- }), { onDismiss: $ }));
1020
- }
1021
- }, ut = (e, t) => {
1022
- let n = [];
1023
- return Object.entries(e).forEach(([e, r]) => {
1024
- let i = `/${e}`;
1025
- r == null ? e in t && n.push({
1026
- op: "remove",
1027
- path: i
1028
- }) : e in t ? n.push({
1029
- op: "replace",
1030
- path: i,
1031
- value: r
1032
- }) : n.push({
1033
- op: "add",
1034
- path: i,
1035
- value: r
1036
- });
1037
- }), n;
1038
- }, dt = async (e) => {
1039
- if (!J) return !1;
1040
- let t = J.id, n = e.name || J.name || t;
1041
- try {
1042
- let r = ut(e, J), i = await it.mutateAsync({
1043
- project_id: P,
1044
- imageId: t,
1045
- operations: r
1046
- });
1047
- return Ce(!1), H(R(n, { onDismiss: $ })), Y(i), A(i), !0;
1048
- } catch (e) {
1049
- let { message: t } = e;
1050
- return H(Ee(n, t, { onDismiss: $ })), Y(null), !1;
1051
- }
1052
- }, ft = async (e, t) => {
1053
- let n = e.name || "Unnamed";
1054
- try {
1055
- Ve(!0);
1056
- let r = await at.mutateAsync({
1057
- project_id: P,
1058
- ...e
1059
- });
1060
- We(r.id), Ke(!0), await E.compute.uploadImage.mutate(t, { context: { headers: {
1061
- "x-project-id": P,
1062
- "x-upload-id": r.id,
1063
- "x-upload-size": String(t.size)
1064
- } } }), H(de(n, { onDismiss: $ })), Q.compute.listImagesWithPagination.invalidate();
1065
- } catch (e) {
1066
- if (e instanceof ze && e.data.path === "compute.createImage") H(ge(n, e.message, { onDismiss: $ }));
1067
- else {
1068
- let { message: n } = e;
1069
- H(le(t.name, n, { onDismiss: $ }));
1070
- }
1071
- } finally {
1072
- Ve(!1), C(!1), Ke(!1), We(null);
1073
- }
1074
- }, pt = async (e) => {
1075
- Ce(!1), Ae(!1);
1076
- let t = e.name || e.id, n = e.id;
1077
- try {
1078
- await qe.mutateAsync({
1079
- project_id: P,
1080
- imageId: n
1081
- }), H(De(t, { onDismiss: $ })), j(n);
1082
- } catch (e) {
1083
- let { message: t } = e;
1084
- H(we(n, t, { onDismiss: $ }));
1085
- }
1086
- Y(null);
1087
- }, mt = async (e) => {
1088
- e.status === F.DEACTIVATED ? (Y(e), Ie(!0)) : (Y(e), Pe(!0));
1089
- }, ht = async (e) => {
1090
- let t = e.name || e.id, n = e.id;
1091
- try {
1092
- await et.mutateAsync({
1093
- project_id: P,
1094
- imageId: n
1095
- }), Ie(!1), Y(null), H(ue(t, { onDismiss: $ }));
1096
- } catch (e) {
1097
- let { message: t } = e;
1098
- H(ye(n, t, { onDismiss: $ }));
1099
- }
1100
- }, gt = async (e) => {
1101
- let t = e.name || e.id, n = e.id;
1102
- try {
1103
- await $e.mutateAsync({
1104
- project_id: P,
1105
- imageId: n
1106
- }), Pe(!1), Y(null), H(U(t, { onDismiss: $ }));
1107
- } catch (e) {
1108
- let { message: t } = e;
1109
- H(B(n, t, { onDismiss: $ }));
1110
- }
1111
- }, _t = (e) => {
1112
- Y(e), Ce(!0);
1113
- }, vt = (e) => {
1114
- Y(e), Ae(!0);
1115
- }, yt = (e) => {
1116
- Y(e), Me(!0);
1117
- }, bt = (e) => {
1118
- Y(e), Re(!0);
1119
- };
1120
- return ct ? /*#__PURE__*/ G("div", {
1121
- "data-testid": "loading",
1122
- children: /*#__PURE__*/ G(T, { children: /*#__PURE__*/ G(r, {
1123
- colSpan: 3,
1124
- children: /*#__PURE__*/ K(c, {
1125
- distribution: "center",
1126
- alignment: "center",
1127
- children: [/*#__PURE__*/ G(l, { variant: "primary" }), /*#__PURE__*/ G(X, { id: "Z3FXyt" })]
1128
- })
1129
- }) })
1130
- }) : /*#__PURE__*/ K(W, { children: [
1131
- /*#__PURE__*/ G(W, { children: p }),
1132
- /*#__PURE__*/ K("div", {
1133
- className: "relative",
1134
- children: [
1135
- s && /*#__PURE__*/ G("div", {
1136
- className: "bg-theme-background-lvl-0/50 absolute inset-0 z-10 flex items-center justify-center backdrop-blur-sm",
1137
- children: /*#__PURE__*/ K(c, {
1138
- direction: "vertical",
1139
- alignment: "center",
1140
- gap: "2",
1141
- children: [/*#__PURE__*/ G(l, {
1142
- variant: "primary",
1143
- size: "large"
1144
- }), /*#__PURE__*/ G("span", {
1145
- className: "text-theme-high font-medium",
1146
- children: /*#__PURE__*/ G(X, { id: "sihD20" })
1147
- })]
1148
- })
1149
- }),
1150
- e.length > 0 ? /*#__PURE__*/ K(W, { children: [/*#__PURE__*/ K(v, {
1151
- columns: N ? 9 : 8,
1152
- minContentColumns: N ? [0, 8] : [7],
1153
- className: "images",
1154
- "data-testid": "images-table",
1155
- children: [/*#__PURE__*/ K(T, { children: [
1156
- N && /*#__PURE__*/ G(n, { children: /*#__PURE__*/ G(te, {
1157
- checked: (() => {
1158
- let t = e.map((e) => e.id);
1159
- return t.length > 0 && t.every((e) => m.includes(e));
1160
- })(),
1161
- onChange: () => {
1162
- let t = e.map((e) => e.id);
1163
- return t.every((e) => m.includes(e)) ? h(m.filter((e) => !t.includes(e))) : h([...new Set([...m, ...t])]);
1164
- }
1165
- }) }),
1166
- /*#__PURE__*/ G(n, { children: /*#__PURE__*/ G(X, { id: "uAQUqI" }) }),
1167
- /*#__PURE__*/ G(n, { children: /*#__PURE__*/ G(X, { id: "ExLULX" }) }),
1168
- /*#__PURE__*/ G(n, { children: /*#__PURE__*/ G(X, { id: "2q/Q7x" }) }),
1169
- /*#__PURE__*/ G(n, { children: /*#__PURE__*/ G(X, { id: "644xgx" }) }),
1170
- /*#__PURE__*/ G(n, { children: /*#__PURE__*/ G(X, { id: "Cj2Gtd" }) }),
1171
- /*#__PURE__*/ G(n, { children: /*#__PURE__*/ G(X, { id: "NopYGU" }) }),
1172
- /*#__PURE__*/ G(n, { children: /*#__PURE__*/ G(X, { id: "d+F6q9" }) }),
1173
- /*#__PURE__*/ G(n, {})
1174
- ] }), e.map((e) => /*#__PURE__*/ G(He, {
1175
- image: e,
1176
- isSelected: m.includes(e.id),
1177
- isPending: !!t.find(({ id: t }) => t === e.id),
1178
- isAccepted: !!i.find(({ id: t }) => t === e.id),
1179
- permissions: o,
1180
- onEditDetails: _t,
1181
- onEditMetadata: vt,
1182
- onDelete: yt,
1183
- onManageAccess: bt,
1184
- showSelectColumn: N,
1185
- onSelect: (e) => {
1186
- if (m.includes(e.id)) return h(m.filter((t) => t !== e.id));
1187
- h([...m, e.id]);
1188
- },
1189
- onActivationStatusChange: mt,
1190
- onUpdateVisibility: lt,
1191
- setToastData: H,
1192
- uploadId: Ue,
1193
- uploadProgressPercent: st?.percent,
1194
- onMemberStatusChanged: M
1195
- }, e.id))]
1196
- }), d > 1 && /*#__PURE__*/ G("div", {
1197
- className: "flex justify-center py-4",
1198
- children: /*#__PURE__*/ G(re, {
1199
- variant: "input",
1200
- currentPage: u,
1201
- pages: d,
1202
- onPressPrevious: () => f?.(Math.max(u - 1, 1)),
1203
- onPressNext: () => f?.(Math.min(u + 1, d)),
1204
- onSelectChange: (e) => f?.(e)
1205
- })
1206
- })] }) : /*#__PURE__*/ G(v, {
1207
- columns: 7,
1208
- minContentColumns: [0, 6],
1209
- className: "images",
1210
- "data-testid": "no-images",
1211
- children: /*#__PURE__*/ G(T, { children: /*#__PURE__*/ K(r, {
1212
- colSpan: 7,
1213
- children: [/*#__PURE__*/ G(ne, { children: /*#__PURE__*/ G(X, { id: "eYlnXt" }) }), /*#__PURE__*/ G("p", { children: /*#__PURE__*/ G(X, { id: "qvF2D8" }) })]
1214
- }) })
1215
- }),
1216
- J && /*#__PURE__*/ K(W, { children: [
1217
- /*#__PURE__*/ G(me, {
1218
- isOpen: pe,
1219
- onClose: () => {
1220
- Y(null), Ce(!1);
1221
- },
1222
- image: J,
1223
- onSave: dt,
1224
- isLoading: it.isPending
1225
- }),
1226
- /*#__PURE__*/ G(I, {
1227
- isOpen: ke,
1228
- onClose: () => {
1229
- Y(null), Ae(!1);
1230
- },
1231
- image: J,
1232
- onSave: dt,
1233
- isLoading: it.isPending
1234
- }),
1235
- /*#__PURE__*/ G(oe, {
1236
- image: J,
1237
- isOpen: je,
1238
- isLoading: ct,
1239
- isDisabled: J.protected || !o.canDelete,
1240
- onClose: () => {
1241
- Y(null), Me(!1);
1242
- },
1243
- onDelete: pt
1244
- }),
1245
- /*#__PURE__*/ G(z, {
1246
- image: J,
1247
- isOpen: Ne,
1248
- isLoading: $e.isPending,
1249
- onClose: () => {
1250
- Y(null), Pe(!1);
1251
- },
1252
- onDeactivate: gt
1253
- }),
1254
- /*#__PURE__*/ G(se, {
1255
- image: J,
1256
- isOpen: Fe,
1257
- isLoading: et.isPending,
1258
- onClose: () => {
1259
- Y(null), Ie(!1);
1260
- },
1261
- onActivate: ht
1262
- }),
1263
- /*#__PURE__*/ G(Qe, {
1264
- image: J,
1265
- isOpen: Le,
1266
- onClose: () => {
1267
- Y(null), Re(!1);
1268
- },
1269
- permissions: o
1270
- })
1271
- ] }),
1272
- /*#__PURE__*/ G(Ye, {
1273
- isOpen: g,
1274
- deletableImages: w,
1275
- protectedImages: ie,
1276
- isLoading: ct,
1277
- onClose: () => _(!1),
1278
- onDelete: async (e) => {
1279
- _(!1);
1280
- try {
1281
- let t = await tt.mutateAsync({
1282
- project_id: P,
1283
- imageIds: e
1284
- }), n = t.successful.length, r = t.failed.length, i = e.length;
1285
- H(r === 0 ? he(n, i, { onDismiss: $ }) : n === 0 ? xe(r, i, { onDismiss: $ }) : V(n, r, { onDismiss: $ })), t.successful.length > 0 && j(t.successful);
1286
- } catch (t) {
1287
- let { message: n } = t;
1288
- console.log("Bulk delete error: ", n), H(xe(e.length, e.length, { onDismiss: $ }));
1289
- }
1290
- }
1291
- }),
1292
- /*#__PURE__*/ G(Xe, {
1293
- isOpen: ee,
1294
- activeImages: O,
1295
- deactivatedImages: k,
1296
- isLoading: ct,
1297
- onClose: () => y(!1),
1298
- onDeactivate: async (e) => {
1299
- y(!1);
1300
- try {
1301
- let t = await rt.mutateAsync({
1302
- project_id: P,
1303
- imageIds: e
1304
- }), n = t.successful.length, r = t.failed.length, i = e.length;
1305
- H(r === 0 ? ve(n, i, { onDismiss: $ }) : n === 0 ? fe(r, i, { onDismiss: $ }) : ce(n, r, { onDismiss: $ }));
1306
- } catch (t) {
1307
- let { message: n } = t;
1308
- console.log("Bulk deactivate error: ", n), H(fe(e.length, e.length, { onDismiss: $ }));
1309
- }
1310
- }
1311
- }),
1312
- /*#__PURE__*/ G(Ze, {
1313
- isOpen: b,
1314
- deactivatedImages: k,
1315
- activeImages: O,
1316
- isLoading: ct,
1317
- onClose: () => x(!1),
1318
- onActivate: async (e) => {
1319
- x(!1);
1320
- try {
1321
- let t = await nt.mutateAsync({
1322
- project_id: P,
1323
- imageIds: e
1324
- }), n = t.successful.length, r = t.failed.length, i = e.length;
1325
- H(r === 0 ? be(n, i, { onDismiss: $ }) : n === 0 ? Se(r, i, { onDismiss: $ }) : _e(n, r, { onDismiss: $ }));
1326
- } catch (t) {
1327
- let { message: n } = t;
1328
- console.log("Bulk activate error: ", n), H(Se(e.length, e.length, { onDismiss: $ }));
1329
- }
1330
- }
1331
- }),
1332
- /*#__PURE__*/ G(Je, {
1333
- isOpen: S,
1334
- onClose: () => {
1335
- Ue && Q.compute.listImagesWithPagination.invalidate(), C(!1);
1336
- },
1337
- onCreate: ft,
1338
- isLoading: at.isPending || Ge || Z,
1339
- isUploadPending: Ge && !!Ue,
1340
- uploadProgressPercent: st?.percent
1341
- })
1342
- ]
1343
- }),
1344
- L && /*#__PURE__*/ G(a, {
1345
- ...L,
1346
- className: "border-theme-light fixed top-5 right-5 z-50 rounded-lg border shadow-lg"
1347
- })
1348
- ] });
1349
- }
1350
- //#endregion
1351
- //#region src/client/routes/_auth/projects/$projectId/compute/-components/Images/urlHelpers.ts
1352
- var et = (e) => {
1353
- let t = [];
1354
- return e.status && (e.status.startsWith("in:") ? e.status.replace("in:", "").split(",") : [e.status]).forEach((e) => {
1355
- t.push({
1356
- name: "status",
1357
- value: e
1358
- });
1359
- }), e.visibility && t.push({
1360
- name: "visibility",
1361
- value: e.visibility
1362
- }), e.disk_format && (e.disk_format.startsWith("in:") ? e.disk_format.replace("in:", "").split(",") : [e.disk_format]).forEach((e) => {
1363
- t.push({
1364
- name: "disk_format",
1365
- value: e
1366
- });
1367
- }), e.container_format && (e.container_format.startsWith("in:") ? e.container_format.replace("in:", "").split(",") : [e.container_format]).forEach((e) => {
1368
- t.push({
1369
- name: "container_format",
1370
- value: e
1371
- });
1372
- }), e.protected && t.push({
1373
- name: "protected",
1374
- value: e.protected
1375
- }), t;
1376
- }, tt = (e, t) => {
1377
- let n = {};
1378
- if (!e?.length) return n;
1379
- let r = e.filter((e) => !e.inactive).reduce((e, t) => (e[t.name] || (e[t.name] = []), e[t.name].push(t.value), e), {});
1380
- return Object.entries(r).forEach(([e, r]) => {
1381
- t.find((t) => t.filterName === e)?.supportsMultiValue && r.length > 1 ? n[e] = `in:${r.join(",")}` : n[e] = r[0];
1382
- }), n;
1383
- }, nt = (e, t, n) => e.some((e) => e.name === t.name && e.value === t.value) ? e : n.find((e) => e.filterName === t.name)?.supportsMultiValue ? [...e, t] : [...e.filter((e) => e.name !== t.name), t], rt = (e, t, n) => {
1384
- let r = {
1385
- search: n.search,
1386
- sortBy: n.sortBy,
1387
- sortDirection: n.sortDirection,
1388
- memberStatus: n.memberStatus === "all" ? void 0 : n.memberStatus
1389
- };
1390
- if (!e?.length) return r;
1391
- let i = e.filter((e) => !e.inactive).reduce((e, t) => (e[t.name] || (e[t.name] = []), e[t.name].push(t.value), e), {});
1392
- return Object.entries(i).forEach(([e, n]) => {
1393
- t.find((t) => t.filterName === e)?.supportsMultiValue && n.length > 1 ? r[e] = `in:${n.join(",")}` : r[e] = n[0];
1394
- }), r;
1395
- }, it = {
1396
- images: [],
1397
- first: void 0,
1398
- next: void 0,
1399
- schema: "/v2/schemas/images",
1400
- listError: void 0
1401
- }, at = (e, t, n, r, i, a) => a.member_status && a.member_status !== "all" ? e.compute.listSharedImagesByMemberStatus.query({
1402
- project_id: t,
1403
- memberStatus: a.member_status,
1404
- name: i || void 0,
1405
- status: a.status,
1406
- disk_format: a.disk_format,
1407
- container_format: a.container_format,
1408
- protected: a.protected,
1409
- sort: `${n}:${r}`
1410
- }).then((e) => ({
1411
- ...it,
1412
- images: e
1413
- })).catch((e) => {
1414
- if (e instanceof ze && e.data?.code === "FORBIDDEN") return {
1415
- ...it,
1416
- listError: e.message
1417
- };
1418
- throw e;
1419
- }) : e.compute.listImagesWithSearch.query({
1420
- project_id: t,
1421
- sort: `${n}:${r}`,
1422
- name: i || void 0,
1423
- ...a,
1424
- member_status: void 0
1425
- }).then((e) => ({
1426
- ...e,
1427
- listError: void 0
1428
- })).catch((e) => {
1429
- if (e instanceof ze && e.data?.code === "FORBIDDEN") return {
1430
- ...it,
1431
- listError: e.message
1432
- };
1433
- throw e;
1434
- }), ot = (e, t) => e.compute.canUser.query({
1435
- project_id: t,
1436
- permission: [
1437
- "images:create",
1438
- "images:delete",
1439
- "images:update",
1440
- "images:create_member",
1441
- "images:delete_member",
1442
- "images:update_member"
1443
- ]
1444
- }).then(([e, t, n, r, i, a]) => ({
1445
- canCreate: e,
1446
- canDelete: t,
1447
- canUpdate: n,
1448
- canCreateMember: r,
1449
- canDeleteMember: i,
1450
- canUpdateMember: a ?? !1
1451
- })), st = 50;
1452
- function ct({ imagesPromise: e, imageOverrides: n, deletedImageIds: r, permissionsPromise: i, searchTerm: a, setSearchTerm: l, sortSettings: u, handleSortChange: f, filterSettings: h, handleFilterChange: g, selectedImages: ee, setSelectedImages: v, createModalOpen: y, setCreateModalOpen: ne, deleteAllModalOpen: x, setDeleteAllModalOpen: S, deactivateAllModalOpen: w, setDeactivateAllModalOpen: T, activateAllModalOpen: re, setActivateAllModalOpen: E, memberStatusView: D, setMemberStatusView: ie, isFetching: O, currentPage: k, onPageChange: j, onImageUpdated: ae, onImageDeleted: oe, onMemberStatusChanged: se }) {
1453
- let { i18n: M, _: N } = Z(), P = Ne(e), I = Ne(i), [L, R] = q(a), z = Le(void 0);
1454
- if (Fe(() => () => clearTimeout(z.current), []), P.listError) return /*#__PURE__*/ G("p", { children: P.listError });
1455
- let B = P.images.filter((e) => !r.has(e.id)).map((e) => n.get(e.id) ?? e), ce = Math.max(1, Math.ceil(B.length / st)), le = Math.min(k, ce), V = B.slice((le - 1) * st, le * st);
1456
- Fe(() => {
1457
- k !== 1 && k > ce && j(1);
1458
- }, [
1459
- ce,
1460
- k,
1461
- j
1462
- ]);
1463
- let H = D === "pending" || D === "accepted" ? {
1464
- ...h,
1465
- filters: h.filters.filter((e) => e.filterName !== "visibility"),
1466
- selectedFilters: (h.selectedFilters || []).filter((e) => e.name !== "visibility")
1467
- } : h, ue = new Set(B.map((e) => e.id)), U = ee.filter((e) => ue.has(e)), de = U.filter((e) => {
1468
- let t = B.find((t) => t.id === e);
1469
- return t && !t.protected;
1470
- }), fe = U.filter((e) => {
1471
- let t = B.find((t) => t.id === e);
1472
- return t && t.protected;
1473
- }), pe = U.filter((e) => {
1474
- let t = B.find((t) => t.id === e);
1475
- return t && t.status === F.ACTIVE;
1476
- }), me = U.filter((e) => {
1477
- let t = B.find((t) => t.id === e);
1478
- return t && t.status === F.DEACTIVATED;
1479
- }), he = !I.canDelete || U.length === 0 || B.filter((e) => U.includes(e.id)).every((e) => e.protected), ge = !I.canUpdate || U.length === 0 || B.filter((e) => U.includes(e.id)).every((e) => e.status === F.DEACTIVATED), _e = !I.canUpdate || U.length === 0 || B.filter((e) => U.includes(e.id)).every((e) => e.status === F.ACTIVE), ve = {
1480
- items: [
1481
- {
1482
- label: M._({ id: "SFo0kK" }),
1483
- value: "all"
1484
- },
1485
- {
1486
- label: M._({ id: "thHAVL" }),
1487
- value: "accepted"
1488
- },
1489
- {
1490
- label: M._({ id: "E4QYe7" }),
1491
- value: "pending"
1492
- }
1493
- ],
1494
- activeItem: D,
1495
- onActiveItemChange: (e) => ie(e)
1496
- };
1497
- return /*#__PURE__*/ K(W, { children: [
1498
- /*#__PURE__*/ K(c, {
1499
- distribution: "between",
1500
- alignment: "center",
1501
- gap: "2",
1502
- children: [/*#__PURE__*/ G(d, {
1503
- activeItem: D,
1504
- onActiveItemChange: ve.onActiveItemChange,
1505
- children: ve.items.map((e) => /*#__PURE__*/ G(o, {
1506
- label: e.label,
1507
- value: e.value
1508
- }, e.value))
1509
- }), /*#__PURE__*/ K(c, {
1510
- gap: "0.5",
1511
- alignment: "center",
1512
- children: [/*#__PURE__*/ G(A, {
1513
- options: u.options,
1514
- sortBy: u.sortBy,
1515
- sortDirection: u.sortDirection ?? "desc",
1516
- onSortByChange: (e) => f({
1517
- ...u,
1518
- sortBy: e,
1519
- sortDirection: u.sortDirection
1520
- }),
1521
- onSortDirectionChange: (e) => f({
1522
- ...u,
1523
- sortDirection: e
1524
- })
1525
- }), I.canCreate && /*#__PURE__*/ G(m, {
1526
- onClick: () => ne(!0),
1527
- variant: "primary",
1528
- children: /*#__PURE__*/ G(X, { id: "a/nTb8" })
1529
- })]
1530
- })]
1531
- }),
1532
- /*#__PURE__*/ G(p, { children: /*#__PURE__*/ K(c, {
1533
- direction: "vertical",
1534
- gap: "2",
1535
- children: [/*#__PURE__*/ K(c, {
1536
- distribution: "between",
1537
- alignment: "center",
1538
- children: [/*#__PURE__*/ G(Ae, {
1539
- filters: H.filters,
1540
- onChange: (e) => {
1541
- let t = nt(H.selectedFilters || [], e, H.filters);
1542
- t !== (H.selectedFilters || []) && g({
1543
- ...h,
1544
- selectedFilters: t
1545
- });
1546
- }
1547
- }), /*#__PURE__*/ G(b, {
1548
- placeholder: M._({ id: "0cl0a5" }),
1549
- "data-testid": "searchbar",
1550
- value: L,
1551
- onInput: (e) => {
1552
- let t = e.currentTarget.value;
1553
- R(t), clearTimeout(z.current), z.current = window.setTimeout(() => l(t), 500);
1554
- },
1555
- onSearch: (e) => {
1556
- clearTimeout(z.current), l(typeof e == "string" ? e : "");
1557
- },
1558
- onClear: () => {
1559
- clearTimeout(z.current), R(""), l("");
1560
- }
1561
- })]
1562
- }), H.selectedFilters && H.selectedFilters.length > 0 && /*#__PURE__*/ G(ke, {
1563
- selectedFilters: H.selectedFilters,
1564
- onDelete: (e) => g({
1565
- ...h,
1566
- selectedFilters: (h.selectedFilters || []).filter((t) => !(t.name === e.name && t.value === e.value))
1567
- }),
1568
- onClear: () => g({
1569
- ...h,
1570
- selectedFilters: []
1571
- })
1572
- })]
1573
- }) }),
1574
- (I.canDelete || I.canUpdate) && /*#__PURE__*/ G(p, { children: /*#__PURE__*/ G(c, {
1575
- distribution: "between",
1576
- alignment: "center",
1577
- children: /*#__PURE__*/ K(c, {
1578
- gap: "2",
1579
- alignment: "center",
1580
- children: [/*#__PURE__*/ G(te, {
1581
- checked: U.length > 0 && V.every((e) => U.includes(e.id)),
1582
- indeterminate: U.length > 0 && !V.every((e) => U.includes(e.id)),
1583
- onChange: () => {
1584
- let e = V.map((e) => e.id);
1585
- e.every((e) => U.includes(e)) ? v(U.filter((t) => !e.includes(t))) : v([...new Set([...U, ...e])]);
1586
- }
1587
- }), /*#__PURE__*/ K(s, { children: [/*#__PURE__*/ G(t, {
1588
- as: "div",
1589
- children: /*#__PURE__*/ G(m, {
1590
- size: "small",
1591
- icon: "moreVert",
1592
- label: M._({ id: "7L01XJ" })
1593
- })
1594
- }), /*#__PURE__*/ K(C, { children: [
1595
- I.canDelete && /*#__PURE__*/ G(_, {
1596
- disabled: he,
1597
- label: M._({ id: "c6b6fz" }),
1598
- onClick: () => S(!0)
1599
- }),
1600
- I.canUpdate && /*#__PURE__*/ G(_, {
1601
- disabled: ge,
1602
- label: M._({ id: "UmQ3/m" }),
1603
- onClick: () => T(!0)
1604
- }),
1605
- I.canUpdate && /*#__PURE__*/ G(_, {
1606
- disabled: _e,
1607
- label: M._({ id: "d/I0J3" }),
1608
- onClick: () => E(!0)
1609
- })
1610
- ] })] })]
1611
- })
1612
- }) }),
1613
- /*#__PURE__*/ G($e, {
1614
- images: V,
1615
- suggestedImages: D === "pending" ? V : [],
1616
- acceptedImages: D === "accepted" ? V : [],
1617
- permissions: I,
1618
- isFetching: O,
1619
- currentPage: le,
1620
- totalPages: ce,
1621
- onPageChange: j,
1622
- selectedImages: ee,
1623
- setSelectedImages: v,
1624
- deleteAllModalOpen: x,
1625
- setDeleteAllModalOpen: S,
1626
- deactivateAllModalOpen: w,
1627
- setDeactivateAllModalOpen: T,
1628
- activateAllModalOpen: re,
1629
- setActivateAllModalOpen: E,
1630
- createModalOpen: y,
1631
- setCreateModalOpen: ne,
1632
- deletableImages: de,
1633
- protectedImages: fe,
1634
- activeImages: pe,
1635
- deactivatedImages: me,
1636
- onImageUpdated: ae,
1637
- onImageDeleted: oe,
1638
- onMemberStatusChanged: se,
1639
- hasAnyBulkAction: I.canDelete || I.canUpdate
1640
- })
1641
- ] });
1642
- }
1643
- var $ = ({ client: t, project: n }) => {
1644
- let { i18n: r, _: i } = Z(), a = Re(), o = Y({ strict: !1 }), [s, u] = q({
1645
- options: [
1646
- {
1647
- label: r._({ id: "88kg0+" }),
1648
- value: "created_at"
1649
- },
1650
- {
1651
- label: r._({ id: "Llcakz" }),
1652
- value: "updated_at"
1653
- },
1654
- {
1655
- label: r._({ id: "6YtxFj" }),
1656
- value: "name"
1657
- },
1658
- {
1659
- label: r._({ id: "Cj2Gtd" }),
1660
- value: "size"
1661
- },
1662
- {
1663
- label: r._({ id: "uAQUqI" }),
1664
- value: "status"
1665
- }
1666
- ],
1667
- sortBy: o.sortBy || "created_at",
1668
- sortDirection: o.sortDirection || "desc"
1669
- }), [d, f] = q({
1670
- filters: [
1671
- {
1672
- displayName: r._({ id: "uAQUqI" }),
1673
- filterName: "status",
1674
- values: Object.values(F),
1675
- supportsMultiValue: !0
1676
- },
1677
- {
1678
- displayName: r._({ id: "2q/Q7x" }),
1679
- filterName: "visibility",
1680
- values: Object.values(L),
1681
- supportsMultiValue: !1
1682
- },
1683
- {
1684
- displayName: r._({ id: "NopYGU" }),
1685
- filterName: "disk_format",
1686
- values: Object.values(P),
1687
- supportsMultiValue: !0
1688
- },
1689
- {
1690
- displayName: r._({ id: "6/xipy" }),
1691
- filterName: "container_format",
1692
- values: Object.values(pe),
1693
- supportsMultiValue: !0
1694
- },
1695
- {
1696
- displayName: r._({ id: "644xgx" }),
1697
- filterName: "protected",
1698
- values: ["true", "false"],
1699
- supportsMultiValue: !1
1700
- }
1701
- ],
1702
- selectedFilters: et(o)
1703
- }), [p, m] = q(o.search || ""), h = o.page ?? 1, [g, _] = q([]), [ee, v] = q(!1), [y, b] = q(!1), [te, ne] = q(!1), [x, S] = q(!1), C = o.memberStatus ?? "all", [w, T] = q(!0), [re, E] = q(/* @__PURE__ */ new Map()), [D, ie] = q(/* @__PURE__ */ new Set()), [O, k] = q(() => new Promise(() => {})), [A] = q(() => ot(t, n)), j = Pe((e) => {
1704
- E((t) => new Map(t).set(e.id, e));
1705
- }, []), ae = Pe((e) => {
1706
- ie((t) => {
1707
- let n = new Set(t);
1708
- return Array.isArray(e) ? e.forEach((e) => n.add(e)) : n.add(e), n;
1709
- });
1710
- }, []), oe = Pe(() => {
1711
- E(/* @__PURE__ */ new Map()), T(!0);
1712
- let e = o.memberStatus ?? "all", r = e === "all" ? void 0 : e;
1713
- Me(() => {
1714
- let i = e === "pending" || e === "accepted" ? (d.selectedFilters || []).filter((e) => e.name !== "visibility") : d.selectedFilters || [], a = at(t, n, s.sortBy, s.sortDirection, p, {
1715
- ...tt(i, d.filters),
1716
- member_status: r
1717
- });
1718
- a.catch(() => {}).finally(() => T(!1)), k(a);
1719
- });
1720
- }, [
1721
- t,
1722
- s,
1723
- p,
1724
- d,
1725
- o.memberStatus
1726
- ]);
1727
- Fe(() => {
1728
- let e = et(o), r = o.sortBy || "created_at", i = o.sortDirection || "desc", a = o.search || "";
1729
- f((t) => ({
1730
- ...t,
1731
- selectedFilters: e
1732
- })), u((e) => ({
1733
- ...e,
1734
- sortBy: r,
1735
- sortDirection: i
1736
- })), m(a), _([]), E(/* @__PURE__ */ new Map()), T(!0);
1737
- let s = o.memberStatus ?? "all", c = s === "all" ? void 0 : s;
1738
- Me(() => {
1739
- let o = at(t, n, r, i, a, {
1740
- ...tt(s === "pending" || s === "accepted" ? (e || []).filter((e) => e.name !== "visibility") : e || [], d.filters),
1741
- member_status: c
1742
- });
1743
- o.catch(() => {}).finally(() => T(!1)), k(o);
1744
- });
1745
- }, [
1746
- o.status,
1747
- o.visibility,
1748
- o.disk_format,
1749
- o.container_format,
1750
- o.protected,
1751
- o.sortBy,
1752
- o.sortDirection,
1753
- o.search,
1754
- o.memberStatus
1755
- ]);
1756
- let se = (e) => {
1757
- let t = {
1758
- options: e.options,
1759
- sortBy: e.sortBy?.toString() || "created_at",
1760
- sortDirection: e.sortDirection || "desc"
1761
- };
1762
- u(t), a({
1763
- search: (e) => ({
1764
- ...e,
1765
- sortBy: t.sortBy,
1766
- sortDirection: t.sortDirection,
1767
- page: void 0
1768
- }),
1769
- replace: !0
1770
- });
1771
- }, M = (e) => {
1772
- f(e), a({
1773
- search: (t) => rt(e.selectedFilters || [], e.filters, {
1774
- search: t.search,
1775
- sortBy: t.sortBy,
1776
- sortDirection: t.sortDirection,
1777
- memberStatus: t.memberStatus
1778
- }),
1779
- replace: !0
1780
- });
1781
- }, N = (e) => {
1782
- let t = typeof e == "string" ? e : "";
1783
- m(t), a({
1784
- search: (e) => ({
1785
- ...e,
1786
- search: t || void 0,
1787
- page: void 0
1788
- }),
1789
- replace: !0
1790
- });
1791
- }, I = (e) => {
1792
- a({ search: (t) => ({
1793
- sortBy: t.sortBy,
1794
- sortDirection: t.sortDirection,
1795
- search: t.search,
1796
- memberStatus: e === "all" ? void 0 : e
1797
- }) });
1798
- }, R = Pe((e) => {
1799
- a({ search: (t) => ({
1800
- ...t,
1801
- page: e === 1 ? void 0 : e
1802
- }) });
1803
- }, [a]);
1804
- return /*#__PURE__*/ G("div", {
1805
- className: "relative",
1806
- children: /*#__PURE__*/ G(Ve, {
1807
- fallbackRender: ({ error: t }) => /*#__PURE__*/ G(e, {
1808
- variant: "error",
1809
- text: t instanceof Error ? t.message : r._({ id: "W5A0Ly" })
1810
- }),
1811
- children: /*#__PURE__*/ G(je, {
1812
- fallback: /*#__PURE__*/ K(c, {
1813
- className: "fixed inset-0",
1814
- distribution: "center",
1815
- alignment: "center",
1816
- direction: "vertical",
1817
- children: [/*#__PURE__*/ G(l, {
1818
- variant: "primary",
1819
- size: "large",
1820
- className: "mb-2"
1821
- }), /*#__PURE__*/ G(X, { id: "HBpi4q" })]
1822
- }),
1823
- children: /*#__PURE__*/ G(ct, {
1824
- imagesPromise: O,
1825
- imageOverrides: re,
1826
- deletedImageIds: D,
1827
- permissionsPromise: A,
1828
- searchTerm: p,
1829
- setSearchTerm: N,
1830
- sortSettings: s,
1831
- handleSortChange: se,
1832
- filterSettings: d,
1833
- handleFilterChange: M,
1834
- selectedImages: g,
1835
- setSelectedImages: _,
1836
- createModalOpen: ee,
1837
- setCreateModalOpen: v,
1838
- deleteAllModalOpen: y,
1839
- setDeleteAllModalOpen: b,
1840
- deactivateAllModalOpen: te,
1841
- setDeactivateAllModalOpen: ne,
1842
- activateAllModalOpen: x,
1843
- setActivateAllModalOpen: S,
1844
- memberStatusView: C,
1845
- setMemberStatusView: I,
1846
- isFetching: w,
1847
- currentPage: h,
1848
- onPageChange: R,
1849
- onImageUpdated: j,
1850
- onImageDeleted: ae,
1851
- onMemberStatusChanged: oe
1852
- })
1853
- })
1854
- })
1855
- });
1856
- };
1857
- //#endregion
1858
- //#region src/client/routes/_auth/projects/$projectId/compute/images/index.tsx?tsr-split=component
1859
- function lt() {
1860
- let { i18n: e, _: t } = Z(), { projectId: n } = O.useParams(), { trpcClient: r } = O.useRouteContext();
1861
- if (!r) throw Error("trpcClient is not available in route context");
1862
- return /*#__PURE__*/ K(W, { children: [/*#__PURE__*/ G(k, {
1863
- title: e._({ id: "an5hVd" }),
1864
- projectId: n
1865
- }), /*#__PURE__*/ G($, {
1866
- client: r,
1867
- project: n
1868
- })] });
1869
- }
1870
- //#endregion
1871
- export { lt as component };
1872
-
1873
- //# sourceMappingURL=images-CKqIXUq52.mjs.map