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