From d62bdb7a8e444d7a250e14b6b3c6cbe6882f2c45 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 5 Feb 2022 14:02:16 +0100 Subject: [PATCH] core-components: make useSupportConfig fall back to default config when needed Signed-off-by: Patrik Oldsberg --- .changeset/three-pigs-sniff.md | 5 +++++ packages/core-components/src/hooks/useSupportConfig.ts | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/three-pigs-sniff.md diff --git a/.changeset/three-pigs-sniff.md b/.changeset/three-pigs-sniff.md new file mode 100644 index 0000000000..c2020c9e80 --- /dev/null +++ b/.changeset/three-pigs-sniff.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-components': patch +--- + +The `ErrorPage` now falls back to using the default support configuration if the `ConfigApi` is not available. diff --git a/packages/core-components/src/hooks/useSupportConfig.ts b/packages/core-components/src/hooks/useSupportConfig.ts index 5d64e38f3d..546d779e01 100644 --- a/packages/core-components/src/hooks/useSupportConfig.ts +++ b/packages/core-components/src/hooks/useSupportConfig.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { useApi, configApiRef } from '@backstage/core-plugin-api'; +import { useApiHolder, configApiRef } from '@backstage/core-plugin-api'; export type SupportItemLink = { url: string; @@ -50,8 +50,9 @@ const DEFAULT_SUPPORT_CONFIG: SupportConfig = { }; export function useSupportConfig(): SupportConfig { - const config = useApi(configApiRef); - const supportConfig = config.getOptionalConfig('app.support'); + const apiHolder = useApiHolder(); + const config = apiHolder.get(configApiRef); + const supportConfig = config?.getOptionalConfig('app.support'); if (!supportConfig) { return DEFAULT_SUPPORT_CONFIG;