@@ -89,18 +106,11 @@ export class UserSettingsPage extends LitElement { `; }); }))} - ${until(new SourcesApi(DEFAULT_CONFIG).sourcesAllUserSettings({}).then((sources) => { - return sources.map((source) => { - // TODO: Check for non-shell sources - return html`
-
-
- -
-
-
-
-
`; + ${until(new SourcesApi(DEFAULT_CONFIG).sourcesAllUserSettings({}).then((source) => { + return source.map((stage) => { + return html`
+ ${this.renderSourceSettings(stage)} +
`; }); }))} diff --git a/web/src/pages/users/settings/SourceSettingsOAuth.ts b/web/src/pages/users/settings/SourceSettingsOAuth.ts new file mode 100644 index 000000000..383c1a7f5 --- /dev/null +++ b/web/src/pages/users/settings/SourceSettingsOAuth.ts @@ -0,0 +1,50 @@ +import { customElement, html, TemplateResult } from "lit-element"; +import { BaseUserSettings } from "./BaseUserSettings"; +import { OAuthSource, SourcesApi } from "authentik-api"; +import { until } from "lit-html/directives/until"; +import { DEFAULT_CONFIG } from "../../../api/Config"; +import { gettext } from "django"; +import { AppURLManager } from "../../../api/legacy"; + +@customElement("ak-user-settings-source-oauth") +export class SourceSettingsOAuth extends BaseUserSettings { + + render(): TemplateResult { + return html`${until(new SourcesApi(DEFAULT_CONFIG).sourcesOauthRead({ + slug: this.objectId + }).then((source) => { + return html`
+
+ ${gettext(`Source ${source.name}`)} +
+
+ ${this.renderInner(source)} +
+
`; + }))}`; + } + + renderInner(source: OAuthSource): TemplateResult { + return html`${until(new SourcesApi(DEFAULT_CONFIG).sourcesOauthUserConnectionsList({ + source: this.objectId + }).then((connection) => { + if (connection.results.length > 0) { + return html`

${gettext("Connected.")}

+ `; + } + return html`

${gettext("Not connected.")}

+ + ${gettext("Connect")} + `; + }))}`; + } + +}