mirror of
https://github.com/strapi/strapi.git
synced 2025-12-04 02:51:26 +00:00
Change content manager routing
This commit is contained in:
parent
16d63f63cf
commit
0a3317ce89
@ -65,7 +65,7 @@ function LeftMenuLinkContainer({ plugins, ...rest }) {
|
|||||||
// Check if the plugins list is empty or not and display plugins by name
|
// Check if the plugins list is empty or not and display plugins by name
|
||||||
const pluginsLinks = !isEmpty(plugins) ? (
|
const pluginsLinks = !isEmpty(plugins) ? (
|
||||||
map(sortBy(plugins, 'name'), plugin => {
|
map(sortBy(plugins, 'name'), plugin => {
|
||||||
if (plugin.id !== 'email') {
|
if (plugin.id !== 'email' && plugin.id !== 'content-manager') {
|
||||||
const pluginSuffixUrl = plugin.suffixUrl
|
const pluginSuffixUrl = plugin.suffixUrl
|
||||||
? plugin.suffixUrl(plugins)
|
? plugin.suffixUrl(plugins)
|
||||||
: '';
|
: '';
|
||||||
|
|||||||
@ -30,7 +30,7 @@ const DisplayedFieldsDropdown = ({
|
|||||||
<MenuDropdown isopen={isOpen.toString()}>
|
<MenuDropdown isopen={isOpen.toString()}>
|
||||||
<DropdownItemLink>
|
<DropdownItemLink>
|
||||||
<LayoutWrapper
|
<LayoutWrapper
|
||||||
to={`/plugins/${pluginId}/ctm-configurations/list-settings/${slug}?source=${source}`}
|
to={`${slug}/ctm-configurations/list-settings?source=${source}`}
|
||||||
>
|
>
|
||||||
<LayoutIcon />
|
<LayoutIcon />
|
||||||
<FormattedMessage id="app.links.configure-view" />
|
<FormattedMessage id="app.links.configure-view" />
|
||||||
|
|||||||
@ -133,7 +133,7 @@ const DraggedField = forwardRef(
|
|||||||
<Link
|
<Link
|
||||||
onClick={e => {
|
onClick={e => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
console.log('cll');
|
|
||||||
goTo(
|
goTo(
|
||||||
`/plugins/${pluginId}/ctm-configurations/edit-settings/groups/${groupUid}`
|
`/plugins/${pluginId}/ctm-configurations/edit-settings/groups/${groupUid}`
|
||||||
);
|
);
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import React, {
|
|||||||
useState,
|
useState,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
import { cloneDeep, get, set } from 'lodash';
|
import { cloneDeep, get, set } from 'lodash';
|
||||||
import {
|
import {
|
||||||
// utils
|
// utils
|
||||||
@ -41,10 +42,9 @@ const EditSettingsView = ({
|
|||||||
groupsAndModelsMainPossibleMainFields,
|
groupsAndModelsMainPossibleMainFields,
|
||||||
history: { push },
|
history: { push },
|
||||||
location: { search },
|
location: { search },
|
||||||
match: {
|
slug,
|
||||||
params: { slug, type },
|
|
||||||
},
|
|
||||||
}) => {
|
}) => {
|
||||||
|
const { groupSlug, type } = useParams();
|
||||||
const [reducerState, dispatch] = useReducer(reducer, initialState);
|
const [reducerState, dispatch] = useReducer(reducer, initialState);
|
||||||
const [isModalFormOpen, setIsModalFormOpen] = useState(false);
|
const [isModalFormOpen, setIsModalFormOpen] = useState(false);
|
||||||
|
|
||||||
@ -127,11 +127,14 @@ const EditSettingsView = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await request(getRequestUrl(`${type}/${slug}`), {
|
const { data } = await request(
|
||||||
method: 'GET',
|
getRequestUrl(`${type}/${slug || groupSlug}`),
|
||||||
params,
|
{
|
||||||
signal,
|
method: 'GET',
|
||||||
});
|
params,
|
||||||
|
signal,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// TODO temporary to remove when api available
|
// TODO temporary to remove when api available
|
||||||
const groups = retrieveDisplayedGroups(
|
const groups = retrieveDisplayedGroups(
|
||||||
@ -202,7 +205,7 @@ const EditSettingsView = ({
|
|||||||
delete body.source;
|
delete body.source;
|
||||||
delete body.isGroup;
|
delete body.isGroup;
|
||||||
|
|
||||||
await request(getRequestUrl(`${type}/${slug}`), {
|
await request(getRequestUrl(`${type}/${slug || groupSlug}`), {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body,
|
body,
|
||||||
params: type === 'groups' ? {} : params,
|
params: type === 'groups' ? {} : params,
|
||||||
@ -371,7 +374,7 @@ const EditSettingsView = ({
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onConfirmSubmit={handleConfirm}
|
onConfirmSubmit={handleConfirm}
|
||||||
slug={slug}
|
slug={slug || groupSlug}
|
||||||
isEditSettings
|
isEditSettings
|
||||||
>
|
>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
@ -439,6 +442,10 @@ const EditSettingsView = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EditSettingsView.defaultProps = {
|
||||||
|
slug: null,
|
||||||
|
};
|
||||||
|
|
||||||
EditSettingsView.propTypes = {
|
EditSettingsView.propTypes = {
|
||||||
deleteLayout: PropTypes.func.isRequired,
|
deleteLayout: PropTypes.func.isRequired,
|
||||||
groupsAndModelsMainPossibleMainFields: PropTypes.object.isRequired,
|
groupsAndModelsMainPossibleMainFields: PropTypes.object.isRequired,
|
||||||
@ -448,12 +455,7 @@ EditSettingsView.propTypes = {
|
|||||||
location: PropTypes.shape({
|
location: PropTypes.shape({
|
||||||
search: PropTypes.string.isRequired,
|
search: PropTypes.string.isRequired,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
match: PropTypes.shape({
|
slug: PropTypes.string,
|
||||||
params: PropTypes.shape({
|
|
||||||
slug: PropTypes.string.isRequired,
|
|
||||||
type: PropTypes.string.isRequired,
|
|
||||||
}).isRequired,
|
|
||||||
}).isRequired,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default EditSettingsView;
|
export default EditSettingsView;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import React, { memo, useEffect, useState, useReducer } from 'react';
|
import React, { memo, useEffect, useState, useReducer } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { cloneDeep, get } from 'lodash';
|
import { cloneDeep, get } from 'lodash';
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
BackHeader,
|
BackHeader,
|
||||||
getQueryParameters,
|
getQueryParameters,
|
||||||
@ -43,11 +44,12 @@ function EditView({
|
|||||||
layouts,
|
layouts,
|
||||||
location: { pathname, search },
|
location: { pathname, search },
|
||||||
history: { push },
|
history: { push },
|
||||||
match: {
|
|
||||||
params: { slug, id },
|
slug,
|
||||||
},
|
|
||||||
plugins,
|
plugins,
|
||||||
}) {
|
}) {
|
||||||
|
const { id } = useParams();
|
||||||
|
|
||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
const { signal } = abortController;
|
const { signal } = abortController;
|
||||||
const layout = get(layouts, [slug], {});
|
const layout = get(layouts, [slug], {});
|
||||||
@ -321,6 +323,8 @@ function EditView({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EditViewProvider
|
<EditViewProvider
|
||||||
addRelation={({ target: { name, value } }) => {
|
addRelation={({ target: { name, value } }) => {
|
||||||
@ -538,7 +542,8 @@ function EditView({
|
|||||||
}}
|
}}
|
||||||
icon="layout"
|
icon="layout"
|
||||||
key={`${pluginId}.link`}
|
key={`${pluginId}.link`}
|
||||||
url={`/plugins/${pluginId}/ctm-configurations/edit-settings/content-types/${slug}${`?source=${source}`}`}
|
// url={`/plugins/${pluginId}/ctm-configurations/edit-settings/content-types/${slug}${`?source=${source}`}`}
|
||||||
|
url={`ctm-configurations/edit-settings/content-types${`?source=${source}`}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
emitEvent('willEditContentTypeLayoutFromEditView');
|
emitEvent('willEditContentTypeLayoutFromEditView');
|
||||||
}}
|
}}
|
||||||
@ -601,12 +606,7 @@ EditView.propTypes = {
|
|||||||
pathname: PropTypes.string,
|
pathname: PropTypes.string,
|
||||||
search: PropTypes.string,
|
search: PropTypes.string,
|
||||||
}),
|
}),
|
||||||
match: PropTypes.shape({
|
slug: PropTypes.string.isRequired,
|
||||||
params: PropTypes.shape({
|
|
||||||
id: PropTypes.string.isRequired,
|
|
||||||
slug: PropTypes.string.isRequired,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
plugins: PropTypes.object,
|
plugins: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -27,13 +27,7 @@ import Toggle from './Toggle';
|
|||||||
import reducer, { initialState } from './reducer';
|
import reducer, { initialState } from './reducer';
|
||||||
import forms from './forms.json';
|
import forms from './forms.json';
|
||||||
|
|
||||||
const ListSettingsView = ({
|
const ListSettingsView = ({ deleteLayout, location: { search }, slug }) => {
|
||||||
deleteLayout,
|
|
||||||
location: { search },
|
|
||||||
match: {
|
|
||||||
params: { slug },
|
|
||||||
},
|
|
||||||
}) => {
|
|
||||||
const [reducerState, dispatch] = useReducer(reducer, initialState);
|
const [reducerState, dispatch] = useReducer(reducer, initialState);
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [isModalFormOpen, setIsModalFormOpen] = useState(false);
|
const [isModalFormOpen, setIsModalFormOpen] = useState(false);
|
||||||
@ -339,11 +333,7 @@ ListSettingsView.propTypes = {
|
|||||||
location: PropTypes.shape({
|
location: PropTypes.shape({
|
||||||
search: PropTypes.string.isRequired,
|
search: PropTypes.string.isRequired,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
match: PropTypes.shape({
|
slug: PropTypes.string.isRequired,
|
||||||
params: PropTypes.shape({
|
|
||||||
slug: PropTypes.string.isRequired,
|
|
||||||
}).isRequired,
|
|
||||||
}).isRequired,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ListSettingsView;
|
export default ListSettingsView;
|
||||||
|
|||||||
@ -49,9 +49,6 @@ function ListView({
|
|||||||
layouts,
|
layouts,
|
||||||
isLoading,
|
isLoading,
|
||||||
history: { push },
|
history: { push },
|
||||||
match: {
|
|
||||||
params: { slug },
|
|
||||||
},
|
|
||||||
onChangeBulk,
|
onChangeBulk,
|
||||||
onChangeBulkSelectall,
|
onChangeBulkSelectall,
|
||||||
onChangeListLabels,
|
onChangeListLabels,
|
||||||
@ -61,6 +58,7 @@ function ListView({
|
|||||||
resetProps,
|
resetProps,
|
||||||
shouldRefetchData,
|
shouldRefetchData,
|
||||||
showWarningDelete,
|
showWarningDelete,
|
||||||
|
slug,
|
||||||
toggleModalDelete,
|
toggleModalDelete,
|
||||||
showWarningDeleteAll,
|
showWarningDeleteAll,
|
||||||
toggleModalDeleteAll,
|
toggleModalDeleteAll,
|
||||||
@ -399,11 +397,6 @@ ListView.propTypes = {
|
|||||||
history: PropTypes.shape({
|
history: PropTypes.shape({
|
||||||
push: PropTypes.func.isRequired,
|
push: PropTypes.func.isRequired,
|
||||||
}),
|
}),
|
||||||
match: PropTypes.shape({
|
|
||||||
params: PropTypes.shape({
|
|
||||||
slug: PropTypes.string.isRequired,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
onChangeBulk: PropTypes.func.isRequired,
|
onChangeBulk: PropTypes.func.isRequired,
|
||||||
onChangeBulkSelectall: PropTypes.func.isRequired,
|
onChangeBulkSelectall: PropTypes.func.isRequired,
|
||||||
onChangeListLabels: PropTypes.func.isRequired,
|
onChangeListLabels: PropTypes.func.isRequired,
|
||||||
@ -414,6 +407,7 @@ ListView.propTypes = {
|
|||||||
shouldRefetchData: PropTypes.bool.isRequired,
|
shouldRefetchData: PropTypes.bool.isRequired,
|
||||||
showWarningDelete: PropTypes.bool.isRequired,
|
showWarningDelete: PropTypes.bool.isRequired,
|
||||||
showWarningDeleteAll: PropTypes.bool.isRequired,
|
showWarningDeleteAll: PropTypes.bool.isRequired,
|
||||||
|
slug: PropTypes.string.isRequired,
|
||||||
toggleModalDelete: PropTypes.func.isRequired,
|
toggleModalDelete: PropTypes.func.isRequired,
|
||||||
toggleModalDeleteAll: PropTypes.func.isRequired,
|
toggleModalDeleteAll: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { Suspense, lazy, memo, useEffect, useRef } from 'react';
|
import React, { Suspense, lazy, useEffect, useRef } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { bindActionCreators, compose } from 'redux';
|
import { bindActionCreators, compose } from 'redux';
|
||||||
@ -10,18 +10,11 @@ import {
|
|||||||
} from 'strapi-helper-plugin';
|
} from 'strapi-helper-plugin';
|
||||||
import { DndProvider } from 'react-dnd';
|
import { DndProvider } from 'react-dnd';
|
||||||
import HTML5Backend from 'react-dnd-html5-backend';
|
import HTML5Backend from 'react-dnd-html5-backend';
|
||||||
|
|
||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
|
|
||||||
import DragLayer from '../../components/DragLayer';
|
import DragLayer from '../../components/DragLayer';
|
||||||
|
|
||||||
const EditView = lazy(() => import('../EditView'));
|
|
||||||
const EditSettingsView = lazy(() => import('../EditSettingsView'));
|
const EditSettingsView = lazy(() => import('../EditSettingsView'));
|
||||||
const ListView = lazy(() => import('../ListView'));
|
const RecursivePath = lazy(() => import('../RecursivePath'));
|
||||||
const ListSettingsView = lazy(() => import('../ListSettingsView'));
|
|
||||||
const SettingViewModel = lazy(() => import('../SettingViewModel'));
|
|
||||||
const SettingViewGroup = lazy(() => import('../SettingViewGroup'));
|
|
||||||
const SettingsView = lazy(() => import('../SettingsView'));
|
|
||||||
|
|
||||||
import { deleteLayout, getData, getLayout, resetProps } from './actions';
|
import { deleteLayout, getData, getLayout, resetProps } from './actions';
|
||||||
import reducer from './reducer';
|
import reducer from './reducer';
|
||||||
@ -55,7 +48,7 @@ function Main({
|
|||||||
resetPropsRef.current = resetProps;
|
resetPropsRef.current = resetProps;
|
||||||
|
|
||||||
const shouldShowLoader =
|
const shouldShowLoader =
|
||||||
slug !== 'ctm-configurations' && layouts[slug] === undefined;
|
!pathname.includes('ctm-configurations/') && layouts[slug] === undefined;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getDataRef.current();
|
getDataRef.current();
|
||||||
@ -91,21 +84,10 @@ function Main({
|
|||||||
);
|
);
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
path: 'ctm-configurations/list-settings/:slug',
|
path: 'ctm-configurations/edit-settings/:type/:groupSlug',
|
||||||
comp: ListSettingsView,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'ctm-configurations/edit-settings/:type/:slug',
|
|
||||||
comp: EditSettingsView,
|
comp: EditSettingsView,
|
||||||
},
|
},
|
||||||
{
|
{ path: ':slug', comp: RecursivePath },
|
||||||
path: 'ctm-configurations/models/:name/:settingType',
|
|
||||||
comp: SettingViewModel,
|
|
||||||
},
|
|
||||||
{ path: 'ctm-configurations/groups/:name', comp: SettingViewGroup },
|
|
||||||
{ path: 'ctm-configurations/:type', comp: SettingsView },
|
|
||||||
{ path: ':slug/:id', comp: EditView },
|
|
||||||
{ path: ':slug', comp: ListView },
|
|
||||||
].map(({ path, comp }) => (
|
].map(({ path, comp }) => (
|
||||||
<Route
|
<Route
|
||||||
key={path}
|
key={path}
|
||||||
@ -162,7 +144,4 @@ const withConnect = connect(
|
|||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
);
|
);
|
||||||
|
|
||||||
export default compose(
|
export default compose(withConnect)(Main);
|
||||||
withConnect,
|
|
||||||
memo
|
|
||||||
)(Main);
|
|
||||||
|
|||||||
@ -0,0 +1,46 @@
|
|||||||
|
import React, { Suspense, lazy } from 'react';
|
||||||
|
import { Switch, Route, useRouteMatch, useParams } from 'react-router-dom';
|
||||||
|
import { LoadingIndicatorPage } from 'strapi-helper-plugin';
|
||||||
|
const EditView = lazy(() => import('../EditView'));
|
||||||
|
const EditSettingsView = lazy(() => import('../EditSettingsView'));
|
||||||
|
const ListView = lazy(() => import('../ListView'));
|
||||||
|
const ListSettingsView = lazy(() => import('../ListSettingsView'));
|
||||||
|
// import EditView from '../EditView';
|
||||||
|
// import EditSettingsView from '../EditSettingsView';
|
||||||
|
// import ListSettingsView from '../ListSettingsView';
|
||||||
|
// import ListView from '../ListView';
|
||||||
|
|
||||||
|
const RecursivePath = props => {
|
||||||
|
const { url } = useRouteMatch();
|
||||||
|
const { slug } = useParams();
|
||||||
|
const renderRoute = (routeProps, Component) => (
|
||||||
|
<Component {...props} {...routeProps} slug={slug} />
|
||||||
|
);
|
||||||
|
|
||||||
|
const routes = [
|
||||||
|
{
|
||||||
|
path: 'ctm-configurations/list-settings',
|
||||||
|
comp: ListSettingsView,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'ctm-configurations/edit-settings/:type',
|
||||||
|
comp: EditSettingsView,
|
||||||
|
},
|
||||||
|
{ path: ':id', comp: EditView },
|
||||||
|
{ path: '', comp: ListView },
|
||||||
|
].map(({ path, comp }) => (
|
||||||
|
<Route
|
||||||
|
key={path}
|
||||||
|
path={`${url}/${path}`}
|
||||||
|
render={props => renderRoute(props, comp)}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Suspense fallback={<LoadingIndicatorPage />}>
|
||||||
|
<Switch>{routes}</Switch>
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RecursivePath;
|
||||||
Loading…
x
Reference in New Issue
Block a user