core-components: make useSupportConfig fall back to default config when needed

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-02-05 14:02:16 +01:00
parent bbd59ed355
commit d62bdb7a8e
2 changed files with 9 additions and 3 deletions
+5
View File
@@ -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.
@@ -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;