mirror of
https://github.com/strapi/strapi.git
synced 2025-11-11 07:39:16 +00:00
Merge branch 'master' into fix/cm-issues
This commit is contained in:
commit
051ee9b468
@ -4,11 +4,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import React, { memo } from 'react';
|
import React, { memo, useMemo } from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { get, upperFirst } from 'lodash';
|
import { get, upperFirst } from 'lodash';
|
||||||
import { auth } from 'strapi-helper-plugin';
|
import { auth, LoadingIndicatorPage } from 'strapi-helper-plugin';
|
||||||
import PageTitle from '../../components/PageTitle';
|
import PageTitle from '../../components/PageTitle';
|
||||||
|
import { useModels } from '../../hooks';
|
||||||
|
|
||||||
import useFetch from './hooks';
|
import useFetch from './hooks';
|
||||||
import { ALink, Block, Container, LinkWrapper, P, Wave, Separator } from './components';
|
import { ALink, Block, Container, LinkWrapper, P, Wave, Separator } from './components';
|
||||||
@ -54,6 +55,9 @@ const SOCIAL_LINKS = [
|
|||||||
|
|
||||||
const HomePage = ({ global: { plugins }, history: { push } }) => {
|
const HomePage = ({ global: { plugins }, history: { push } }) => {
|
||||||
const { error, isLoading, posts } = useFetch();
|
const { error, isLoading, posts } = useFetch();
|
||||||
|
// Temporary until we develop the menu API
|
||||||
|
const { collectionTypes, singleTypes, isLoading: isLoadingForModels } = useModels();
|
||||||
|
|
||||||
const handleClick = e => {
|
const handleClick = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -61,10 +65,18 @@ const HomePage = ({ global: { plugins }, history: { push } }) => {
|
|||||||
'/plugins/content-type-builder/content-types/plugins::users-permissions.user?modalType=contentType&kind=collectionType&actionType=create&settingType=base&forTarget=contentType&headerId=content-type-builder.modalForm.contentType.header-create&header_icon_isCustom_1=false&header_icon_name_1=contentType&header_label_1=null'
|
'/plugins/content-type-builder/content-types/plugins::users-permissions.user?modalType=contentType&kind=collectionType&actionType=create&settingType=base&forTarget=contentType&headerId=content-type-builder.modalForm.contentType.header-create&header_icon_isCustom_1=false&header_icon_name_1=contentType&header_label_1=null'
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const hasAlreadyCreatedContentTypes =
|
|
||||||
get(plugins, ['content-manager', 'leftMenuSections', '0', 'links'], []).filter(
|
const hasAlreadyCreatedContentTypes = useMemo(() => {
|
||||||
contentType => contentType.isDisplayed === true
|
const filterContentTypes = contentTypes => contentTypes.filter(c => c.isDisplayed);
|
||||||
).length > 1;
|
|
||||||
|
return (
|
||||||
|
filterContentTypes(collectionTypes).length > 1 || filterContentTypes(singleTypes).length > 0
|
||||||
|
);
|
||||||
|
}, [collectionTypes, singleTypes]);
|
||||||
|
|
||||||
|
if (isLoadingForModels) {
|
||||||
|
return <LoadingIndicatorPage />;
|
||||||
|
}
|
||||||
|
|
||||||
const headerId = hasAlreadyCreatedContentTypes
|
const headerId = hasAlreadyCreatedContentTypes
|
||||||
? 'HomePage.greetings'
|
? 'HomePage.greetings'
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Creatable from 'react-select/creatable';
|
import Creatable from 'react-select/creatable';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { uniqBy } from 'lodash';
|
||||||
import useDataManager from '../../hooks/useDataManager';
|
import useDataManager from '../../hooks/useDataManager';
|
||||||
|
|
||||||
const CreatableSelect = ({ onChange, name, styles, value }) => {
|
const CreatableSelect = ({ onChange, name, styles, value }) => {
|
||||||
@ -19,7 +20,13 @@ const CreatableSelect = ({ onChange, name, styles, value }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const formatOptions = () => {
|
const formatOptions = () => {
|
||||||
return allComponentsCategories.map(cat => ({ value: cat, label: cat }));
|
const options = allComponentsCategories.map(cat => ({ value: cat, label: cat }));
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
return uniqBy(options.concat({ value, label: value }), 'value');
|
||||||
|
}
|
||||||
|
|
||||||
|
return options;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getValue = () => {
|
const getValue = () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user