org: update cards to grab entity from context
This commit is contained in:
@@ -21,7 +21,7 @@ import {
|
||||
RELATION_PARENT_OF,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Avatar, InfoCard } from '@backstage/core';
|
||||
import { entityRouteParams } from '@backstage/plugin-catalog-react';
|
||||
import { useEntity, entityRouteParams } from '@backstage/plugin-catalog-react';
|
||||
import { Box, Grid, Link, Tooltip, Typography } from '@material-ui/core';
|
||||
import AccountTreeIcon from '@material-ui/icons/AccountTree';
|
||||
import EmailIcon from '@material-ui/icons/Email';
|
||||
@@ -33,26 +33,29 @@ import { generatePath, Link as RouterLink } from 'react-router-dom';
|
||||
const GroupLink = ({
|
||||
groupName,
|
||||
index = 0,
|
||||
entity,
|
||||
}: {
|
||||
groupName: string;
|
||||
index?: number;
|
||||
entity: Entity;
|
||||
}) => (
|
||||
<>
|
||||
{index >= 1 ? ', ' : ''}
|
||||
<Link
|
||||
component={RouterLink}
|
||||
to={generatePath(
|
||||
`/catalog/:namespace/group/${groupName}`,
|
||||
entityRouteParams(entity),
|
||||
)}
|
||||
>
|
||||
[{groupName}]
|
||||
</Link>
|
||||
</>
|
||||
);
|
||||
/** @deprecated The entity is now grabbed from context instead */
|
||||
entity?: Entity;
|
||||
}) => {
|
||||
const { entity } = useEntity();
|
||||
|
||||
return (
|
||||
<>
|
||||
{index >= 1 ? ', ' : ''}
|
||||
<Link
|
||||
component={RouterLink}
|
||||
to={generatePath(
|
||||
`/catalog/:namespace/group/${groupName}`,
|
||||
entityRouteParams(entity),
|
||||
)}
|
||||
>
|
||||
[{groupName}]
|
||||
</Link>
|
||||
</>
|
||||
);
|
||||
};
|
||||
const CardTitle = ({ title }: { title: string }) => (
|
||||
<Box display="flex" alignItems="center">
|
||||
<GroupIcon fontSize="inherit" />
|
||||
@@ -61,12 +64,13 @@ const CardTitle = ({ title }: { title: string }) => (
|
||||
);
|
||||
|
||||
export const GroupProfileCard = ({
|
||||
entity: group,
|
||||
variant,
|
||||
}: {
|
||||
entity: GroupEntity;
|
||||
/** @deprecated The entity is now grabbed from context instead */
|
||||
entity?: GroupEntity;
|
||||
variant: string;
|
||||
}) => {
|
||||
const group = useEntity().entity as GroupEntity;
|
||||
const {
|
||||
metadata: { name, description },
|
||||
spec: { profile },
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from '@backstage/catalog-model';
|
||||
import { Avatar, InfoCard, Progress, useApi } from '@backstage/core';
|
||||
import {
|
||||
useEntity,
|
||||
catalogApiRef,
|
||||
entityRouteParams,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
@@ -105,11 +106,11 @@ const MemberComponent = ({
|
||||
);
|
||||
};
|
||||
|
||||
export const MembersListCard = ({
|
||||
entity: groupEntity,
|
||||
}: {
|
||||
entity: GroupEntity;
|
||||
export const MembersListCard = (_props: {
|
||||
/** @deprecated The entity is now grabbed from context instead */
|
||||
entity?: GroupEntity;
|
||||
}) => {
|
||||
const groupEntity = useEntity().entity as GroupEntity;
|
||||
const {
|
||||
metadata: { name: groupName },
|
||||
spec: { profile },
|
||||
|
||||
@@ -16,7 +16,11 @@
|
||||
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { InfoCard, Progress, useApi } from '@backstage/core';
|
||||
import { catalogApiRef, isOwnerOf } from '@backstage/plugin-catalog-react';
|
||||
import {
|
||||
catalogApiRef,
|
||||
isOwnerOf,
|
||||
useEntity,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { pageTheme } from '@backstage/theme';
|
||||
import {
|
||||
Box,
|
||||
@@ -113,12 +117,13 @@ const EntityCountTile = ({
|
||||
};
|
||||
|
||||
export const OwnershipCard = ({
|
||||
entity,
|
||||
variant,
|
||||
}: {
|
||||
entity: Entity;
|
||||
/** @deprecated The entity is now grabbed from context instead */
|
||||
entity?: Entity;
|
||||
variant: string;
|
||||
}) => {
|
||||
const { entity } = useEntity();
|
||||
const catalogApi = useApi(catalogApiRef);
|
||||
const {
|
||||
loading,
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
UserEntity,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Avatar, InfoCard } from '@backstage/core';
|
||||
import { entityRouteParams } from '@backstage/plugin-catalog-react';
|
||||
import { useEntity, entityRouteParams } from '@backstage/plugin-catalog-react';
|
||||
import { Box, Grid, Link, Tooltip, Typography } from '@material-ui/core';
|
||||
import EmailIcon from '@material-ui/icons/Email';
|
||||
import GroupIcon from '@material-ui/icons/Group';
|
||||
@@ -60,12 +60,13 @@ const CardTitle = ({ title }: { title?: string }) =>
|
||||
) : null;
|
||||
|
||||
export const UserProfileCard = ({
|
||||
entity: user,
|
||||
variant,
|
||||
}: {
|
||||
entity: UserEntity;
|
||||
/** @deprecated The entity is now grabbed from context instead */
|
||||
entity?: UserEntity;
|
||||
variant: string;
|
||||
}) => {
|
||||
const user = useEntity().entity as UserEntity;
|
||||
const {
|
||||
metadata: { name: metaName },
|
||||
spec: { profile },
|
||||
|
||||
Reference in New Issue
Block a user