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