mirror of
https://github.com/zitadel/zitadel.git
synced 2025-05-07 16:07:10 +00:00

* variable parser * rm plugin * set fcn * env * EnvCode component * cleanup env demo * env * rm remark plugin * auth request context * auth req component * authorize endpoint construction * rev react page * fix endpoint * styling * query params with anchor * desc * tailwind coexistence * fix styles * add login_hint, organizationId scope * auth request without prompt * show login_hint * sync displayed url with actual href * fix fcn * coloring * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <mpa@zitadel.com> * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <mpa@zitadel.com> * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <mpa@zitadel.com> * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <mpa@zitadel.com> * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <mpa@zitadel.com> * Update docs/src/components/authrequest.jsx Co-authored-by: mffap <mpa@zitadel.com> * add plausible, header * add pkce * move * adds pkce code challenge * replace cboa * reaname and move to required * fall back to cboa due to webpack error * trailing slash * reorder org_id * remove resourceowner * texts * update references * buffer, fix some react dom components * Apply suggestions from code review Co-authored-by: Florian Forster <florian@zitadel.com> * standard scopes Co-authored-by: mffap <mpa@zitadel.com> Co-authored-by: Florian Forster <florian@zitadel.com>
134 lines
3.0 KiB
JavaScript
134 lines
3.0 KiB
JavaScript
import React, { useContext, useEffect } from "react";
|
|
import { EnvironmentContext } from "../utils/environment";
|
|
import styles from "../css/environment.module.css";
|
|
import Interpolate from "@docusaurus/Interpolate";
|
|
import CodeBlock from "@theme/CodeBlock";
|
|
|
|
export function SetEnvironment() {
|
|
const {
|
|
instance: [instance, setInstance],
|
|
clientId: [clientId, setClientId],
|
|
} = useContext(EnvironmentContext);
|
|
|
|
useEffect(() => {
|
|
const params = new URLSearchParams(window.location.search); // id=123
|
|
const clientId = params.get("clientId");
|
|
const instance = params.get("instance");
|
|
|
|
const localClientId = localStorage.getItem("clientId");
|
|
const localInstance = localStorage.getItem("instance");
|
|
|
|
setClientId(clientId ?? localClientId ?? "");
|
|
setInstance(instance ?? localInstance ?? "");
|
|
}, []);
|
|
|
|
function setAndSaveInstance(value) {
|
|
if (instance !== value) {
|
|
localStorage.setItem("instance", value);
|
|
setInstance(value);
|
|
}
|
|
}
|
|
|
|
function setAndSaveClientId(value) {
|
|
if (clientId !== value) {
|
|
localStorage.setItem("clientId", value);
|
|
setClientId(value);
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<div className={styles.inputwrapper}>
|
|
<label className={styles.label}>Your instance domain</label>
|
|
<input
|
|
className={styles.input}
|
|
id="instance"
|
|
value={instance}
|
|
onChange={(event) => {
|
|
const value = event.target.value;
|
|
if (value) {
|
|
setAndSaveInstance(value);
|
|
} else {
|
|
localStorage.removeItem("instance");
|
|
}
|
|
}}
|
|
/>
|
|
</div>
|
|
|
|
<br />
|
|
|
|
<div className={styles.inputwrapper}>
|
|
<label className={styles.label}>Client ID</label>
|
|
<input
|
|
className={styles.input}
|
|
id="clientid"
|
|
value={clientId}
|
|
onChange={(event) => {
|
|
const value = event.target.value;
|
|
if (value) {
|
|
setAndSaveClientId(value);
|
|
} else {
|
|
localStorage.removeItem("clientId");
|
|
}
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function Env({ name }) {
|
|
const env = useContext(EnvironmentContext);
|
|
const variable = env[name];
|
|
|
|
return <div>{variable}</div>;
|
|
}
|
|
|
|
export function EnvInterpolate({ children }) {
|
|
const {
|
|
instance: [instance],
|
|
clientId: [clientId],
|
|
} = useContext(EnvironmentContext);
|
|
|
|
return (
|
|
<Interpolate
|
|
values={{
|
|
clientId,
|
|
instance,
|
|
}}
|
|
>
|
|
{children}
|
|
</Interpolate>
|
|
);
|
|
}
|
|
|
|
export function EnvCode({
|
|
language,
|
|
title,
|
|
code,
|
|
showLineNumbers = false,
|
|
children,
|
|
}) {
|
|
const {
|
|
instance: [instance],
|
|
clientId: [clientId],
|
|
} = useContext(EnvironmentContext);
|
|
|
|
return (
|
|
<CodeBlock
|
|
language={language}
|
|
title={title}
|
|
showLineNumbers={showLineNumbers}
|
|
>
|
|
<Interpolate
|
|
values={{
|
|
clientId,
|
|
instance,
|
|
}}
|
|
>
|
|
{children}
|
|
</Interpolate>
|
|
</CodeBlock>
|
|
);
|
|
}
|