mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
Merge pull request #9589 from nixocio/ui_issue_9250
Do not allow user to modify EE managed by tower Do not allow user to attempt to modify EE managed by tower. See: #9250 Reviewed-by: Ryan Petrello <None> Reviewed-by: Jake McDermott <yo@jakemcdermott.me> Reviewed-by: Tiago Góes <tiago.goes2009@gmail.com>
This commit is contained in:
commit
31124e07c6
@ -26,6 +26,7 @@ function ExecutionEnvironmentDetails({ executionEnvironment, i18n }) {
|
||||
pull,
|
||||
organization,
|
||||
summary_fields,
|
||||
managed_by_tower: managedByTower,
|
||||
} = executionEnvironment;
|
||||
|
||||
const {
|
||||
@ -103,25 +104,27 @@ function ExecutionEnvironmentDetails({ executionEnvironment, i18n }) {
|
||||
dataCy="execution-environment-modified"
|
||||
/>
|
||||
</DetailList>
|
||||
<CardActionsRow>
|
||||
<Button
|
||||
aria-label={i18n._(t`edit`)}
|
||||
component={Link}
|
||||
to={`/execution_environments/${id}/edit`}
|
||||
ouiaId="edit-button"
|
||||
>
|
||||
{i18n._(t`Edit`)}
|
||||
</Button>
|
||||
<DeleteButton
|
||||
name={image}
|
||||
modalTitle={i18n._(t`Delete Execution Environment`)}
|
||||
onConfirm={deleteExecutionEnvironment}
|
||||
isDisabled={isLoading}
|
||||
ouiaId="delete-button"
|
||||
>
|
||||
{i18n._(t`Delete`)}
|
||||
</DeleteButton>
|
||||
</CardActionsRow>
|
||||
{!managedByTower && (
|
||||
<CardActionsRow>
|
||||
<Button
|
||||
aria-label={i18n._(t`edit`)}
|
||||
component={Link}
|
||||
to={`/execution_environments/${id}/edit`}
|
||||
ouiaId="edit-button"
|
||||
>
|
||||
{i18n._(t`Edit`)}
|
||||
</Button>
|
||||
<DeleteButton
|
||||
name={image}
|
||||
modalTitle={i18n._(t`Delete Execution Environment`)}
|
||||
onConfirm={deleteExecutionEnvironment}
|
||||
isDisabled={isLoading}
|
||||
ouiaId="delete-button"
|
||||
>
|
||||
{i18n._(t`Delete`)}
|
||||
</DeleteButton>
|
||||
</CardActionsRow>
|
||||
)}
|
||||
|
||||
{error && (
|
||||
<AlertModal
|
||||
|
||||
@ -77,6 +77,12 @@ describe('<ExecutionEnvironmentDetails/>', () => {
|
||||
expect(dates).toHaveLength(2);
|
||||
expect(dates.at(0).prop('date')).toEqual(executionEnvironment.created);
|
||||
expect(dates.at(1).prop('date')).toEqual(executionEnvironment.modified);
|
||||
const editButton = wrapper.find('Button[aria-label="edit"]');
|
||||
expect(editButton.text()).toEqual('Edit');
|
||||
expect(editButton.prop('to')).toBe('/execution_environments/17/edit');
|
||||
|
||||
const deleteButton = wrapper.find('Button[aria-label="Delete"]');
|
||||
expect(deleteButton.text()).toEqual('Delete');
|
||||
});
|
||||
|
||||
test('should render organization detail', async () => {
|
||||
@ -135,4 +141,38 @@ describe('<ExecutionEnvironmentDetails/>', () => {
|
||||
expect(ExecutionEnvironmentsAPI.destroy).toHaveBeenCalledTimes(1);
|
||||
expect(history.location.pathname).toBe('/execution_environments');
|
||||
});
|
||||
|
||||
test('should not render action buttons to ee managed by tower', async () => {
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
<ExecutionEnvironmentDetails
|
||||
executionEnvironment={{
|
||||
...executionEnvironment,
|
||||
managed_by_tower: true,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
});
|
||||
wrapper.update();
|
||||
|
||||
expect(wrapper.find('Detail[label="Image"]').prop('value')).toEqual(
|
||||
executionEnvironment.image
|
||||
);
|
||||
expect(wrapper.find('Detail[label="Description"]').prop('value')).toEqual(
|
||||
'Foo'
|
||||
);
|
||||
expect(wrapper.find('Detail[label="Organization"]').prop('value')).toEqual(
|
||||
'Globally Available'
|
||||
);
|
||||
expect(
|
||||
wrapper.find('Detail[label="Credential"]').prop('value').props.children
|
||||
).toEqual(executionEnvironment.summary_fields.credential.name);
|
||||
const dates = wrapper.find('UserDateDetail');
|
||||
expect(dates).toHaveLength(2);
|
||||
expect(dates.at(0).prop('date')).toEqual(executionEnvironment.created);
|
||||
expect(dates.at(1).prop('date')).toEqual(executionEnvironment.modified);
|
||||
expect(wrapper.find('Button[aria-label="edit"]')).toHaveLength(0);
|
||||
|
||||
expect(wrapper.find('Button[aria-label="Delete"]')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
@ -23,6 +23,7 @@ describe('<ExecutionEnvironmentListItem/>', () => {
|
||||
summary_fields: {
|
||||
user_capabilities: { edit: true, copy: true, delete: true },
|
||||
},
|
||||
managed_by_tower: false,
|
||||
};
|
||||
|
||||
test('should mount successfully', async () => {
|
||||
@ -144,4 +145,46 @@ describe('<ExecutionEnvironmentListItem/>', () => {
|
||||
);
|
||||
expect(wrapper.find('CopyButton').length).toBe(0);
|
||||
});
|
||||
|
||||
test('should not render the pencil action for ee managed by tower', async () => {
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
<table>
|
||||
<tbody>
|
||||
<ExecutionEnvironmentListItem
|
||||
executionEnvironment={{
|
||||
...executionEnvironment,
|
||||
summary_fields: { user_capabilities: { edit: false } },
|
||||
managed_by_tower: true,
|
||||
}}
|
||||
detailUrl="execution_environments/1/details"
|
||||
isSelected={false}
|
||||
onSelect={() => {}}
|
||||
/>
|
||||
</tbody>
|
||||
</table>
|
||||
);
|
||||
});
|
||||
expect(
|
||||
wrapper
|
||||
.find('Td')
|
||||
.at(1)
|
||||
.text()
|
||||
).toBe(executionEnvironment.name);
|
||||
expect(
|
||||
wrapper
|
||||
.find('Td')
|
||||
.at(2)
|
||||
.text()
|
||||
).toBe(executionEnvironment.image);
|
||||
|
||||
expect(
|
||||
wrapper
|
||||
.find('Td')
|
||||
.at(3)
|
||||
.text()
|
||||
).toBe('Globally Available');
|
||||
|
||||
expect(wrapper.find('PencilAltIcon').exists()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user