@replicated/portal-components 0.0.19 → 0.0.21
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.
- package/components/metadata/registry.json +2 -2
- package/components/metadata/registry.md +2 -2
- package/dist/actions/change-team.js +66 -7
- package/dist/actions/change-team.js.map +1 -1
- package/dist/actions/index.d.mts +3 -1
- package/dist/actions/index.d.ts +3 -1
- package/dist/actions/index.js +182 -465
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/install-actions.d.mts +3 -1
- package/dist/actions/install-actions.d.ts +3 -1
- package/dist/actions/install-actions.js +58 -5
- package/dist/actions/install-actions.js.map +1 -1
- package/dist/actions/service-account.d.mts +3 -1
- package/dist/actions/service-account.d.ts +3 -1
- package/dist/actions/service-account.js +58 -5
- package/dist/actions/service-account.js.map +1 -1
- package/dist/actions/support-bundles.d.mts +3 -1
- package/dist/actions/support-bundles.d.ts +3 -1
- package/dist/actions/support-bundles.js +58 -5
- package/dist/actions/support-bundles.js.map +1 -1
- package/dist/actions/team-settings.d.mts +3 -1
- package/dist/actions/team-settings.d.ts +3 -1
- package/dist/actions/team-settings.js +91 -27
- package/dist/actions/team-settings.js.map +1 -1
- package/dist/actions/trial-signup.d.mts +24 -0
- package/dist/actions/trial-signup.d.ts +24 -0
- package/dist/actions/trial-signup.js +482 -0
- package/dist/actions/trial-signup.js.map +1 -0
- package/dist/actions/user-settings.d.mts +3 -1
- package/dist/actions/user-settings.d.ts +3 -1
- package/dist/actions/user-settings.js +58 -5
- package/dist/actions/user-settings.js.map +1 -1
- package/dist/airgap-instances.d.mts +3 -1
- package/dist/airgap-instances.d.ts +3 -1
- package/dist/airgap-instances.js +41 -112
- package/dist/airgap-instances.js.map +1 -1
- package/dist/branding-BsMSywts.d.mts +36 -0
- package/dist/branding-BsMSywts.d.ts +36 -0
- package/dist/error-page.js +10 -2
- package/dist/error-page.js.map +1 -1
- package/dist/error.js +10 -2
- package/dist/error.js.map +1 -1
- package/dist/esm/actions/change-team.js +66 -7
- package/dist/esm/actions/change-team.js.map +1 -1
- package/dist/esm/actions/index.js +181 -462
- package/dist/esm/actions/index.js.map +1 -1
- package/dist/esm/actions/install-actions.js +58 -5
- package/dist/esm/actions/install-actions.js.map +1 -1
- package/dist/esm/actions/service-account.js +58 -5
- package/dist/esm/actions/service-account.js.map +1 -1
- package/dist/esm/actions/support-bundles.js +58 -5
- package/dist/esm/actions/support-bundles.js.map +1 -1
- package/dist/esm/actions/team-settings.js +91 -27
- package/dist/esm/actions/team-settings.js.map +1 -1
- package/dist/esm/actions/trial-signup.js +478 -0
- package/dist/esm/actions/trial-signup.js.map +1 -0
- package/dist/esm/actions/user-settings.js +58 -5
- package/dist/esm/actions/user-settings.js.map +1 -1
- package/dist/esm/airgap-instances.js +40 -112
- package/dist/esm/airgap-instances.js.map +1 -1
- package/dist/esm/error-page.js +10 -2
- package/dist/esm/error-page.js.map +1 -1
- package/dist/esm/error.js +10 -2
- package/dist/esm/error.js.map +1 -1
- package/dist/esm/helm-install-wizard.js +118 -79
- package/dist/esm/helm-install-wizard.js.map +1 -1
- package/dist/esm/index.js +706 -438
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install-actions.js +40 -5
- package/dist/esm/install-actions.js.map +1 -1
- package/dist/esm/install-card.js +9 -6
- package/dist/esm/install-card.js.map +1 -1
- package/dist/esm/install-targets.js +9 -2
- package/dist/esm/install-targets.js.map +1 -1
- package/dist/esm/instance-card.js +39 -111
- package/dist/esm/instance-card.js.map +1 -1
- package/dist/esm/join-team.js +9 -3
- package/dist/esm/join-team.js.map +1 -1
- package/dist/esm/license-card.js +24 -22
- package/dist/esm/license-card.js.map +1 -1
- package/dist/esm/license-details.js +128 -334
- package/dist/esm/license-details.js.map +1 -1
- package/dist/esm/linux-install-wizard.js +95 -41
- package/dist/esm/linux-install-wizard.js.map +1 -1
- package/dist/esm/login.js +20 -4
- package/dist/esm/login.js.map +1 -1
- package/dist/esm/middleware.js +33 -0
- package/dist/esm/middleware.js.map +1 -0
- package/dist/esm/online-instance-list.js +40 -112
- package/dist/esm/online-instance-list.js.map +1 -1
- package/dist/esm/release-history-panel.js +27 -14
- package/dist/esm/release-history-panel.js.map +1 -1
- package/dist/esm/saml-callback-client.js +82 -0
- package/dist/esm/saml-callback-client.js.map +1 -0
- package/dist/esm/saml-handlers.js +138 -0
- package/dist/esm/saml-handlers.js.map +1 -0
- package/dist/esm/security-card.js +53 -38
- package/dist/esm/security-card.js.map +1 -1
- package/dist/esm/service-accounts-tab.js +800 -0
- package/dist/esm/service-accounts-tab.js.map +1 -0
- package/dist/esm/support-bundle-collection-card.js +48 -24
- package/dist/esm/support-bundle-collection-card.js.map +1 -1
- package/dist/esm/support-bundles-card.js +10 -5
- package/dist/esm/support-bundles-card.js.map +1 -1
- package/dist/esm/support-card.js +37 -5
- package/dist/esm/support-card.js.map +1 -1
- package/dist/esm/team-selection.js +5 -1
- package/dist/esm/team-selection.js.map +1 -1
- package/dist/esm/team-settings-card.js +5 -2
- package/dist/esm/team-settings-card.js.map +1 -1
- package/dist/esm/team-settings.js +7 -2
- package/dist/esm/team-settings.js.map +1 -1
- package/dist/esm/top-nav-user-menu.js +5 -1
- package/dist/esm/top-nav-user-menu.js.map +1 -1
- package/dist/esm/top-nav.js +175 -62
- package/dist/esm/top-nav.js.map +1 -1
- package/dist/esm/trial-signup.js +256 -0
- package/dist/esm/trial-signup.js.map +1 -0
- package/dist/esm/update-layout.js +175 -62
- package/dist/esm/update-layout.js.map +1 -1
- package/dist/esm/updates-card.js +15 -4
- package/dist/esm/updates-card.js.map +1 -1
- package/dist/esm/upload-support-bundle-modal.js +9 -4
- package/dist/esm/upload-support-bundle-modal.js.map +1 -1
- package/dist/esm/user-settings-card.js +5 -2
- package/dist/esm/user-settings-card.js.map +1 -1
- package/dist/esm/user-settings.js +12 -6
- package/dist/esm/user-settings.js.map +1 -1
- package/dist/esm/utils/index.js +204 -13
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/fetch-license-iTyF7_GY.d.mts +81 -0
- package/dist/fetch-license-iTyF7_GY.d.ts +81 -0
- package/dist/helm-install-wizard.d.mts +11 -3
- package/dist/helm-install-wizard.d.ts +11 -3
- package/dist/helm-install-wizard.js +118 -79
- package/dist/helm-install-wizard.js.map +1 -1
- package/dist/{index-BAiVrSSR.d.mts → index-DyzJ0yKD.d.mts} +48 -50
- package/dist/{index-DWt-N5od.d.ts → index-sMbq94M7.d.ts} +48 -50
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +726 -438
- package/dist/index.js.map +1 -1
- package/dist/install-actions.d.mts +4 -2
- package/dist/install-actions.d.ts +4 -2
- package/dist/install-actions.js +40 -5
- package/dist/install-actions.js.map +1 -1
- package/dist/install-card.d.mts +2 -3
- package/dist/install-card.d.ts +2 -3
- package/dist/install-card.js +9 -6
- package/dist/install-card.js.map +1 -1
- package/dist/install-targets.js +9 -2
- package/dist/install-targets.js.map +1 -1
- package/dist/instance-card.d.mts +3 -1
- package/dist/instance-card.d.ts +3 -1
- package/dist/instance-card.js +40 -111
- package/dist/instance-card.js.map +1 -1
- package/dist/join-team.js +9 -3
- package/dist/join-team.js.map +1 -1
- package/dist/license-card.d.mts +2 -3
- package/dist/license-card.d.ts +2 -3
- package/dist/license-card.js +24 -22
- package/dist/license-card.js.map +1 -1
- package/dist/license-details.js +128 -334
- package/dist/license-details.js.map +1 -1
- package/dist/linux-install-wizard.d.mts +9 -3
- package/dist/linux-install-wizard.d.ts +9 -3
- package/dist/linux-install-wizard.js +95 -41
- package/dist/linux-install-wizard.js.map +1 -1
- package/dist/login.d.mts +4 -0
- package/dist/login.d.ts +4 -0
- package/dist/login.js +20 -4
- package/dist/login.js.map +1 -1
- package/dist/middleware.d.mts +13 -0
- package/dist/middleware.d.ts +13 -0
- package/dist/middleware.js +35 -0
- package/dist/middleware.js.map +1 -0
- package/dist/online-instance-list.d.mts +3 -1
- package/dist/online-instance-list.d.ts +3 -1
- package/dist/online-instance-list.js +41 -112
- package/dist/online-instance-list.js.map +1 -1
- package/dist/pending-installations.d.mts +3 -1
- package/dist/pending-installations.d.ts +3 -1
- package/dist/release-history-panel.js +27 -14
- package/dist/release-history-panel.js.map +1 -1
- package/dist/saml-callback-client.d.mts +36 -0
- package/dist/saml-callback-client.d.ts +36 -0
- package/dist/saml-callback-client.js +88 -0
- package/dist/saml-callback-client.js.map +1 -0
- package/dist/saml-handlers.d.mts +50 -0
- package/dist/saml-handlers.d.ts +50 -0
- package/dist/saml-handlers.js +141 -0
- package/dist/saml-handlers.js.map +1 -0
- package/dist/security-card.d.mts +3 -1
- package/dist/security-card.d.ts +3 -1
- package/dist/security-card.js +53 -38
- package/dist/security-card.js.map +1 -1
- package/dist/service-accounts-tab.d.mts +51 -0
- package/dist/service-accounts-tab.d.ts +51 -0
- package/dist/service-accounts-tab.js +802 -0
- package/dist/service-accounts-tab.js.map +1 -0
- package/dist/styles.css +375 -127
- package/dist/support-bundle-collection-card.d.mts +1 -1
- package/dist/support-bundle-collection-card.d.ts +1 -1
- package/dist/support-bundle-collection-card.js +47 -23
- package/dist/support-bundle-collection-card.js.map +1 -1
- package/dist/support-bundles-card.d.mts +4 -2
- package/dist/support-bundles-card.d.ts +4 -2
- package/dist/support-bundles-card.js +10 -5
- package/dist/support-bundles-card.js.map +1 -1
- package/dist/support-card.js +37 -5
- package/dist/support-card.js.map +1 -1
- package/dist/team-selection.js +5 -1
- package/dist/team-selection.js.map +1 -1
- package/dist/team-settings-card.js +5 -2
- package/dist/team-settings-card.js.map +1 -1
- package/dist/team-settings.js +7 -2
- package/dist/team-settings.js.map +1 -1
- package/dist/{top-nav-IRIn66wS.d.ts → top-nav-BUQAGoG1.d.mts} +14 -2
- package/dist/{top-nav-IRIn66wS.d.mts → top-nav-CEqw0KpO.d.ts} +14 -2
- package/dist/top-nav-user-menu.js +5 -1
- package/dist/top-nav-user-menu.js.map +1 -1
- package/dist/top-nav.d.mts +2 -1
- package/dist/top-nav.d.ts +2 -1
- package/dist/top-nav.js +175 -62
- package/dist/top-nav.js.map +1 -1
- package/dist/trial-signup.d.mts +31 -0
- package/dist/trial-signup.d.ts +31 -0
- package/dist/trial-signup.js +258 -0
- package/dist/trial-signup.js.map +1 -0
- package/dist/update-layout.js +175 -62
- package/dist/update-layout.js.map +1 -1
- package/dist/updates-card.js +15 -4
- package/dist/updates-card.js.map +1 -1
- package/dist/upload-support-bundle-modal.js +9 -4
- package/dist/upload-support-bundle-modal.js.map +1 -1
- package/dist/user-settings-card.js +5 -2
- package/dist/user-settings-card.js.map +1 -1
- package/dist/user-settings.js +12 -6
- package/dist/user-settings.js.map +1 -1
- package/dist/utils/index.d.mts +74 -16
- package/dist/utils/index.d.ts +74 -16
- package/dist/utils/index.js +215 -12
- package/dist/utils/index.js.map +1 -1
- package/package.json +37 -2
package/dist/esm/utils/index.js
CHANGED
|
@@ -5,6 +5,18 @@ import { cache } from 'react';
|
|
|
5
5
|
* Enterprise Portal Components
|
|
6
6
|
* This file is generated by tsup. Do not edit manually.
|
|
7
7
|
*/
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// datadog/tracer.ts
|
|
15
|
+
var tracer_exports = {};
|
|
16
|
+
__export(tracer_exports, {
|
|
17
|
+
default: () => tracer_default
|
|
18
|
+
});
|
|
19
|
+
var tracer_default;
|
|
8
20
|
|
|
9
21
|
// src/utils/api-client.ts
|
|
10
22
|
var UnauthorizedError = class extends Error {
|
|
@@ -38,8 +50,17 @@ async function handle401() {
|
|
|
38
50
|
const { redirect } = await import('next/navigation');
|
|
39
51
|
return redirect("/?expired=1");
|
|
40
52
|
}
|
|
53
|
+
function isErrorPage(url) {
|
|
54
|
+
try {
|
|
55
|
+
const urlObj = new URL(url);
|
|
56
|
+
return urlObj.pathname === "/error";
|
|
57
|
+
} catch {
|
|
58
|
+
return url === "/error" || url.startsWith("/error?");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
41
61
|
async function handleServerError(statusCode) {
|
|
42
62
|
const { redirect } = await import('next/navigation');
|
|
63
|
+
const { cookies } = await import('next/headers');
|
|
43
64
|
let sourceUrl;
|
|
44
65
|
try {
|
|
45
66
|
const { headers } = await import('next/headers');
|
|
@@ -47,12 +68,20 @@ async function handleServerError(statusCode) {
|
|
|
47
68
|
const referer = headersList.get("referer");
|
|
48
69
|
const host = headersList.get("host");
|
|
49
70
|
const pathname = headersList.get("x-invoke-path") || headersList.get("x-forwarded-path");
|
|
50
|
-
if (referer) {
|
|
71
|
+
if (referer && !isErrorPage(referer)) {
|
|
51
72
|
sourceUrl = referer;
|
|
52
73
|
} else if (host && pathname) {
|
|
53
74
|
const protocol = headersList.get("x-forwarded-proto") || "https";
|
|
54
75
|
sourceUrl = `${protocol}://${host}${pathname}`;
|
|
55
76
|
}
|
|
77
|
+
if (!sourceUrl || isErrorPage(sourceUrl)) {
|
|
78
|
+
const cookieStore = await cookies();
|
|
79
|
+
const preservedSource = cookieStore.get("portal_error_source");
|
|
80
|
+
if (preservedSource?.value) {
|
|
81
|
+
sourceUrl = decodeURIComponent(preservedSource.value);
|
|
82
|
+
cookieStore.delete("portal_error_source");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
56
85
|
} catch (error) {
|
|
57
86
|
console.debug("[portal-components] Could not determine source URL", error);
|
|
58
87
|
}
|
|
@@ -62,6 +91,16 @@ async function handleServerError(statusCode) {
|
|
|
62
91
|
}
|
|
63
92
|
return redirect(`/error?${params.toString()}`);
|
|
64
93
|
}
|
|
94
|
+
|
|
95
|
+
// src/utils/constants.ts
|
|
96
|
+
var DEFAULT_FAVICON = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='1.5'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cellipse cx='12' cy='12' rx='4' ry='10'/%3E%3Cpath d='M2 12h20'/%3E%3C/svg%3E";
|
|
97
|
+
var DEFAULT_PRIMARY_COLOR = "#4f46e5";
|
|
98
|
+
var DEFAULT_SECONDARY_COLOR = "#6366f1";
|
|
99
|
+
var isHttpApiOrigin = () => {
|
|
100
|
+
return process.env.REPLICATED_APP_ORIGIN?.startsWith("http://") || false;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// src/utils/branding.ts
|
|
65
104
|
var normalizeColor = (color) => {
|
|
66
105
|
if (!color || typeof color !== "string") {
|
|
67
106
|
return void 0;
|
|
@@ -70,11 +109,33 @@ var normalizeColor = (color) => {
|
|
|
70
109
|
if (/^#?[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/.test(trimmed)) {
|
|
71
110
|
return trimmed.startsWith("#") ? trimmed : `#${trimmed}`;
|
|
72
111
|
}
|
|
73
|
-
|
|
112
|
+
console.debug("[portal-components] Invalid color format rejected (only hex supported):", trimmed);
|
|
113
|
+
return void 0;
|
|
114
|
+
};
|
|
115
|
+
var sanitizeUrlForCss = (url) => {
|
|
116
|
+
if (!url || typeof url !== "string") {
|
|
117
|
+
return void 0;
|
|
118
|
+
}
|
|
119
|
+
const trimmed = url.trim();
|
|
120
|
+
try {
|
|
121
|
+
const urlObj = new URL(trimmed);
|
|
122
|
+
if (!["http:", "https:", "data:"].includes(urlObj.protocol)) {
|
|
123
|
+
console.debug("[portal-components] Invalid URL protocol for background image:", urlObj.protocol);
|
|
124
|
+
return void 0;
|
|
125
|
+
}
|
|
126
|
+
} catch {
|
|
127
|
+
console.debug("[portal-components] Invalid URL format for background image:", trimmed);
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
const escaped = trimmed.replace(/\\/g, "\\\\").replace(/\)/g, "\\)").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/[\x00-\x1F\x7F]/g, "");
|
|
131
|
+
return escaped;
|
|
74
132
|
};
|
|
75
133
|
var decodeBranding = ({ brandingData }) => {
|
|
76
134
|
if (!brandingData || typeof brandingData !== "string") {
|
|
77
|
-
return {
|
|
135
|
+
return {
|
|
136
|
+
primaryColor: DEFAULT_PRIMARY_COLOR,
|
|
137
|
+
secondaryColor: DEFAULT_SECONDARY_COLOR
|
|
138
|
+
};
|
|
78
139
|
}
|
|
79
140
|
try {
|
|
80
141
|
const decoded = Buffer.from(brandingData, "base64").toString("utf-8");
|
|
@@ -82,19 +143,39 @@ var decodeBranding = ({ brandingData }) => {
|
|
|
82
143
|
const logo = typeof parsed.logo === "string" ? parsed.logo : void 0;
|
|
83
144
|
const titleRaw = typeof parsed.title === "string" ? parsed.title.trim() : "";
|
|
84
145
|
const title = titleRaw ? titleRaw : void 0;
|
|
85
|
-
const
|
|
86
|
-
const
|
|
146
|
+
const favicon = typeof parsed.favicon === "string" ? parsed.favicon : void 0;
|
|
147
|
+
const primaryColorRaw = parsed.primaryColor ?? parsed.primary_color;
|
|
148
|
+
const secondaryColorRaw = parsed.secondaryColor ?? parsed.secondary_color;
|
|
149
|
+
const primaryColor = normalizeColor(primaryColorRaw);
|
|
150
|
+
const secondaryColor = normalizeColor(secondaryColorRaw);
|
|
151
|
+
const supportPortalLink = typeof parsed.supportPortalLink === "string" ? parsed.supportPortalLink : void 0;
|
|
152
|
+
const backgroundRaw = parsed.background;
|
|
153
|
+
const background = backgroundRaw === "minimal" || backgroundRaw === "custom" || backgroundRaw === "image" ? backgroundRaw : void 0;
|
|
154
|
+
const backgroundImage = sanitizeUrlForCss(parsed.backgroundImage);
|
|
155
|
+
const backgroundGradientStart = normalizeColor(parsed.customColor1);
|
|
156
|
+
const backgroundGradientEnd = normalizeColor(parsed.customColor2);
|
|
87
157
|
return {
|
|
88
158
|
logo,
|
|
89
159
|
title,
|
|
90
|
-
|
|
91
|
-
|
|
160
|
+
favicon,
|
|
161
|
+
primaryColor: primaryColor || DEFAULT_PRIMARY_COLOR,
|
|
162
|
+
secondaryColor: secondaryColor || DEFAULT_SECONDARY_COLOR,
|
|
163
|
+
supportPortalLink,
|
|
164
|
+
background,
|
|
165
|
+
backgroundImage,
|
|
166
|
+
backgroundGradientStart,
|
|
167
|
+
backgroundGradientEnd
|
|
92
168
|
};
|
|
93
169
|
} catch (error) {
|
|
94
170
|
console.debug("[portal-components] unable to parse branding JSON", error);
|
|
95
|
-
return {
|
|
171
|
+
return {
|
|
172
|
+
primaryColor: DEFAULT_PRIMARY_COLOR,
|
|
173
|
+
secondaryColor: DEFAULT_SECONDARY_COLOR
|
|
174
|
+
};
|
|
96
175
|
}
|
|
97
176
|
};
|
|
177
|
+
|
|
178
|
+
// src/actions/index.ts
|
|
98
179
|
var getApiOrigin = () => {
|
|
99
180
|
return (process.env.REPLICATED_APP_ORIGIN || "https://replicated.app").replace(/\/+$/, "");
|
|
100
181
|
};
|
|
@@ -125,11 +206,15 @@ var fetchCustomBrandingImpl = async () => {
|
|
|
125
206
|
const payload = await response.json();
|
|
126
207
|
const brandingObject = {
|
|
127
208
|
logo: payload.logoUrl,
|
|
128
|
-
title: payload.
|
|
129
|
-
|
|
130
|
-
|
|
209
|
+
title: payload.title,
|
|
210
|
+
primaryColor: payload.primaryColor,
|
|
211
|
+
secondaryColor: payload.secondaryColor,
|
|
131
212
|
favicon: payload.faviconUrl,
|
|
132
|
-
supportPortalLink: payload.supportPortalLink || ""
|
|
213
|
+
supportPortalLink: payload.supportPortalLink || "",
|
|
214
|
+
background: payload.background,
|
|
215
|
+
backgroundImage: payload.backgroundImage,
|
|
216
|
+
customColor1: payload.customColor1,
|
|
217
|
+
customColor2: payload.customColor2
|
|
133
218
|
};
|
|
134
219
|
const brandingData = Buffer.from(JSON.stringify(brandingObject)).toString("base64");
|
|
135
220
|
return {
|
|
@@ -170,6 +255,112 @@ async function deleteSessionCookie() {
|
|
|
170
255
|
cookieStore.delete("portal_session");
|
|
171
256
|
}
|
|
172
257
|
|
|
173
|
-
|
|
258
|
+
// src/utils/format.ts
|
|
259
|
+
function formatBytes(bytes, decimals = 1) {
|
|
260
|
+
if (bytes === 0) return "0 Bytes";
|
|
261
|
+
const k = 1024;
|
|
262
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
263
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
|
264
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
265
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
266
|
+
}
|
|
267
|
+
function formatDateShort(dateString) {
|
|
268
|
+
if (!dateString) return "Never";
|
|
269
|
+
const date = new Date(dateString);
|
|
270
|
+
if (isNaN(date.getTime())) {
|
|
271
|
+
return dateString;
|
|
272
|
+
}
|
|
273
|
+
return date.toLocaleDateString("en-US", {
|
|
274
|
+
year: "numeric",
|
|
275
|
+
month: "2-digit",
|
|
276
|
+
day: "2-digit"
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
function formatDate(dateString) {
|
|
280
|
+
if (!dateString) return "Never";
|
|
281
|
+
const date = new Date(dateString);
|
|
282
|
+
if (isNaN(date.getTime())) {
|
|
283
|
+
return dateString;
|
|
284
|
+
}
|
|
285
|
+
return date.toLocaleDateString("en-US", {
|
|
286
|
+
month: "short",
|
|
287
|
+
day: "numeric",
|
|
288
|
+
year: "numeric",
|
|
289
|
+
hour: "numeric",
|
|
290
|
+
minute: "2-digit",
|
|
291
|
+
hour12: true
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
function formatDateTime(dateString) {
|
|
295
|
+
const date = new Date(dateString);
|
|
296
|
+
if (isNaN(date.getTime())) {
|
|
297
|
+
return dateString;
|
|
298
|
+
}
|
|
299
|
+
return date.toLocaleString("en-US", {
|
|
300
|
+
timeZone: "UTC",
|
|
301
|
+
year: "numeric",
|
|
302
|
+
month: "2-digit",
|
|
303
|
+
day: "2-digit",
|
|
304
|
+
hour: "2-digit",
|
|
305
|
+
minute: "2-digit",
|
|
306
|
+
second: "2-digit",
|
|
307
|
+
hour12: false
|
|
308
|
+
}) + " UTC";
|
|
309
|
+
}
|
|
310
|
+
function formatDateTimeLocal(dateString) {
|
|
311
|
+
if (!dateString) return "N/A";
|
|
312
|
+
try {
|
|
313
|
+
const date = new Date(dateString);
|
|
314
|
+
if (isNaN(date.getTime())) {
|
|
315
|
+
return dateString;
|
|
316
|
+
}
|
|
317
|
+
return date.toLocaleDateString("en-US", {
|
|
318
|
+
month: "numeric",
|
|
319
|
+
day: "numeric",
|
|
320
|
+
year: "numeric",
|
|
321
|
+
hour: "numeric",
|
|
322
|
+
minute: "2-digit",
|
|
323
|
+
hour12: true
|
|
324
|
+
});
|
|
325
|
+
} catch {
|
|
326
|
+
return "N/A";
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// src/utils/release-helpers.ts
|
|
331
|
+
function convertToReleaseEntry(release, channelName, options) {
|
|
332
|
+
const sections = [];
|
|
333
|
+
if (release.release_notes && release.release_notes.trim().length > 0) {
|
|
334
|
+
if (options.releaseNotesMode === "markdown") {
|
|
335
|
+
sections.push({
|
|
336
|
+
title: "Release Notes",
|
|
337
|
+
description: release.release_notes
|
|
338
|
+
});
|
|
339
|
+
} else {
|
|
340
|
+
const releaseNotesItems = release.release_notes.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
341
|
+
sections.push({
|
|
342
|
+
title: "Release Notes",
|
|
343
|
+
description: releaseNotesItems.length === 0 ? release.release_notes : void 0,
|
|
344
|
+
items: releaseNotesItems.length > 0 ? releaseNotesItems : void 0
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const charts = release.helm_charts ? release.helm_charts.filter((chart) => !chart.is_kots_installer_only).map((chart) => `${chart.name} v${chart.version}`) : [];
|
|
349
|
+
if (charts.length > 0) {
|
|
350
|
+
sections.push({
|
|
351
|
+
title: "Helm Charts",
|
|
352
|
+
items: charts,
|
|
353
|
+
description: "Latest chart versions included in this release."
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
version: release.label || `Release ${release.release_sequence}`,
|
|
358
|
+
channel: channelName || `Channel ${release.channel_sequence}`,
|
|
359
|
+
releasedAt: release.release_date,
|
|
360
|
+
sections
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export { DEFAULT_FAVICON, DEFAULT_PRIMARY_COLOR, DEFAULT_SECONDARY_COLOR, UnauthorizedError, authenticatedFetch, convertToReleaseEntry, decodeBranding, deleteSessionCookie, formatBytes, formatDate, formatDateShort, formatDateTime, formatDateTimeLocal, isHttpApiOrigin, isRedirectError, normalizeColor, sanitizeUrlForCss, validateSession };
|
|
174
365
|
//# sourceMappingURL=index.js.map
|
|
175
366
|
//# sourceMappingURL=index.js.map
|