From cb178f7f2d5e75d4f470473c8c51b38f39af3817 Mon Sep 17 00:00:00 2001 From: Ken Sternberg <133134217+kensternberg-authentik@users.noreply.github.com> Date: Fri, 28 Jun 2024 08:12:50 -0700 Subject: [PATCH 1/2] web: restore hasLaunchUrl to client-side criteria for filtering apps (#10291) * web: fix esbuild issue with style sheets Getting ESBuild, Lit, and Storybook to all agree on how to read and parse stylesheets is a serious pain. This fix better identifies the value types (instances) being passed from various sources in the repo to the three *different* kinds of style processors we're using (the native one, the polyfill one, and whatever the heck Storybook does internally). Falling back to using older CSS instantiating techniques one era at a time seems to do the trick. It's ugly, but in the face of the aggressive styling we use to avoid Flashes of Unstyled Content (FLoUC), it's the logic with which we're left. In standard mode, the following warning appears on the console when running a Flow: ``` Autofocus processing was blocked because a document already has a focused element. ``` In compatibility mode, the following **error** appears on the console when running a Flow: ``` crawler-inject.js:1106 Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'. at initDomMutationObservers (crawler-inject.js:1106:18) at crawler-inject.js:1114:24 at Array.forEach () at initDomMutationObservers (crawler-inject.js:1114:10) at crawler-inject.js:1549:1 initDomMutationObservers @ crawler-inject.js:1106 (anonymous) @ crawler-inject.js:1114 initDomMutationObservers @ crawler-inject.js:1114 (anonymous) @ crawler-inject.js:1549 ``` Despite this error, nothing seems to be broken and flows work as anticipated. * web: restore `hasLaunchUrl` to the The `filteredApps` criteria I misunderstood where this information was coming from. Sorry about that. * Use the most efficient operator here. --- web/src/user/LibraryPage/ak-library-impl.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/web/src/user/LibraryPage/ak-library-impl.ts b/web/src/user/LibraryPage/ak-library-impl.ts index 8f41b75119..dc7fafa4de 100644 --- a/web/src/user/LibraryPage/ak-library-impl.ts +++ b/web/src/user/LibraryPage/ak-library-impl.ts @@ -13,6 +13,7 @@ import styles from "./LibraryPageImpl.css"; import type { Application } from "@goauthentik/api"; +import { appHasLaunchUrl } from "./LibraryPageImpl.utils"; import "./ak-library-application-empty-list.js"; import "./ak-library-application-list.js"; import "./ak-library-application-search-empty.js"; @@ -136,7 +137,10 @@ export class LibraryPage extends AKElement { const selected = this.selectedApp?.slug; const layout = this.uiConfig.layout as string; const background = this.uiConfig.background; - const groupedApps = groupBy(this.filteredApps, (app) => app.group || ""); + const groupedApps = groupBy( + this.filteredApps.filter(appHasLaunchUrl), + (app) => app.group || "", + ); return html``; } + renderNoAppsFound() { + return html``; + } + renderSearchEmpty() { return nothing; } @@ -162,10 +170,9 @@ export class LibraryPage extends AKElement { ?isadmin=${this.isAdmin} >`; } - if (this.filteredApps.length === 0) { - return html``; - } - return this.renderApps(); + return this.filteredApps.some(appHasLaunchUrl) // prettier-ignore + ? this.renderApps() + : this.renderNoAppsFound(); } render() { From 136b7dea54d4984d0c78c806faeebb36a8df4556 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Fri, 28 Jun 2024 17:40:27 +0200 Subject: [PATCH 2/2] core: applications api: prefetch related policies (#10273) --- authentik/core/api/applications.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authentik/core/api/applications.py b/authentik/core/api/applications.py index cc747fd8c8..6e6db93df5 100644 --- a/authentik/core/api/applications.py +++ b/authentik/core/api/applications.py @@ -103,7 +103,7 @@ class ApplicationSerializer(ModelSerializer): class ApplicationViewSet(UsedByMixin, ModelViewSet): """Application Viewset""" - queryset = Application.objects.all().prefetch_related("provider") + queryset = Application.objects.all().prefetch_related("provider").prefetch_related("policies") serializer_class = ApplicationSerializer search_fields = [ "name",