From 214d02fa8d60a61d148f910f11e66d85f77bee51 Mon Sep 17 00:00:00 2001 From: Manuel Scurti Date: Tue, 12 Sep 2023 11:39:17 +0200 Subject: [PATCH] fixed api report and docs Signed-off-by: Manuel Scurti --- .changeset/many-panthers-wink.md | 2 +- docs/auth/autologout.md | 20 +++++++++--------- packages/core-components/api-report.md | 21 ++----------------- .../src/components/AutoLogout/AutoLogout.tsx | 4 ++-- 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/.changeset/many-panthers-wink.md b/.changeset/many-panthers-wink.md index 1a7c5c1331..724a3aada6 100644 --- a/.changeset/many-panthers-wink.md +++ b/.changeset/many-panthers-wink.md @@ -2,4 +2,4 @@ '@backstage/core-components': patch --- -Added AutoLogoutProvider which introduces an optional automatic logout mechanism on user inactivity +Added `` component which introduces an optional automatic logout mechanism on user inactivity diff --git a/docs/auth/autologout.md b/docs/auth/autologout.md index 1c20f3f613..b792ac6ea1 100644 --- a/docs/auth/autologout.md +++ b/docs/auth/autologout.md @@ -27,7 +27,7 @@ To enable and configure Auto Logout, you will need to add the `` com Here's how to add it: ```ts -import { AutoLogoutProvider } from '@backstage/core-components'; +import { AutoLogout } from '@backstage/core-components'; // ... App.tsx contents @@ -63,13 +63,13 @@ auth: enabled: true ``` -Bear in mind that, in case the same property is found both in the `` component and the `app-config` file then the properties set in the React component take precedence over configuration properties found inside your `app-config`. -You will now be able to configure the AutoLogoutProvider through your `app-config`. These are the available settings: +Bear in mind that, properties configured in `app-config` take precedence over the props passed to the `` React component. +These are the available settings: -| Configuration Key | Component Property | Description | Allowed Values | Default Value | -| ----------------------------------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------- | -| `auth.autologout.enabled` | `enabled` | Enable/disable the Auto Logout feature. | `true`/`false` | With `` default is enabled (`true`). With `` default is disabled (`false`) | -| `auth.autologout.idleTimeoutMinutes` | `idleTimeoutMinutes` | Sets the idle time (in minutes) after which the user will be logged out. | `>= 0.5` minutes | `60` | -| `auth.autologout.promptBeforeIdleSeconds` | `promptBeforeIdleSeconds` | Determines the time (in seconds) prior to idle state when a prompt will appear. A value of 0 disables the prompt. This must be less than the value of `idleTimeoutMinutes`. | `>= 0` seconds | `10` | -| `auth.autologout.useWorkerTimers` | `useWorkerTimers` | Enables or disables the use of Node's worker thread timers instead of main thread timers. This can be beneficial if the browser is terminating timers in inactive tabs, like those used by auto logout. In case of browser incompatibility, try setting this to false. | `true`/`false` | `true` | -| `auth.autologout.logoutIfDisconnected` | `logoutIfDisconnected` | Enable/disable auto logout for disconnected users. Disconnected users are those who are logged in but do not have any active Backstage tabs open in their browsers. If enabled, such users will be automatically logged out after `idleTimeoutMinutes`. | `true`/`false` | `true` | +| Configuration Key | Component Property | Description | Allowed Values | Default Value | +| ----------------------------------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | --------------------------- | +| `auth.autologout.enabled` | `enabled` | Enable/disable the Auto Logout feature. | `true`/`false` | Default is enabled (`true`) | +| `auth.autologout.idleTimeoutMinutes` | `idleTimeoutMinutes` | Sets the idle time (in minutes) after which the user will be logged out. | `>= 0.5` minutes | `60` | +| `auth.autologout.promptBeforeIdleSeconds` | `promptBeforeIdleSeconds` | Determines the time (in seconds) prior to idle state when a prompt will appear. A value of 0 disables the prompt. This must be less than the value of `idleTimeoutMinutes`. | `>= 0` seconds | `10` | +| `auth.autologout.useWorkerTimers` | `useWorkerTimers` | Enables or disables the use of Node's worker thread timers instead of main thread timers. This can be beneficial if the browser is terminating timers in inactive tabs, like those used by auto logout. In case of browser incompatibility, try setting this to false. | `true`/`false` | `true` | +| `auth.autologout.logoutIfDisconnected` | `logoutIfDisconnected` | Enable/disable auto logout for disconnected users. Disconnected users are those who are logged in but do not have any active Backstage tabs open in their browsers. If enabled, such users will be automatically logged out after `idleTimeoutMinutes`. | `true`/`false` | `true` | diff --git a/packages/core-components/api-report.md b/packages/core-components/api-report.md index 388282a854..e7a3a47713 100644 --- a/packages/core-components/api-report.md +++ b/packages/core-components/api-report.md @@ -69,23 +69,14 @@ export type AlertDisplayProps = { }; // @public -export const AutoLogoutProvider: ({ - children, - enabled, - idleTimeoutMinutes, - promptBeforeIdleSeconds, - useWorkerTimers, - events, - logoutIfDisconnected, -}: PropsWithChildren) => JSX.Element; +export const AutoLogout: (props: AutoLogoutProps) => JSX.Element | null; // @public (undocumented) -export type AutoLogoutProviderProps = { +export type AutoLogoutProps = { enabled?: boolean; idleTimeoutMinutes?: number; promptBeforeIdleSeconds?: number; useWorkerTimers?: boolean; - events?: AutoLogoutTrackableEvent[]; logoutIfDisconnected?: boolean; }; @@ -190,14 +181,6 @@ export interface CodeSnippetProps { text: string; } -// @public -export const ConfigBasedAutoLogoutProvider: ({ - children, -}: PropsWithChildren) => JSX.Element; - -// @public (undocumented) -export type ConfigBasedAutoLogoutProviderProps = {}; - // Warning: (ae-forgotten-export) The symbol "Props_13" needs to be exported by the entry point index.d.ts // // @public diff --git a/packages/core-components/src/components/AutoLogout/AutoLogout.tsx b/packages/core-components/src/components/AutoLogout/AutoLogout.tsx index 96ae497208..56ff2f19c8 100644 --- a/packages/core-components/src/components/AutoLogout/AutoLogout.tsx +++ b/packages/core-components/src/components/AutoLogout/AutoLogout.tsx @@ -229,7 +229,7 @@ const parseConfig = ( * * @public */ -export const AutoLogout = (props: AutoLogoutProps): JSX.Element => { +export const AutoLogout = (props: AutoLogoutProps): JSX.Element | null => { const identityApi = useApi(identityApiRef); const configApi = useApi(configApiRef); const [isLogged, setIsLogged] = useState(false); @@ -293,7 +293,7 @@ export const AutoLogout = (props: AutoLogoutProps): JSX.Element => { }); if (!enabled || !isLogged) { - return <>; + return null; } return (