Prettier and ESLint had opinions.
This commit is contained in:
@ -14,8 +14,8 @@
|
|||||||
"build": "run-s build-locales esbuild:build",
|
"build": "run-s build-locales esbuild:build",
|
||||||
"build-proxy": "run-s build-locales esbuild:build-proxy",
|
"build-proxy": "run-s build-locales esbuild:build-proxy",
|
||||||
"watch": "run-s build-locales esbuild:watch",
|
"watch": "run-s build-locales esbuild:watch",
|
||||||
"lint": "cross-env NODE_OPTIONS='--max_old_space_size=16384' eslint . --max-warnings 0 --fix",
|
"lint": "cross-env NODE_OPTIONS='--max_old_space_size=65536' eslint . --max-warnings 0 --fix",
|
||||||
"lint:precommit": "cross-env NODE_OPTIONS='--max_old_space_size=16384' node scripts/eslint-precommit.mjs",
|
"lint:precommit": "cross-env NODE_OPTIONS='--max_old_space_size=65536' node scripts/eslint-precommit.mjs",
|
||||||
"lint:spelling": "node scripts/check-spelling.mjs",
|
"lint:spelling": "node scripts/check-spelling.mjs",
|
||||||
"lit-analyse": "lit-analyzer src",
|
"lit-analyse": "lit-analyzer src",
|
||||||
"precommit": "npm-run-all --parallel tsc lit-analyse lint:spelling --sequential lint:precommit prettier",
|
"precommit": "npm-run-all --parallel tsc lit-analyse lint:spelling --sequential lint:precommit prettier",
|
||||||
|
@ -3,23 +3,24 @@ type CatchFn<T> = (error: unknown) => T;
|
|||||||
|
|
||||||
type TryCatchArgs<T> = {
|
type TryCatchArgs<T> = {
|
||||||
tryFn: TryFn<T>;
|
tryFn: TryFn<T>;
|
||||||
catchFn: CatchFn<T>;
|
catchFn?: CatchFn<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function tryCatch<T>({ tryFn, catchFn }: TryCatchArgs<T>): T;
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export function tryCatch<T>(tryFn: TryFn<T>, catchFn: CatchFn<T>): T;
|
|
||||||
|
|
||||||
const isTryCatchArgs = <T>(t: any): t is TryCatchArgs<T> =>
|
const isTryCatchArgs = <T>(t: any): t is TryCatchArgs<T> =>
|
||||||
typeof t === "object" && "tryFn" in t && "catchFn" in t;
|
typeof t === "object" && "tryFn" in t && "catchFn" in t;
|
||||||
|
|
||||||
export function tryCatch<T>(tryFn: TryFn<T> | TryCatchProps<T>, catchFn?: CatchFn<T>): T {
|
export function tryCatch<T>({ tryFn, catchFn }: TryCatchArgs<T>): T;
|
||||||
|
export function tryCatch<T>(tryFn: TryFn<T>): T;
|
||||||
|
export function tryCatch<T>(tryFn: TryFn<T>, catchFn: CatchFn<T>): T;
|
||||||
|
export function tryCatch<T>(tryFn: TryFn<T> | TryCatchArgs<T>, catchFn?: CatchFn<T>): T {
|
||||||
if (isTryCatchArgs(tryFn)) {
|
if (isTryCatchArgs(tryFn)) {
|
||||||
catchFn = tryFn.catchFn;
|
catchFn = tryFn.catchFn;
|
||||||
tryFn = tryFn.tryFn;
|
tryFn = tryFn.tryFn;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (catchFn === undefined) {
|
if (catchFn === undefined) {
|
||||||
catchFn = () => null;
|
catchFn = () => null as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { PFSize } from "@goauthentik/common/enums.js";
|
import { PFSize } from "@goauthentik/common/enums.js";
|
||||||
import { LayoutType } from "@goauthentik/common/ui/config";
|
import { LayoutType } from "@goauthentik/common/ui/config";
|
||||||
import { AKElement, rootInterface } from "@goauthentik/elements/Base";
|
import { AKElement, rootInterface } from "@goauthentik/elements/Base";
|
||||||
|
import { UserInterface } from "@goauthentik/user/UserInterface";
|
||||||
|
|
||||||
import { msg } from "@lit/localize";
|
import { msg } from "@lit/localize";
|
||||||
import { css, html, nothing } from "lit";
|
import { css, html, nothing } from "lit";
|
||||||
@ -9,33 +10,14 @@ import { classMap } from "lit/directives/class-map.js";
|
|||||||
import { ifDefined } from "lit/directives/if-defined.js";
|
import { ifDefined } from "lit/directives/if-defined.js";
|
||||||
|
|
||||||
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
||||||
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
|
||||||
import PFEmptyState from "@patternfly/patternfly/components/EmptyState/empty-state.css";
|
import PFEmptyState from "@patternfly/patternfly/components/EmptyState/empty-state.css";
|
||||||
import PFTable from "@patternfly/patternfly/components/Table/table.css";
|
import PFTable from "@patternfly/patternfly/components/Table/table.css";
|
||||||
import PFGrid from "@patternfly/patternfly/layouts/Grid/grid.css";
|
|
||||||
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||||
|
|
||||||
import type { Application } from "@goauthentik/api";
|
import type { Application } from "@goauthentik/api";
|
||||||
|
|
||||||
import type { AppGroupEntry, AppGroupList } from "./types";
|
import type { AppGroupEntry, AppGroupList } from "./types";
|
||||||
|
|
||||||
type Pair = [string, string];
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
const LAYOUTS = new Map<string, [string, string]>([
|
|
||||||
[
|
|
||||||
"row",
|
|
||||||
["pf-m-12-col", "pf-m-all-6-col-on-sm pf-m-all-4-col-on-md pf-m-all-5-col-on-lg pf-m-all-2-col-on-xl"]],
|
|
||||||
[
|
|
||||||
"2-column",
|
|
||||||
["pf-m-6-col", "pf-m-all-12-col-on-sm pf-m-all-12-col-on-md pf-m-all-4-col-on-lg pf-m-all-4-col-on-xl"],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"3-column",
|
|
||||||
["pf-m-4-col", "pf-m-all-12-col-on-sm pf-m-all-12-col-on-md pf-m-all-6-col-on-lg pf-m-all-6-col-on-xl"],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
@customElement("ak-library-application-list")
|
@customElement("ak-library-application-list")
|
||||||
export class LibraryPageApplicationList extends AKElement {
|
export class LibraryPageApplicationList extends AKElement {
|
||||||
static get styles() {
|
static get styles() {
|
||||||
@ -66,19 +48,10 @@ export class LibraryPageApplicationList extends AKElement {
|
|||||||
|
|
||||||
expanded = new Set<string>();
|
expanded = new Set<string>();
|
||||||
|
|
||||||
get currentLayout(): Pair {
|
|
||||||
const layout = LAYOUTS.get(this.layout);
|
|
||||||
if (!layout) {
|
|
||||||
console.warn(`Unrecognized layout: ${this.layout || "-undefined-"}`);
|
|
||||||
return LAYOUTS.get("row") as Pair;
|
|
||||||
}
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const me = rootInterface<UserInterface>()?.me;
|
||||||
const canEdit =
|
const canEdit =
|
||||||
rootInterface()?.uiConfig?.enabledFeatures.applicationEdit &&
|
rootInterface()?.uiConfig?.enabledFeatures.applicationEdit && me?.user.isSuperuser;
|
||||||
rootInterface()?.me?.user.isSuperuser;
|
|
||||||
|
|
||||||
const toggleExpansion = (pk: string) => {
|
const toggleExpansion = (pk: string) => {
|
||||||
if (this.expanded.has(pk)) {
|
if (this.expanded.has(pk)) {
|
||||||
@ -89,8 +62,6 @@ export class LibraryPageApplicationList extends AKElement {
|
|||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
const [groupClass, groupGrid] = this.currentLayout;
|
|
||||||
|
|
||||||
const expandedClass = (pk: string) => ({
|
const expandedClass = (pk: string) => ({
|
||||||
"pf-m-expanded": this.expanded.has(pk),
|
"pf-m-expanded": this.expanded.has(pk),
|
||||||
});
|
});
|
||||||
|
@ -76,11 +76,8 @@ export class LibraryPage extends AKElement {
|
|||||||
this.viewPreference =
|
this.viewPreference =
|
||||||
this.viewPreference ??
|
this.viewPreference ??
|
||||||
tryCatch(
|
tryCatch(
|
||||||
() => window.localStorage.getItem(VIEW_KEY),
|
() => window.localStorage.getItem(VIEW_KEY) ?? undefined,
|
||||||
(e) => {
|
(e) => "card",
|
||||||
console.log(e);
|
|
||||||
return "card";
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
if (this.filteredApps === undefined) {
|
if (this.filteredApps === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -128,7 +125,9 @@ export class LibraryPage extends AKElement {
|
|||||||
|
|
||||||
setView(view: string) {
|
setView(view: string) {
|
||||||
this.viewPreference = view;
|
this.viewPreference = view;
|
||||||
tryCatch(() => window.localStorage.setItem(VIEW_KEY, view));
|
tryCatch(() => {
|
||||||
|
window.localStorage.setItem(VIEW_KEY, view);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
renderEmptyState() {
|
renderEmptyState() {
|
||||||
|
Reference in New Issue
Block a user