@cobaltcore-dev/aurora 2.1.0 → 2.2.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 (171) hide show
  1. package/README.md +31 -25
  2. package/dist/client/AuroraApp.d.ts +9 -2
  3. package/dist/client/context/AppConfigContext.d.ts +44 -0
  4. package/dist/client/index.d.ts +2 -0
  5. package/dist/client/index.js +41221 -844
  6. package/dist/client/index.js.map +1 -1
  7. package/dist/client/trpcClient.d.ts +314 -1
  8. package/dist/client/utils/appConfigGating.d.ts +21 -0
  9. package/dist/server/index.d.ts +694 -4
  10. package/dist/server/index.js +2521 -1243
  11. package/package.json +2 -2
  12. package/dist/client/AuthProvider-CVSAwW9f.mjs +0 -83
  13. package/dist/client/AuthProvider-CVSAwW9f.mjs.map +0 -1
  14. package/dist/client/ContentHeader-fKKZVu-o.mjs +0 -116
  15. package/dist/client/ContentHeader-fKKZVu-o.mjs.map +0 -1
  16. package/dist/client/DeleteFlavorModal-Be2GFiB_.mjs +0 -802
  17. package/dist/client/DeleteFlavorModal-Be2GFiB_.mjs.map +0 -1
  18. package/dist/client/DynamicBreadcrumbContext-CVcUQFou.mjs +0 -26
  19. package/dist/client/DynamicBreadcrumbContext-CVcUQFou.mjs.map +0 -1
  20. package/dist/client/FiltersInput-Becwxo_J.mjs +0 -85
  21. package/dist/client/FiltersInput-Becwxo_J.mjs.map +0 -1
  22. package/dist/client/FloatingIpActionModals-Cq10WljB.mjs +0 -466
  23. package/dist/client/FloatingIpActionModals-Cq10WljB.mjs.map +0 -1
  24. package/dist/client/ImageToastNotifications-BWfzOUMc.mjs +0 -1135
  25. package/dist/client/ImageToastNotifications-BWfzOUMc.mjs.map +0 -1
  26. package/dist/client/RouteIdLevelDefaultError-DPF_x2tG.mjs +0 -26
  27. package/dist/client/RouteIdLevelDefaultError-DPF_x2tG.mjs.map +0 -1
  28. package/dist/client/Slot-CWb612-_.mjs +0 -28
  29. package/dist/client/Slot-CWb612-_.mjs.map +0 -1
  30. package/dist/client/SortInput-4g7nSTHW.mjs +0 -34
  31. package/dist/client/SortInput-4g7nSTHW.mjs.map +0 -1
  32. package/dist/client/StorageNotFound-B-zVinVD.mjs +0 -30
  33. package/dist/client/StorageNotFound-B-zVinVD.mjs.map +0 -1
  34. package/dist/client/TwoColumnDescriptionList-DKS42RKa.mjs +0 -28
  35. package/dist/client/TwoColumnDescriptionList-DKS42RKa.mjs.map +0 -1
  36. package/dist/client/_-CAsCx-Ay.mjs +0 -6
  37. package/dist/client/_-CAsCx-Ay.mjs.map +0 -1
  38. package/dist/client/_auth-SrDjHL6j.mjs +0 -12
  39. package/dist/client/_auth-SrDjHL6j.mjs.map +0 -1
  40. package/dist/client/_flavorId-0PioWpEp.mjs +0 -276
  41. package/dist/client/_flavorId-0PioWpEp.mjs.map +0 -1
  42. package/dist/client/_flavorId-B7fp6Nk8.mjs +0 -22
  43. package/dist/client/_flavorId-B7fp6Nk8.mjs.map +0 -1
  44. package/dist/client/_flavorId-CgueqKTs.mjs +0 -27
  45. package/dist/client/_flavorId-CgueqKTs.mjs.map +0 -1
  46. package/dist/client/_floatingIpId-B8r64AL9.mjs +0 -196
  47. package/dist/client/_floatingIpId-B8r64AL9.mjs.map +0 -1
  48. package/dist/client/_floatingIpId-lEobpOER.mjs +0 -26
  49. package/dist/client/_floatingIpId-lEobpOER.mjs.map +0 -1
  50. package/dist/client/_imageId-Ccv8PedW.mjs +0 -40
  51. package/dist/client/_imageId-Ccv8PedW.mjs.map +0 -1
  52. package/dist/client/_imageId-CiqEQB_J.mjs +0 -558
  53. package/dist/client/_imageId-CiqEQB_J.mjs.map +0 -1
  54. package/dist/client/_imageId-D9LR-02T.mjs +0 -22
  55. package/dist/client/_imageId-D9LR-02T.mjs.map +0 -1
  56. package/dist/client/_projectId-BDARsteX.mjs +0 -77
  57. package/dist/client/_projectId-BDARsteX.mjs.map +0 -1
  58. package/dist/client/_projectId-CtyAHqhH.mjs +0 -30
  59. package/dist/client/_projectId-CtyAHqhH.mjs.map +0 -1
  60. package/dist/client/_projectId-D3VOH5lN.mjs +0 -94
  61. package/dist/client/_projectId-D3VOH5lN.mjs.map +0 -1
  62. package/dist/client/_projectId-ZBk6vka0.mjs +0 -283
  63. package/dist/client/_projectId-ZBk6vka0.mjs.map +0 -1
  64. package/dist/client/_securityGroupId-BwgZnoiR.mjs +0 -29
  65. package/dist/client/_securityGroupId-BwgZnoiR.mjs.map +0 -1
  66. package/dist/client/_securityGroupId-Cz2NUHdB.mjs +0 -1819
  67. package/dist/client/_securityGroupId-Cz2NUHdB.mjs.map +0 -1
  68. package/dist/client/_serviceType-DS8DxsrP.mjs +0 -20
  69. package/dist/client/_serviceType-DS8DxsrP.mjs.map +0 -1
  70. package/dist/client/_serviceType-M8d9rOT6.mjs +0 -6
  71. package/dist/client/_serviceType-M8d9rOT6.mjs.map +0 -1
  72. package/dist/client/_storageType-BNpP1A2N.mjs +0 -13
  73. package/dist/client/_storageType-BNpP1A2N.mjs.map +0 -1
  74. package/dist/client/_storageType-BxSGKhAI.mjs +0 -15
  75. package/dist/client/_storageType-BxSGKhAI.mjs.map +0 -1
  76. package/dist/client/_storageType-DZYCmiLt.mjs +0 -30
  77. package/dist/client/_storageType-DZYCmiLt.mjs.map +0 -1
  78. package/dist/client/_storageType-UqAMP-8d.mjs +0 -859
  79. package/dist/client/_storageType-UqAMP-8d.mjs.map +0 -1
  80. package/dist/client/_storageType-u51_7OwJ.mjs +0 -7
  81. package/dist/client/_storageType-u51_7OwJ.mjs.map +0 -1
  82. package/dist/client/about-BmQTyLWc.mjs +0 -92
  83. package/dist/client/about-BmQTyLWc.mjs.map +0 -1
  84. package/dist/client/assets/__mocks__/svgMock.d.ts +0 -3
  85. package/dist/client/aurora-CIml-f2f.mjs +0 -19
  86. package/dist/client/aurora-CIml-f2f.mjs.map +0 -1
  87. package/dist/client/build-WuxXRAqf.mjs +0 -14530
  88. package/dist/client/build-WuxXRAqf.mjs.map +0 -1
  89. package/dist/client/cn-DM4Cy3jv.mjs +0 -10
  90. package/dist/client/cn-DM4Cy3jv.mjs.map +0 -1
  91. package/dist/client/flavors-Ce3J-cFa.mjs +0 -15
  92. package/dist/client/flavors-Ce3J-cFa.mjs.map +0 -1
  93. package/dist/client/flavors-D5ThLaXO.mjs +0 -666
  94. package/dist/client/flavors-D5ThLaXO.mjs.map +0 -1
  95. package/dist/client/flavors-DWMZ6TuJ.mjs +0 -8
  96. package/dist/client/flavors-DWMZ6TuJ.mjs.map +0 -1
  97. package/dist/client/floatingips-Cz9k80cc.mjs +0 -8
  98. package/dist/client/floatingips-Cz9k80cc.mjs.map +0 -1
  99. package/dist/client/floatingips-DXnRlLvV.mjs +0 -551
  100. package/dist/client/floatingips-DXnRlLvV.mjs.map +0 -1
  101. package/dist/client/floatingips-HRbuLxiN.mjs +0 -22
  102. package/dist/client/floatingips-HRbuLxiN.mjs.map +0 -1
  103. package/dist/client/floatingips-nN1kQmsu.mjs +0 -14
  104. package/dist/client/floatingips-nN1kQmsu.mjs.map +0 -1
  105. package/dist/client/formatBytes-CZv_XyCY.mjs +0 -38
  106. package/dist/client/formatBytes-CZv_XyCY.mjs.map +0 -1
  107. package/dist/client/helpers-1PpYf-fC.mjs +0 -6
  108. package/dist/client/helpers-1PpYf-fC.mjs.map +0 -1
  109. package/dist/client/hooks-D0yKIumu.mjs +0 -22
  110. package/dist/client/hooks-D0yKIumu.mjs.map +0 -1
  111. package/dist/client/images-C8M3ysWR.mjs +0 -2023
  112. package/dist/client/images-C8M3ysWR.mjs.map +0 -1
  113. package/dist/client/images-Cf5R28NR.mjs +0 -15
  114. package/dist/client/images-Cf5R28NR.mjs.map +0 -1
  115. package/dist/client/images-NBf2bV43.mjs +0 -8
  116. package/dist/client/images-NBf2bV43.mjs.map +0 -1
  117. package/dist/client/md-kvaGCNAK.mjs +0 -336
  118. package/dist/client/md-kvaGCNAK.mjs.map +0 -1
  119. package/dist/client/network-DuZm76BZ.mjs +0 -8
  120. package/dist/client/network-DuZm76BZ.mjs.map +0 -1
  121. package/dist/client/objects-BudUAfWY.mjs +0 -12909
  122. package/dist/client/objects-BudUAfWY.mjs.map +0 -1
  123. package/dist/client/objects-Dc7sKUr8.mjs +0 -67
  124. package/dist/client/objects-Dc7sKUr8.mjs.map +0 -1
  125. package/dist/client/objects-Dw7oeTq2.mjs +0 -80
  126. package/dist/client/objects-Dw7oeTq2.mjs.map +0 -1
  127. package/dist/client/objects-_g7nGIn5.mjs +0 -25
  128. package/dist/client/objects-_g7nGIn5.mjs.map +0 -1
  129. package/dist/client/objects-eBxvY6_n.mjs +0 -78
  130. package/dist/client/objects-eBxvY6_n.mjs.map +0 -1
  131. package/dist/client/projects-yiK0HGSA.mjs +0 -7
  132. package/dist/client/projects-yiK0HGSA.mjs.map +0 -1
  133. package/dist/client/routeInfo-DP3v74Wg.mjs +0 -19
  134. package/dist/client/routeInfo-DP3v74Wg.mjs.map +0 -1
  135. package/dist/client/routes-CJj7SR_K.mjs +0 -10
  136. package/dist/client/routes-CJj7SR_K.mjs.map +0 -1
  137. package/dist/client/routes-xofA3ksU.mjs +0 -110
  138. package/dist/client/routes-xofA3ksU.mjs.map +0 -1
  139. package/dist/client/securitygroups-67fFxiwt.mjs +0 -15
  140. package/dist/client/securitygroups-67fFxiwt.mjs.map +0 -1
  141. package/dist/client/securitygroups-CtKne8UQ.mjs +0 -8
  142. package/dist/client/securitygroups-CtKne8UQ.mjs.map +0 -1
  143. package/dist/client/securitygroups-DXrfyuVF.mjs +0 -580
  144. package/dist/client/securitygroups-DXrfyuVF.mjs.map +0 -1
  145. package/dist/client/securitygroups-WLB1_IM6.mjs +0 -22
  146. package/dist/client/securitygroups-WLB1_IM6.mjs.map +0 -1
  147. package/dist/client/securitygroups-o0IXZM6S.mjs +0 -14
  148. package/dist/client/securitygroups-o0IXZM6S.mjs.map +0 -1
  149. package/dist/client/serviceCatalog-B3lKWC9V.mjs +0 -6
  150. package/dist/client/serviceCatalog-B3lKWC9V.mjs.map +0 -1
  151. package/dist/client/services-D1PbooD1.mjs +0 -6
  152. package/dist/client/services-D1PbooD1.mjs.map +0 -1
  153. package/dist/client/services-DEMVtFyn.mjs +0 -9
  154. package/dist/client/services-DEMVtFyn.mjs.map +0 -1
  155. package/dist/client/storageProviders-CJ5rOh13.mjs +0 -15
  156. package/dist/client/storageProviders-CJ5rOh13.mjs.map +0 -1
  157. package/dist/client/trpcClient-D7gpR7YG.mjs +0 -71
  158. package/dist/client/trpcClient-D7gpR7YG.mjs.map +0 -1
  159. package/dist/client/useBreadcrumbs-ha3IlaxX.mjs +0 -54
  160. package/dist/client/useBreadcrumbs-ha3IlaxX.mjs.map +0 -1
  161. package/dist/client/useModal-DCs1OJh7.mjs +0 -12
  162. package/dist/client/useModal-DCs1OJh7.mjs.map +0 -1
  163. package/dist/client/useModalTracking-BYd37pXm.mjs +0 -37
  164. package/dist/client/useModalTracking-BYd37pXm.mjs.map +0 -1
  165. package/dist/client/useProjectId-DBc5lpoU.mjs +0 -11
  166. package/dist/client/useProjectId-DBc5lpoU.mjs.map +0 -1
  167. package/dist/client/useSecurityGroupPermissions--hK4aR8Y.mjs +0 -294
  168. package/dist/client/useSecurityGroupPermissions--hK4aR8Y.mjs.map +0 -1
  169. package/dist/client/useSetBreadcrumb-tn7lBaQV.mjs +0 -19
  170. package/dist/client/useSetBreadcrumb-tn7lBaQV.mjs.map +0 -1
  171. package/dist/client/utils/trpcErrors.d.ts +0 -13
