catalog: Use route ref for navigation
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ApiProvider, ApiRegistry } from '@backstage/core';
|
||||
import { ApiProvider, ApiRegistry, createRouteRef } from '@backstage/core';
|
||||
|
||||
import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
catalogRouteRef,
|
||||
EntityProvider,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
@@ -54,6 +55,11 @@ describe('<EntityOrphanWarning />', () => {
|
||||
<EntityOrphanWarning />
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/create': catalogRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(
|
||||
getByText(
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { useRouteRef } from '@backstage/core';
|
||||
import { catalogRouteRef, useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { Alert } from '@material-ui/lab';
|
||||
import React, { useState } from 'react';
|
||||
import { useNavigate } from 'react-router';
|
||||
@@ -29,12 +30,13 @@ export const isOrphan = (entity: Entity) =>
|
||||
*/
|
||||
export const EntityOrphanWarning = () => {
|
||||
const navigate = useNavigate();
|
||||
const catalogLink = useRouteRef(catalogRouteRef);
|
||||
const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false);
|
||||
const { entity } = useEntity();
|
||||
|
||||
const cleanUpAfterRemoval = async () => {
|
||||
setConfirmationDialogOpen(false);
|
||||
navigate('/');
|
||||
navigate(catalogLink());
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user