Merge branch 'master' of github.com:backstage/backstage into update-org-cards

This commit is contained in:
Adam Harvey
2021-02-08 13:45:55 -05:00
118 changed files with 2385 additions and 333 deletions
@@ -24,6 +24,7 @@ import { Avatar, InfoCard } from '@backstage/core';
import {
getEntityRelations,
entityRouteParams,
useEntity,
} from '@backstage/plugin-catalog-react';
import {
Box,
@@ -45,26 +46,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" />
@@ -73,12 +77,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 },
@@ -16,7 +16,11 @@
import { Entity, GroupEntity } from '@backstage/catalog-model';
import { ApiProvider, ApiRegistry } from '@backstage/core';
import { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog-react';
import {
CatalogApi,
catalogApiRef,
EntityProvider,
} from '@backstage/plugin-catalog-react';
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
import React from 'react';
import { MembersListCard } from './MembersListCard';
@@ -78,7 +82,10 @@ describe('MemberTab Test', () => {
const rendered = await renderWithEffects(
wrapInTestApp(
<ApiProvider apis={apis}>
<MembersListCard entity={groupEntity} />
<EntityProvider entity={groupEntity}>
<MembersListCard />
</EntityProvider>
,
</ApiProvider>,
),
);
@@ -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,
@@ -15,6 +15,7 @@
*/
import { UserEntity } from '@backstage/catalog-model';
import { EntityProvider } from '@backstage/plugin-catalog-react';
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
import React from 'react';
import { UserProfileCard } from './UserProfileCard';
@@ -48,7 +49,11 @@ describe('UserSummary Test', () => {
it('Display Profile Card', async () => {
const rendered = await renderWithEffects(
wrapInTestApp(<UserProfileCard entity={userEntity} variant="gridItem" />),
wrapInTestApp(
<EntityProvider entity={userEntity}>
<UserProfileCard entity={userEntity} variant="gridItem" />
</EntityProvider>,
),
);
expect(rendered.getByText('calum-leavy@example.com')).toBeInTheDocument();
@@ -19,7 +19,7 @@ import {
UserEntity,
} from '@backstage/catalog-model';
import { Avatar, InfoCard } from '@backstage/core';
import { entityRouteParams } from '@backstage/plugin-catalog-react';
import { entityRouteParams, useEntity } from '@backstage/plugin-catalog-react';
import {
Box,
Grid,
@@ -69,12 +69,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 },