From d330e9ee7f2ec29a6c90e6d9ae35dc5063947401 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 3 May 2021 22:08:25 +0200 Subject: [PATCH] web/flows: fix rendering for plex login Signed-off-by: Jens Langhammer --- authentik/sources/oauth/views/callback.py | 3 +- web/.eslintrc.json | 6 ++- web/package-lock.json | 13 +++++++ web/package.json | 1 + web/src/flows/sources/plex/PlexLoginInit.ts | 42 ++++++++++++++++----- web/src/locales/en.po | 4 ++ web/src/locales/pseudo-LOCALE.po | 4 ++ 7 files changed, 61 insertions(+), 12 deletions(-) diff --git a/authentik/sources/oauth/views/callback.py b/authentik/sources/oauth/views/callback.py index 8c82bea5a..fa6d9b735 100644 --- a/authentik/sources/oauth/views/callback.py +++ b/authentik/sources/oauth/views/callback.py @@ -97,7 +97,8 @@ class OAuthSourceFlowManager(SourceFlowManager): connection_type = UserOAuthSourceConnection def update_connection( - self, connection: UserOAuthSourceConnection, + self, + connection: UserOAuthSourceConnection, access_token: Optional[str] = None, ) -> UserOAuthSourceConnection: """Set the access_token on the connection""" diff --git a/web/.eslintrc.json b/web/.eslintrc.json index 39bca2824..82e527d4f 100644 --- a/web/.eslintrc.json +++ b/web/.eslintrc.json @@ -6,7 +6,8 @@ "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended", - "plugin:lit/recommended" + "plugin:lit/recommended", + "plugin:custom-elements/recommended" ], "parser": "@typescript-eslint/parser", "parserOptions": { @@ -15,7 +16,8 @@ }, "plugins": [ "@typescript-eslint", - "lit" + "lit", + "custom-elements" ], "rules": { "indent": "off", diff --git a/web/package-lock.json b/web/package-lock.json index 71f47e181..41d9f6731 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -3723,6 +3723,14 @@ "resolved": "https://registry.npmjs.org/eslint-config-google/-/eslint-config-google-0.14.0.tgz", "integrity": "sha512-WsbX4WbjuMvTdeVL6+J3rK1RGhCTqjsFjX7UMSMgZiyxxaNLkoJENbrGExzERFeoTpGw3F3FypTiWAP9ZXzkEw==" }, + "eslint-plugin-custom-elements": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-custom-elements/-/eslint-plugin-custom-elements-0.0.2.tgz", + "integrity": "sha512-lIRBhxh0M/1seyMzSPJwdfdNtlVSPArJ+erF2xqjPsd/6SdCuT43hCQNV2A2te3GqBWhgh/unXSVRO09c1kyPA==", + "requires": { + "eslint-rule-documentation": ">=1.0.0" + } + }, "eslint-plugin-lit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/eslint-plugin-lit/-/eslint-plugin-lit-1.3.0.tgz", @@ -3733,6 +3741,11 @@ "requireindex": "^1.2.0" } }, + "eslint-rule-documentation": { + "version": "1.0.23", + "resolved": "https://registry.npmjs.org/eslint-rule-documentation/-/eslint-rule-documentation-1.0.23.tgz", + "integrity": "sha512-pWReu3fkohwyvztx/oQWWgld2iad25TfUdi6wvhhaDPIQjHU/pyvlKgXFw1kX31SQK2Nq9MH+vRDWB0ZLy8fYw==" + }, "eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", diff --git a/web/package.json b/web/package.json index 144efa4b1..08062e76e 100644 --- a/web/package.json +++ b/web/package.json @@ -67,6 +67,7 @@ "construct-style-sheets-polyfill": "^2.4.16", "eslint": "^7.25.0", "eslint-config-google": "^0.14.0", + "eslint-plugin-custom-elements": "0.0.2", "eslint-plugin-lit": "^1.3.0", "flowchart.js": "^1.15.0", "lit-element": "^2.5.0", diff --git a/web/src/flows/sources/plex/PlexLoginInit.ts b/web/src/flows/sources/plex/PlexLoginInit.ts index 5a134933a..a968f8293 100644 --- a/web/src/flows/sources/plex/PlexLoginInit.ts +++ b/web/src/flows/sources/plex/PlexLoginInit.ts @@ -1,10 +1,17 @@ +import { t } from "@lingui/macro"; import { Challenge } from "authentik-api"; -import {customElement, property} from "lit-element"; -import {html, TemplateResult} from "lit-html"; -import { PFSize } from "../../../elements/Spinner"; +import PFLogin from "@patternfly/patternfly/components/Login/login.css"; +import PFForm from "@patternfly/patternfly/components/Form/form.css"; +import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css"; +import PFTitle from "@patternfly/patternfly/components/Title/title.css"; +import PFButton from "@patternfly/patternfly/components/Button/button.css"; +import PFBase from "@patternfly/patternfly/patternfly-base.css"; +import AKGlobal from "../../../authentik.css"; +import { CSSResult, customElement, property } from "lit-element"; +import { html, TemplateResult } from "lit-html"; import { BaseStage } from "../../stages/base"; -import {PlexAPIClient, popupCenterScreen} from "./API"; -import {DEFAULT_CONFIG} from "../../../api/Config"; +import { PlexAPIClient, popupCenterScreen } from "./API"; +import { DEFAULT_CONFIG } from "../../../api/Config"; import { SourcesApi } from "authentik-api"; export interface PlexAuthenticationChallenge extends Challenge { @@ -20,6 +27,10 @@ export class PlexLoginInit extends BaseStage { @property({ attribute: false }) challenge?: PlexAuthenticationChallenge; + static get styles(): CSSResult[] { + return [PFBase, PFLogin, PFForm, PFFormControl, PFButton, PFTitle, AKGlobal]; + } + async firstUpdated(): Promise { const authInfo = await PlexAPIClient.getPin(this.challenge?.client_id || ""); const authWindow = popupCenterScreen(authInfo.authUrl, "plex auth", 550, 700); @@ -36,10 +47,23 @@ export class PlexLoginInit extends BaseStage { }); } - renderLoading(): TemplateResult { - return html`
- -
`; + render(): TemplateResult { + return html` + + `; } } diff --git a/web/src/locales/en.po b/web/src/locales/en.po index b958c8b02..6e753cb64 100644 --- a/web/src/locales/en.po +++ b/web/src/locales/en.po @@ -281,6 +281,10 @@ msgstr "Attributes" msgid "Audience" msgstr "Audience" +#: src/flows/sources/plex/PlexLoginInit.ts:56 +msgid "Authenticating with Plex..." +msgstr "Authenticating with Plex..." + #: src/pages/flows/FlowForm.ts:55 msgid "Authentication" msgstr "Authentication" diff --git a/web/src/locales/pseudo-LOCALE.po b/web/src/locales/pseudo-LOCALE.po index 117acd43b..9b2270490 100644 --- a/web/src/locales/pseudo-LOCALE.po +++ b/web/src/locales/pseudo-LOCALE.po @@ -277,6 +277,10 @@ msgstr "" msgid "Audience" msgstr "" +#: src/flows/sources/plex/PlexLoginInit.ts:56 +msgid "Authenticating with Plex..." +msgstr "" + #: src/pages/flows/FlowForm.ts:55 msgid "Authentication" msgstr ""