Change so edit icon is not visible by default

Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com>
This commit is contained in:
Andre Wanlin
2022-08-17 12:54:02 -05:00
parent ab6650ede9
commit 8d8bde24f6
2 changed files with 18 additions and 20 deletions
@@ -75,7 +75,7 @@ describe('UserSummary Test', () => {
});
describe('Edit Button', () => {
it('Should default to disabled', async () => {
it('Should not be present by default', async () => {
const userEntity: UserEntity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'User',
@@ -111,10 +111,10 @@ describe('Edit Button', () => {
),
);
expect(rendered.getByRole('button')).toBeDisabled();
expect(rendered.queryByTitle('Edit Metadata')).not.toBeInTheDocument();
});
it('Should be enabled when edit URL annotation is present', async () => {
it('Should be visible when edit URL annotation is present', async () => {
const annotations: Record<string, string> = {
'backstage.io/edit-url': 'https://example.com/user.yaml',
};
@@ -153,6 +153,6 @@ describe('Edit Button', () => {
},
),
);
expect(rendered.getByRole('button')).toBeEnabled();
expect(rendered.getByRole('button')).toBeInTheDocument();
});
});
@@ -75,27 +75,25 @@ export const UserProfileCard = (props: { variant?: InfoCardVariants }) => {
kind: 'Group',
});
const infoCardAction = entityMetadataEditUrl ? (
<IconButton
aria-label="Edit"
title="Edit Metadata"
component={Link}
to={entityMetadataEditUrl}
>
<EditIcon />
</IconButton>
) : (
<IconButton aria-label="Edit" disabled title="Edit Metadata">
<EditIcon />
</IconButton>
);
return (
<InfoCard
title={<CardTitle title={displayName} />}
subheader={description}
variant={props.variant}
action={infoCardAction}
action={
<>
{entityMetadataEditUrl && (
<IconButton
aria-label="Edit"
title="Edit Metadata"
component={Link}
to={entityMetadataEditUrl}
>
<EditIcon />
</IconButton>
)}
</>
}
>
<Grid container spacing={3} alignItems="flex-start">
<Grid item xs={12} sm={2} xl={1}>