Remove the redirect url

Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
soupette 2020-06-22 15:02:52 +02:00 committed by Alexandre Bodin
parent 896f7a5d96
commit c0a28d7064
6 changed files with 10 additions and 40 deletions

View File

@ -12,17 +12,15 @@ import Row from './Row';
const CustomTable = ({ canUpdate, canDelete, data, headers, isBulkable, showLoader }) => {
const { emitEvent, entriesToDelete, label, filters, _q } = useListView();
const { pathname, search } = useLocation();
const { pathname } = useLocation();
const { push } = useHistory();
const redirectUrl = `redirectUrl=${pathname}${search}`;
const colSpanLength = isBulkable && canDelete ? headers.length + 2 : headers.length + 1;
const handleGoTo = id => {
emitEvent('willEditEntryFromList');
push({
pathname: `${pathname}/${id}`,
search: redirectUrl,
});
};

View File

@ -9,16 +9,8 @@ import ItemTypes from '../../utils/ItemTypes';
import { Li } from './components';
import Relation from './Relation';
function ListItem({
data,
findRelation,
mainField,
moveRelation,
nextSearch,
onRemove,
targetModel,
}) {
const to = `/plugins/${pluginId}/collectionType/${targetModel}/${data.id}?redirectUrl=${nextSearch}`;
function ListItem({ data, findRelation, mainField, moveRelation, onRemove, targetModel }) {
const to = `/plugins/${pluginId}/collectionType/${targetModel}/${data.id}`;
const originalIndex = findRelation(data.id).index;
const [{ isDragging }, drag, preview] = useDrag({
@ -60,7 +52,6 @@ function ListItem({
ListItem.defaultProps = {
findRelation: () => {},
moveRelation: () => {},
nextSearch: '',
onRemove: () => {},
targetModel: '',
};
@ -70,7 +61,6 @@ ListItem.propTypes = {
findRelation: PropTypes.func,
mainField: PropTypes.string.isRequired,
moveRelation: PropTypes.func,
nextSearch: PropTypes.string,
onRemove: PropTypes.func,
targetModel: PropTypes.string,
};

View File

@ -16,7 +16,6 @@ function SelectMany({
isDisabled,
isLoading,
move,
nextSearch,
onInputChange,
onMenuClose,
onMenuScrollToBottom,
@ -99,7 +98,6 @@ function SelectMany({
findRelation={findRelation}
mainField={mainField}
moveRelation={moveRelation}
nextSearch={nextSearch}
onRemove={() => onRemove(`${name}.${index}`)}
targetModel={targetModel}
/>
@ -123,7 +121,6 @@ SelectMany.propTypes = {
mainField: PropTypes.string.isRequired,
move: PropTypes.func,
name: PropTypes.string.isRequired,
nextSearch: PropTypes.string.isRequired,
isLoading: PropTypes.bool.isRequired,
onInputChange: PropTypes.func.isRequired,
onMenuClose: PropTypes.func.isRequired,

View File

@ -2,7 +2,7 @@
import React, { useState, useEffect, useMemo, useRef, memo } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { Link, useLocation } from 'react-router-dom';
import { Link } from 'react-router-dom';
import { cloneDeep, findIndex, get, isArray, isEmpty } from 'lodash';
import { request } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
@ -23,7 +23,6 @@ function SelectWrapper({
targetModel,
placeholder,
}) {
const { pathname, search } = useLocation();
// Disable the input in case of a polymorphic relation
const isMorph = relationType.toLowerCase().includes('morph');
const { addRelation, modifiedData, moveRelation, onChange, onRemoveRelation } = useDataManager();
@ -154,10 +153,8 @@ function SelectWrapper({
const isSingle = ['oneWay', 'oneToOne', 'manyToOne', 'oneToManyMorph', 'oneToOneMorph'].includes(
relationType
);
const nextSearch = `${pathname}${search}`;
const to = `/plugins/${pluginId}/collectionType/${targetModel}/${
value ? value.id : null
}?redirectUrl=${nextSearch}`;
const to = `/plugins/${pluginId}/collectionType/${targetModel}/${value ? value.id : null}`;
const link =
value === null ||
value === undefined ||
@ -208,7 +205,6 @@ function SelectWrapper({
mainField={mainField}
move={moveRelation}
name={name}
nextSearch={nextSearch}
options={filteredOptions}
onChange={value => {
onChange({ target: { name, value: value ? value.value : value } });

View File

@ -25,10 +25,9 @@ import reducer, { initialState } from './reducer';
const EditView = ({ components, currentEnvironment, deleteLayout, layouts, plugins, slug }) => {
const formatLayoutRef = useRef();
formatLayoutRef.current = createAttributesLayout;
// Retrieve push to programmatically navigate between views
const { push } = useHistory();
const { goBack } = useHistory();
// Retrieve the search and the pathname
const { search, pathname } = useLocation();
const { pathname } = useLocation();
const {
params: { contentType },
} = useRouteMatch('/plugins/content-manager/:contentType');
@ -103,15 +102,6 @@ const EditView = ({ components, currentEnvironment, deleteLayout, layouts, plugi
const { formattedContentTypeLayout, isDraggingComponent } = reducerState.toJS();
// We can't use the getQueryParameters helper here because the search
// can contain 'redirectUrl' several times since we can navigate between documents
const redirectURL = search
.split('redirectUrl=')
.filter((_, index) => index !== 0)
.join('redirectUrl=');
const redirectToPreviousPage = () => push(redirectURL);
return (
<EditViewProvider
allLayoutData={allLayoutData}
@ -131,10 +121,10 @@ const EditView = ({ components, currentEnvironment, deleteLayout, layouts, plugi
>
<EditViewDataManagerProvider
allLayoutData={allLayoutData}
redirectToPreviousPage={redirectToPreviousPage}
redirectToPreviousPage={goBack}
slug={slug}
>
<BackHeader onClick={redirectToPreviousPage} />
<BackHeader onClick={goBack} />
<Container className="container-fluid">
<Header />
<div className="row" style={{ paddingTop: 3 }}>

View File

@ -439,7 +439,6 @@ function ListView({
emitEvent('willCreateEntry');
push({
pathname: `${pathname}/create`,
search: `redirectUrl=${pathname}${search}`,
});
},
color: 'primary',