From b0154b39a30bc5c30cd921e936285c020cea87fc Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 10 Aug 2021 13:49:08 +0200 Subject: [PATCH] added component to set lifespan of token (#955) --- src/clients/advanced/AdvancedSettings.tsx | 34 ++------- src/clients/advanced/TokenLifespan.tsx | 89 +++++++++++++++++++++++ src/clients/messages.ts | 4 + 3 files changed, 101 insertions(+), 26 deletions(-) create mode 100644 src/clients/advanced/TokenLifespan.tsx diff --git a/src/clients/advanced/AdvancedSettings.tsx b/src/clients/advanced/AdvancedSettings.tsx index ebbd05b16e..cf364b0adc 100644 --- a/src/clients/advanced/AdvancedSettings.tsx +++ b/src/clients/advanced/AdvancedSettings.tsx @@ -14,6 +14,7 @@ import { import { FormAccess } from "../../components/form-access/FormAccess"; import { HelpItem } from "../../components/help-enabler/HelpItem"; import { TimeSelector } from "../../components/time-selector/TimeSelector"; +import { TokenLifespan } from "./TokenLifespan"; type AdvancedSettingsProps = { control: Control>; @@ -60,32 +61,13 @@ export const AdvancedSettings = ({ )} {protocol === "openid-connect" && ( <> - - } - > - ( - - )} - /> - + ; + units?: Unit[]; +}; + +const never = "tokenLifespan.never"; +const expires = "tokenLifespan.expires"; + +export const TokenLifespan = ({ + id, + name, + defaultValue, + control, + units, +}: TokenLifespanProps) => { + const { t } = useTranslation("clients"); + const [open, setOpen] = useState(false); + + return ( + + } + > + ( + + + + + + {typeof value === "number" && value !== -1 && ( + + )} + + + )} + /> + + ); +}; diff --git a/src/clients/messages.ts b/src/clients/messages.ts index 3e11d149c0..08f941bc4b 100644 --- a/src/clients/messages.ts +++ b/src/clients/messages.ts @@ -245,5 +245,9 @@ export default { importFile: "Import file", importSuccess: "New certificate imported", importError: "Could not import certificate {{error}}", + tokenLifespan: { + expires: "Expires in", + never: "Never expires", + }, }, };