mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Merge pull request #8657 from mabashian/7816-user-role-empty-name
Display 'System' for user role resource name when summary_fields.resource_name not present Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
983d377a93
@ -18,12 +18,16 @@ function UserRolesListItem({ role, i18n, detailUrl, onSelect }) {
|
||||
<DataListItemRow>
|
||||
<DataListItemCells
|
||||
dataListCells={[
|
||||
<DataListCell key="name" aria-label={i18n._(t`resource name`)}>
|
||||
<Link to={`${detailUrl}`} id={labelId}>
|
||||
<b>{role.summary_fields.resource_name}</b>
|
||||
</Link>
|
||||
<DataListCell key="name" aria-label={i18n._(t`Resource name`)}>
|
||||
{role.summary_fields.resource_name ? (
|
||||
<Link to={`${detailUrl}`} id={labelId}>
|
||||
<b>{role.summary_fields.resource_name}</b>
|
||||
</Link>
|
||||
) : (
|
||||
<b>{i18n._(t`System`)}</b>
|
||||
)}
|
||||
</DataListCell>,
|
||||
<DataListCell key="type" aria-label={i18n._(t`resource type`)}>
|
||||
<DataListCell key="type" aria-label={i18n._(t`Resource type`)}>
|
||||
{role.summary_fields && (
|
||||
<DetailList stacked>
|
||||
<Detail
|
||||
@ -33,7 +37,7 @@ function UserRolesListItem({ role, i18n, detailUrl, onSelect }) {
|
||||
</DetailList>
|
||||
)}
|
||||
</DataListCell>,
|
||||
<DataListCell key="role" aria-label={i18n._(t`resource role`)}>
|
||||
<DataListCell key="role" aria-label={i18n._(t`Resource role`)}>
|
||||
{role.name && (
|
||||
<DetailList stacked>
|
||||
<Detail
|
||||
|
||||
@ -35,13 +35,13 @@ describe('<UserRolesListItem/>', () => {
|
||||
/>
|
||||
);
|
||||
expect(
|
||||
wrapper.find('PFDataListCell[aria-label="resource name"]').text()
|
||||
wrapper.find('PFDataListCell[aria-label="Resource name"]').text()
|
||||
).toBe('template delete project');
|
||||
expect(
|
||||
wrapper.find('PFDataListCell[aria-label="resource type"]').text()
|
||||
wrapper.find('PFDataListCell[aria-label="Resource type"]').text()
|
||||
).toContain('Job Template');
|
||||
expect(
|
||||
wrapper.find('PFDataListCell[aria-label="resource role"]').text()
|
||||
wrapper.find('PFDataListCell[aria-label="Resource role"]').text()
|
||||
).toContain('Admin');
|
||||
});
|
||||
test('should render deletable chip', () => {
|
||||
@ -63,4 +63,19 @@ describe('<UserRolesListItem/>', () => {
|
||||
);
|
||||
expect(wrapper.find('Chip').prop('isReadOnly')).toBe(true);
|
||||
});
|
||||
test('should display System as name when no resource_name is present in summary_fields', () => {
|
||||
wrapper = mountWithContexts(
|
||||
<UserRolesListItem
|
||||
role={{
|
||||
...role,
|
||||
summary_fields: {
|
||||
user_capabilities: { unattach: false },
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
expect(
|
||||
wrapper.find('PFDataListCell[aria-label="Resource name"]').text()
|
||||
).toBe('System');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user