mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00

* WIP * Update vite * Add oauth landing page * Add API support for GitHub oauthing * Remove console.logs * Add support for logging and and out of GitHub * Add bridge API methods * Add base link styling * Sugar syntax main get * Update vite * changelog * Review changes * Use instance to match UI * lint --------- Co-authored-by: Justin Carlson <justinc@element.io>
40 lines
1018 B
TypeScript
40 lines
1018 B
TypeScript
import "./fonts/fonts.scss"
|
|
import "./styling.scss";
|
|
import "./oauth.scss";
|
|
import { render } from 'preact';
|
|
import 'preact/devtools';
|
|
|
|
const root = document.getElementsByTagName('main')[0];
|
|
|
|
const ServiceToName: Record<string,string> = {
|
|
github: 'GitHub',
|
|
gitlab: 'GitLab',
|
|
default: ''
|
|
}
|
|
|
|
|
|
function RenderOAuth() {
|
|
const params = new URLSearchParams(window.location.search);
|
|
const service = params.get('service') ?? 'default';
|
|
const error = params.get('error');
|
|
const errcode = params.get('errcode');
|
|
const oauthKind = params.get('oauth-kind') ?? 'account';
|
|
|
|
if (error) {
|
|
return <>
|
|
<h1>Could not connect your { ServiceToName[service] } {oauthKind} to Hookshot.</h1>
|
|
<p>
|
|
<code>{errcode}</code> {error}
|
|
</p>
|
|
</>;
|
|
}
|
|
|
|
return <>
|
|
<h1>Your { ServiceToName[service] } {oauthKind} has been connected.</h1>
|
|
<p>You may close this window.</p>
|
|
</>;
|
|
}
|
|
|
|
if (root) {
|
|
render(<RenderOAuth />, root);
|
|
} |