diff --git a/web/src/pages/sources/oauth/OAuthSourceForm.ts b/web/src/pages/sources/oauth/OAuthSourceForm.ts index d997ce690..959607af1 100644 --- a/web/src/pages/sources/oauth/OAuthSourceForm.ts +++ b/web/src/pages/sources/oauth/OAuthSourceForm.ts @@ -9,6 +9,7 @@ import "../../../elements/forms/HorizontalFormElement"; import { ifDefined } from "lit-html/directives/if-defined"; import { until } from "lit-html/directives/until"; import { first } from "../../../utils"; +import { AppURLManager } from "../../../api/legacy"; @customElement("ak-source-oauth-form") export class OAuthSourceForm extends Form { @@ -97,6 +98,14 @@ export class OAuthSourceForm extends Form { `; } + getRedirectURI(slug?: string): string { + if (!slug) { + return ""; + } + const path = AppURLManager.sourceOAuth(slug, "callback"); + return `${window.location.protocol}//${window.location.host}${path}`; + } + renderForm(): TemplateResult { return html`
{ label=${t`Slug`} ?required=${true} name="slug"> - + { + const current = (ev.target as HTMLInputElement).value; + const label = this.shadowRoot?.querySelector("#callback-url"); + if (!label) return; + label.innerText = this.getRedirectURI(current); + }}> +

+ ${t`Use this redirect URL:`} + ${this.getRedirectURI(this.source?.slug)} +