mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
Merge pull request #10544 from strapi/cm/change-routing
[WIP] Change content manager routing
This commit is contained in:
commit
dbfbca533b
@ -66,9 +66,7 @@ class StrapiApp {
|
||||
`Expected link.to to be a string instead received ${typeof link.to}`
|
||||
);
|
||||
invariant(
|
||||
['/plugins/content-manager', '/plugins/content-type-builder', '/plugins/upload'].includes(
|
||||
link.to
|
||||
),
|
||||
['/plugins/content-type-builder', '/plugins/upload'].includes(link.to),
|
||||
'This method is not available for your plugin'
|
||||
);
|
||||
invariant(
|
||||
|
@ -15,7 +15,7 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }) => {
|
||||
<LinksContainer>
|
||||
<BaselineAlignment top size="16px" />
|
||||
<LeftMenuLink
|
||||
to="/plugins/content-manager"
|
||||
to="/content-manager"
|
||||
icon="book-open"
|
||||
intlLabel={{
|
||||
id: `content-manager.plugin.name`,
|
||||
|
@ -267,8 +267,7 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
|
||||
// Enable navigation and remove loaders
|
||||
dispatch(setStatus('resolved'));
|
||||
|
||||
// FIXME when updating the routing
|
||||
replace(`/plugins/content-manager/collectionType/${slug}/${data.id}${rawQuery}`);
|
||||
replace(`/content-manager/collectionType/${slug}/${data.id}${rawQuery}`);
|
||||
} catch (err) {
|
||||
trackUsageRef.current('didNotCreateEntry', { error: err, trackerProperty });
|
||||
displayErrors(err);
|
||||
|
@ -140,8 +140,8 @@ const DraggedField = forwardRef(
|
||||
<Link
|
||||
onClick={e => {
|
||||
e.stopPropagation();
|
||||
// FIXME when changing the routing
|
||||
goTo(`/plugins/content-manager/components/${componentUid}/configurations/edit`);
|
||||
|
||||
goTo(`/content-manager/components/${componentUid}/configurations/edit`);
|
||||
}}
|
||||
>
|
||||
<FontAwesomeIcon icon="cog" />
|
||||
|
@ -45,8 +45,7 @@ const DynamicComponent = ({ componentUid, friendlyName, icon, setIsOverDynamicZo
|
||||
isOver={isOver}
|
||||
onClick={() => {
|
||||
if (!isLoading && canAccess) {
|
||||
// FIXME when changing the routing
|
||||
push(`/plugins/content-manager/components/${componentUid}/configurations/edit`);
|
||||
push(`/content-manager/components/${componentUid}/configurations/edit`);
|
||||
}
|
||||
}}
|
||||
onMouseEvent={handleMouseEvent}
|
||||
|
@ -19,8 +19,7 @@ function ListItem({
|
||||
searchToPersist,
|
||||
targetModel,
|
||||
}) {
|
||||
// FIXME when changing the routing
|
||||
const to = `/plugins/content-manager/collectionType/${targetModel}/${data.id}`;
|
||||
const to = `/content-manager/collectionType/${targetModel}/${data.id}`;
|
||||
|
||||
const hasDraftAndPublish = has(data, 'published_at');
|
||||
|
||||
|
@ -230,8 +230,7 @@ function SelectWrapper({
|
||||
setIsOpen(true);
|
||||
};
|
||||
|
||||
// FIXME when changing the routing
|
||||
const to = `/plugins/content-manager/collectionType/${targetModel}/${value ? value.id : null}`;
|
||||
const to = `/content-manager/collectionType/${targetModel}/${value ? value.id : null}`;
|
||||
|
||||
const searchToPersist = stringify(buildParams(query, paramsToKeep), { encode: false });
|
||||
|
||||
|
@ -162,7 +162,7 @@ const SettingsViewWrapper = ({
|
||||
)}${pluginsQueryParams ? `&${pluginsQueryParams}` : ''}`;
|
||||
|
||||
// FIXME when changing the routing
|
||||
history.replace(`/plugins/content-manager/${kind}/${uid}?${goBackSearch}`);
|
||||
history.replace(`/content-manager/${kind}/${uid}?${goBackSearch}`);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -17,7 +17,7 @@ describe('CONTENT MANAGER | Containers | CollectionTypeFormWrapper | selectors',
|
||||
name: 'application::address.address',
|
||||
search: 'page=1&pageSize=50&_sort=city:ASC&plugins[i18n][locale]=fr',
|
||||
title: 'Addresses',
|
||||
to: '/plugins/content-manager/collectionType/application::address.address',
|
||||
to: '/content-manager/collectionType/application::address.address',
|
||||
uid: 'application::address.address',
|
||||
},
|
||||
{
|
||||
@ -25,7 +25,7 @@ describe('CONTENT MANAGER | Containers | CollectionTypeFormWrapper | selectors',
|
||||
name: 'application::category.category',
|
||||
search: 'page=1&pageSize=50&_sort=city:ASC&plugins[i18n][locale]=fr',
|
||||
title: 'Categories',
|
||||
to: '/plugins/content-manager/collectionType/application::category.category',
|
||||
to: '/content-manager/collectionType/application::category.category',
|
||||
uid: 'application::category.category',
|
||||
},
|
||||
],
|
||||
@ -38,7 +38,7 @@ describe('CONTENT MANAGER | Containers | CollectionTypeFormWrapper | selectors',
|
||||
name: 'application::address.address',
|
||||
search: 'page=1&pageSize=50&_sort=city:ASC&plugins[i18n][locale]=fr',
|
||||
title: 'Addresses',
|
||||
to: '/plugins/content-manager/collectionType/application::address.address',
|
||||
to: '/content-manager/collectionType/application::address.address',
|
||||
uid: 'application::address.address',
|
||||
},
|
||||
{
|
||||
@ -46,7 +46,7 @@ describe('CONTENT MANAGER | Containers | CollectionTypeFormWrapper | selectors',
|
||||
name: 'application::category.category',
|
||||
search: 'page=1&pageSize=50&_sort=city:ASC&plugins[i18n][locale]=fr',
|
||||
title: 'Categories',
|
||||
to: '/plugins/content-manager/collectionType/application::category.category',
|
||||
to: '/content-manager/collectionType/application::category.category',
|
||||
uid: 'application::category.category',
|
||||
},
|
||||
];
|
||||
|
@ -16,7 +16,7 @@ import useModels from './useModels';
|
||||
const cmPermissions = permissions.contentManager;
|
||||
|
||||
const App = () => {
|
||||
const contentTypeMatch = useRouteMatch(`/plugins/content-manager/:kind/:uid`);
|
||||
const contentTypeMatch = useRouteMatch(`/content-manager/:kind/:uid`);
|
||||
const { status, collectionTypeLinks, singleTypeLinks, models, refetchData } = useModels();
|
||||
const authorisedModels = [...collectionTypeLinks, ...singleTypeLinks];
|
||||
const { pathname } = useLocation();
|
||||
@ -27,17 +27,13 @@ const App = () => {
|
||||
|
||||
// Redirect the user to the 403 page
|
||||
// FIXME when changing the routing
|
||||
if (
|
||||
authorisedModels.length === 0 &&
|
||||
models.length > 0 &&
|
||||
pathname !== '/plugins/content-manager/403'
|
||||
) {
|
||||
return <Redirect to="/plugins/content-manager/403" />;
|
||||
if (authorisedModels.length === 0 && models.length > 0 && pathname !== '/content-manager/403') {
|
||||
return <Redirect to="/content-manager/403" />;
|
||||
}
|
||||
|
||||
// Redirect the user to the create content type page
|
||||
if (models.length === 0 && pathname !== '/plugins/content-manager/no-content-types') {
|
||||
return <Redirect to="/plugins/content-manager/no-content-types" />;
|
||||
if (models.length === 0 && pathname !== '/content-manager/no-content-types') {
|
||||
return <Redirect to="/content-manager/no-content-types" />;
|
||||
}
|
||||
|
||||
if (!contentTypeMatch && authorisedModels.length > 0) {
|
||||
@ -59,26 +55,26 @@ const App = () => {
|
||||
<LeftMenu />
|
||||
<div className="col-md-9" style={{ padding: 0 }}>
|
||||
<Switch>
|
||||
<Route path="/plugins/content-manager/components/:uid/configurations/edit">
|
||||
<Route path="/content-manager/components/:uid/configurations/edit">
|
||||
<CheckPagePermissions permissions={cmPermissions.componentsConfigurations}>
|
||||
<ComponentSettingsView />
|
||||
</CheckPagePermissions>
|
||||
</Route>
|
||||
<Route
|
||||
path="/plugins/content-manager/collectionType/:slug"
|
||||
path="/content-manager/collectionType/:slug"
|
||||
component={CollectionTypeRecursivePath}
|
||||
/>
|
||||
<Route
|
||||
path="/plugins/content-manager/singleType/:slug"
|
||||
path="/content-manager/singleType/:slug"
|
||||
component={SingleTypeRecursivePath}
|
||||
/>
|
||||
|
||||
{/* These pages must be defined */}
|
||||
<Route
|
||||
path="/plugins/content-manager/403"
|
||||
path="/content-manager/403"
|
||||
render={() => <div>TBD No rights to see the content types</div>}
|
||||
/>
|
||||
<Route path="/plugins/content-manager/no-content-types">
|
||||
<Route path="/content-manager/no-content-types">
|
||||
<NoContentType />
|
||||
</Route>
|
||||
<Route path="" component={NotFound} />
|
||||
|
@ -9,8 +9,6 @@ import ContentManagerApp from '..';
|
||||
import cmReducers from '../../../../reducers';
|
||||
import useModels from '../useModels';
|
||||
|
||||
const pluginId = 'content-manager';
|
||||
|
||||
jest.mock('../useModels', () =>
|
||||
jest.fn(() => {
|
||||
return {};
|
||||
@ -43,7 +41,7 @@ describe('Content manager | App | main', () => {
|
||||
uid: 'category',
|
||||
title: 'Categories',
|
||||
name: 'category',
|
||||
to: `/plugins/${pluginId}/collectionType/category`,
|
||||
to: '/content-manager/collectionType/category',
|
||||
kind: 'collectionType',
|
||||
isDisplayed: true,
|
||||
permissions: [
|
||||
@ -83,9 +81,9 @@ describe('Content manager | App | main', () => {
|
||||
};
|
||||
useModels.mockImplementation(() => contentManagerState);
|
||||
const rootReducer = combineReducers(cmReducers);
|
||||
const store = createStore(rootReducer, { [`${pluginId}_app`]: contentManagerState });
|
||||
const store = createStore(rootReducer, { 'content-manager_app': contentManagerState });
|
||||
const history = createMemoryHistory();
|
||||
history.push(`/plugins/${pluginId}`);
|
||||
history.push('/content-manager');
|
||||
|
||||
const { container } = render(
|
||||
<Provider store={store}>
|
||||
@ -97,7 +95,7 @@ describe('Content manager | App | main', () => {
|
||||
|
||||
expect(screen.getByText('Home page')).toBeVisible();
|
||||
expect(screen.getByText('Categories')).toBeVisible();
|
||||
expect(history.location.pathname).toEqual(`/plugins/${pluginId}/collectionType/category`);
|
||||
expect(history.location.pathname).toEqual('/content-manager/collectionType/category');
|
||||
expect(container.firstChild).toMatchInlineSnapshot(`
|
||||
.c2 {
|
||||
margin-bottom: 0;
|
||||
@ -344,7 +342,7 @@ describe('Content manager | App | main', () => {
|
||||
<a
|
||||
aria-current="page"
|
||||
class="active"
|
||||
href="/plugins/content-manager/collectionType/category"
|
||||
href="/content-manager/collectionType/category"
|
||||
>
|
||||
<p>
|
||||
Categories
|
||||
@ -416,7 +414,7 @@ describe('Content manager | App | main', () => {
|
||||
uid: 'homepage',
|
||||
title: 'Home page',
|
||||
name: 'homepage',
|
||||
to: `/plugins/${pluginId}/homepage`,
|
||||
to: '/content-manager/homepage',
|
||||
kind: 'singleType',
|
||||
isDisplayed: true,
|
||||
permissions: [
|
||||
@ -440,9 +438,9 @@ describe('Content manager | App | main', () => {
|
||||
};
|
||||
useModels.mockImplementation(() => contentManagerState);
|
||||
const rootReducer = combineReducers(cmReducers);
|
||||
const store = createStore(rootReducer, { [`${pluginId}_app`]: contentManagerState });
|
||||
const store = createStore(rootReducer, { 'content-manager_app': contentManagerState });
|
||||
const history = createMemoryHistory();
|
||||
history.push(`/plugins/${pluginId}`);
|
||||
history.push('/content-manager');
|
||||
|
||||
render(
|
||||
<Provider store={store}>
|
||||
@ -452,7 +450,7 @@ describe('Content manager | App | main', () => {
|
||||
</Provider>
|
||||
);
|
||||
|
||||
expect(history.location.pathname).toEqual(`/plugins/${pluginId}/homepage`);
|
||||
expect(history.location.pathname).toEqual('/content-manager/homepage');
|
||||
});
|
||||
|
||||
it('should redirect to 403 page', () => {
|
||||
@ -478,8 +476,8 @@ describe('Content manager | App | main', () => {
|
||||
})
|
||||
);
|
||||
const rootReducer = combineReducers(cmReducers);
|
||||
const store = createStore(rootReducer, { [`${pluginId}_app`]: contentManagerState });
|
||||
history.push(`/plugins/${pluginId}/collectionType/category`);
|
||||
const store = createStore(rootReducer, { 'content-manager_app': contentManagerState });
|
||||
history.push('/content-manager/collectionType/category');
|
||||
|
||||
render(
|
||||
<Provider store={store}>
|
||||
@ -489,7 +487,7 @@ describe('Content manager | App | main', () => {
|
||||
</Provider>
|
||||
);
|
||||
|
||||
expect(history.location.pathname).toEqual(`/plugins/${pluginId}/403`);
|
||||
expect(history.location.pathname).toEqual('/content-manager/403');
|
||||
});
|
||||
|
||||
it('should redirect to the no-content-types page', () => {
|
||||
@ -508,8 +506,8 @@ describe('Content manager | App | main', () => {
|
||||
})
|
||||
);
|
||||
const rootReducer = combineReducers(cmReducers);
|
||||
const store = createStore(rootReducer, { [`${pluginId}_app`]: contentManagerState });
|
||||
history.push(`/plugins/${pluginId}/collectionType/category`);
|
||||
const store = createStore(rootReducer, { 'content-manager_app': contentManagerState });
|
||||
history.push('/content-manager/collectionType/category');
|
||||
|
||||
render(
|
||||
<Provider store={store}>
|
||||
@ -519,6 +517,6 @@ describe('Content manager | App | main', () => {
|
||||
</Provider>
|
||||
);
|
||||
|
||||
expect(history.location.pathname).toEqual(`/plugins/${pluginId}/no-content-types`);
|
||||
expect(history.location.pathname).toEqual('/content-manager/no-content-types');
|
||||
});
|
||||
});
|
||||
|
@ -34,7 +34,7 @@ const generateLinks = (links, type, configurations = []) => {
|
||||
search,
|
||||
kind: link.kind,
|
||||
title: link.info.label,
|
||||
to: `/plugins/content-manager/${link.kind}/${link.uid}`,
|
||||
to: `/content-manager/${link.kind}/${link.uid}`,
|
||||
uid: link.uid,
|
||||
// Used for the list item key in the helper plugin
|
||||
name: link.uid,
|
||||
|
@ -46,7 +46,7 @@ describe('ADMIN | LeftMenu | utils', () => {
|
||||
|
||||
const expected = [
|
||||
{
|
||||
to: '/plugins/content-manager/collectionType/application::address.address',
|
||||
to: '/content-manager/collectionType/application::address.address',
|
||||
isDisplayed: true,
|
||||
search: `page=1&pageSize=2&_sort=name:ASC`,
|
||||
permissions: [
|
||||
@ -65,7 +65,7 @@ describe('ADMIN | LeftMenu | utils', () => {
|
||||
name: 'application::address.address',
|
||||
},
|
||||
{
|
||||
to: '/plugins/content-manager/singleType/application::test1.test1',
|
||||
to: '/content-manager/singleType/application::test1.test1',
|
||||
isDisplayed: true,
|
||||
search: null,
|
||||
kind: 'singleType',
|
||||
@ -125,7 +125,7 @@ describe('ADMIN | LeftMenu | utils', () => {
|
||||
search: null,
|
||||
kind: 'collectionType',
|
||||
title: 'Addresses',
|
||||
to: '/plugins/content-manager/collectionType/application::address.address',
|
||||
to: '/content-manager/collectionType/application::address.address',
|
||||
uid: 'application::address.address',
|
||||
name: 'application::address.address',
|
||||
permissions: [
|
||||
@ -146,7 +146,7 @@ describe('ADMIN | LeftMenu | utils', () => {
|
||||
kind: 'singleType',
|
||||
search: null,
|
||||
title: 'Test 1',
|
||||
to: '/plugins/content-manager/singleType/application::test1.test1',
|
||||
to: '/content-manager/singleType/application::test1.test1',
|
||||
uid: 'application::test1.test1',
|
||||
name: 'application::test1.test1',
|
||||
permissions: [
|
||||
|
@ -92,7 +92,7 @@ describe('checkPermissions', () => {
|
||||
const expected = {
|
||||
authorizedCtLinks: [
|
||||
{
|
||||
destination: '/plugins/content-manager/collectionType/application::address.address',
|
||||
destination: '/content-manager/collectionType/application::address.address',
|
||||
icon: 'circle',
|
||||
isDisplayed: true,
|
||||
label: 'address',
|
||||
@ -109,7 +109,7 @@ describe('checkPermissions', () => {
|
||||
search: 'page=1&pageSize=10&_sort=name:ASC',
|
||||
},
|
||||
{
|
||||
destination: '/plugins/content-manager/collectionType/application::article.article',
|
||||
destination: '/content-manager/collectionType/application::article.article',
|
||||
icon: 'circle',
|
||||
isDisplayed: true,
|
||||
label: 'article',
|
||||
|
@ -51,7 +51,7 @@ const EditView = ({
|
||||
}, [isSingleType]);
|
||||
|
||||
// FIXME when changing the routing
|
||||
const configurationsURL = `/plugins/content-manager/${
|
||||
const configurationsURL = `/content-manager/${
|
||||
isSingleType ? 'singleType' : 'collectionType'
|
||||
}/${slug}/configurations/edit`;
|
||||
const currentContentTypeLayoutData = useMemo(() => get(layout, ['contentType'], {}), [layout]);
|
||||
|
@ -96,7 +96,7 @@ const Admin = () => {
|
||||
<Route path="/" component={HomePage} exact />
|
||||
<Route path="/me" component={ProfilePage} exact />
|
||||
|
||||
<Route path="/plugins/content-manager" component={CM} />
|
||||
<Route path="/content-manager" component={CM} />
|
||||
<Route path="/plugins/content-type-builder" component={CTB} />
|
||||
<Route path="/plugins/upload" component={Upload} />
|
||||
{routes}
|
||||
|
@ -54,7 +54,7 @@ describe('<Admin />', () => {
|
||||
useStrapiApp.mockImplementation(() => ({
|
||||
menu: [
|
||||
{
|
||||
to: '/plugins/content-manager',
|
||||
to: '/plugins/ctb',
|
||||
},
|
||||
{
|
||||
to: '/plugins/documentation',
|
||||
|
@ -225,10 +225,13 @@ describe('ADMIN | StrapiApp', () => {
|
||||
it('addCorePluginMenuLink should add a link to the menu', () => {
|
||||
const app = StrapiApp({ middlewares, reducers, library, locales });
|
||||
const link = {
|
||||
to: '/plugins/content-manager',
|
||||
to: '/plugins/content-type-builder',
|
||||
icon: 'book',
|
||||
permissions: [],
|
||||
intlLabel: { id: 'content-manager.plugin.name', defaultMessage: 'Content Manager' },
|
||||
intlLabel: {
|
||||
id: 'content-type-builder.plugin.name',
|
||||
defaultMessage: 'Content Type builder',
|
||||
},
|
||||
};
|
||||
|
||||
app.addCorePluginMenuLink(link);
|
||||
|
@ -50,9 +50,9 @@ const LinkToCMSettingsView = ({ isTemporary, isInContentTypeView, contentTypeKin
|
||||
}
|
||||
|
||||
if (isInContentTypeView) {
|
||||
push(`/plugins/content-manager/collectionType/${targetUid}/configurations/edit`);
|
||||
push(`/content-manager/collectionType/${targetUid}/configurations/edit`);
|
||||
} else {
|
||||
push(`/plugins/content-manager/components/${targetUid}/configurations/edit`);
|
||||
push(`/content-manager/components/${targetUid}/configurations/edit`);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -51,7 +51,7 @@ const CMEditViewLocalePicker = ({
|
||||
|
||||
if (status === 'did-not-create-locale') {
|
||||
push({
|
||||
pathname: `/plugins/content-manager/collectionType/${slug}/create`,
|
||||
pathname: `/content-manager/collectionType/${slug}/create`,
|
||||
search: stringify(defaultParams, { encode: false }),
|
||||
});
|
||||
|
||||
@ -59,7 +59,7 @@ const CMEditViewLocalePicker = ({
|
||||
}
|
||||
|
||||
push({
|
||||
pathname: `/plugins/content-manager/collectionType/${slug}/${id}`,
|
||||
pathname: `/content-manager/collectionType/${slug}/${id}`,
|
||||
search: stringify(defaultParams, { encode: false }),
|
||||
});
|
||||
};
|
||||
|
@ -46,7 +46,7 @@ const LocalePicker = () => {
|
||||
const [{ query }, setQuery] = useQueryParams();
|
||||
const {
|
||||
params: { slug },
|
||||
} = useRouteMatch('/plugins/content-manager/collectionType/:slug');
|
||||
} = useRouteMatch('/content-manager/collectionType/:slug');
|
||||
const isFieldLocalized = useHasI18n();
|
||||
const { createPermissions, readPermissions } = useContentTypePermissions(slug);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user