mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 17:28:51 -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:
@@ -18,12 +18,16 @@ function UserRolesListItem({ role, i18n, detailUrl, onSelect }) {
|
|||||||
<DataListItemRow>
|
<DataListItemRow>
|
||||||
<DataListItemCells
|
<DataListItemCells
|
||||||
dataListCells={[
|
dataListCells={[
|
||||||
<DataListCell key="name" aria-label={i18n._(t`resource name`)}>
|
<DataListCell key="name" aria-label={i18n._(t`Resource name`)}>
|
||||||
<Link to={`${detailUrl}`} id={labelId}>
|
{role.summary_fields.resource_name ? (
|
||||||
<b>{role.summary_fields.resource_name}</b>
|
<Link to={`${detailUrl}`} id={labelId}>
|
||||||
</Link>
|
<b>{role.summary_fields.resource_name}</b>
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<b>{i18n._(t`System`)}</b>
|
||||||
|
)}
|
||||||
</DataListCell>,
|
</DataListCell>,
|
||||||
<DataListCell key="type" aria-label={i18n._(t`resource type`)}>
|
<DataListCell key="type" aria-label={i18n._(t`Resource type`)}>
|
||||||
{role.summary_fields && (
|
{role.summary_fields && (
|
||||||
<DetailList stacked>
|
<DetailList stacked>
|
||||||
<Detail
|
<Detail
|
||||||
@@ -33,7 +37,7 @@ function UserRolesListItem({ role, i18n, detailUrl, onSelect }) {
|
|||||||
</DetailList>
|
</DetailList>
|
||||||
)}
|
)}
|
||||||
</DataListCell>,
|
</DataListCell>,
|
||||||
<DataListCell key="role" aria-label={i18n._(t`resource role`)}>
|
<DataListCell key="role" aria-label={i18n._(t`Resource role`)}>
|
||||||
{role.name && (
|
{role.name && (
|
||||||
<DetailList stacked>
|
<DetailList stacked>
|
||||||
<Detail
|
<Detail
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ describe('<UserRolesListItem/>', () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('PFDataListCell[aria-label="resource name"]').text()
|
wrapper.find('PFDataListCell[aria-label="Resource name"]').text()
|
||||||
).toBe('template delete project');
|
).toBe('template delete project');
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('PFDataListCell[aria-label="resource type"]').text()
|
wrapper.find('PFDataListCell[aria-label="Resource type"]').text()
|
||||||
).toContain('Job Template');
|
).toContain('Job Template');
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('PFDataListCell[aria-label="resource role"]').text()
|
wrapper.find('PFDataListCell[aria-label="Resource role"]').text()
|
||||||
).toContain('Admin');
|
).toContain('Admin');
|
||||||
});
|
});
|
||||||
test('should render deletable chip', () => {
|
test('should render deletable chip', () => {
|
||||||
@@ -63,4 +63,19 @@ describe('<UserRolesListItem/>', () => {
|
|||||||
);
|
);
|
||||||
expect(wrapper.find('Chip').prop('isReadOnly')).toBe(true);
|
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');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user