mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
Redirection after record deletion
This commit is contained in:
parent
6267955b41
commit
1baf70727d
@ -25,7 +25,15 @@ import { translationMessages } from './i18n';
|
||||
// Plugin identifier based on the package.json `name` value
|
||||
const pluginId = require('../package.json').name.replace(/^strapi-plugin-/i, '');
|
||||
|
||||
// Define Strapi admin router
|
||||
let router;
|
||||
|
||||
class comp extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||||
componentWillMount() {
|
||||
// Expose Strapi admin router
|
||||
router = this.context.router;
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
@ -35,6 +43,10 @@ class comp extends React.Component { // eslint-disable-line react/prefer-statele
|
||||
}
|
||||
}
|
||||
|
||||
comp.contextTypes = {
|
||||
router: React.PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
// Register the plugin
|
||||
if (window.Strapi) {
|
||||
window.Strapi.registerPlugin({
|
||||
@ -71,4 +83,5 @@ export {
|
||||
store,
|
||||
apiUrl,
|
||||
pluginId,
|
||||
router,
|
||||
};
|
||||
|
@ -2,6 +2,7 @@ import { takeLatest } from 'redux-saga';
|
||||
import { put, select, fork, call } from 'redux-saga/effects';
|
||||
import request from 'utils/request';
|
||||
import { browserHistory } from 'react-router';
|
||||
import { router } from 'app';
|
||||
|
||||
import {
|
||||
recordLoaded,
|
||||
@ -80,7 +81,9 @@ export function* deleteRecord() {
|
||||
|
||||
yield put(recordDeleted());
|
||||
window.Strapi.notification.success('The entry has been successfully deleted.');
|
||||
// TODO: Redirect to the list page.
|
||||
|
||||
// Redirect to the list page.
|
||||
router.push(`/plugins/content-manager/${currentModelName}`);
|
||||
} catch (err) {
|
||||
yield put(recordDeleteError());
|
||||
window.Strapi.notification.error('An error occurred during record deletion.');
|
||||
|
Loading…
x
Reference in New Issue
Block a user