auth-react: remove CompatAppProgress since it's no longer needed
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { useApp } from '@backstage/core-plugin-api';
|
||||
import { useVersionedContext } from '@backstage/version-bridge';
|
||||
|
||||
import {
|
||||
coreComponentRefs,
|
||||
useComponentRef,
|
||||
} from '@backstage/frontend-plugin-api';
|
||||
|
||||
function LegacyAppProgress() {
|
||||
const app = useApp();
|
||||
const { Progress } = app.getComponents();
|
||||
return <Progress />;
|
||||
}
|
||||
|
||||
function NewAppProgress() {
|
||||
const Progress = useComponentRef(coreComponentRefs.progress);
|
||||
return <Progress />;
|
||||
}
|
||||
|
||||
export function CompatAppProgress() {
|
||||
const isInNewApp = !useVersionedContext<{ 1: unknown }>('app-context');
|
||||
return isInNewApp ? <NewAppProgress /> : <LegacyAppProgress />;
|
||||
}
|
||||
+5
-4
@@ -16,9 +16,9 @@
|
||||
|
||||
import React, { ReactNode } from 'react';
|
||||
import { ErrorPanel } from '@backstage/core-components';
|
||||
import { Button } from '@material-ui/core';
|
||||
import { useApp } from '@backstage/core-plugin-api';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import { useCookieAuthRefresh } from '../../hooks';
|
||||
import { CompatAppProgress } from './CompatAppProgress';
|
||||
|
||||
/**
|
||||
* @public
|
||||
@@ -41,12 +41,13 @@ export function CookieAuthRefreshProvider(
|
||||
props: CookieAuthRefreshProviderProps,
|
||||
): JSX.Element {
|
||||
const { children, ...options } = props;
|
||||
const app = useApp();
|
||||
const { Progress } = app.getComponents();
|
||||
|
||||
const result = useCookieAuthRefresh(options);
|
||||
|
||||
if (result.status === 'loading') {
|
||||
// This component should be compatible with both old and new frontend systems
|
||||
return <CompatAppProgress />;
|
||||
return <Progress />;
|
||||
}
|
||||
|
||||
if (result.status === 'error') {
|
||||
|
||||
Reference in New Issue
Block a user