mirror of
https://github.com/ansible/awx.git
synced 2026-01-20 22:18:01 -03:30
Address PR feedback.
This commit is contained in:
parent
21156d1409
commit
0495214f47
@ -114,7 +114,6 @@ describe('<AccessList />', () => {
|
||||
});
|
||||
|
||||
test('getTeamRoles returns empty array if dataset is missing team_id attribute', (done) => {
|
||||
|
||||
const wrapper = mount(
|
||||
<I18nProvider>
|
||||
<MemoryRouter>
|
||||
@ -140,7 +139,7 @@ describe('<AccessList />', () => {
|
||||
test('test handleWarning, confirmDelete, and removeRole methods for Alert component', (done) => {
|
||||
const handleWarning = jest.spyOn(AccessList.prototype, 'handleWarning');
|
||||
const confirmDelete = jest.spyOn(AccessList.prototype, 'confirmDelete');
|
||||
const removeRole = jest.spyOn(AccessList.prototype, 'removeRole');
|
||||
const removeRole = jest.spyOn(AccessList.prototype, 'removeAccessRole');
|
||||
const wrapper = mount(
|
||||
<I18nProvider>
|
||||
<MemoryRouter>
|
||||
@ -182,19 +181,13 @@ describe('<AccessList />', () => {
|
||||
</MemoryRouter>
|
||||
</I18nProvider>
|
||||
).find('AccessList');
|
||||
|
||||
expect(wrapper.state().warningMsg).not.toBeDefined;
|
||||
expect(wrapper.state().warningTitle).not.toBeDefined;
|
||||
expect(wrapper.state().deleteType).not.toBeDefined;
|
||||
expect(wrapper.state().deleteRoleId).not.toBeDefined;
|
||||
expect(wrapper.state().deleteResourceId).not.toBeDefined;
|
||||
|
||||
setImmediate(() => {
|
||||
const expected = [
|
||||
{
|
||||
deleteType: 'users'
|
||||
},
|
||||
{
|
||||
{
|
||||
deleteRoleId: mockData[0].summary_fields.foo[0].role.id
|
||||
},
|
||||
{
|
||||
@ -208,10 +201,10 @@ describe('<AccessList />', () => {
|
||||
expect(wrapper.state().warningTitle).not.toBe(null);
|
||||
expect(wrapper.state().warningMsg).not.toBe(null);
|
||||
expected.forEach(criteria => {
|
||||
for (const prop in criteria) {
|
||||
expect(wrapper.state()[prop]).toEqual(criteria[prop]);
|
||||
}
|
||||
})
|
||||
Object.keys(criteria).forEach(key => {
|
||||
expect(wrapper.state()[key]).toEqual(criteria[key]);
|
||||
});
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@ -275,3 +275,10 @@
|
||||
.at-u-textRight {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.awx-c-chip {
|
||||
padding: 3px 0;
|
||||
height: 24px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
@ -116,7 +116,7 @@ class AccessList extends React.Component {
|
||||
this.onCompact = this.onCompact.bind(this);
|
||||
this.onSort = this.onSort.bind(this);
|
||||
this.getQueryParams = this.getQueryParams.bind(this);
|
||||
this.removeRole = this.removeRole.bind(this);
|
||||
this.removeAccessRole = this.removeAccessRole.bind(this);
|
||||
this.handleWarning = this.handleWarning.bind(this);
|
||||
this.hideWarning = this.hideWarning.bind(this);
|
||||
this.confirmDelete = this.confirmDelete.bind(this);
|
||||
@ -225,8 +225,8 @@ class AccessList extends React.Component {
|
||||
}
|
||||
});
|
||||
|
||||
result.teamRoles = teamRoles || [];
|
||||
result.userRoles = userRoles || [];
|
||||
result.teamRoles = teamRoles;
|
||||
result.userRoles = userRoles;
|
||||
});
|
||||
this.setState(stateToUpdate);
|
||||
} catch (error) {
|
||||
@ -234,10 +234,14 @@ class AccessList extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
async removeRole (roleId, resourceId, type) {
|
||||
async removeAccessRole (roleId, resourceId, type) {
|
||||
const { removeRole } = this.props;
|
||||
const url = `/api/v2/${type}/${resourceId}/roles/`;
|
||||
await removeRole(url, roleId);
|
||||
try {
|
||||
await removeRole(url, roleId);
|
||||
} catch (error) {
|
||||
this.setState({ error });
|
||||
}
|
||||
const queryParams = this.getQueryParams();
|
||||
try {
|
||||
this.fetchOrgAccessList(queryParams);
|
||||
@ -280,7 +284,7 @@ class AccessList extends React.Component {
|
||||
|
||||
confirmDelete () {
|
||||
const { deleteType, deleteResourceId, deleteRoleId } = this.state;
|
||||
this.removeRole(deleteRoleId, deleteResourceId, deleteType);
|
||||
this.removeAccessRole(deleteRoleId, deleteResourceId, deleteType);
|
||||
}
|
||||
|
||||
render () {
|
||||
|
||||
@ -8,10 +8,3 @@
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.awx-c-chip {
|
||||
padding: 3px 0;
|
||||
height: 24px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user