web: Clean up version constants. Tidy types
This commit is contained in:

committed by
Teffen Ellis

parent
e8b1f82c3e
commit
b8e394227e
@ -1,5 +1,4 @@
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { VERSION } from "@goauthentik/common/constants";
|
||||
import { globalAK } from "@goauthentik/common/global";
|
||||
import { DefaultBrand } from "@goauthentik/common/ui/config";
|
||||
import "@goauthentik/elements/EmptyState";
|
||||
@ -45,7 +44,7 @@ export class AboutModal extends WithLicenseSummary(WithBrandConfig(ModalButton))
|
||||
}
|
||||
return [
|
||||
[msg("Version"), version.versionCurrent],
|
||||
[msg("UI Version"), VERSION],
|
||||
[msg("UI Version"), import.meta.env.AK_VERSION],
|
||||
[msg("Build"), build],
|
||||
[msg("Python version"), status.runtime.pythonVersion],
|
||||
[msg("Platform"), status.runtime.platform],
|
||||
|
@ -8,7 +8,6 @@ import "@goauthentik/admin/admin-overview/cards/WorkerStatusCard";
|
||||
import "@goauthentik/admin/admin-overview/charts/AdminLoginAuthorizeChart";
|
||||
import "@goauthentik/admin/admin-overview/charts/OutpostStatusChart";
|
||||
import "@goauthentik/admin/admin-overview/charts/SyncStatusChart";
|
||||
import { VERSION } from "@goauthentik/common/constants";
|
||||
import { me } from "@goauthentik/common/users";
|
||||
import { AKElement } from "@goauthentik/elements/Base";
|
||||
import { WithLicenseSummary } from "@goauthentik/elements/Interface/licenseSummaryProvider.js";
|
||||
@ -22,8 +21,6 @@ import { msg, str } from "@lit/localize";
|
||||
import { CSSResult, TemplateResult, css, html, nothing } from "lit";
|
||||
import { customElement, state } from "lit/decorators.js";
|
||||
import { classMap } from "lit/directives/class-map.js";
|
||||
import { map } from "lit/directives/map.js";
|
||||
import { when } from "lit/directives/when.js";
|
||||
|
||||
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
||||
import PFDivider from "@patternfly/patternfly/components/Divider/divider.css";
|
||||
@ -33,21 +30,17 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||
|
||||
import { SessionUser } from "@goauthentik/api";
|
||||
|
||||
export function versionFamily(): string {
|
||||
const parts = VERSION.split(".");
|
||||
parts.pop();
|
||||
return parts.join(".");
|
||||
function createReleaseNotesURL(semver: string): URL {
|
||||
const segments = semver.split(".");
|
||||
const versionFamily = segments.slice(0, -1).join(".");
|
||||
|
||||
const release = `${versionFamily}#fixed-in-${segments.join("")}`;
|
||||
|
||||
return new URL(`/docs/releases/${release}`, "https://goauthentik.io");
|
||||
}
|
||||
|
||||
const RELEASE = `${VERSION.split(".").slice(0, -1).join(".")}#fixed-in-${VERSION.replaceAll(
|
||||
".",
|
||||
"",
|
||||
)}`;
|
||||
|
||||
const AdminOverviewBase = WithLicenseSummary(AKElement);
|
||||
|
||||
type Renderer = () => TemplateResult | typeof nothing;
|
||||
|
||||
@customElement("ak-admin-overview")
|
||||
export class AdminOverviewPage extends AdminOverviewBase {
|
||||
static get styles(): CSSResult[] {
|
||||
@ -83,7 +76,11 @@ export class AdminOverviewPage extends AdminOverviewBase {
|
||||
[msg("Check the logs"), paramURL("/events/log")],
|
||||
[msg("Explore integrations"), "https://goauthentik.io/integrations/", true],
|
||||
[msg("Manage users"), paramURL("/identity/users")],
|
||||
[msg("Check the release notes"), `https://goauthentik.io/docs/releases/${RELEASE}`, true],
|
||||
[
|
||||
msg("Check the release notes"),
|
||||
createReleaseNotesURL(import.meta.env.AK_VERSION).href,
|
||||
true,
|
||||
],
|
||||
];
|
||||
|
||||
@state()
|
||||
@ -193,45 +190,6 @@ export class AdminOverviewPage extends AdminOverviewBase {
|
||||
</div>`
|
||||
: nothing} `;
|
||||
}
|
||||
|
||||
renderActions() {
|
||||
const release = `${versionFamily()}#fixed-in-${VERSION.replaceAll(".", "")}`;
|
||||
|
||||
const quickActions: [string, string][] = [
|
||||
[msg("Create a new application"), paramURL("/core/applications", { createForm: true })],
|
||||
[msg("Check the logs"), paramURL("/events/log")],
|
||||
[msg("Explore integrations"), "https://goauthentik.io/integrations/"],
|
||||
[msg("Manage users"), paramURL("/identity/users")],
|
||||
[msg("Check the release notes"), `https://goauthentik.io/docs/releases/${release}`],
|
||||
];
|
||||
|
||||
const action = ([label, url]: [string, string]) => {
|
||||
const isExternal = url.startsWith("https://");
|
||||
const ex = (truecase: Renderer, falsecase: Renderer) =>
|
||||
when(isExternal, truecase, falsecase);
|
||||
|
||||
const content = html`${label}${ex(
|
||||
() => html`<i class="fas fa-external-link-alt ak-external-link"></i>`,
|
||||
() => nothing,
|
||||
)}`;
|
||||
|
||||
return html`<li>
|
||||
${ex(
|
||||
() =>
|
||||
html`<a
|
||||
href="${url}"
|
||||
class="pf-u-mb-xl"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>${content}</a
|
||||
>`,
|
||||
() => html`<a href="${url}" class="pf-u-mb-xl" )>${content}</a>`,
|
||||
)}
|
||||
</li>`;
|
||||
};
|
||||
|
||||
return html`${map(quickActions, action)}`;
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
@ -3,7 +3,7 @@ import {
|
||||
EventMiddleware,
|
||||
LoggingMiddleware,
|
||||
} from "@goauthentik/common/api/middleware.js";
|
||||
import { EVENT_LOCALE_REQUEST, VERSION } from "@goauthentik/common/constants.js";
|
||||
import { EVENT_LOCALE_REQUEST } from "@goauthentik/common/constants.js";
|
||||
import { globalAK } from "@goauthentik/common/global.js";
|
||||
import { SentryMiddleware } from "@goauthentik/common/sentry/middleware";
|
||||
|
||||
@ -79,4 +79,6 @@ export function AndNext(url: string): string {
|
||||
return `?next=${encodeURIComponent(url)}`;
|
||||
}
|
||||
|
||||
console.debug(`authentik(early): version ${VERSION}, apiBase ${DEFAULT_CONFIG.basePath}`);
|
||||
console.debug(
|
||||
`authentik(early): version ${import.meta.env.AK_VERSION}, apiBase ${DEFAULT_CONFIG.basePath}`,
|
||||
);
|
||||
|
@ -1,12 +1,35 @@
|
||||
/**
|
||||
* @file Global constants used throughout the application.
|
||||
*
|
||||
* @todo Much of this content can be moved to a specific file, element, or component.
|
||||
*/
|
||||
|
||||
/// <reference types="../../types/esbuild.js" />
|
||||
|
||||
//#region Patternfly
|
||||
|
||||
export const SECONDARY_CLASS = "pf-m-secondary";
|
||||
export const SUCCESS_CLASS = "pf-m-success";
|
||||
export const ERROR_CLASS = "pf-m-danger";
|
||||
export const PROGRESS_CLASS = "pf-m-in-progress";
|
||||
export const CURRENT_CLASS = "pf-m-current";
|
||||
export const VERSION = "2025.4.1";
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Application
|
||||
|
||||
export const TITLE_DEFAULT = "authentik";
|
||||
/**
|
||||
* The delimiter used to parse the URL for the current route.
|
||||
*
|
||||
* @todo Move this to the ak-router.
|
||||
*/
|
||||
export const ROUTE_SEPARATOR = ";";
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Events
|
||||
|
||||
export const EVENT_REFRESH = "ak-refresh";
|
||||
export const EVENT_NOTIFICATION_DRAWER_TOGGLE = "ak-notification-toggle";
|
||||
export const EVENT_API_DRAWER_TOGGLE = "ak-api-drawer-toggle";
|
||||
@ -20,7 +43,17 @@ export const EVENT_MESSAGE = "ak-message";
|
||||
export const EVENT_THEME_CHANGE = "ak-theme-change";
|
||||
export const EVENT_REFRESH_ENTERPRISE = "ak-refresh-enterprise";
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region WebSocket
|
||||
|
||||
export const WS_MSG_TYPE_MESSAGE = "message";
|
||||
export const WS_MSG_TYPE_REFRESH = "refresh";
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region LocalStorage
|
||||
|
||||
export const LOCALSTORAGE_AUTHENTIK_KEY = "authentik-local-settings";
|
||||
|
||||
//#endregion
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { VERSION } from "@goauthentik/common/constants";
|
||||
import { SentryIgnoredError } from "@goauthentik/common/sentry";
|
||||
|
||||
export interface PlexPinResponse {
|
||||
@ -19,7 +18,7 @@ export const DEFAULT_HEADERS = {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"X-Plex-Product": "authentik",
|
||||
"X-Plex-Version": VERSION,
|
||||
"X-Plex-Version": import.meta.env.AK_VERSION,
|
||||
"X-Plex-Device-Vendor": "goauthentik.io",
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { VERSION } from "@goauthentik/common/constants";
|
||||
import { globalAK } from "@goauthentik/common/global";
|
||||
import { me } from "@goauthentik/common/users";
|
||||
import { readInterfaceRouteParam } from "@goauthentik/elements/router/utils";
|
||||
@ -41,7 +40,7 @@ export function configureSentry(canDoPpi = false) {
|
||||
/MutationObserver.observe/gi,
|
||||
/NS_ERROR_FAILURE/gi,
|
||||
],
|
||||
release: `authentik@${VERSION}`,
|
||||
release: `authentik@${import.meta.env.AK_VERSION}`,
|
||||
integrations: [
|
||||
browserTracingIntegration({
|
||||
// https://docs.sentry.io/platforms/javascript/tracing/instrumentation/automatic-instrumentation/#custom-routing
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { VERSION } from "@goauthentik/common/constants";
|
||||
import { PFSize } from "@goauthentik/common/enums.js";
|
||||
import {
|
||||
EventContext,
|
||||
@ -76,7 +75,7 @@ ${context.message as string}
|
||||
|
||||
|
||||
**Version and Deployment (please complete the following information):**
|
||||
- authentik version: ${VERSION}
|
||||
- authentik version: ${import.meta.env.AK_VERSION}
|
||||
- Deployment: [e.g. docker-compose, helm]
|
||||
|
||||
**Additional context**
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { VERSION } from "@goauthentik/common/constants";
|
||||
import { AKElement } from "@goauthentik/elements/Base";
|
||||
import { WithVersion } from "@goauthentik/elements/Interface/versionProvider";
|
||||
|
||||
@ -10,20 +9,19 @@ import PFBanner from "@patternfly/patternfly/components/Banner/banner.css";
|
||||
|
||||
@customElement("ak-version-banner")
|
||||
export class VersionBanner extends WithVersion(AKElement) {
|
||||
static get styles() {
|
||||
return [PFBanner];
|
||||
}
|
||||
static styles = [PFBanner];
|
||||
|
||||
render() {
|
||||
return this.version && this.version.versionCurrent !== VERSION
|
||||
? html`
|
||||
<div class="pf-c-banner pf-m-sticky pf-m-gold">
|
||||
${msg(
|
||||
str`A newer version (${this.version.versionCurrent}) of the UI is available.`,
|
||||
)}
|
||||
</div>
|
||||
`
|
||||
: nothing;
|
||||
if (!this.version?.versionCurrent) return nothing;
|
||||
if (this.version.versionCurrent === import.meta.env.AK_VERSION) return nothing;
|
||||
|
||||
return html`
|
||||
<div class="pf-c-banner pf-m-sticky pf-m-gold">
|
||||
${msg(
|
||||
str`A newer version (${this.version.versionCurrent}) of the UI is available.`,
|
||||
)}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user