mirror of
https://github.com/ansible/awx.git
synced 2026-03-17 17:07:33 -02:30
Hide Edit button for non system admin
Hide Edit button for non system admin See: https://github.com/ansible/tower/issues/5032
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
|||||||
} from '../../../../util/dates';
|
} from '../../../../util/dates';
|
||||||
|
|
||||||
function SubscriptionDetail() {
|
function SubscriptionDetail() {
|
||||||
const { license_info, version } = useConfig();
|
const { me = {}, license_info, version } = useConfig();
|
||||||
const baseURL = '/settings/subscription';
|
const baseURL = '/settings/subscription';
|
||||||
const tabsArray = [
|
const tabsArray = [
|
||||||
{
|
{
|
||||||
@@ -164,15 +164,17 @@ function SubscriptionDetail() {
|
|||||||
contact us.
|
contact us.
|
||||||
</Button>
|
</Button>
|
||||||
</Trans>
|
</Trans>
|
||||||
<CardActionsRow>
|
{me.is_superuser && (
|
||||||
<Button
|
<CardActionsRow>
|
||||||
aria-label={t`edit`}
|
<Button
|
||||||
component={Link}
|
aria-label={t`edit`}
|
||||||
to="/settings/subscription/edit"
|
component={Link}
|
||||||
>
|
to="/settings/subscription/edit"
|
||||||
<Trans>Edit</Trans>
|
>
|
||||||
</Button>
|
<Trans>Edit</Trans>
|
||||||
</CardActionsRow>
|
</Button>
|
||||||
|
</CardActionsRow>
|
||||||
|
)}
|
||||||
</CardBody>
|
</CardBody>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -71,6 +71,14 @@ describe('<SubscriptionDetail />', () => {
|
|||||||
assertDetail('Hosts remaining', '1000');
|
assertDetail('Hosts remaining', '1000');
|
||||||
assertDetail('Hosts automated', '12 since 3/2/2021, 7:43:48 PM');
|
assertDetail('Hosts automated', '12 since 3/2/2021, 7:43:48 PM');
|
||||||
|
|
||||||
|
expect(wrapper.find('Button[aria-label="edit"]').length).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render edit button for system admin', () => {
|
||||||
|
wrapper = mountWithContexts(<SubscriptionDetail />, {
|
||||||
|
context: { ...config, me: { is_superuser: true } },
|
||||||
|
});
|
||||||
|
|
||||||
expect(wrapper.find('Button[aria-label="edit"]').length).toBe(1);
|
expect(wrapper.find('Button[aria-label="edit"]').length).toBe(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user