Merge pull request #14466 from Bonial-International-GmbH/pjungermann/catalog-graph/preserve-config

feat(catalog-graph): preserve entity graph options + increment max depth
This commit is contained in:
Johan Haals
2022-11-07 14:19:40 +01:00
committed by GitHub
3 changed files with 46 additions and 2 deletions
@@ -116,7 +116,31 @@ describe('<CatalogGraphCard/>', () => {
expect(button).toBeInTheDocument();
expect(button.closest('a')).toHaveAttribute(
'href',
'/catalog-graph?rootEntityRefs%5B%5D=b%3Ad%2Fc',
'/catalog-graph?rootEntityRefs%5B%5D=b%3Ad%2Fc&maxDepth=2&unidirectional=true&mergeRelations=true&direction=LR',
);
});
test('renders link to standalone viewer with custom config', async () => {
const { findByText, getByText } = await renderInTestApp(
<ApiProvider apis={apis}>
<EntityProvider entity={entity}>
<CatalogGraphCard maxDepth={2} mergeRelations={false} />
</EntityProvider>
</ApiProvider>,
{
mountedRoutes: {
'/entity/{kind}/{namespace}/{name}': entityRouteRef,
'/catalog-graph': catalogGraphRouteRef,
},
},
);
expect(await findByText('b:d/c')).toBeInTheDocument();
const button = getByText('View graph');
expect(button).toBeInTheDocument();
expect(button.closest('a')).toHaveAttribute(
'href',
'/catalog-graph?rootEntityRefs%5B%5D=b%3Ad%2Fc&maxDepth=3&unidirectional=true&mergeRelations=false&direction=LR',
);
});
@@ -106,7 +106,15 @@ export const CatalogGraphCard = (props: {
);
const catalogGraphParams = qs.stringify(
{ rootEntityRefs: [stringifyEntityRef(entity)] },
{
rootEntityRefs: [stringifyEntityRef(entity)],
maxDepth: maxDepth + 1,
unidirectional,
mergeRelations,
kinds,
relations,
direction,
},
{ arrayFormat: 'brackets', addQueryPrefix: true },
);
const catalogGraphUrl = `${catalogGraphRoute()}${catalogGraphParams}`;