mirror of
https://github.com/strapi/strapi.git
synced 2025-08-22 15:48:59 +00:00
Refetch roles after delete
This commit is contained in:
parent
cf1cb7050b
commit
ed696f70a0
@ -40,11 +40,11 @@ class ListRow extends React.Component { // eslint-disable-line react/prefer-stat
|
||||
|
||||
switch (this.props.settingType) {
|
||||
case 'roles':
|
||||
if (includes(this.protectedRoleIDs, get(this.props.item, 'type').toString())) {
|
||||
if (includes(this.protectedRoleIDs, get(this.props.item, 'type', ''))) {
|
||||
icons = [];
|
||||
}
|
||||
|
||||
if (includes(this.undeletableIDs, get(this.props.item, 'type').toString())) {
|
||||
if (includes(this.undeletableIDs, get(this.props.item, 'type', ''))) {
|
||||
icons = [{ icoType: 'pencil', onClick: this.handleClick }];
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ class ListRow extends React.Component { // eslint-disable-line react/prefer-stat
|
||||
handleClick = () => {
|
||||
switch (this.props.settingType) {
|
||||
case 'roles': {
|
||||
if (!includes(this.protectedRoleIDs, get(this.props.item, 'type').toString())) {
|
||||
if (!includes(this.protectedRoleIDs, get(this.props.item, 'type', ''))) {
|
||||
return router.push(`${router.location.pathname}/edit/${this.props.item.id}`);
|
||||
}
|
||||
return;
|
||||
|
@ -99,7 +99,7 @@ export function* submit() {
|
||||
};
|
||||
|
||||
const requestURL = actionType === 'POST' ? '/users-permissions/roles' : `/users-permissions/roles/${roleId}`;
|
||||
const response = yield call(request, requestURL, opts, true);
|
||||
const response = yield call(request, requestURL, opts);
|
||||
|
||||
if (response.ok) {
|
||||
yield put(submitSucceeded());
|
||||
|
@ -57,6 +57,10 @@ export class HomePage extends React.Component {
|
||||
if (shouldRedirect) {
|
||||
this.props.history.push('/404');
|
||||
}
|
||||
|
||||
if (nextProps.didDeleteData !== this.props.didDeleteData) {
|
||||
this.props.fetchData(nextProps.match.params.settingType);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
@ -161,6 +165,7 @@ HomePage.defaultProps = {};
|
||||
HomePage.propTypes = {
|
||||
data: PropTypes.array.isRequired,
|
||||
deleteData: PropTypes.func.isRequired,
|
||||
didDeleteData: PropTypes.bool.isRequired,
|
||||
fetchData: PropTypes.func.isRequired,
|
||||
history: PropTypes.object.isRequired,
|
||||
location: PropTypes.object.isRequired,
|
||||
|
@ -21,6 +21,7 @@ const initialState = fromJS({
|
||||
initialData: Map({}),
|
||||
modifiedData: Map({}),
|
||||
showButtons: false,
|
||||
didDeleteData: false,
|
||||
});
|
||||
|
||||
function homePageReducer(state = initialState, action) {
|
||||
@ -33,7 +34,8 @@ function homePageReducer(state = initialState, action) {
|
||||
return state
|
||||
.update('data', list => list.splice(action.indexDataToDelete, 1))
|
||||
.set('deleteEndPoint', '')
|
||||
.set('dataToDelete', Map({}));
|
||||
.set('dataToDelete', Map({}))
|
||||
.update('didDeleteData', (v) => !v);
|
||||
case FETCH_DATA_SUCCEEDED:
|
||||
return state.set('data', List(action.data));
|
||||
case ON_CHANGE:
|
||||
|
@ -34,7 +34,7 @@ export function* dataDelete() {
|
||||
if (indexDataToDelete !== -1) {
|
||||
const id = dataToDelete.id;
|
||||
const requestURL = `/users-permissions/${endPointAPI}/${id}`;
|
||||
const response = yield call(request, requestURL, { method: 'DELETE' }, true);
|
||||
const response = yield call(request, requestURL, { method: 'DELETE' });
|
||||
|
||||
if (response.ok) {
|
||||
yield put(deleteDataSucceeded(indexDataToDelete));
|
||||
|
@ -20,14 +20,10 @@ module.exports = {
|
||||
return ctx.badRequest(null, [{ messages: [{ id: 'Cannot be empty' }] }]);
|
||||
}
|
||||
|
||||
strapi.reload.isWatching = false;
|
||||
|
||||
try {
|
||||
await strapi.plugins['users-permissions'].services.userspermissions.createRole(ctx.request.body);
|
||||
|
||||
ctx.send({ ok: true });
|
||||
|
||||
strapi.reload();
|
||||
} catch(err) {
|
||||
ctx.badRequest(null, [{ messages: [{ id: 'An error occured' }] }]);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "strapi-plugin-users-permissions",
|
||||
"version": "3.0.0-alpha.8",
|
||||
"version": "3.0.0-alpha.8.3",
|
||||
"description": "Protect your API with a full-authentication process based on JWT",
|
||||
"strapi": {
|
||||
"name": "Auth & Permissions",
|
||||
|
Loading…
x
Reference in New Issue
Block a user