Skip to content

Commit

Permalink
core-components: make useSupportConfig fall back to default config wh…
Browse files Browse the repository at this point in the history
…en needed

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
  • Loading branch information
Rugvip committed Feb 5, 2022
1 parent bbd59ed commit d62bdb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .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.
7 changes: 4 additions & 3 deletions packages/core-components/src/hooks/useSupportConfig.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d62bdb7

Please sign in to comment.