web: Clean up version constants. Tidy types

This commit is contained in:
Teffen Ellis
2025-05-19 00:45:00 +02:00
committed by Teffen Ellis
parent e8b1f82c3e
commit b8e394227e
8 changed files with 65 additions and 78 deletions

View File

@ -1,5 +1,4 @@
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import { VERSION } from "@goauthentik/common/constants";
import { globalAK } from "@goauthentik/common/global"; import { globalAK } from "@goauthentik/common/global";
import { DefaultBrand } from "@goauthentik/common/ui/config"; import { DefaultBrand } from "@goauthentik/common/ui/config";
import "@goauthentik/elements/EmptyState"; import "@goauthentik/elements/EmptyState";
@ -45,7 +44,7 @@ export class AboutModal extends WithLicenseSummary(WithBrandConfig(ModalButton))
} }
return [ return [
[msg("Version"), version.versionCurrent], [msg("Version"), version.versionCurrent],
[msg("UI Version"), VERSION], [msg("UI Version"), import.meta.env.AK_VERSION],
[msg("Build"), build], [msg("Build"), build],
[msg("Python version"), status.runtime.pythonVersion], [msg("Python version"), status.runtime.pythonVersion],
[msg("Platform"), status.runtime.platform], [msg("Platform"), status.runtime.platform],

View File

@ -8,7 +8,6 @@ import "@goauthentik/admin/admin-overview/cards/WorkerStatusCard";
import "@goauthentik/admin/admin-overview/charts/AdminLoginAuthorizeChart"; import "@goauthentik/admin/admin-overview/charts/AdminLoginAuthorizeChart";
import "@goauthentik/admin/admin-overview/charts/OutpostStatusChart"; import "@goauthentik/admin/admin-overview/charts/OutpostStatusChart";
import "@goauthentik/admin/admin-overview/charts/SyncStatusChart"; import "@goauthentik/admin/admin-overview/charts/SyncStatusChart";
import { VERSION } from "@goauthentik/common/constants";
import { me } from "@goauthentik/common/users"; import { me } from "@goauthentik/common/users";
import { AKElement } from "@goauthentik/elements/Base"; import { AKElement } from "@goauthentik/elements/Base";
import { WithLicenseSummary } from "@goauthentik/elements/Interface/licenseSummaryProvider.js"; 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 { CSSResult, TemplateResult, css, html, nothing } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.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 PFContent from "@patternfly/patternfly/components/Content/content.css";
import PFDivider from "@patternfly/patternfly/components/Divider/divider.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"; import { SessionUser } from "@goauthentik/api";
export function versionFamily(): string { function createReleaseNotesURL(semver: string): URL {
const parts = VERSION.split("."); const segments = semver.split(".");
parts.pop(); const versionFamily = segments.slice(0, -1).join(".");
return parts.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); const AdminOverviewBase = WithLicenseSummary(AKElement);
type Renderer = () => TemplateResult | typeof nothing;
@customElement("ak-admin-overview") @customElement("ak-admin-overview")
export class AdminOverviewPage extends AdminOverviewBase { export class AdminOverviewPage extends AdminOverviewBase {
static get styles(): CSSResult[] { static get styles(): CSSResult[] {
@ -83,7 +76,11 @@ export class AdminOverviewPage extends AdminOverviewBase {
[msg("Check the logs"), paramURL("/events/log")], [msg("Check the logs"), paramURL("/events/log")],
[msg("Explore integrations"), "https://goauthentik.io/integrations/", true], [msg("Explore integrations"), "https://goauthentik.io/integrations/", true],
[msg("Manage users"), paramURL("/identity/users")], [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() @state()
@ -193,45 +190,6 @@ export class AdminOverviewPage extends AdminOverviewBase {
</div>` </div>`
: nothing} `; : 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 { declare global {

View File

@ -3,7 +3,7 @@ import {
EventMiddleware, EventMiddleware,
LoggingMiddleware, LoggingMiddleware,
} from "@goauthentik/common/api/middleware.js"; } 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 { globalAK } from "@goauthentik/common/global.js";
import { SentryMiddleware } from "@goauthentik/common/sentry/middleware"; import { SentryMiddleware } from "@goauthentik/common/sentry/middleware";
@ -79,4 +79,6 @@ export function AndNext(url: string): string {
return `?next=${encodeURIComponent(url)}`; 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}`,
);

View File

@ -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 SECONDARY_CLASS = "pf-m-secondary";
export const SUCCESS_CLASS = "pf-m-success"; export const SUCCESS_CLASS = "pf-m-success";
export const ERROR_CLASS = "pf-m-danger"; export const ERROR_CLASS = "pf-m-danger";
export const PROGRESS_CLASS = "pf-m-in-progress"; export const PROGRESS_CLASS = "pf-m-in-progress";
export const CURRENT_CLASS = "pf-m-current"; export const CURRENT_CLASS = "pf-m-current";
export const VERSION = "2025.4.1";
//#endregion
//#region Application
export const TITLE_DEFAULT = "authentik"; 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 = ";"; export const ROUTE_SEPARATOR = ";";
//#endregion
//#region Events
export const EVENT_REFRESH = "ak-refresh"; export const EVENT_REFRESH = "ak-refresh";
export const EVENT_NOTIFICATION_DRAWER_TOGGLE = "ak-notification-toggle"; export const EVENT_NOTIFICATION_DRAWER_TOGGLE = "ak-notification-toggle";
export const EVENT_API_DRAWER_TOGGLE = "ak-api-drawer-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_THEME_CHANGE = "ak-theme-change";
export const EVENT_REFRESH_ENTERPRISE = "ak-refresh-enterprise"; export const EVENT_REFRESH_ENTERPRISE = "ak-refresh-enterprise";
//#endregion
//#region WebSocket
export const WS_MSG_TYPE_MESSAGE = "message"; export const WS_MSG_TYPE_MESSAGE = "message";
export const WS_MSG_TYPE_REFRESH = "refresh"; export const WS_MSG_TYPE_REFRESH = "refresh";
//#endregion
//#region LocalStorage
export const LOCALSTORAGE_AUTHENTIK_KEY = "authentik-local-settings"; export const LOCALSTORAGE_AUTHENTIK_KEY = "authentik-local-settings";
//#endregion

View File

@ -1,4 +1,3 @@
import { VERSION } from "@goauthentik/common/constants";
import { SentryIgnoredError } from "@goauthentik/common/sentry"; import { SentryIgnoredError } from "@goauthentik/common/sentry";
export interface PlexPinResponse { export interface PlexPinResponse {
@ -19,7 +18,7 @@ export const DEFAULT_HEADERS = {
"Accept": "application/json", "Accept": "application/json",
"Content-Type": "application/json", "Content-Type": "application/json",
"X-Plex-Product": "authentik", "X-Plex-Product": "authentik",
"X-Plex-Version": VERSION, "X-Plex-Version": import.meta.env.AK_VERSION,
"X-Plex-Device-Vendor": "goauthentik.io", "X-Plex-Device-Vendor": "goauthentik.io",
}; };

View File

@ -1,4 +1,3 @@
import { VERSION } from "@goauthentik/common/constants";
import { globalAK } from "@goauthentik/common/global"; import { globalAK } from "@goauthentik/common/global";
import { me } from "@goauthentik/common/users"; import { me } from "@goauthentik/common/users";
import { readInterfaceRouteParam } from "@goauthentik/elements/router/utils"; import { readInterfaceRouteParam } from "@goauthentik/elements/router/utils";
@ -41,7 +40,7 @@ export function configureSentry(canDoPpi = false) {
/MutationObserver.observe/gi, /MutationObserver.observe/gi,
/NS_ERROR_FAILURE/gi, /NS_ERROR_FAILURE/gi,
], ],
release: `authentik@${VERSION}`, release: `authentik@${import.meta.env.AK_VERSION}`,
integrations: [ integrations: [
browserTracingIntegration({ browserTracingIntegration({
// https://docs.sentry.io/platforms/javascript/tracing/instrumentation/automatic-instrumentation/#custom-routing // https://docs.sentry.io/platforms/javascript/tracing/instrumentation/automatic-instrumentation/#custom-routing

View File

@ -1,5 +1,4 @@
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import { VERSION } from "@goauthentik/common/constants";
import { PFSize } from "@goauthentik/common/enums.js"; import { PFSize } from "@goauthentik/common/enums.js";
import { import {
EventContext, EventContext,
@ -76,7 +75,7 @@ ${context.message as string}
**Version and Deployment (please complete the following information):** **Version and Deployment (please complete the following information):**
- authentik version: ${VERSION} - authentik version: ${import.meta.env.AK_VERSION}
- Deployment: [e.g. docker-compose, helm] - Deployment: [e.g. docker-compose, helm]
**Additional context** **Additional context**

View File

@ -1,4 +1,3 @@
import { VERSION } from "@goauthentik/common/constants";
import { AKElement } from "@goauthentik/elements/Base"; import { AKElement } from "@goauthentik/elements/Base";
import { WithVersion } from "@goauthentik/elements/Interface/versionProvider"; import { WithVersion } from "@goauthentik/elements/Interface/versionProvider";
@ -10,20 +9,19 @@ import PFBanner from "@patternfly/patternfly/components/Banner/banner.css";
@customElement("ak-version-banner") @customElement("ak-version-banner")
export class VersionBanner extends WithVersion(AKElement) { export class VersionBanner extends WithVersion(AKElement) {
static get styles() { static styles = [PFBanner];
return [PFBanner];
}
render() { render() {
return this.version && this.version.versionCurrent !== VERSION if (!this.version?.versionCurrent) return nothing;
? html` if (this.version.versionCurrent === import.meta.env.AK_VERSION) return nothing;
<div class="pf-c-banner pf-m-sticky pf-m-gold">
${msg( return html`
str`A newer version (${this.version.versionCurrent}) of the UI is available.`, <div class="pf-c-banner pf-m-sticky pf-m-gold">
)} ${msg(
</div> str`A newer version (${this.version.versionCurrent}) of the UI is available.`,
` )}
: nothing; </div>
`;
} }
} }