[OwnershipCard] Add type as subtitle + adjust query params
Signed-off-by: Pascal Lukanek <pascal.lukanek@live.de>
This commit is contained in:
@@ -56,11 +56,13 @@ const useStyles = makeStyles((theme: BackstageTheme) =>
|
||||
const EntityCountTile = ({
|
||||
counter,
|
||||
type,
|
||||
kind,
|
||||
name,
|
||||
url,
|
||||
}: {
|
||||
counter: number;
|
||||
type: string;
|
||||
kind: string;
|
||||
name: string;
|
||||
url: string;
|
||||
}) => {
|
||||
@@ -80,6 +82,7 @@ const EntityCountTile = ({
|
||||
<Typography className={classes.bold} variant="h6">
|
||||
{pluralize(name, counter)}
|
||||
</Typography>
|
||||
{kind != type && <Typography variant="subtitle1">{kind}</Typography>}
|
||||
</Box>
|
||||
</Link>
|
||||
);
|
||||
@@ -116,6 +119,7 @@ export const ComponentsGrid = ({
|
||||
<Grid item xs={6} md={6} lg={4} key={c.name}>
|
||||
<EntityCountTile
|
||||
counter={c.counter}
|
||||
kind={c.kind}
|
||||
type={c.type}
|
||||
name={c.name}
|
||||
url={`${catalogLink()}/?${c.queryParams}`}
|
||||
|
||||
@@ -217,10 +217,16 @@ describe('OwnershipCard', () => {
|
||||
expect(
|
||||
queryByText(getByText('SYSTEM').parentElement!, '1'),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
queryByText(getByText('SYSTEM').parentElement!, 'System'),
|
||||
).not.toBeInTheDocument();
|
||||
expect(getByText('OPENAPI')).toBeInTheDocument();
|
||||
expect(
|
||||
queryByText(getByText('OPENAPI').parentElement!, '1'),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
queryByText(getByText('OPENAPI').parentElement!, 'API'),
|
||||
).toBeInTheDocument();
|
||||
expect(() => getByText('LIBRARY')).toThrow();
|
||||
});
|
||||
|
||||
@@ -246,7 +252,7 @@ describe('OwnershipCard', () => {
|
||||
|
||||
expect(getByText('OPENAPI').closest('a')).toHaveAttribute(
|
||||
'href',
|
||||
'/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D=my-team&filters%5Buser%5D=all',
|
||||
'/create/?filters%5Bkind%5D=api&filters%5Btype%5D=openapi&filters%5Bowners%5D=my-team&filters%5Buser%5D=all',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -292,7 +298,7 @@ describe('OwnershipCard', () => {
|
||||
|
||||
expect(getByText('OPENAPI').closest('a')).toHaveAttribute(
|
||||
'href',
|
||||
'/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D=user%3Athe-user&filters%5Bowners%5D=my-team&filters%5Bowners%5D=custom%2Fsome-team&filters%5Buser%5D=all',
|
||||
'/create/?filters%5Bkind%5D=api&filters%5Btype%5D=openapi&filters%5Bowners%5D=user%3Athe-user&filters%5Bowners%5D=my-team&filters%5Bowners%5D=custom%2Fsome-team&filters%5Buser%5D=all',
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ const getQueryParams = (
|
||||
humanizeEntityRef(parseEntityRef(owner), { defaultKind: 'group' }),
|
||||
);
|
||||
const filters = {
|
||||
kind,
|
||||
kind: kind.toLowerCase(),
|
||||
type,
|
||||
owners,
|
||||
user: 'all',
|
||||
@@ -135,6 +135,7 @@ export function useGetEntities(
|
||||
| {
|
||||
counter: number;
|
||||
type: string;
|
||||
kind: string;
|
||||
name: string;
|
||||
queryParams: string;
|
||||
}[]
|
||||
@@ -197,11 +198,13 @@ export function useGetEntities(
|
||||
return topN.map(topOwnedEntity => ({
|
||||
counter: topOwnedEntity.count,
|
||||
type: topOwnedEntity.type,
|
||||
kind: topOwnedEntity.kind,
|
||||
name: topOwnedEntity.type.toLocaleUpperCase('en-US'),
|
||||
queryParams: getQueryParams(owners, topOwnedEntity),
|
||||
})) as Array<{
|
||||
counter: number;
|
||||
type: string;
|
||||
kind: string;
|
||||
name: string;
|
||||
queryParams: string;
|
||||
}>;
|
||||
|
||||
Reference in New Issue
Block a user