@@ -1,1819 +0,0 @@
1
- import { A as e, C as t, D as n, E as r, K as i, L as a, M as o, P as s, Q as c, R as l, S as u, T as d, X as f, c as p, et as m, ft as h, g, h as _, i as v, it as y, l as b, lt as x, m as S, n as C, o as w, ot as T, p as E, rt as D, s as O, t as k, v as A, x as j } from "./build-WuxXRAqf.mjs";
2
- import { a as M } from "./trpcClient-D7gpR7YG.mjs";
3
- import { t as N } from "./_securityGroupId-BwgZnoiR.mjs";
4
- import { t as P } from "./useProjectId-DBc5lpoU.mjs";
5
- import { t as F } from "./SortInput-4g7nSTHW.mjs";
6
- import { t as I } from "./useModalTracking-BYd37pXm.mjs";
7
- import { t as ee } from "./ContentHeader-fKKZVu-o.mjs";
8
- import { t as L } from "./useSetBreadcrumb-tn7lBaQV.mjs";
9
- import "./hooks-D0yKIumu.mjs";
10
- import { t as te } from "./useModal-DCs1OJh7.mjs";
11
- import { t as ne } from "./TwoColumnDescriptionList-DKS42RKa.mjs";
12
- import { n as re, t as ie } from "./FiltersInput-Becwxo_J.mjs";
13
- import { a as ae, c as oe, d as se, f as R, h as ce, i as le, l as ue, m as de, n as fe, o as z, p as pe, r as me, s as B, t as he, u as V } from "./useSecurityGroupPermissions--hK4aR8Y.mjs";
14
- import { Fragment as H, jsx as U, jsxs as W } from "react/jsx-runtime";
15
- import { startTransition as G, useEffect as K, useMemo as ge, useRef as _e, useState as q } from "react";
16
- import { useNavigate as ve } from "@tanstack/react-router";
17
- import { Trans as J, useLingui as Y } from "@lingui/react";
18
- import { z as X } from "zod";
19
- import { useForm as Z, useStore as Q } from "@tanstack/react-form";
20
- //#region src/client/utils/useListWithFiltering.ts
21
- function ye({ defaultSortKey: e, defaultSortDir: t, sortOptions: n, filterSettings: r }) {
22
- let [i, a] = q(""), o = (e) => {
23
- let t = typeof e == "string" ? e : "";
24
- G(() => a(t));
25
- }, [s, c] = q({
26
- options: n,
27
- sortBy: e,
28
- sortDirection: t
29
- }), l = (n) => {
30
- let r = {
31
- options: n.options ?? s.options,
32
- sortBy: n.sortBy?.toString() || e,
33
- sortDirection: n.sortDirection || t
34
- };
35
- c(r);
36
- }, [u, d] = q(r);
37
- return {
38
- searchTerm: i,
39
- sortSettings: s,
40
- filterSettings: u,
41
- handleSearchChange: o,
42
- handleSortChange: l,
43
- handleFilterChange: (e) => {
44
- G(() => d(e));
45
- }
46
- };
47
- }
48
- //#endregion
49
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-components/-details/SecurityGroupBasicInfo.tsx
50
- function be({ securityGroup: e }) {
51
- let { i18n: t, _: n } = Y(), r = [
52
- {
53
- label: t._({ id: "Nu4oKW" }),
54
- value: e.description || t._({ id: "h47p9L" })
55
- },
56
- {
57
- label: t._({ id: "S0kLOH" }),
58
- value: e.id
59
- },
60
- {
61
- label: t._({ id: "OYHzN1" }),
62
- value: e.tags?.join(", ") || t._({ id: "h47p9L" })
63
- },
64
- {
65
- label: t._({ id: "6YtxFj" }),
66
- value: e.name || t._({ id: "h47p9L" })
67
- },
68
- {
69
- label: t._({ id: "Jim5X9" }),
70
- value: e.stateful ?? !0 ? t._({ id: "l75CjT" }) : t._({ id: "1UzENP" })
71
- },
72
- {
73
- label: t._({ id: "aI8Tgp" }),
74
- value: e.project_id || t._({ id: "h47p9L" })
75
- },
76
- {
77
- label: t._({ id: "0Gd0NU" }),
78
- value: e.shared ? t._({ id: "l75CjT" }) : t._({ id: "1UzENP" })
79
- }
80
- ];
81
- return /*#__PURE__*/ U(ne, { items: r });
82
- }
83
- //#endregion
84
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-components/-details/SecurityGroupTabs.tsx
85
- function xe({ activeTab: e, onTabChange: t, showRBACTab: n = !0 }) {
86
- let r = (t) => `px-6 py-3 font-semibold border-b-2 transition-colors ${e === t ? "border-theme-accent text-theme-highest" : "border-transparent text-theme-secondary hover:text-theme-high"}`;
87
- return /*#__PURE__*/ U("div", {
88
- className: "border-theme-background-lvl-3 mt-4 border-b",
89
- children: /*#__PURE__*/ W(c, {
90
- direction: "horizontal",
91
- gap: "0",
92
- children: [/*#__PURE__*/ U("button", {
93
- className: r("rules"),
94
- onClick: () => t("rules"),
95
- children: /*#__PURE__*/ U(J, { id: "4EZrJN" })
96
- }), n && /*#__PURE__*/ U("button", {
97
- className: r("rbac"),
98
- onClick: () => t("rbac"),
99
- children: /*#__PURE__*/ U(J, { id: "/eFtWI" })
100
- })]
101
- })
102
- });
103
- }
104
- //#endregion
105
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/DeleteRuleDialog.tsx
106
- function Se({ rule: e, open: t, onClose: n, onConfirm: r, isLoading: i, error: o }) {
107
- let { i18n: s, _: l } = Y(), { trackClose: u, markSubmitted: d, resetTracking: p } = I({
108
- isOpen: t,
109
- actionPrefix: "network.securitygroup.rule.delete"
110
- }), m = X.object({ confirm: X.string().refine((e) => e === "delete", { message: s._({ id: "QytzQr" }) }) }), g = Z({
111
- defaultValues: { confirm: "" },
112
- validators: { onSubmit: m },
113
- onSubmit: async () => {
114
- !e || i || (d(), r(e.id));
115
- }
116
- }), _ = Q(g.store, (e) => e.isSubmitting || e.values.confirm !== "delete");
117
- return e ? /*#__PURE__*/ U(f, {
118
- open: t,
119
- onCancel: () => {
120
- u(), g.reset(), p(), n();
121
- },
122
- size: "small",
123
- title: s._({ id: "TM93nK" }),
124
- confirmButtonLabel: i ? s._({ id: "EF2EU9" }) : s._({ id: "lN3xvy" }),
125
- confirmButtonVariant: "primary-danger",
126
- onConfirm: g.handleSubmit,
127
- cancelButtonLabel: s._({ id: "dEgA5A" }),
128
- disableConfirmButton: _ || i,
129
- disableCancelButton: i,
130
- disableCloseButton: i,
131
- children: /*#__PURE__*/ W(c, {
132
- direction: "vertical",
133
- gap: "4",
134
- children: [
135
- o && /*#__PURE__*/ U(a, {
136
- variant: "error",
137
- children: o
138
- }),
139
- /*#__PURE__*/ U("p", {
140
- className: "text-theme-default",
141
- children: /*#__PURE__*/ U(J, { id: "CMVP7y" })
142
- }),
143
- /*#__PURE__*/ W("div", {
144
- className: "bg-theme-background-lvl-1 rounded p-4",
145
- children: [/*#__PURE__*/ U("p", {
146
- className: "mb-2 font-semibold",
147
- children: /*#__PURE__*/ U(J, { id: "uly9ET" })
148
- }), /*#__PURE__*/ W("ul", {
149
- className: "list-inside list-disc space-y-1 text-sm",
150
- children: [
151
- /*#__PURE__*/ W("li", { children: [
152
- /*#__PURE__*/ U(J, { id: "MRB7nI" }),
153
- ": ",
154
- e.direction
155
- ] }),
156
- e.description && /*#__PURE__*/ W("li", { children: [
157
- /*#__PURE__*/ U(J, { id: "Nu4oKW" }),
158
- ": ",
159
- e.description
160
- ] }),
161
- /*#__PURE__*/ W("li", { children: [
162
- /*#__PURE__*/ U(J, { id: "yp0UjB" }),
163
- ": ",
164
- e.ethertype
165
- ] }),
166
- e.protocol && /*#__PURE__*/ W("li", { children: [
167
- /*#__PURE__*/ U(J, { id: "6+OdGi" }),
168
- ": ",
169
- e.protocol
170
- ] }),
171
- e.port_range_min !== null && e.port_range_max !== null && /*#__PURE__*/ W("li", { children: [
172
- /*#__PURE__*/ U(J, { id: "tV/Ozb" }),
173
- ":",
174
- " ",
175
- e.port_range_min === e.port_range_max ? e.port_range_min : `${e.port_range_min}-${e.port_range_max}`
176
- ] }),
177
- e.remote_ip_prefix && /*#__PURE__*/ W("li", { children: [
178
- /*#__PURE__*/ U(J, { id: "WoSkGY" }),
179
- ": ",
180
- e.remote_ip_prefix
181
- ] }),
182
- e.remote_group_id && /*#__PURE__*/ W("li", { children: [
183
- /*#__PURE__*/ U(J, { id: "i9TIyi" }),
184
- ": ",
185
- e.remote_group_id
186
- ] })
187
- ]
188
- })]
189
- }),
190
- /*#__PURE__*/ U(h, {
191
- className: "mb-0",
192
- id: "delete-rule-form",
193
- onSubmit: (e) => {
194
- e.preventDefault(), g.handleSubmit();
195
- },
196
- children: /*#__PURE__*/ U(E, { children: /*#__PURE__*/ U(g.Field, {
197
- name: "confirm",
198
- children: (e) => /*#__PURE__*/ U(S, {
199
- label: s._({ id: "QytzQr" }),
200
- id: e.name,
201
- name: e.name,
202
- value: e.state.value,
203
- onChange: (t) => e.handleChange(t.target.value),
204
- placeholder: "delete",
205
- autoComplete: "off",
206
- autoFocus: !0,
207
- disabled: i,
208
- "data-testid": "delete-rule-confirmation-input",
209
- required: !0
210
- })
211
- }) })
212
- })
213
- ]
214
- })
215
- }) : null;
216
- }
217
- //#endregion
218
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/AddRuleModal/validation/validationHelpers.ts
219
- function Ce(e) {
220
- return e.includes(".") ? "IPv4" : e.includes(":") ? "IPv6" : null;
221
- }
222
- function we(e, t, n) {
223
- if (e != null && isNaN(e) || t != null && isNaN(t)) return {
224
- valid: !1,
225
- error: "Port must be a valid number"
226
- };
227
- if (n?.toLowerCase() === "tcp" || n?.toLowerCase() === "udp") {
228
- if (e != null && (e < 1 || e > 65535) || t != null && (t < 1 || t > 65535)) return {
229
- valid: !1,
230
- error: "For TCP/UDP: port must be between 1 and 65535"
231
- };
232
- } else if (e != null && (e < 0 || e > 65535) || t != null && (t < 0 || t > 65535)) return {
233
- valid: !1,
234
- error: "Port must be between 0 and 65535"
235
- };
236
- return e != null && t != null && e > t ? {
237
- valid: !1,
238
- error: "port_range_min must be less than or equal to port_range_max"
239
- } : { valid: !0 };
240
- }
241
- function Te(e, t) {
242
- return e != null && isNaN(e) ? {
243
- valid: !1,
244
- error: "ICMP type must be a valid number"
245
- } : t != null && isNaN(t) ? {
246
- valid: !1,
247
- error: "ICMP code must be a valid number"
248
- } : e != null && (e < 0 || e > 255) ? {
249
- valid: !1,
250
- error: "ICMP type must be between 0 and 255"
251
- } : t != null && (t < 0 || t > 255) ? {
252
- valid: !1,
253
- error: "ICMP code must be between 0 and 255"
254
- } : { valid: !0 };
255
- }
256
- function Ee(e) {
257
- let t = e.split("/");
258
- if (t.length !== 2) return !1;
259
- let [n, r] = t;
260
- if (!/^\d+$/.test(r)) return !1;
261
- let i = parseInt(r, 10);
262
- if (isNaN(i) || i < 0) return !1;
263
- if (n.includes(".")) {
264
- let e = n.split(".");
265
- if (e.length !== 4) return !1;
266
- for (let t of e) {
267
- let e = parseInt(t, 10);
268
- if (isNaN(e) || e < 0 || e > 255 || t !== e.toString()) return !1;
269
- }
270
- return i <= 32;
271
- }
272
- if (n.includes(":")) {
273
- if (n.includes(":::") || i > 128) return !1;
274
- let e = n.includes("::"), t = n.split(":").filter((e) => e !== "");
275
- if (e) {
276
- if (t.length > 7) return !1;
277
- } else if (t.length !== 8) return !1;
278
- for (let e of t) if (e.length === 0 || e.length > 4 || !/^[0-9a-fA-F]+$/.test(e)) return !1;
279
- return !((n.match(/::/g) || []).length > 1 || n.startsWith(":") && !n.startsWith("::") || n.endsWith(":") && !n.endsWith("::"));
280
- }
281
- return !1;
282
- }
283
- //#endregion
284
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/AddRuleModal/constants.ts
285
- var De = "0.0.0.0/0", Oe = "::/0", ke = "other-protocol", Ae = X.object({
286
- ruleType: X.string().min(1, "Rule type is required"),
287
- direction: X.enum(["ingress", "egress"]),
288
- ethertype: X.enum(["IPv4", "IPv6"]),
289
- description: X.string(),
290
- protocol: X.string().nullable(),
291
- portFrom: X.string(),
292
- portTo: X.string(),
293
- icmpType: X.string(),
294
- icmpCode: X.string(),
295
- remoteSourceType: X.enum(["cidr", "security_group"]),
296
- remoteCidr: X.string(),
297
- remoteSecurityGroupId: X.string()
298
- }).superRefine((e, t) => {
299
- let n = e.protocol === "tcp" || e.protocol === "udp", r = e.protocol === "icmp" || e.protocol === "ipv6-icmp", i = e.ruleType === ke, a = n && ["custom-tcp", "custom-udp"].includes(e.ruleType);
300
- if (i && !e.protocol && t.addIssue({
301
- code: X.ZodIssueCode.custom,
302
- message: "Protocol is required",
303
- path: ["protocol"]
304
- }), a) if (!e.portFrom) t.addIssue({
305
- code: X.ZodIssueCode.custom,
306
- message: "Port (from) is required",
307
- path: ["portFrom"]
308
- });
309
- else {
310
- let n = parseInt(e.portFrom, 10);
311
- if (isNaN(n)) t.addIssue({
312
- code: X.ZodIssueCode.custom,
313
- message: "Port must be a valid number",
314
- path: ["portFrom"]
315
- });
316
- else if (e.portTo) {
317
- let r = parseInt(e.portTo, 10);
318
- if (isNaN(r)) t.addIssue({
319
- code: X.ZodIssueCode.custom,
320
- message: "Port must be a valid number",
321
- path: ["portTo"]
322
- });
323
- else if (n >= r) t.addIssue({
324
- code: X.ZodIssueCode.custom,
325
- message: "\"Port (from)\" must be less than \"Port (to)\"",
326
- path: ["portFrom"]
327
- });
328
- else {
329
- let i = we(n, r, e.protocol);
330
- i.valid || t.addIssue({
331
- code: X.ZodIssueCode.custom,
332
- message: i.error || "Invalid port range",
333
- path: ["portFrom"]
334
- });
335
- }
336
- } else {
337
- let r = we(n, n, e.protocol);
338
- r.valid || t.addIssue({
339
- code: X.ZodIssueCode.custom,
340
- message: r.error || "Invalid port",
341
- path: ["portFrom"]
342
- });
343
- }
344
- }
345
- if (r) {
346
- let n = e.icmpType ? parseInt(e.icmpType, 10) : null, r = e.icmpCode ? parseInt(e.icmpCode, 10) : null;
347
- if (e.icmpType && isNaN(n) && t.addIssue({
348
- code: X.ZodIssueCode.custom,
349
- message: "ICMP type must be a valid number",
350
- path: ["icmpType"]
351
- }), e.icmpCode && isNaN(r) && t.addIssue({
352
- code: X.ZodIssueCode.custom,
353
- message: "ICMP code must be a valid number",
354
- path: ["icmpCode"]
355
- }), e.icmpCode && !e.icmpType && t.addIssue({
356
- code: X.ZodIssueCode.custom,
357
- message: "ICMP type is required when ICMP code is specified",
358
- path: ["icmpType"]
359
- }), n !== null || r !== null) {
360
- let e = Te(n, r);
361
- e.valid || (e.error?.includes("type") && t.addIssue({
362
- code: X.ZodIssueCode.custom,
363
- message: "ICMP type must be between 0 and 255",
364
- path: ["icmpType"]
365
- }), e.error?.includes("code") && t.addIssue({
366
- code: X.ZodIssueCode.custom,
367
- message: "ICMP code must be between 0 and 255",
368
- path: ["icmpCode"]
369
- }));
370
- }
371
- }
372
- if (e.remoteSourceType === "cidr" && e.remoteCidr) if (!Ee(e.remoteCidr)) t.addIssue({
373
- code: X.ZodIssueCode.custom,
374
- message: "Invalid CIDR format. Examples: 0.0.0.0/0 (IPv4) or ::/0 (IPv6)",
375
- path: ["remoteCidr"]
376
- });
377
- else {
378
- let n = Ce(e.remoteCidr);
379
- n && n !== e.ethertype && t.addIssue({
380
- code: X.ZodIssueCode.custom,
381
- message: `CIDR family (${n}) must match Ethertype (${e.ethertype})`,
382
- path: ["remoteCidr"]
383
- });
384
- }
385
- }), je = {
386
- ruleType: "",
387
- direction: "ingress",
388
- ethertype: "IPv4",
389
- description: "",
390
- protocol: null,
391
- portFrom: "",
392
- portTo: "",
393
- icmpType: "",
394
- icmpCode: "",
395
- remoteSourceType: "cidr",
396
- remoteCidr: De,
397
- remoteSecurityGroupId: ""
398
- }, Me = [
399
- {
400
- value: "",
401
- label: "",
402
- protocol: null,
403
- portRangeMin: null,
404
- portRangeMax: null
405
- },
406
- {
407
- value: "custom-tcp",
408
- label: "Custom TCP Rule",
409
- protocol: "tcp",
410
- portRangeMin: null,
411
- portRangeMax: null
412
- },
413
- {
414
- value: "custom-udp",
415
- label: "Custom UDP Rule",
416
- protocol: "udp",
417
- portRangeMin: null,
418
- portRangeMax: null
419
- },
420
- {
421
- value: "custom-icmp",
422
- label: "Custom ICMP Rule",
423
- protocol: "icmp",
424
- portRangeMin: null,
425
- portRangeMax: null
426
- },
427
- {
428
- value: "all-tcp",
429
- label: "All TCP",
430
- protocol: "tcp",
431
- portRangeMin: 1,
432
- portRangeMax: 65535
433
- },
434
- {
435
- value: "all-udp",
436
- label: "All UDP",
437
- protocol: "udp",
438
- portRangeMin: 1,
439
- portRangeMax: 65535
440
- },
441
- {
442
- value: "all-icmp",
443
- label: "All ICMP",
444
- protocol: "icmp",
445
- portRangeMin: null,
446
- portRangeMax: null
447
- },
448
- {
449
- value: "other-protocol",
450
- label: "Other Protocol",
451
- protocol: null,
452
- portRangeMin: null,
453
- portRangeMax: null
454
- },
455
- {
456
- value: "dns",
457
- label: "DNS",
458
- protocol: "tcp",
459
- portRangeMin: 53,
460
- portRangeMax: 53
461
- },
462
- {
463
- value: "http",
464
- label: "HTTP",
465
- protocol: "tcp",
466
- portRangeMin: 80,
467
- portRangeMax: 80
468
- },
469
- {
470
- value: "https",
471
- label: "HTTPS",
472
- protocol: "tcp",
473
- portRangeMin: 443,
474
- portRangeMax: 443
475
- },
476
- {
477
- value: "imap",
478
- label: "IMAP",
479
- protocol: "tcp",
480
- portRangeMin: 143,
481
- portRangeMax: 143
482
- },
483
- {
484
- value: "imaps",
485
- label: "IMAPS",
486
- protocol: "tcp",
487
- portRangeMin: 993,
488
- portRangeMax: 993
489
- },
490
- {
491
- value: "ldap",
492
- label: "LDAP",
493
- protocol: "tcp",
494
- portRangeMin: 389,
495
- portRangeMax: 389
496
- },
497
- {
498
- value: "ms-sql",
499
- label: "MS SQL",
500
- protocol: "tcp",
501
- portRangeMin: 1433,
502
- portRangeMax: 1433
503
- },
504
- {
505
- value: "mysql",
506
- label: "MySQL",
507
- protocol: "tcp",
508
- portRangeMin: 3306,
509
- portRangeMax: 3306
510
- },
511
- {
512
- value: "pop3",
513
- label: "POP3",
514
- protocol: "tcp",
515
- portRangeMin: 110,
516
- portRangeMax: 110
517
- },
518
- {
519
- value: "pop3s",
520
- label: "POP3S",
521
- protocol: "tcp",
522
- portRangeMin: 995,
523
- portRangeMax: 995
524
- },
525
- {
526
- value: "rdp",
527
- label: "RDP",
528
- protocol: "tcp",
529
- portRangeMin: 3389,
530
- portRangeMax: 3389
531
- },
532
- {
533
- value: "ssh",
534
- label: "SSH",
535
- protocol: "tcp",
536
- portRangeMin: 22,
537
- portRangeMax: 22
538
- },
539
- {
540
- value: "smtp",
541
- label: "SMTP",
542
- protocol: "tcp",
543
- portRangeMin: 25,
544
- portRangeMax: 25
545
- },
546
- {
547
- value: "smtps",
548
- label: "SMTPS",
549
- protocol: "tcp",
550
- portRangeMin: 465,
551
- portRangeMax: 465
552
- }
553
- ];
554
- //#endregion
555
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/AddRuleModal/sections/RuleTypeSection.tsx
556
- function Ne({ form: e, disabled: t = !1 }) {
557
- let { i18n: n, _: r } = Y();
558
- return /*#__PURE__*/ U(e.Field, {
559
- name: "ruleType",
560
- mode: "value",
561
- children: (r) => /*#__PURE__*/ U(_, {
562
- className: "mb-6",
563
- children: /*#__PURE__*/ U(y, {
564
- id: "ruleType",
565
- label: n._({ id: "YuGQWb" }),
566
- value: r.state.value,
567
- onChange: (t) => {
568
- let n = String(t || "");
569
- if (r.handleChange(n), !n) {
570
- e.setFieldValue("protocol", null), e.setFieldValue("portFrom", ""), e.setFieldValue("portTo", ""), e.setFieldValue("icmpType", ""), e.setFieldValue("icmpCode", "");
571
- return;
572
- }
573
- let i = Me.find((e) => e.value === n);
574
- i && (e.setFieldValue("protocol", i.protocol), (i.protocol === "tcp" || i.protocol === "udp") && i.portRangeMin !== null && i.portRangeMax !== null ? (e.setFieldValue("portFrom", String(i.portRangeMin)), e.setFieldValue("portTo", String(i.portRangeMax))) : (e.setFieldValue("portFrom", ""), e.setFieldValue("portTo", "")), i.protocol !== "icmp" && i.protocol !== "ipv6-icmp" && (e.setFieldValue("icmpType", ""), e.setFieldValue("icmpCode", "")));
575
- },
576
- disabled: t,
577
- children: Me.map((e) => e.value === "" ? /*#__PURE__*/ U(l, {
578
- value: e.value,
579
- label: n._({ id: "eh/k36" })
580
- }, e.value) : /*#__PURE__*/ U(l, {
581
- value: e.value,
582
- label: e.label
583
- }, e.value))
584
- })
585
- })
586
- });
587
- }
588
- //#endregion
589
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/AddRuleModal/sections/DirectionEthertypeSection.tsx
590
- function Pe({ form: e, disabled: t = !1 }) {
591
- let { i18n: n, _: r } = Y();
592
- return /*#__PURE__*/ U(e.Field, {
593
- name: "direction",
594
- children: (e) => /*#__PURE__*/ U(_, { children: /*#__PURE__*/ U(A, {
595
- name: "direction",
596
- label: n._({ id: "MRB7nI" }),
597
- selected: e.state.value,
598
- onChange: (t) => e.handleChange(String(t)),
599
- required: !0,
600
- disabled: t,
601
- children: /*#__PURE__*/ W("div", {
602
- className: "flex gap-4",
603
- children: [/*#__PURE__*/ U(m, {
604
- value: "ingress",
605
- label: n._({ id: "fzfAAa" })
606
- }), /*#__PURE__*/ U(m, {
607
- value: "egress",
608
- label: n._({ id: "nETBrc" })
609
- })]
610
- })
611
- }) })
612
- });
613
- }
614
- function Fe({ form: e, disabled: t = !1 }) {
615
- let { i18n: n, _: r } = Y();
616
- return /*#__PURE__*/ U(e.Field, {
617
- name: "ethertype",
618
- children: (e) => /*#__PURE__*/ U(_, { children: /*#__PURE__*/ U(A, {
619
- name: "ethertype",
620
- label: n._({ id: "16085O" }),
621
- selected: e.state.value,
622
- onChange: (t) => e.handleChange(String(t)),
623
- required: !0,
624
- disabled: t,
625
- children: /*#__PURE__*/ W("div", {
626
- className: "flex gap-4",
627
- children: [/*#__PURE__*/ U(m, {
628
- value: "IPv4",
629
- label: "IPv4"
630
- }), /*#__PURE__*/ U(m, {
631
- value: "IPv6",
632
- label: "IPv6"
633
- })]
634
- })
635
- }) })
636
- });
637
- }
638
- //#endregion
639
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/AddRuleModal/sections/ProtocolSection.tsx
640
- function Ie({ form: e, disabled: t = !1 }) {
641
- let { i18n: n, _: r } = Y();
642
- return /*#__PURE__*/ U(e.Field, {
643
- name: "protocol",
644
- children: (e) => /*#__PURE__*/ U(_, {
645
- className: "mb-6",
646
- children: /*#__PURE__*/ U(S, {
647
- id: "protocol",
648
- name: "protocol",
649
- label: n._({ id: "6+OdGi" }),
650
- value: e.state.value || "",
651
- onChange: (t) => e.handleChange(t.target.value || null),
652
- errortext: e.state.meta.errors[0]?.message,
653
- placeholder: n._({ id: "8wdCNd" }),
654
- disabled: t
655
- })
656
- })
657
- });
658
- }
659
- //#endregion
660
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/AddRuleModal/sections/PortRangeSection.tsx
661
- function Le({ form: e, disabled: t = !1 }) {
662
- let { i18n: n, _: r } = Y(), i = Q(e.store, (e) => e.values.portFrom), a = Q(e.store, (e) => e.fieldMeta.portFrom?.errors[0]?.message), o = Q(e.store, (e) => e.fieldMeta.portTo?.errors[0]?.message), s = t || !i || i.trim() === "";
663
- return /*#__PURE__*/ W(_, {
664
- className: "mb-6",
665
- children: [
666
- /*#__PURE__*/ W("div", {
667
- className: "flex items-center gap-4",
668
- children: [
669
- /*#__PURE__*/ U(e.Field, {
670
- name: "portFrom",
671
- children: (r) => /*#__PURE__*/ U("div", {
672
- className: "flex-1",
673
- children: /*#__PURE__*/ U(S, {
674
- id: "portFrom",
675
- name: "portFrom",
676
- label: n._({ id: "LMdsuJ" }),
677
- value: r.state.value || "",
678
- onChange: (t) => {
679
- let n = t.target.value;
680
- r.handleChange(n), (!n || n.trim() === "") && e.setFieldValue("portTo", ""), e.validateField("portTo", "change");
681
- },
682
- invalid: r.state.meta.errors.length > 0,
683
- disabled: t,
684
- required: !0
685
- })
686
- })
687
- }),
688
- /*#__PURE__*/ U("div", {
689
- className: "text-theme-secondary flex items-center justify-center",
690
- children: "—"
691
- }),
692
- /*#__PURE__*/ U(e.Field, {
693
- name: "portTo",
694
- children: (t) => /*#__PURE__*/ U("div", {
695
- className: "flex-1",
696
- children: /*#__PURE__*/ U(S, {
697
- id: "portTo",
698
- name: "portTo",
699
- label: n._({ id: "a12lSo" }),
700
- value: t.state.value || "",
701
- onChange: (n) => {
702
- t.handleChange(n.target.value), e.validateField("portFrom", "change");
703
- },
704
- invalid: t.state.meta.errors.length > 0,
705
- placeholder: "",
706
- disabled: s
707
- })
708
- })
709
- })
710
- ]
711
- }),
712
- (a || o) && /*#__PURE__*/ W("div", {
713
- className: "text-theme-error mt-2 text-sm",
714
- children: [a && /*#__PURE__*/ U("div", { children: a }), o && /*#__PURE__*/ U("div", { children: o })]
715
- }),
716
- /*#__PURE__*/ U("p", {
717
- className: "mt-2 text-sm",
718
- children: n._({ id: "QAUa4B" })
719
- })
720
- ]
721
- });
722
- }
723
- //#endregion
724
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/AddRuleModal/sections/IcmpSection.tsx
725
- function Re({ form: e, disabled: t = !1 }) {
726
- let { i18n: n, _: r } = Y();
727
- return /*#__PURE__*/ U(_, {
728
- className: "mb-6",
729
- children: /*#__PURE__*/ W("div", {
730
- className: "flex w-full gap-4",
731
- children: [/*#__PURE__*/ U(e.Field, {
732
- name: "icmpType",
733
- children: (e) => /*#__PURE__*/ U("div", {
734
- className: "flex-1",
735
- children: /*#__PURE__*/ U(S, {
736
- id: "icmpType",
737
- name: "icmpType",
738
- label: n._({ id: "yPWFWy" }),
739
- value: e.state.value,
740
- onChange: (t) => e.handleChange(t.target.value),
741
- errortext: e.state.meta.errors[0]?.message,
742
- placeholder: n._({ id: "GPuCEo" }),
743
- disabled: t
744
- })
745
- })
746
- }), /*#__PURE__*/ U(e.Field, {
747
- name: "icmpCode",
748
- children: (e) => /*#__PURE__*/ U("div", {
749
- className: "flex-1",
750
- children: /*#__PURE__*/ U(S, {
751
- id: "icmpCode",
752
- name: "icmpCode",
753
- label: n._({ id: "76RKuS" }),
754
- value: e.state.value,
755
- onChange: (t) => e.handleChange(t.target.value),
756
- errortext: e.state.meta.errors[0]?.message,
757
- placeholder: n._({ id: "UkVkoq" }),
758
- disabled: t
759
- })
760
- })
761
- })]
762
- })
763
- });
764
- }
765
- //#endregion
766
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/AddRuleModal/sections/RemoteSourceSection.tsx
767
- function ze({ form: e, disabled: t = !1, availableSecurityGroups: n }) {
768
- let { i18n: r, _: i } = Y();
769
- return /*#__PURE__*/ W(H, { children: [
770
- /*#__PURE__*/ U(e.Field, {
771
- name: "remoteSourceType",
772
- mode: "value",
773
- children: (n) => /*#__PURE__*/ U(_, {
774
- className: "mb-1",
775
- children: /*#__PURE__*/ U(A, {
776
- name: "remoteSourceType",
777
- label: r._({ id: "I5kZVK" }),
778
- selected: n.state.value,
779
- onChange: (t) => {
780
- let r = String(t);
781
- n.handleChange(r), r !== "security_group" && e.setFieldValue("ethertype", "IPv4");
782
- },
783
- disabled: t,
784
- children: /*#__PURE__*/ W("div", {
785
- className: "flex gap-4",
786
- children: [/*#__PURE__*/ U(m, {
787
- value: "cidr",
788
- label: r._({ id: "4uXhtt" })
789
- }), /*#__PURE__*/ U(m, {
790
- value: "security_group",
791
- label: r._({ id: "bwhBhT" })
792
- })]
793
- })
794
- })
795
- })
796
- }),
797
- /*#__PURE__*/ U(e.Field, {
798
- name: "remoteSourceType",
799
- children: (n) => n.state.value === "cidr" ? /*#__PURE__*/ U(e.Field, {
800
- name: "remoteCidr",
801
- children: (n) => /*#__PURE__*/ U(e.Field, {
802
- name: "ethertype",
803
- children: (e) => /*#__PURE__*/ U(_, {
804
- className: "mb-6",
805
- children: /*#__PURE__*/ U(S, {
806
- id: "remoteCidr",
807
- name: "remoteCidr",
808
- label: r._({ id: "vmYyLY" }),
809
- value: n.state.value,
810
- onChange: (e) => n.handleChange(e.target.value),
811
- errortext: n.state.meta.errors[0]?.message,
812
- placeholder: e.state.value === "IPv4" ? De : Oe,
813
- disabled: t
814
- })
815
- })
816
- })
817
- }) : null
818
- }),
819
- /*#__PURE__*/ U(e.Field, {
820
- name: "remoteSourceType",
821
- children: (i) => i.state.value === "security_group" ? /*#__PURE__*/ U(e.Field, {
822
- name: "remoteSecurityGroupId",
823
- children: (e) => /*#__PURE__*/ U(_, {
824
- className: "mb-6",
825
- children: /*#__PURE__*/ W(y, {
826
- id: "remoteSecurityGroupId",
827
- label: r._({ id: "i9TIyi" }),
828
- value: e.state.value,
829
- onChange: (t) => e.handleChange(String(t)),
830
- errortext: e.state.meta.errors[0]?.message,
831
- disabled: t,
832
- children: [/*#__PURE__*/ U(l, {
833
- value: "",
834
- label: r._({ id: "ZvIpwi" })
835
- }), n.map((e) => /*#__PURE__*/ U(l, {
836
- value: e.id,
837
- label: e.name || e.id
838
- }, e.id))]
839
- })
840
- })
841
- }) : null
842
- })
843
- ] });
844
- }
845
- //#endregion
846
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/AddRuleModal/sections/DescriptionSection.tsx
847
- function Be({ form: e, disabled: t = !1 }) {
848
- let { i18n: n, _: r } = Y();
849
- return /*#__PURE__*/ U(e.Field, {
850
- name: "description",
851
- children: (e) => /*#__PURE__*/ U(_, {
852
- className: "mb-0",
853
- children: /*#__PURE__*/ U(x, {
854
- id: "description",
855
- name: "description",
856
- label: n._({ id: "Nu4oKW" }),
857
- value: e.state.value,
858
- onChange: (t) => e.handleChange(t.target.value),
859
- placeholder: n._({ id: "pbzA+s" }),
860
- disabled: t,
861
- rows: 2
862
- })
863
- })
864
- });
865
- }
866
- //#endregion
867
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/AddRuleModal/AddRuleModal.tsx
868
- var Ve = ({ securityGroupId: e, open: t, onClose: n, onCreate: r, isLoading: c = !1, error: l = null, availableSecurityGroups: u = [] }) => {
869
- let { i18n: d, _: p } = Y(), m = Z({
870
- defaultValues: je,
871
- validators: { onSubmit: Ae },
872
- onSubmit: async ({ value: t }) => {
873
- if (c) return;
874
- let n = {
875
- security_group_id: e,
876
- direction: t.direction,
877
- ethertype: t.ethertype,
878
- description: t.description || void 0,
879
- protocol: t.protocol || null,
880
- remote_ip_prefix: void 0,
881
- remote_group_id: void 0,
882
- remote_address_group_id: void 0
883
- };
884
- if ((t.protocol === "tcp" || t.protocol === "udp") && t.portFrom) {
885
- let e = parseInt(t.portFrom, 10);
886
- n.port_range_min = e, n.port_range_max = t.portTo ? parseInt(t.portTo, 10) : e;
887
- }
888
- (t.protocol === "icmp" || t.protocol === "ipv6-icmp") && (t.icmpType && (n.port_range_min = parseInt(t.icmpType, 10)), t.icmpCode && (n.port_range_max = parseInt(t.icmpCode, 10))), t.remoteSourceType === "cidr" && t.remoteCidr ? n.remote_ip_prefix = t.remoteCidr : t.remoteSourceType === "security_group" && t.remoteSecurityGroupId && (n.remote_group_id = t.remoteSecurityGroupId), await r(n), g();
889
- }
890
- }), g = () => {
891
- m.reset(), n();
892
- };
893
- return /*#__PURE__*/ W(f, {
894
- open: t,
895
- onCancel: g,
896
- size: "large",
897
- title: d._({ id: "b2BLBa" }),
898
- modalFooter: /*#__PURE__*/ U(s, {
899
- className: "flex justify-end",
900
- children: /*#__PURE__*/ U(m.Subscribe, { children: (e) => {
901
- let t = !!e.values.ruleType;
902
- return /*#__PURE__*/ W(o, { children: [/*#__PURE__*/ U(v, {
903
- variant: "default",
904
- onClick: g,
905
- disabled: c || e.isSubmitting,
906
- children: /*#__PURE__*/ U(J, { id: "dEgA5A" })
907
- }), /*#__PURE__*/ U(v, {
908
- variant: "primary",
909
- type: "button",
910
- onClick: () => m.handleSubmit(),
911
- disabled: c || e.isSubmitting || !t,
912
- "data-testid": "add-rule-button",
913
- children: e.isSubmitting || c ? /*#__PURE__*/ U(i, { size: "small" }) : /*#__PURE__*/ U(J, { id: "bmQLn5" })
914
- })] });
915
- } })
916
- }),
917
- children: [
918
- l && /*#__PURE__*/ U(a, {
919
- dismissible: !1,
920
- variant: "error",
921
- className: "mb-4",
922
- children: l
923
- }),
924
- c && /*#__PURE__*/ U(D, {
925
- status: "progress",
926
- title: d._({ id: "9RslTb" }),
927
- className: "mt-0"
928
- }),
929
- /*#__PURE__*/ U(h, {
930
- className: "mb-6",
931
- onSubmit: (e) => {
932
- e.preventDefault(), m.handleSubmit();
933
- },
934
- children: /*#__PURE__*/ W(E, {
935
- className: "mb-6",
936
- children: [/*#__PURE__*/ U(Ne, {
937
- form: m,
938
- disabled: c
939
- }), /*#__PURE__*/ U(m.Subscribe, { children: (e) => {
940
- if (!e.values.ruleType) return null;
941
- let t = (e.values.protocol === "tcp" || e.values.protocol === "udp") && ["custom-tcp", "custom-udp"].includes(e.values.ruleType), n = e.values.protocol === "icmp" || e.values.protocol === "ipv6-icmp";
942
- return /*#__PURE__*/ W(H, { children: [
943
- /*#__PURE__*/ U(Pe, {
944
- form: m,
945
- disabled: c
946
- }),
947
- e.values.ruleType === "other-protocol" && /*#__PURE__*/ U(Ie, {
948
- form: m,
949
- disabled: c
950
- }),
951
- t && /*#__PURE__*/ U(Le, {
952
- form: m,
953
- disabled: c
954
- }),
955
- n && /*#__PURE__*/ U(Re, {
956
- form: m,
957
- disabled: c
958
- }),
959
- /*#__PURE__*/ U(ze, {
960
- form: m,
961
- disabled: c,
962
- availableSecurityGroups: u
963
- }),
964
- e.values.remoteSourceType === "security_group" && /*#__PURE__*/ U(Fe, {
965
- form: m,
966
- disabled: c
967
- }),
968
- /*#__PURE__*/ U(Be, {
969
- form: m,
970
- disabled: c
971
- })
972
- ] });
973
- } })]
974
- })
975
- })
976
- ]
977
- });
978
- }, He = /* @__PURE__ */ new Set([
979
- "icmp",
980
- "1",
981
- "ipv6-icmp",
982
- "icmpv6",
983
- "58"
984
- ]);
985
- function Ue(e) {
986
- return e != null && He.has(e.toLowerCase());
987
- }
988
- function We({ rules: e, onDeleteRule: r, isDeletingRule: i, deleteError: a, searchTerm: o = "", onSearchChange: s, sortSettings: l, onSortChange: f, filterSettings: p, onFilterChange: m, securityGroupId: h, onCreateRule: _, isCreatingRule: y = !1, createRuleError: x = null, availableSecurityGroups: S = [], canCreateRule: C, canDeleteRule: T }) {
989
- let { i18n: E, _: O } = Y(), [A, M] = q(null), [N, P] = te(), [I, ee] = q(o), L = _e(void 0);
990
- K(() => () => clearTimeout(L.current), []);
991
- let ne = (e) => {
992
- M(e);
993
- }, ae = (e) => {
994
- r(e);
995
- }, oe = () => {
996
- i || M(null);
997
- };
998
- K(() => {
999
- !i && !a && M(null);
1000
- }, [i, a]);
1001
- let se = (e) => {
1002
- let t = e.port_range_min, n = e.port_range_max;
1003
- if (Ue(e.protocol)) {
1004
- let e = t, r = n;
1005
- return e == null ? E._({ id: "h47p9L" }) : r == null ? E._({
1006
- id: "3BgEOh",
1007
- values: { typeValue: e }
1008
- }) : E._({
1009
- id: "0p+s6m",
1010
- values: {
1011
- typeValue: e,
1012
- codeValue: r
1013
- }
1014
- });
1015
- }
1016
- return t == null || n == null ? E._({ id: "h47p9L" }) : t === n ? String(t) : `${t}-${n}`;
1017
- }, R = T ? 6 : 5;
1018
- return /*#__PURE__*/ W(H, { children: [
1019
- /*#__PURE__*/ W(c, {
1020
- distribution: "end",
1021
- alignment: "center",
1022
- gap: "2",
1023
- className: "pb-2",
1024
- children: [l && f && /*#__PURE__*/ U(F, {
1025
- options: l.options,
1026
- sortBy: l.sortBy,
1027
- sortDirection: l.sortDirection ?? "asc",
1028
- selectClassName: "min-w-40",
1029
- onSortByChange: (e) => f({
1030
- ...l,
1031
- sortBy: e,
1032
- sortDirection: l.sortDirection
1033
- }),
1034
- onSortDirectionChange: (e) => f({
1035
- ...l,
1036
- sortDirection: e
1037
- })
1038
- }), C && _ && /*#__PURE__*/ U(v, {
1039
- variant: "primary",
1040
- onClick: P,
1041
- className: "whitespace-nowrap",
1042
- children: /*#__PURE__*/ U(J, { id: "bmQLn5" })
1043
- })]
1044
- }),
1045
- (p || s) && /*#__PURE__*/ U(b, { children: /*#__PURE__*/ W(c, {
1046
- direction: "vertical",
1047
- gap: "2",
1048
- children: [/*#__PURE__*/ W(c, {
1049
- distribution: "between",
1050
- alignment: "center",
1051
- children: [p && m && /*#__PURE__*/ U(ie, {
1052
- filters: p.filters,
1053
- selectClassName: "sm:min-w-40",
1054
- comboboxClassName: "sm:min-w-40",
1055
- onChange: (e) => {
1056
- if ((p.selectedFilters || []).some((t) => t.name === e.name && t.value === e.value)) return;
1057
- let t = p.filters.find((t) => t.filterName === e.name)?.supportsMultiValue ? [...p.selectedFilters || [], e] : [...(p.selectedFilters || []).filter((t) => t.name !== e.name), e];
1058
- m({
1059
- ...p,
1060
- selectedFilters: t
1061
- });
1062
- }
1063
- }), s && /*#__PURE__*/ U(t, {
1064
- className: "w-60 sm:w-68",
1065
- placeholder: E._({ id: "HMV+cw" }),
1066
- "data-testid": "searchbar",
1067
- value: I,
1068
- onInput: (e) => {
1069
- let t = e.currentTarget.value;
1070
- ee(t), clearTimeout(L.current), L.current = window.setTimeout(() => s(t), 500);
1071
- },
1072
- onSearch: (e) => {
1073
- clearTimeout(L.current), s(typeof e == "string" ? e : "");
1074
- },
1075
- onClear: () => {
1076
- clearTimeout(L.current), ee(""), s("");
1077
- }
1078
- })]
1079
- }), p?.selectedFilters && p.selectedFilters.length > 0 && /*#__PURE__*/ U(re, {
1080
- selectedFilters: p.selectedFilters,
1081
- onDelete: (e) => m?.({
1082
- ...p,
1083
- selectedFilters: (p.selectedFilters || []).filter((t) => t.name !== e.name || t.value !== e.value)
1084
- }),
1085
- onClear: () => m?.({
1086
- ...p,
1087
- selectedFilters: []
1088
- })
1089
- })]
1090
- }) }),
1091
- /*#__PURE__*/ W(w, {
1092
- columns: R,
1093
- className: "security-group-rules-table",
1094
- children: [/*#__PURE__*/ W(d, { children: [
1095
- /*#__PURE__*/ U(u, { children: E._({ id: "MRB7nI" }) }),
1096
- /*#__PURE__*/ U(u, { children: E._({ id: "Nu4oKW" }) }),
1097
- /*#__PURE__*/ U(u, { children: E._({ id: "yp0UjB" }) }),
1098
- /*#__PURE__*/ U(u, { children: E._({ id: "6+OdGi" }) }),
1099
- /*#__PURE__*/ U(u, { children: E._({ id: "6jAi8c" }) }),
1100
- T && /*#__PURE__*/ U(u, {})
1101
- ] }), e.length === 0 ? /*#__PURE__*/ U(d, { children: /*#__PURE__*/ U(k, {
1102
- colSpan: R,
1103
- children: /*#__PURE__*/ U(D, {
1104
- status: "empty",
1105
- title: E._({ id: "nnxwBn" })
1106
- })
1107
- }) }) : e.map((e) => /*#__PURE__*/ W(d, {
1108
- "data-testid": `rule-row-${e.id}`,
1109
- children: [
1110
- /*#__PURE__*/ U(k, { children: e.direction || E._({ id: "h47p9L" }) }),
1111
- /*#__PURE__*/ U(k, { children: e.description || E._({ id: "h47p9L" }) }),
1112
- /*#__PURE__*/ U(k, { children: e.ethertype }),
1113
- /*#__PURE__*/ U(k, { children: e.protocol || E._({ id: "h47p9L" }) }),
1114
- /*#__PURE__*/ U(k, { children: se(e) }),
1115
- T && /*#__PURE__*/ U(k, {
1116
- onClick: (e) => e.stopPropagation(),
1117
- className: "items-end pr-0",
1118
- children: /*#__PURE__*/ U(n, { children: /*#__PURE__*/ U(g, { children: /*#__PURE__*/ U(j, {
1119
- label: E._({ id: "lN3xvy" }),
1120
- onClick: () => ne(e)
1121
- }) }) })
1122
- })
1123
- ]
1124
- }, e.id))]
1125
- }),
1126
- T && /*#__PURE__*/ U(Se, {
1127
- rule: A,
1128
- open: !!A,
1129
- onClose: oe,
1130
- onConfirm: ae,
1131
- isLoading: i,
1132
- error: a
1133
- }),
1134
- C && h && _ && N && /*#__PURE__*/ U(Ve, {
1135
- securityGroupId: h,
1136
- open: N,
1137
- onClose: P,
1138
- onCreate: _,
1139
- isLoading: y,
1140
- error: x,
1141
- availableSecurityGroups: S
1142
- })
1143
- ] });
1144
- }
1145
- //#endregion
1146
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-components/-details/RBACPolicyRow.tsx
1147
- function Ge({ policy: e, onDelete: t, canDelete: r }) {
1148
- let { i18n: i, _: a } = Y();
1149
- return /*#__PURE__*/ W(d, { children: [
1150
- /*#__PURE__*/ U(k, { children: e.target_tenant }),
1151
- /*#__PURE__*/ U(k, { children: e.action }),
1152
- /*#__PURE__*/ U(k, {
1153
- onClick: (e) => e.stopPropagation(),
1154
- className: "items-end pr-0",
1155
- children: r && /*#__PURE__*/ U(n, { children: /*#__PURE__*/ U(g, { children: /*#__PURE__*/ U(j, {
1156
- label: i._({ id: "qh5W8q" }),
1157
- onClick: t
1158
- }) }) })
1159
- })
1160
- ] });
1161
- }
1162
- //#endregion
1163
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/AddRBACPolicyModal.tsx
1164
- var Ke = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, qe = /^[0-9a-f]{32}$/i;
1165
- function Je(e) {
1166
- return Ke.test(e) || qe.test(e);
1167
- }
1168
- function Ye({ isOpen: e, onClose: t, securityGroupId: n }) {
1169
- let { i18n: r, _: i } = Y(), o = M.useUtils(), s = P(), [c, l] = q(!1), u = X.object({ targetTenant: X.string().min(1, r._({ id: "1RwosK" })).refine(Je, { message: r._({ id: "CunRry" }) }) }), d = M.network.rbacPolicy.create.useMutation({
1170
- onSuccess: (e, t) => {
1171
- o.network.rbacPolicy.list.invalidate({
1172
- project_id: s,
1173
- securityGroupId: n
1174
- }), o.network.securityGroup.getById.invalidate({
1175
- project_id: s,
1176
- securityGroupId: n
1177
- });
1178
- let { message: r, ...i } = ae(t.targetTenant);
1179
- T.success(r, i), m();
1180
- },
1181
- onError: (e) => {
1182
- let { message: t, ...n } = le(e.message);
1183
- T.error(t, n);
1184
- }
1185
- }), p = Z({
1186
- defaultValues: { targetTenant: "" },
1187
- validators: { onSubmit: u },
1188
- onSubmit: async ({ value: e }) => {
1189
- d.isPending || d.mutate({
1190
- project_id: s,
1191
- securityGroupId: n,
1192
- targetTenant: e.targetTenant.trim()
1193
- });
1194
- }
1195
- }), m = () => {
1196
- p.reset(), d.reset(), l(!1), t();
1197
- }, g = async () => {
1198
- l(!0), await p.handleSubmit();
1199
- };
1200
- return /*#__PURE__*/ W(f, {
1201
- open: e,
1202
- onCancel: m,
1203
- title: r._({ id: "vmRPFm" }),
1204
- size: "large",
1205
- onConfirm: g,
1206
- cancelButtonLabel: r._({ id: "dEgA5A" }),
1207
- confirmButtonLabel: r._({ id: "1G4zXb" }),
1208
- disableConfirmButton: d.isPending,
1209
- children: [
1210
- d.error && /*#__PURE__*/ U(a, {
1211
- variant: "error",
1212
- className: "mb-4",
1213
- children: (() => {
1214
- let e = d.error.message.toLowerCase();
1215
- return e.includes("conflict") || e.includes("409") ? r._({ id: "rbuO5A" }) : e.includes("not found") || e.includes("404") ? r._({ id: "FwSyEp" }) : e.includes("forbidden") || e.includes("403") ? r._({ id: "kqJVBO" }) : d.error.message;
1216
- })()
1217
- }),
1218
- /*#__PURE__*/ U("p", {
1219
- className: "mb-4",
1220
- children: /*#__PURE__*/ U(J, { id: "cjEOmc" })
1221
- }),
1222
- /*#__PURE__*/ U(h, {
1223
- className: "mb-0",
1224
- onSubmit: (e) => {
1225
- e.preventDefault(), g();
1226
- },
1227
- children: /*#__PURE__*/ U(E, { children: /*#__PURE__*/ U(p.Field, {
1228
- name: "targetTenant",
1229
- validators: {
1230
- onBlur: ({ value: e }) => {
1231
- let t = e.trim();
1232
- if (!t) return r._({ id: "1RwosK" });
1233
- if (!Je(t)) return r._({ id: "CunRry" });
1234
- },
1235
- onChange: ({ value: e }) => {
1236
- if (!c) return;
1237
- let t = e.trim();
1238
- if (!t) return r._({ id: "1RwosK" });
1239
- if (!Je(t)) return r._({ id: "CunRry" });
1240
- }
1241
- },
1242
- children: (e) => {
1243
- let t = (e.state.meta.isTouched || c) && e.state.meta.errors.length > 0, n = e.state.meta.errors[0], i = t ? typeof n == "string" ? n : n?.message : void 0;
1244
- return /*#__PURE__*/ U(S, {
1245
- id: e.name,
1246
- name: e.name,
1247
- label: r._({ id: "WzVwU0" }),
1248
- value: e.state.value,
1249
- onChange: (t) => e.handleChange(t.target.value),
1250
- onBlur: e.handleBlur,
1251
- placeholder: r._({ id: "he4q+i" }),
1252
- required: !0,
1253
- helptext: r._({ id: "PkfPsB" }),
1254
- disabled: d.isPending,
1255
- errortext: i,
1256
- invalid: t
1257
- });
1258
- }
1259
- }) })
1260
- })
1261
- ]
1262
- });
1263
- }
1264
- //#endregion
1265
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-modals/DeleteRBACPolicyDialog.tsx
1266
- function Xe({ policy: e, open: t, onClose: n, onConfirm: i, isLoading: o, error: s }) {
1267
- let { i18n: l, _: u } = Y(), { trackClose: d, markSubmitted: p, resetTracking: m } = I({
1268
- isOpen: t,
1269
- actionPrefix: "network.securitygroup.rbacpolicy.delete"
1270
- }), g = X.object({ confirm: X.string().refine((e) => e === "remove", { message: l._({ id: "SVLToM" }) }) }), _ = Z({
1271
- defaultValues: { confirm: "" },
1272
- validators: { onSubmit: g },
1273
- onSubmit: async () => {
1274
- o || (p(), i(e.id));
1275
- }
1276
- }), v = Q(_.store, (e) => e.isSubmitting || e.values.confirm !== "remove");
1277
- return /*#__PURE__*/ U(f, {
1278
- open: t,
1279
- onCancel: () => {
1280
- d(), _.reset(), m(), n();
1281
- },
1282
- size: "small",
1283
- title: l._({ id: "Dt5W9T" }),
1284
- onConfirm: _.handleSubmit,
1285
- cancelButtonLabel: l._({ id: "dEgA5A" }),
1286
- confirmButtonLabel: o ? l._({ id: "M5RhXF" }) : l._({ id: "qh5W8q" }),
1287
- confirmButtonVariant: "primary-danger",
1288
- disableConfirmButton: v || o,
1289
- disableCancelButton: o,
1290
- disableCloseButton: o,
1291
- children: /*#__PURE__*/ W(c, {
1292
- direction: "vertical",
1293
- gap: "4",
1294
- children: [
1295
- s && /*#__PURE__*/ U(a, {
1296
- variant: "error",
1297
- children: s
1298
- }),
1299
- /*#__PURE__*/ U("p", {
1300
- className: "text-theme-default",
1301
- children: /*#__PURE__*/ U(J, { id: "BMTd81" })
1302
- }),
1303
- /*#__PURE__*/ W(O, { children: [
1304
- /*#__PURE__*/ U(C, { children: /*#__PURE__*/ U(J, { id: "WzVwU0" }) }),
1305
- /*#__PURE__*/ U(r, { children: e.target_tenant }),
1306
- /*#__PURE__*/ U(C, { children: /*#__PURE__*/ U(J, { id: "bwRvnp" }) }),
1307
- /*#__PURE__*/ U(r, { children: e.action }),
1308
- /*#__PURE__*/ U(C, { children: /*#__PURE__*/ U(J, { id: "UGhVPl" }) }),
1309
- /*#__PURE__*/ U(r, { children: e.object_type })
1310
- ] }),
1311
- /*#__PURE__*/ U(h, {
1312
- className: "mb-0",
1313
- id: "delete-rbac-policy-form",
1314
- onSubmit: (e) => {
1315
- e.preventDefault(), _.handleSubmit();
1316
- },
1317
- children: /*#__PURE__*/ U(E, { children: /*#__PURE__*/ U(_.Field, {
1318
- name: "confirm",
1319
- children: (e) => /*#__PURE__*/ U(S, {
1320
- label: l._({ id: "SVLToM" }),
1321
- id: e.name,
1322
- name: e.name,
1323
- value: e.state.value,
1324
- onChange: (t) => e.handleChange(t.target.value),
1325
- placeholder: "remove",
1326
- autoComplete: "off",
1327
- autoFocus: !0,
1328
- disabled: o,
1329
- "data-testid": "remove-policy-confirmation-input",
1330
- required: !0
1331
- })
1332
- }) })
1333
- })
1334
- ]
1335
- })
1336
- });
1337
- }
1338
- //#endregion
1339
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-components/-details/SecurityGroupRBACPolicies.tsx
1340
- var $ = 3;
1341
- function Ze({ securityGroupId: e, canManageAccess: n }) {
1342
- let r = M.useUtils(), { i18n: i, _: a } = Y(), o = P(), [s, l] = te(), [f, p] = q(null), [m, h] = q(""), [g, _] = q(""), y = _e(void 0);
1343
- K(() => () => clearTimeout(y.current), []);
1344
- let { data: x, isPending: S, isError: C, error: E } = M.network.rbacPolicy.list.useQuery({
1345
- project_id: o,
1346
- securityGroupId: e
1347
- }, { refetchOnWindowFocus: !1 }), O = M.network.rbacPolicy.delete.useMutation({
1348
- onSuccess: () => {
1349
- r.network.rbacPolicy.list.invalidate({
1350
- project_id: o,
1351
- securityGroupId: e
1352
- }), r.network.securityGroup.getById.invalidate({
1353
- project_id: o,
1354
- securityGroupId: e
1355
- });
1356
- },
1357
- onError: (e) => {
1358
- let { message: t, ...n } = z(e.message);
1359
- T.error(t, n);
1360
- }
1361
- }), A = (e) => {
1362
- p(e);
1363
- }, j = (e) => {
1364
- let t = f?.target_tenant || e;
1365
- O.mutate({
1366
- project_id: o,
1367
- policyId: e
1368
- }, { onSuccess: () => {
1369
- let { message: e, ...n } = B(t);
1370
- T.success(e, n);
1371
- } });
1372
- }, N = () => {
1373
- O.isPending || p(null);
1374
- };
1375
- K(() => {
1376
- !O.isPending && !O.error && O.isSuccess && p(null);
1377
- }, [
1378
- O.isPending,
1379
- O.error,
1380
- O.isSuccess
1381
- ]);
1382
- let F = ge(() => {
1383
- if (!x) return [];
1384
- if (!m) return x;
1385
- let e = m.toLowerCase();
1386
- return x.filter((t) => t.target_tenant?.toLowerCase().includes(e) || t.action?.toLowerCase().includes(e));
1387
- }, [x, m]);
1388
- return /*#__PURE__*/ W(H, { children: [
1389
- /*#__PURE__*/ U(c, {
1390
- distribution: "end",
1391
- alignment: "center",
1392
- gap: "2",
1393
- className: "pb-2",
1394
- children: n && /*#__PURE__*/ U(v, {
1395
- variant: "primary",
1396
- onClick: l,
1397
- className: "whitespace-nowrap",
1398
- children: /*#__PURE__*/ U(J, { id: "vmRPFm" })
1399
- })
1400
- }),
1401
- /*#__PURE__*/ U(b, { children: /*#__PURE__*/ U(c, {
1402
- distribution: "end",
1403
- alignment: "center",
1404
- children: /*#__PURE__*/ U(t, {
1405
- className: "w-60 sm:w-68",
1406
- placeholder: i._({ id: "5kjInU" }),
1407
- "data-testid": "searchbar",
1408
- value: g,
1409
- onInput: (e) => {
1410
- let t = e.currentTarget.value;
1411
- _(t), clearTimeout(y.current), y.current = window.setTimeout(() => h(t), 500);
1412
- },
1413
- onSearch: (e) => {
1414
- clearTimeout(y.current), h(typeof e == "string" ? e : "");
1415
- },
1416
- onClear: () => {
1417
- clearTimeout(y.current), _(""), h("");
1418
- }
1419
- })
1420
- }) }),
1421
- /*#__PURE__*/ W(w, {
1422
- columns: $,
1423
- children: [/*#__PURE__*/ W(d, { children: [
1424
- /*#__PURE__*/ U(u, { children: /*#__PURE__*/ U(J, { id: "WzVwU0" }) }),
1425
- /*#__PURE__*/ U(u, { children: /*#__PURE__*/ U(J, { id: "bwRvnp" }) }),
1426
- /*#__PURE__*/ U(u, {})
1427
- ] }), S ? /*#__PURE__*/ U(d, { children: /*#__PURE__*/ U(k, {
1428
- colSpan: $,
1429
- children: /*#__PURE__*/ U(D, {
1430
- status: "progress",
1431
- title: i._({ id: "Z3FXyt" })
1432
- })
1433
- }) }) : C ? /*#__PURE__*/ U(d, { children: /*#__PURE__*/ U(k, {
1434
- colSpan: $,
1435
- children: /*#__PURE__*/ U(D, {
1436
- status: "error",
1437
- title: E.message
1438
- })
1439
- }) }) : F.length === 0 ? /*#__PURE__*/ U(d, { children: /*#__PURE__*/ U(k, {
1440
- colSpan: $,
1441
- children: /*#__PURE__*/ U(D, {
1442
- status: "empty",
1443
- title: m ? i._({ id: "qxxo7y" }) : i._({ id: "Dia2Ue" })
1444
- })
1445
- }) }) : F.map((e) => /*#__PURE__*/ U(Ge, {
1446
- policy: e,
1447
- onDelete: () => A(e),
1448
- canDelete: n
1449
- }, e.id))]
1450
- }),
1451
- !!f && /*#__PURE__*/ U(Xe, {
1452
- policy: f,
1453
- open: !!f,
1454
- onClose: N,
1455
- onConfirm: j,
1456
- isLoading: O.isPending,
1457
- error: O.error?.message || null
1458
- }),
1459
- s && /*#__PURE__*/ U(Ye, {
1460
- isOpen: s,
1461
- onClose: l,
1462
- securityGroupId: e
1463
- })
1464
- ] });
1465
- }
1466
- //#endregion
1467
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-components/SecurityGroupDetailsView.tsx
1468
- function Qe({ securityGroup: t, filteredAndSortedRules: n, onDeleteRule: r, isDeletingRule: i = !1, deleteRuleError: a = null, filterControls: o, onCreateRule: s, isCreatingRule: l = !1, createRuleError: u = null, availableSecurityGroups: d = [], currentProjectId: f, permissions: p }) {
1469
- let [m, h] = q("rules"), g = t.project_id === f && p.canViewRBAC;
1470
- return /*#__PURE__*/ U(e, {
1471
- px: !1,
1472
- py: !0,
1473
- children: /*#__PURE__*/ W(c, {
1474
- direction: "vertical",
1475
- gap: "4",
1476
- children: [
1477
- /*#__PURE__*/ U(be, { securityGroup: t }),
1478
- /*#__PURE__*/ U(xe, {
1479
- activeTab: m,
1480
- onTabChange: h,
1481
- showRBACTab: g
1482
- }),
1483
- /*#__PURE__*/ W("div", {
1484
- className: "mt-6",
1485
- children: [m === "rules" && /*#__PURE__*/ U(We, {
1486
- rules: n,
1487
- onDeleteRule: r,
1488
- isDeletingRule: i,
1489
- deleteError: a,
1490
- searchTerm: o.searchTerm,
1491
- onSearchChange: o.onSearchChange,
1492
- sortSettings: o.sortSettings,
1493
- onSortChange: o.onSortChange,
1494
- filterSettings: o.filterSettings,
1495
- onFilterChange: o.onFilterChange,
1496
- securityGroupId: t.id,
1497
- onCreateRule: p.canCreateRule ? s : void 0,
1498
- isCreatingRule: l,
1499
- createRuleError: u,
1500
- availableSecurityGroups: d,
1501
- canCreateRule: p.canCreateRule,
1502
- canDeleteRule: p.canDeleteRule
1503
- }), m === "rbac" && /*#__PURE__*/ U(Ze, {
1504
- securityGroupId: t.id,
1505
- canManageAccess: p.canManageAccess
1506
- })]
1507
- })
1508
- ]
1509
- })
1510
- });
1511
- }
1512
- //#endregion
1513
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/-hooks/useSecurityGroupDetails.ts
1514
- function $e({ securityGroupId: e, filterControls: t }) {
1515
- let [n, r] = q(!1), [i, a] = q(!1), o = P(), s = M.useUtils(), c = M.network.securityGroup.getById.useQuery({
1516
- project_id: o,
1517
- securityGroupId: e
1518
- }, { placeholderData: () => s.network.securityGroup.getById.getData({
1519
- project_id: o,
1520
- securityGroupId: e
1521
- }) }), l = ge(() => {
1522
- let e = c.data?.security_group_rules || [], n = t.filterSettings.selectedFilters?.find((e) => e.name === "direction")?.value, r = t.filterSettings.selectedFilters?.find((e) => e.name === "ethertype")?.value, i = t.filterSettings.selectedFilters?.find((e) => e.name === "protocol")?.value;
1523
- if (n && n !== "all" && (e = e.filter((e) => e.direction === n)), r && r !== "all" && (e = e.filter((e) => e.ethertype === r)), i && i !== "all" && (e = e.filter((e) => e.protocol !== null && e.protocol === i)), t.searchTerm) {
1524
- let n = t.searchTerm.toLowerCase();
1525
- e = e.filter((e) => e.description?.toLowerCase().includes(n) || e.protocol?.toLowerCase().includes(n) || e.ethertype?.toLowerCase().includes(n));
1526
- }
1527
- if (t.sortSettings.sortBy) {
1528
- let n = t.sortSettings.sortBy;
1529
- e = [...e].sort((e, r) => {
1530
- let i = e[n] || "", a = r[n] || "", o = i.localeCompare(a);
1531
- return t.sortSettings.sortDirection === "asc" ? o : -o;
1532
- });
1533
- }
1534
- return e;
1535
- }, [c.data?.security_group_rules, t]), u = M.network.securityGroup.update.useMutation({
1536
- onSuccess: (t, n) => {
1537
- s.network.securityGroup.getById.invalidate({
1538
- project_id: o,
1539
- securityGroupId: e
1540
- }), s.network.securityGroup.list.invalidate();
1541
- let { message: i, ...a } = ce(n.name || c.data?.name || e);
1542
- T.success(i, a), r(!1);
1543
- },
1544
- onError: (e) => {
1545
- let { message: t, ...n } = de(e.message);
1546
- T.error(t, n);
1547
- }
1548
- }), d = M.network.securityGroup.deleteById.useMutation({
1549
- onSuccess: () => {
1550
- s.network.securityGroup.list.invalidate();
1551
- let { message: t, ...n } = ue(c.data?.name || e);
1552
- T.success(t, n), a(!1);
1553
- },
1554
- onError: (e) => {
1555
- let { message: t, ...n } = oe(e.message);
1556
- T.error(t, n);
1557
- }
1558
- }), f = M.network.securityGroupRule.delete.useMutation({
1559
- onSuccess: () => {
1560
- s.network.securityGroup.getById.invalidate({
1561
- project_id: o,
1562
- securityGroupId: e
1563
- }), s.network.securityGroup.list.invalidate();
1564
- let { message: t, ...n } = pe();
1565
- T.success(t, n);
1566
- },
1567
- onError: (e) => {
1568
- let { message: t, ...n } = R(e.message);
1569
- T.error(t, n);
1570
- }
1571
- }), p = M.network.securityGroupRule.create.useMutation({
1572
- onSuccess: () => {
1573
- s.network.securityGroup.getById.invalidate({
1574
- project_id: o,
1575
- securityGroupId: e
1576
- }), s.network.securityGroup.list.invalidate();
1577
- let { message: t, ...n } = se();
1578
- T.success(t, n);
1579
- },
1580
- onError: (e) => {
1581
- let { message: t, ...n } = V(e.message);
1582
- T.error(t, n);
1583
- }
1584
- });
1585
- return {
1586
- securityGroup: c.data,
1587
- filteredAndSortedRules: l,
1588
- isLoading: c.isPending,
1589
- isError: c.isError,
1590
- error: c.error,
1591
- isUpdating: u.isPending,
1592
- updateError: u.error?.message || null,
1593
- isDeleting: d.isPending,
1594
- deleteError: d.error?.message || null,
1595
- isDeletingRule: f.isPending,
1596
- deleteRuleError: f.error?.message || null,
1597
- isCreatingRule: p.isPending,
1598
- createRuleError: p.error?.message || null,
1599
- editModalOpen: n,
1600
- deleteModalOpen: i,
1601
- handleEdit: () => {
1602
- r(!0);
1603
- },
1604
- handleCloseEditModal: () => {
1605
- r(!1);
1606
- },
1607
- handleUpdate: async (e, t) => {
1608
- await u.mutateAsync({
1609
- project_id: o,
1610
- securityGroupId: e,
1611
- ...t
1612
- });
1613
- },
1614
- handleDelete: () => {
1615
- a(!0);
1616
- },
1617
- handleCloseDeleteModal: () => {
1618
- a(!1);
1619
- },
1620
- handleDeleteSecurityGroup: async () => {
1621
- await d.mutateAsync({
1622
- project_id: o,
1623
- securityGroupId: e
1624
- });
1625
- },
1626
- handleDeleteRule: async (e) => {
1627
- await f.mutateAsync({
1628
- project_id: o,
1629
- ruleId: e
1630
- });
1631
- },
1632
- handleCreateRule: async (e) => {
1633
- await p.mutateAsync({
1634
- project_id: o,
1635
- ...e
1636
- });
1637
- }
1638
- };
1639
- }
1640
- //#endregion
1641
- //#region src/client/routes/_auth/projects/$projectId/network/securitygroups/$securityGroupId/index.tsx?tsr-split=component
1642
- function et() {
1643
- let { securityGroupId: e } = N.useParams(), { trpcClient: t } = N.useRouteContext(), r = P(), i = ve(), { i18n: a, _: o } = Y();
1644
- if (!t) throw Error("trpcClient is not available in route context");
1645
- let { permissions: s, isLoading: l, isError: u } = he(r), { searchTerm: d, sortSettings: f, filterSettings: m, handleSearchChange: h, handleSortChange: _, handleFilterChange: y } = ye({
1646
- defaultSortKey: "direction",
1647
- defaultSortDir: "asc",
1648
- sortOptions: [
1649
- {
1650
- label: a._({ id: "MRB7nI" }),
1651
- value: "direction"
1652
- },
1653
- {
1654
- label: a._({ id: "6+OdGi" }),
1655
- value: "protocol"
1656
- },
1657
- {
1658
- label: a._({ id: "Nu4oKW" }),
1659
- value: "description"
1660
- }
1661
- ],
1662
- filterSettings: { filters: [
1663
- {
1664
- displayName: a._({ id: "MRB7nI" }),
1665
- filterName: "direction",
1666
- values: ["ingress", "egress"],
1667
- supportsMultiValue: !1
1668
- },
1669
- {
1670
- displayName: a._({ id: "yp0UjB" }),
1671
- filterName: "ethertype",
1672
- values: ["IPv4", "IPv6"],
1673
- supportsMultiValue: !1
1674
- },
1675
- {
1676
- displayName: a._({ id: "6+OdGi" }),
1677
- filterName: "protocol",
1678
- values: [
1679
- "tcp",
1680
- "udp",
1681
- "icmp",
1682
- "ipv6-icmp"
1683
- ],
1684
- supportsMultiValue: !1
1685
- }
1686
- ] }
1687
- }), b = {
1688
- searchTerm: d,
1689
- onSearchChange: h,
1690
- sortSettings: f,
1691
- onSortChange: _,
1692
- filterSettings: m,
1693
- onFilterChange: y
1694
- }, { securityGroup: x, filteredAndSortedRules: S, isLoading: C, isError: w, error: T, isUpdating: E, updateError: O, isDeleting: k, deleteError: A, isDeletingRule: F, deleteRuleError: I, isCreatingRule: te, createRuleError: ne, editModalOpen: re, deleteModalOpen: ie, handleEdit: ae, handleCloseEditModal: oe, handleUpdate: se, handleDelete: R, handleCloseDeleteModal: ce, handleDeleteSecurityGroup: le, handleDeleteRule: ue, handleCreateRule: de } = $e({
1695
- securityGroupId: e,
1696
- filterControls: b
1697
- });
1698
- L(N.id, x?.name ?? void 0);
1699
- let { data: z } = M.network.securityGroup.list.useQuery({ project_id: r }), pe = ge(() => (z || []).filter((t) => t.id !== e).map((e) => ({
1700
- id: e.id,
1701
- name: e.name || e.id
1702
- })), [z, e]), B = () => {
1703
- i({
1704
- to: "/projects/$projectId/network/securitygroups",
1705
- params: { projectId: r }
1706
- });
1707
- };
1708
- if (l) return /*#__PURE__*/ U(D, {
1709
- status: "progress",
1710
- title: a._({ id: "EpWoJ9" })
1711
- });
1712
- let V = u ? {
1713
- canView: !1,
1714
- canCreate: !1,
1715
- canUpdate: !1,
1716
- canDelete: !1,
1717
- canCreateRule: !1,
1718
- canDeleteRule: !1,
1719
- canManageAccess: !1,
1720
- canViewRBAC: !1
1721
- } : s;
1722
- if (C) return /*#__PURE__*/ U(D, {
1723
- status: "progress",
1724
- title: a._({ id: "3x7Sws" })
1725
- });
1726
- if (w) {
1727
- let e = T?.message || a._({ id: "LobdAW" });
1728
- return /*#__PURE__*/ U(D, {
1729
- status: "error",
1730
- title: a._({ id: "PA/BPt" }),
1731
- body: e,
1732
- action: /*#__PURE__*/ U(v, {
1733
- onClick: B,
1734
- variant: "primary",
1735
- children: /*#__PURE__*/ U(J, { id: "U9q4M7" })
1736
- })
1737
- });
1738
- }
1739
- if (!x) return /*#__PURE__*/ U(D, {
1740
- status: "empty",
1741
- title: a._({ id: "XuDQlk" }),
1742
- action: /*#__PURE__*/ U(v, {
1743
- onClick: B,
1744
- variant: "primary",
1745
- children: /*#__PURE__*/ U(J, { id: "U9q4M7" })
1746
- })
1747
- });
1748
- let H = !!(x.project_id && x.project_id !== r), G = V.canUpdate && !H, K = V.canDelete && !H, _e = (G || K) && /*#__PURE__*/ W(c, {
1749
- gap: "0.5",
1750
- alignment: "center",
1751
- children: [K && /*#__PURE__*/ W(n, {
1752
- className: "flex items-center",
1753
- children: [/*#__PURE__*/ U(p, {
1754
- as: "div",
1755
- children: /*#__PURE__*/ U(v, {
1756
- icon: "moreVert",
1757
- title: a._({ id: "PgNNGl" }),
1758
- disabled: k
1759
- })
1760
- }), /*#__PURE__*/ U(g, { children: /*#__PURE__*/ U(j, {
1761
- label: a._({ id: "bcOdok" }),
1762
- onClick: R
1763
- }) })]
1764
- }), G && /*#__PURE__*/ U(v, {
1765
- variant: "primary",
1766
- onClick: ae,
1767
- disabled: k,
1768
- children: /*#__PURE__*/ U(J, { id: "Y1YKad" })
1769
- })]
1770
- });
1771
- return /*#__PURE__*/ W(c, {
1772
- direction: "vertical",
1773
- children: [
1774
- /*#__PURE__*/ U(ee, {
1775
- title: x.name || x.id,
1776
- projectId: r,
1777
- actions: _e
1778
- }),
1779
- /*#__PURE__*/ U(Qe, {
1780
- securityGroup: x,
1781
- filteredAndSortedRules: S,
1782
- onDeleteRule: ue,
1783
- isDeletingRule: F,
1784
- deleteRuleError: I,
1785
- filterControls: b,
1786
- onCreateRule: de,
1787
- isCreatingRule: te,
1788
- createRuleError: ne,
1789
- availableSecurityGroups: pe,
1790
- currentProjectId: r,
1791
- permissions: V
1792
- }),
1793
- /*#__PURE__*/ U(me, {
1794
- securityGroup: x,
1795
- open: re,
1796
- onClose: oe,
1797
- onUpdate: se,
1798
- isLoading: E,
1799
- error: O
1800
- }),
1801
- ie && /*#__PURE__*/ U(fe, {
1802
- securityGroup: x,
1803
- isOpen: ie,
1804
- onClose: ce,
1805
- onDelete: async () => {
1806
- try {
1807
- await le(), B();
1808
- } catch {}
1809
- },
1810
- isDeleting: k,
1811
- error: A
1812
- })
1813
- ]
1814
- });
1815
- }
1816
- //#endregion
1817
- export { et as component };
1818
-
1819
- //# sourceMappingURL=_securityGroupId-Cz2NUHdB.mjs.map