mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Add remove role functionality.
This commit is contained in:
@@ -155,14 +155,14 @@ describe('APIClient (api.js)', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('disassociateInstanceGroup calls expected http method with expected data', async (done) => {
|
test('disassociate calls expected http method with expected data', async (done) => {
|
||||||
const createPromise = () => Promise.resolve();
|
const createPromise = () => Promise.resolve();
|
||||||
const mockHttp = ({ post: jest.fn(createPromise) });
|
const mockHttp = ({ post: jest.fn(createPromise) });
|
||||||
|
|
||||||
const api = new APIClient(mockHttp);
|
const api = new APIClient(mockHttp);
|
||||||
const url = 'foo/bar/';
|
const url = 'foo/bar/';
|
||||||
const id = 1;
|
const id = 1;
|
||||||
await api.disassociateInstanceGroup(url, id);
|
await api.disassociate(url, id);
|
||||||
|
|
||||||
expect(mockHttp.post).toHaveBeenCalledTimes(1);
|
expect(mockHttp.post).toHaveBeenCalledTimes(1);
|
||||||
expect(mockHttp.post.mock.calls[0][0]).toEqual(url);
|
expect(mockHttp.post.mock.calls[0][0]).toEqual(url);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ describe('<AccessList />', () => {
|
|||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '1' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '1' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => {}}
|
getAccessList={() => {}}
|
||||||
|
removeRole={() => {}}
|
||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
@@ -48,6 +49,7 @@ describe('<AccessList />', () => {
|
|||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => ({ data: { count: 1, results: mockResults } })}
|
getAccessList={() => ({ data: { count: 1, results: mockResults } })}
|
||||||
|
removeRole={() => {}}
|
||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
@@ -69,6 +71,7 @@ describe('<AccessList />', () => {
|
|||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => ({ data: { count: 1, results: mockResults } })}
|
getAccessList={() => ({ data: { count: 1, results: mockResults } })}
|
||||||
|
removeRole={() => {}}
|
||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
@@ -95,6 +98,7 @@ describe('<AccessList />', () => {
|
|||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => ({ data: { count: 1, results: mockResults } })}
|
getAccessList={() => ({ data: { count: 1, results: mockResults } })}
|
||||||
|
removeRole={() => {}}
|
||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
@@ -144,6 +148,7 @@ describe('<AccessList />', () => {
|
|||||||
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
||||||
location={{ search: '', pathname: '/organizations/1/access' }}
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
getAccessList={() => ({ data: { count: 1, results: mockData } })}
|
||||||
|
removeRole={() => {}}
|
||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
@@ -157,4 +162,36 @@ describe('<AccessList />', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('test handleWarning, confirmDelete, and removeRole methods for Alert component', async (done) => {
|
||||||
|
const handleWarning = jest.spyOn(AccessList.prototype, 'handleWarning');
|
||||||
|
const confirmDelete = jest.spyOn(AccessList.prototype, 'confirmDelete');
|
||||||
|
const removeRole = jest.spyOn(AccessList.prototype, 'removeRole');
|
||||||
|
const wrapper = mount(
|
||||||
|
<I18nProvider>
|
||||||
|
<MemoryRouter>
|
||||||
|
<AccessList
|
||||||
|
match={{ path: '/organizations/:id', url: '/organizations/1', params: { id: '0' } }}
|
||||||
|
location={{ search: '', pathname: '/organizations/1/access' }}
|
||||||
|
getAccessList={() => ({ data: { count: 1, results: mockResults } })}
|
||||||
|
removeRole={() => {}}
|
||||||
|
/>
|
||||||
|
</MemoryRouter>
|
||||||
|
</I18nProvider>
|
||||||
|
).find('AccessList');
|
||||||
|
expect(handleWarning).not.toHaveBeenCalled();
|
||||||
|
expect(confirmDelete).not.toHaveBeenCalled();
|
||||||
|
expect(removeRole).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
setImmediate(() => {
|
||||||
|
const rendered = wrapper.update().find('ChipButton');
|
||||||
|
rendered.find('button[aria-label="close"]').simulate('click');
|
||||||
|
expect(handleWarning).toHaveBeenCalled();
|
||||||
|
const alert = wrapper.update().find('Alert');
|
||||||
|
alert.find('button[aria-label="confirm-delete"]').simulate('click');
|
||||||
|
expect(confirmDelete).toHaveBeenCalled();
|
||||||
|
expect(removeRole).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ const mockGetOrganzationAccessList = jest.fn(() => (
|
|||||||
Promise.resolve(mockAPIAccessList)
|
Promise.resolve(mockAPIAccessList)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
const mockResponse = {
|
||||||
|
status: 'success',
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockRemoveRole = jest.fn(() => (
|
||||||
|
Promise.resolve(mockResponse)
|
||||||
|
));
|
||||||
|
|
||||||
describe('<OrganizationAccess />', () => {
|
describe('<OrganizationAccess />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mount(
|
||||||
@@ -37,11 +45,14 @@ describe('<OrganizationAccess />', () => {
|
|||||||
params={{}}
|
params={{}}
|
||||||
api={{
|
api={{
|
||||||
getOrganzationAccessList: mockGetOrganzationAccessList,
|
getOrganzationAccessList: mockGetOrganzationAccessList,
|
||||||
|
disassociate: mockRemoveRole
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
).find('OrganizationAccess');
|
).find('OrganizationAccess');
|
||||||
const accessList = await wrapper.instance().getOrgAccessList();
|
const accessList = await wrapper.instance().getOrgAccessList();
|
||||||
expect(accessList).toEqual(mockAPIAccessList);
|
expect(accessList).toEqual(mockAPIAccessList);
|
||||||
|
const resp = await wrapper.instance().removeRole(2, 3, 'users');
|
||||||
|
expect(resp).toEqual(mockResponse);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ describe('<OrganizationEdit />', () => {
|
|||||||
getOrganizationInstanceGroups: getOrganizationInstanceGroupsFn,
|
getOrganizationInstanceGroups: getOrganizationInstanceGroupsFn,
|
||||||
updateOrganizationDetails: updateOrganizationDetailsFn,
|
updateOrganizationDetails: updateOrganizationDetailsFn,
|
||||||
associateInstanceGroup: associateInstanceGroupFn,
|
associateInstanceGroup: associateInstanceGroupFn,
|
||||||
disassociateInstanceGroup: disassociateInstanceGroupFn
|
disassociate: disassociateInstanceGroupFn
|
||||||
};
|
};
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class APIClient {
|
|||||||
return this.http.post(url, { id });
|
return this.http.post(url, { id });
|
||||||
}
|
}
|
||||||
|
|
||||||
disassociateInstanceGroup (url, id) {
|
disassociate (url, id) {
|
||||||
return this.http.post(url, { id, disassociate: true });
|
return this.http.post(url, { id, disassociate: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/app.scss
33
src/app.scss
@@ -220,14 +220,6 @@
|
|||||||
// and bem style, as well as moved into component-based scss files
|
// and bem style, as well as moved into component-based scss files
|
||||||
//
|
//
|
||||||
|
|
||||||
.awx-lookup {
|
|
||||||
min-height: 36px;
|
|
||||||
|
|
||||||
.pf-c-form-control {
|
|
||||||
--pf-c-form-control--Height: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.awx-c-list {
|
.awx-c-list {
|
||||||
border-bottom: 1px solid #d7d7d7;
|
border-bottom: 1px solid #d7d7d7;
|
||||||
}
|
}
|
||||||
@@ -238,3 +230,28 @@
|
|||||||
--pf-c-card__body--PaddingX: 0;
|
--pf-c-card__body--PaddingX: 0;
|
||||||
--pf-c-card__body--PaddingY: 0;
|
--pf-c-card__body--PaddingY: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.awx-c-card {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.awx-c-alert {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pf-c-alert {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
& button {
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pf-c-alert__icon > svg {
|
||||||
|
fill: white;
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
DataList, DataListItem, DataListCell, Text,
|
DataList, DataListItem, DataListCell, Text,
|
||||||
TextContent, TextVariants
|
TextContent, TextVariants, Chip, Alert, AlertActionCloseButton, Button
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
|
|
||||||
import { I18n, i18nMark } from '@lingui/react';
|
import { I18n, i18nMark } from '@lingui/react';
|
||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
Link
|
Link
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
|
|
||||||
import BasicChip from '../BasicChip/BasicChip';
|
|
||||||
import Pagination from '../Pagination';
|
import Pagination from '../Pagination';
|
||||||
import DataListToolbar from '../DataListToolbar';
|
import DataListToolbar from '../DataListToolbar';
|
||||||
|
|
||||||
@@ -46,6 +45,10 @@ const hiddenStyle = {
|
|||||||
display: 'none',
|
display: 'none',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const buttonGroupStyle = {
|
||||||
|
float: 'right',
|
||||||
|
};
|
||||||
|
|
||||||
const Detail = ({ label, value, url, customStyles }) => {
|
const Detail = ({ label, value, url, customStyles }) => {
|
||||||
let detail = null;
|
let detail = null;
|
||||||
if (value) {
|
if (value) {
|
||||||
@@ -104,6 +107,7 @@ class AccessList extends React.Component {
|
|||||||
sortOrder: 'ascending',
|
sortOrder: 'ascending',
|
||||||
sortedColumnKey: 'username',
|
sortedColumnKey: 'username',
|
||||||
isCompact: false,
|
isCompact: false,
|
||||||
|
showWarning: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.fetchOrgAccessList = this.fetchOrgAccessList.bind(this);
|
this.fetchOrgAccessList = this.fetchOrgAccessList.bind(this);
|
||||||
@@ -112,7 +116,10 @@ class AccessList extends React.Component {
|
|||||||
this.onCompact = this.onCompact.bind(this);
|
this.onCompact = this.onCompact.bind(this);
|
||||||
this.onSort = this.onSort.bind(this);
|
this.onSort = this.onSort.bind(this);
|
||||||
this.getQueryParams = this.getQueryParams.bind(this);
|
this.getQueryParams = this.getQueryParams.bind(this);
|
||||||
this.getTeamRoles = this.getTeamRoles.bind(this);
|
this.removeRole = this.removeRole.bind(this);
|
||||||
|
this.handleWarning = this.handleWarning.bind(this);
|
||||||
|
this.hideWarning = this.hideWarning.bind(this);
|
||||||
|
this.confirmDelete = this.confirmDelete.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
@@ -171,23 +178,6 @@ class AccessList extends React.Component {
|
|||||||
return Object.assign({}, this.defaultParams, searchParams, overrides);
|
return Object.assign({}, this.defaultParams, searchParams, overrides);
|
||||||
}
|
}
|
||||||
|
|
||||||
getRoles = roles => Object.values(roles)
|
|
||||||
.reduce((val, role) => {
|
|
||||||
if (role.length > 0) {
|
|
||||||
val.push(role[0].role);
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
getTeamRoles = roles => roles
|
|
||||||
.reduce((val, item) => {
|
|
||||||
if (item.role.team_id) {
|
|
||||||
const { role } = item;
|
|
||||||
val.push(role);
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
async fetchOrgAccessList (queryParams) {
|
async fetchOrgAccessList (queryParams) {
|
||||||
const { match, getAccessList } = this.props;
|
const { match, getAccessList } = this.props;
|
||||||
|
|
||||||
@@ -216,13 +206,27 @@ class AccessList extends React.Component {
|
|||||||
sortedColumnKey,
|
sortedColumnKey,
|
||||||
results,
|
results,
|
||||||
};
|
};
|
||||||
|
|
||||||
results.forEach((result) => {
|
results.forEach((result) => {
|
||||||
if (result.summary_fields.direct_access) {
|
// Separate out roles into user roles or team roles
|
||||||
result.teamRoles = this.getTeamRoles(result.summary_fields.direct_access);
|
// based on whether or not a team_id attribute is present
|
||||||
} else {
|
const teamRoles = [];
|
||||||
result.teamRoles = [];
|
const userRoles = [];
|
||||||
}
|
Object.values(result.summary_fields).forEach(field => {
|
||||||
result.userRoles = this.getRoles(result.summary_fields) || [];
|
if (field.length > 0) {
|
||||||
|
field.forEach(item => {
|
||||||
|
const { role } = item;
|
||||||
|
if (role.team_id) {
|
||||||
|
teamRoles.push(role);
|
||||||
|
} else {
|
||||||
|
userRoles.push(role);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
result.teamRoles = teamRoles || [];
|
||||||
|
result.userRoles = userRoles || [];
|
||||||
});
|
});
|
||||||
this.setState(stateToUpdate);
|
this.setState(stateToUpdate);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -230,6 +234,55 @@ class AccessList extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async removeRole (roleId, resourceId, type) {
|
||||||
|
const { removeRole } = this.props;
|
||||||
|
const url = `/api/v2/${type}/${resourceId}/roles/`;
|
||||||
|
await removeRole(url, roleId);
|
||||||
|
const queryParams = this.getQueryParams();
|
||||||
|
try {
|
||||||
|
this.fetchOrgAccessList(queryParams);
|
||||||
|
} catch (error) {
|
||||||
|
this.setState({ error });
|
||||||
|
}
|
||||||
|
this.setState({ showWarning: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
handleWarning (roleName, roleId, resourceName, resourceId, type) {
|
||||||
|
let warningTitle;
|
||||||
|
let warningMsg;
|
||||||
|
|
||||||
|
if (type === 'users') {
|
||||||
|
warningTitle = i18nMark('User Access Removal');
|
||||||
|
warningMsg = i18nMark(`Please confirm that you would like to remove ${roleName}
|
||||||
|
access from ${resourceName}.`);
|
||||||
|
}
|
||||||
|
if (type === 'teams') {
|
||||||
|
warningTitle = i18nMark('Team Access Removal');
|
||||||
|
warningMsg = i18nMark(`Please confirm that you would like to remove ${roleName}
|
||||||
|
access from the team ${resourceName}. This will affect all
|
||||||
|
members of the team. If you would like to only remove access
|
||||||
|
for this particular user, please remove them from the team.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
showWarning: true,
|
||||||
|
warningMsg,
|
||||||
|
warningTitle,
|
||||||
|
deleteType: type,
|
||||||
|
deleteRoleId: roleId,
|
||||||
|
deleteResourceId: resourceId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
hideWarning () {
|
||||||
|
this.setState({ showWarning: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmDelete () {
|
||||||
|
const { deleteType, deleteResourceId, deleteRoleId } = this.state;
|
||||||
|
this.removeRole(deleteRoleId, deleteResourceId, deleteType);
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const {
|
const {
|
||||||
results,
|
results,
|
||||||
@@ -241,6 +294,9 @@ class AccessList extends React.Component {
|
|||||||
sortedColumnKey,
|
sortedColumnKey,
|
||||||
sortOrder,
|
sortOrder,
|
||||||
isCompact,
|
isCompact,
|
||||||
|
warningMsg,
|
||||||
|
warningTitle,
|
||||||
|
showWarning
|
||||||
} = this.state;
|
} = this.state;
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
@@ -268,6 +324,20 @@ class AccessList extends React.Component {
|
|||||||
isCompact={isCompact}
|
isCompact={isCompact}
|
||||||
showExpandCollapse
|
showExpandCollapse
|
||||||
/>
|
/>
|
||||||
|
{showWarning && (
|
||||||
|
<Alert
|
||||||
|
variant="danger"
|
||||||
|
title={warningTitle}
|
||||||
|
action={<AlertActionCloseButton onClose={this.hideWarning} />}
|
||||||
|
>
|
||||||
|
{warningMsg}
|
||||||
|
<span style={buttonGroupStyle}>
|
||||||
|
<Button variant="danger" aria-label="confirm-delete" onClick={this.confirmDelete}>Delete</Button>
|
||||||
|
<Button variant="secondary" onClick={this.hideWarning}>Cancel</Button>
|
||||||
|
</span>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<I18n>
|
<I18n>
|
||||||
{({ i18n }) => (
|
{({ i18n }) => (
|
||||||
@@ -304,10 +374,13 @@ class AccessList extends React.Component {
|
|||||||
>
|
>
|
||||||
<Text component={TextVariants.h6} style={detailLabelStyle}>{i18n._(t`User Roles`)}</Text>
|
<Text component={TextVariants.h6} style={detailLabelStyle}>{i18n._(t`User Roles`)}</Text>
|
||||||
{result.userRoles.map(role => (
|
{result.userRoles.map(role => (
|
||||||
<BasicChip
|
<Chip
|
||||||
key={role.id}
|
key={role.id}
|
||||||
text={role.name}
|
className="awx-c-chip"
|
||||||
/>
|
onClick={() => this.handleWarning(role.name, role.id, result.username, result.id, 'users')}
|
||||||
|
>
|
||||||
|
{role.name}
|
||||||
|
</Chip>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
@@ -318,10 +391,13 @@ class AccessList extends React.Component {
|
|||||||
>
|
>
|
||||||
<Text component={TextVariants.h6} style={detailLabelStyle}>{i18n._(t`Team Roles`)}</Text>
|
<Text component={TextVariants.h6} style={detailLabelStyle}>{i18n._(t`Team Roles`)}</Text>
|
||||||
{result.teamRoles.map(role => (
|
{result.teamRoles.map(role => (
|
||||||
<BasicChip
|
<Chip
|
||||||
key={role.id}
|
key={role.id}
|
||||||
text={role.name}
|
className="awx-c-chip"
|
||||||
/>
|
onClick={() => this.handleWarning(role.name, role.id, role.team_name, role.team_id, 'teams')}
|
||||||
|
>
|
||||||
|
{role.name}
|
||||||
|
</Chip>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
@@ -348,6 +424,7 @@ class AccessList extends React.Component {
|
|||||||
|
|
||||||
AccessList.propTypes = {
|
AccessList.propTypes = {
|
||||||
getAccessList: PropTypes.func.isRequired,
|
getAccessList: PropTypes.func.isRequired,
|
||||||
|
removeRole: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AccessList;
|
export default AccessList;
|
||||||
|
|||||||
@@ -8,3 +8,10 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.awx-c-chip {
|
||||||
|
padding: 3px 0;
|
||||||
|
height: 24px;
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
@@ -112,7 +112,7 @@ class Organization extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PageSection>
|
<PageSection>
|
||||||
<Card>
|
<Card className="awx-c-card">
|
||||||
{ cardHeader }
|
{ cardHeader }
|
||||||
<Switch>
|
<Switch>
|
||||||
<Redirect
|
<Redirect
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class OrganizationAccess extends React.Component {
|
|||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.getOrgAccessList = this.getOrgAccessList.bind(this);
|
this.getOrgAccessList = this.getOrgAccessList.bind(this);
|
||||||
|
this.removeRole = this.removeRole.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
getOrgAccessList (id, params) {
|
getOrgAccessList (id, params) {
|
||||||
@@ -13,6 +14,11 @@ class OrganizationAccess extends React.Component {
|
|||||||
return api.getOrganzationAccessList(id, params);
|
return api.getOrganzationAccessList(id, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeRole (url, id) {
|
||||||
|
const { api } = this.props;
|
||||||
|
return api.disassociate(url, id);
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const {
|
const {
|
||||||
location,
|
location,
|
||||||
@@ -23,6 +29,7 @@ class OrganizationAccess extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<AccessList
|
<AccessList
|
||||||
getAccessList={this.getOrgAccessList}
|
getAccessList={this.getOrgAccessList}
|
||||||
|
removeRole={this.removeRole}
|
||||||
match={match}
|
match={match}
|
||||||
location={location}
|
location={location}
|
||||||
history={history}
|
history={history}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ class OrganizationEdit extends Component {
|
|||||||
await api.associateInstanceGroup(url, id);
|
await api.associateInstanceGroup(url, id);
|
||||||
}));
|
}));
|
||||||
await Promise.all(groupsToDisassociate.map(async id => {
|
await Promise.all(groupsToDisassociate.map(async id => {
|
||||||
await api.disassociateInstanceGroup(url, id);
|
await api.disassociate(url, id);
|
||||||
}));
|
}));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.setState({ error: err });
|
this.setState({ error: err });
|
||||||
|
|||||||
Reference in New Issue
Block a user