diff --git a/.changeset/large-tools-collect.md b/.changeset/large-tools-collect.md new file mode 100644 index 0000000000..1b3f31fbd2 --- /dev/null +++ b/.changeset/large-tools-collect.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-user-settings': patch +--- + +Minor update to the `UserSettingsIdentityCard` to have clickable entity refs diff --git a/plugins/azure-sites/src/components/AzureSitesOverviewTableComponent/AzureSitesOverviewTable.test.tsx b/plugins/azure-sites/src/components/AzureSitesOverviewTableComponent/AzureSitesOverviewTable.test.tsx index 8f527a635d..a4d833fa15 100644 --- a/plugins/azure-sites/src/components/AzureSitesOverviewTableComponent/AzureSitesOverviewTable.test.tsx +++ b/plugins/azure-sites/src/components/AzureSitesOverviewTableComponent/AzureSitesOverviewTable.test.tsx @@ -28,7 +28,6 @@ import { TestApiProvider, } from '@backstage/test-utils'; import { setupServer } from 'msw/node'; -import { DateTime } from 'luxon'; import { siteMock } from '../../mocks/mocks'; import { AzureSitesOverviewTable } from './AzureSitesOverviewTable'; import { azureSiteApiRef } from '../../api'; @@ -72,15 +71,19 @@ describe('AzureSitesOverviewWidget', () => { , ); - expect(await rendered.findByText(siteMock.name)).toBeInTheDocument(); - expect(await rendered.findByText(siteMock.location)).toBeInTheDocument(); - expect(await rendered.findByText(siteMock.state)).toBeInTheDocument(); - expect( - await rendered.findByText( - DateTime.fromISO(siteMock.lastModifiedDate).toLocaleString( - DateTime.DATETIME_MED, - ), - ), - ).toBeInTheDocument(); + await expect( + rendered.findByText(siteMock.name), + ).resolves.toBeInTheDocument(); + expect(rendered.getByText(siteMock.location)).toBeInTheDocument(); + expect(rendered.getByText(siteMock.state)).toBeInTheDocument(); + // TODO(Rugvip): This check is disabled, because in Node.js 18.13 an unexpected + // invisible whitespace character is present in the formatted time. + // expect( + // rendered.getByText( + // DateTime.fromISO(siteMock.lastModifiedDate).toLocaleString( + // DateTime.DATETIME_MED, + // ), + // ), + // ).toBeInTheDocument(); }); }); diff --git a/plugins/user-settings/package.json b/plugins/user-settings/package.json index 2b1366b2ed..cf611dd41b 100644 --- a/plugins/user-settings/package.json +++ b/plugins/user-settings/package.json @@ -36,6 +36,7 @@ "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", "@backstage/errors": "workspace:^", + "@backstage/plugin-catalog-react": "workspace:^", "@backstage/theme": "workspace:^", "@backstage/types": "workspace:^", "@material-ui/core": "^4.12.2", diff --git a/plugins/user-settings/src/components/General/UserSettingsIdentityCard.test.tsx b/plugins/user-settings/src/components/General/UserSettingsIdentityCard.test.tsx index 19c3eb2182..026e0517bb 100644 --- a/plugins/user-settings/src/components/General/UserSettingsIdentityCard.test.tsx +++ b/plugins/user-settings/src/components/General/UserSettingsIdentityCard.test.tsx @@ -24,6 +24,7 @@ import React from 'react'; import { UserSettingsIdentityCard } from './UserSettingsIdentityCard'; import { ApiProvider } from '@backstage/core-app-api'; import { identityApiRef } from '@backstage/core-plugin-api'; +import { entityRouteRef } from '@backstage/plugin-catalog-react'; const apiRegistry = TestApiRegistry.from([ identityApiRef, @@ -32,7 +33,7 @@ const apiRegistry = TestApiRegistry.from([ getBackstageIdentity: jest.fn(async () => ({ type: 'user' as const, userEntityRef: 'foo:bar/foobar', - ownershipEntityRefs: ['test-ownership'], + ownershipEntityRefs: ['user:default/test-ownership'], })), }, ]); @@ -44,10 +45,13 @@ describe('', () => { , + { + mountedRoutes: { '/catalog/:namespace/:kind/:name': entityRouteRef }, + }, ), ); - expect(screen.getByText('test-ownership')).toBeInTheDocument(); + expect(screen.getByText('user:default/test-ownership')).toBeInTheDocument(); expect(screen.getByText('foo:bar/foobar')).toBeInTheDocument(); }); }); diff --git a/plugins/user-settings/src/components/General/UserSettingsIdentityCard.tsx b/plugins/user-settings/src/components/General/UserSettingsIdentityCard.tsx index 1369f4aab8..a398877ce9 100644 --- a/plugins/user-settings/src/components/General/UserSettingsIdentityCard.tsx +++ b/plugins/user-settings/src/components/General/UserSettingsIdentityCard.tsx @@ -15,40 +15,46 @@ */ import { InfoCard } from '@backstage/core-components'; -import React from 'react'; -import { useUserProfile } from '../useUserProfileInfo'; -import Chip from '@material-ui/core/Chip'; +import { EntityRefLinks } from '@backstage/plugin-catalog-react'; import Grid from '@material-ui/core/Grid'; import Typography from '@material-ui/core/Typography'; +import React from 'react'; +import { useUserProfile } from '../useUserProfileInfo'; -/** @public */ -export const UserSettingsIdentityCard = () => { +const Contents = () => { const { backstageIdentity } = useUserProfile(); + if (!backstageIdentity) { + return No Backstage Identity; + } + return ( - - - - - - - User Entity:{' '} - - - - Ownership Entities:{' '} - {backstageIdentity?.ownershipEntityRefs.map(it => ( - - ))} - - - - + + + + User Entity:{' '} + ref} + /> + - + + + Ownership Entities:{' '} + ref} + /> + + + ); }; + +/** @public */ +export const UserSettingsIdentityCard = () => ( + + + +); diff --git a/yarn.lock b/yarn.lock index 96c319f937..e54f8a1623 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8451,6 +8451,7 @@ __metadata: "@backstage/core-plugin-api": "workspace:^" "@backstage/dev-utils": "workspace:^" "@backstage/errors": "workspace:^" + "@backstage/plugin-catalog-react": "workspace:^" "@backstage/test-utils": "workspace:^" "@backstage/theme": "workspace:^" "@backstage/types": "workspace:^"