diff --git a/.changeset/quick-horses-cry.md b/.changeset/quick-horses-cry.md index 58708d63b2..8b40c92b41 100644 --- a/.changeset/quick-horses-cry.md +++ b/.changeset/quick-horses-cry.md @@ -2,4 +2,4 @@ '@backstage/plugin-org': patch --- -Small change to allow disabling of links in the user and group profile cards +Update `UserProfileCard` and `GroupProfileCard` to not render links unless the `showLinks` prop is set. The primary component for rendering links are the `EntityLinksCard` from plugin-catalog. diff --git a/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx index c138c73735..5e795b2710 100644 --- a/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx +++ b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.tsx @@ -65,7 +65,7 @@ const CardTitle = (props: { title: string }) => ( /** @public */ export const GroupProfileCard = (props: { variant?: InfoCardVariants; - hideLinks?: boolean; + showLinks?: boolean; }) => { const catalogApi = useApi(catalogApiRef); const alertApi = useApi(alertApiRef); @@ -195,7 +195,7 @@ export const GroupProfileCard = (props: { secondary="Child Groups" /> - {!props?.hideLinks && } + {props?.showLinks && } diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx index 449b66b96d..547c636d22 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.test.tsx @@ -156,7 +156,7 @@ describe('Edit Button', () => { expect(rendered.getByRole('button')).toBeInTheDocument(); }); - it('Should show the extra fields if either links', async () => { + it('Should not show links by default', async () => { const annotations: Record = { 'backstage.io/edit-url': 'https://example.com/user.yaml', }; @@ -206,11 +206,11 @@ describe('Edit Button', () => { }, ), ); - expect(rendered.getByText('Slack')).toBeInTheDocument(); - expect(rendered.getByText('Google')).toBeInTheDocument(); + expect(rendered.queryByText('Slack')).toBeNull(); + expect(rendered.queryByText('Google')).toBeNull(); }); - it('Should hide the links if hidelinks', async () => { + it('Should show the links if showLinks is set', async () => { const annotations: Record = { 'backstage.io/edit-url': 'https://example.com/user.yaml', }; @@ -251,7 +251,7 @@ describe('Edit Button', () => { const rendered = await renderWithEffects( wrapInTestApp( - + , { mountedRoutes: { @@ -260,7 +260,7 @@ describe('Edit Button', () => { }, ), ); - expect(rendered.queryByText('Slack')).toBeNull(); - expect(rendered.queryByText('Google')).toBeNull(); + expect(rendered.getByText('Slack')).toBeInTheDocument(); + expect(rendered.getByText('Google')).toBeInTheDocument(); }); }); diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx index 2421d609d4..a45658b3a6 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.tsx @@ -60,7 +60,7 @@ const CardTitle = (props: { title?: string }) => /** @public */ export const UserProfileCard = (props: { variant?: InfoCardVariants; - hideLinks?: boolean; + showLinks?: boolean; }) => { const { entity: user } = useEntity(); if (!user) { @@ -134,7 +134,7 @@ export const UserProfileCard = (props: { - {!props?.hideLinks && } + {props?.showLinks && }