mirror of
https://github.com/strapi/strapi.git
synced 2025-08-13 11:17:42 +00:00
Fix after PR comments
Signed-off-by: HichamELBSI <elabbassih@gmail.com>
This commit is contained in:
parent
4f5cd5a209
commit
fc1541330b
@ -37,7 +37,7 @@ const LeftMenuLinkContainer = ({ plugins }) => {
|
|||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
// Generate the list of plugin links
|
// Generate the list of plugin links (plugins without a mainComponent should not appear in the left menu)
|
||||||
const pluginsLinks = Object.values(plugins)
|
const pluginsLinks = Object.values(plugins)
|
||||||
.filter(
|
.filter(
|
||||||
plugin =>
|
plugin =>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"contentTypes": {
|
"collectionType": {
|
||||||
"id": "app.components.LeftMenuLinkContainer.contentTypes",
|
"id": "app.components.LeftMenuLinkContainer.collectionTypes",
|
||||||
"defaultMessage": "Collection Types"
|
"defaultMessage": "Collection Types"
|
||||||
},
|
},
|
||||||
"singleTypes": {
|
"singleType": {
|
||||||
"id": "app.components.LeftMenuLinkContainer.singleTypes",
|
"id": "app.components.LeftMenuLinkContainer.singleTypes",
|
||||||
"defaultMessage": "Single Types"
|
"defaultMessage": "Single Types"
|
||||||
},
|
},
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const SearchButton = styled.button`
|
||||||
|
padding: 0 10px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default SearchButton;
|
@ -0,0 +1,29 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const Title = styled.div`
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding-left: 2rem;
|
||||||
|
padding-right: 1.6rem;
|
||||||
|
padding-top: 0.7rem;
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
color: ${props => props.theme.main.colors.leftMenu['title-color']};
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
letter-spacing: 0.1rem;
|
||||||
|
font-weight: 800;
|
||||||
|
`;
|
||||||
|
|
||||||
|
Title.defaultProps = {
|
||||||
|
theme: {
|
||||||
|
main: {
|
||||||
|
colors: {
|
||||||
|
leftMenu: {
|
||||||
|
'title-color': '#5b626f',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Title;
|
@ -2,28 +2,12 @@ import React, { useState, createRef, useEffect } from 'react';
|
|||||||
import { camelCase } from 'lodash';
|
import { camelCase } from 'lodash';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import styled from 'styled-components';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
|
||||||
import messages from '../LeftMenuLinkContainer/messages.json';
|
import messages from '../LeftMenuLinkContainer/messages.json';
|
||||||
import Search from './Search';
|
import Search from './Search';
|
||||||
|
import Title from './Title';
|
||||||
const Title = styled.div`
|
import SearchButton from './SearchButton';
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding-left: 2rem;
|
|
||||||
padding-right: 1.6rem;
|
|
||||||
padding-top: 0.7rem;
|
|
||||||
margin-bottom: 0.8rem;
|
|
||||||
color: ${props => props.theme.main.colors.leftMenu['title-color']};
|
|
||||||
text-transform: uppercase;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
letter-spacing: 0.1rem;
|
|
||||||
font-weight: 800;
|
|
||||||
`;
|
|
||||||
const SearchButton = styled.button`
|
|
||||||
padding: 0 10px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const LeftMenuLinkHeader = ({ section, searchable, setSearch, search }) => {
|
const LeftMenuLinkHeader = ({ section, searchable, setSearch, search }) => {
|
||||||
const [showSearch, setShowSearch] = useState(false);
|
const [showSearch, setShowSearch] = useState(false);
|
||||||
@ -63,12 +47,16 @@ const LeftMenuLinkHeader = ({ section, searchable, setSearch, search }) => {
|
|||||||
<div>
|
<div>
|
||||||
<FontAwesomeIcon icon="search" />
|
<FontAwesomeIcon icon="search" />
|
||||||
</div>
|
</div>
|
||||||
|
<FormattedMessage id="components.Search.placeholder">
|
||||||
|
{message => (
|
||||||
<Search
|
<Search
|
||||||
ref={ref}
|
ref={ref}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
value={search}
|
value={search}
|
||||||
placeholder="search…"
|
placeholder={message}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
</FormattedMessage>
|
||||||
<SearchButton onClick={clearSearch}>
|
<SearchButton onClick={clearSearch}>
|
||||||
<FontAwesomeIcon icon="times" />
|
<FontAwesomeIcon icon="times" />
|
||||||
</SearchButton>
|
</SearchButton>
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const EmptyLinksList = styled.div`
|
||||||
|
color: ${props => props.theme.main.colors.white};
|
||||||
|
padding-left: 1.6rem;
|
||||||
|
padding-right: 1.6rem;
|
||||||
|
font-weight: 300;
|
||||||
|
min-height: 3.6rem;
|
||||||
|
padding-top: 0.2rem;
|
||||||
|
`;
|
||||||
|
|
||||||
|
EmptyLinksList.defaultProps = {
|
||||||
|
theme: {
|
||||||
|
main: {
|
||||||
|
colors: {
|
||||||
|
white: '#ffffff',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EmptyLinksList;
|
@ -0,0 +1,8 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const LeftMenuListLink = styled.div`
|
||||||
|
max-height: 180px;
|
||||||
|
overflow: auto;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default LeftMenuListLink;
|
@ -1,25 +1,13 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import matchSorter from 'match-sorter';
|
import matchSorter from 'match-sorter';
|
||||||
import styled from 'styled-components';
|
|
||||||
import { sortBy } from 'lodash';
|
import { sortBy } from 'lodash';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
import LeftMenuLink from '../LeftMenuLink';
|
import LeftMenuLink from '../LeftMenuLink';
|
||||||
import LeftMenuLinkHeader from '../LeftMenuLinkHeader';
|
import LeftMenuLinkHeader from '../LeftMenuLinkHeader';
|
||||||
|
import EmptyLinksList from './EmptyLinksList';
|
||||||
const LeftMenuListLink = styled.div`
|
import LeftMenuListLink from './LeftMenuListLink';
|
||||||
max-height: 180px;
|
|
||||||
overflow: auto;
|
|
||||||
`;
|
|
||||||
const EmptyLinksList = styled.div`
|
|
||||||
color: ${props => props.theme.main.colors.white};
|
|
||||||
padding-left: 1.6rem;
|
|
||||||
padding-right: 1.6rem;
|
|
||||||
font-weight: 300;
|
|
||||||
min-height: 3.6rem;
|
|
||||||
padding-top: 0.2rem;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const LeftMenuLinksSection = ({
|
const LeftMenuLinksSection = ({
|
||||||
section,
|
section,
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
"app.components.LeftMenuLinkContainer.general": "General",
|
"app.components.LeftMenuLinkContainer.general": "General",
|
||||||
"app.components.LeftMenuLinkContainer.installNewPlugin": "Marketplace",
|
"app.components.LeftMenuLinkContainer.installNewPlugin": "Marketplace",
|
||||||
"app.components.LeftMenuLinkContainer.listPlugins": "Plugins",
|
"app.components.LeftMenuLinkContainer.listPlugins": "Plugins",
|
||||||
"app.components.LeftMenuLinkContainer.contentTypes": "Collection Types",
|
"app.components.LeftMenuLinkContainer.collectionTypes": "Collection Types",
|
||||||
"app.components.LeftMenuLinkContainer.singleTypes": "Single Types",
|
"app.components.LeftMenuLinkContainer.singleTypes": "Single Types",
|
||||||
"app.components.LeftMenuLinkContainer.noPluginsInstalled": "No plugins installed yet",
|
"app.components.LeftMenuLinkContainer.noPluginsInstalled": "No plugins installed yet",
|
||||||
"app.components.LeftMenuLinkContainer.plugins": "Plugins",
|
"app.components.LeftMenuLinkContainer.plugins": "Plugins",
|
||||||
@ -143,6 +143,7 @@
|
|||||||
"components.PageFooter.select": "entries per page",
|
"components.PageFooter.select": "entries per page",
|
||||||
"components.ProductionBlocker.description": "For safety purposes we have to disable this plugin in other environments.",
|
"components.ProductionBlocker.description": "For safety purposes we have to disable this plugin in other environments.",
|
||||||
"components.ProductionBlocker.header": "This plugin is only available in development.",
|
"components.ProductionBlocker.header": "This plugin is only available in development.",
|
||||||
|
"components.Search.placeholder": "Search...",
|
||||||
"components.Wysiwyg.ToggleMode.markdown": "Switch to markdown",
|
"components.Wysiwyg.ToggleMode.markdown": "Switch to markdown",
|
||||||
"components.Wysiwyg.ToggleMode.preview": "Switch to preview",
|
"components.Wysiwyg.ToggleMode.preview": "Switch to preview",
|
||||||
"components.Wysiwyg.collapse": "Collapse",
|
"components.Wysiwyg.collapse": "Collapse",
|
||||||
|
@ -139,6 +139,7 @@
|
|||||||
"components.PageFooter.select": "entrées par page",
|
"components.PageFooter.select": "entrées par page",
|
||||||
"components.ProductionBlocker.description": "Pour des raisons de sécurité il est désactivé dans les autres environnements.",
|
"components.ProductionBlocker.description": "Pour des raisons de sécurité il est désactivé dans les autres environnements.",
|
||||||
"components.ProductionBlocker.header": "Ce plugin est disponible uniquement en développement.",
|
"components.ProductionBlocker.header": "Ce plugin est disponible uniquement en développement.",
|
||||||
|
"components.Search.placeholder": "Rechercher...",
|
||||||
"components.Wysiwyg.ToggleMode.markdown": "Retour au markdown",
|
"components.Wysiwyg.ToggleMode.markdown": "Retour au markdown",
|
||||||
"components.Wysiwyg.ToggleMode.preview": "Voir une prévisualisation",
|
"components.Wysiwyg.ToggleMode.preview": "Voir une prévisualisation",
|
||||||
"components.Wysiwyg.collapse": "Fermer",
|
"components.Wysiwyg.collapse": "Fermer",
|
||||||
|
@ -74,7 +74,6 @@
|
|||||||
"app.components.LeftMenuLinkContainer.general": "Ogólne",
|
"app.components.LeftMenuLinkContainer.general": "Ogólne",
|
||||||
"app.components.LeftMenuLinkContainer.installNewPlugin": "Sklep",
|
"app.components.LeftMenuLinkContainer.installNewPlugin": "Sklep",
|
||||||
"app.components.LeftMenuLinkContainer.listPlugins": "Wtyczki",
|
"app.components.LeftMenuLinkContainer.listPlugins": "Wtyczki",
|
||||||
"app.components.LeftMenuLinkContainer.contentTypes": "Modele",
|
|
||||||
"app.components.LeftMenuLinkContainer.noPluginsInstalled": "Brak zainstalowanych wtyczek",
|
"app.components.LeftMenuLinkContainer.noPluginsInstalled": "Brak zainstalowanych wtyczek",
|
||||||
"app.components.LeftMenuLinkContainer.plugins": "Wtyczki",
|
"app.components.LeftMenuLinkContainer.plugins": "Wtyczki",
|
||||||
"app.components.LeftMenuLinkContainer.settings": "Ustawienia",
|
"app.components.LeftMenuLinkContainer.settings": "Ustawienia",
|
||||||
|
@ -73,7 +73,6 @@
|
|||||||
"app.components.LeftMenuLinkContainer.general": "Genel",
|
"app.components.LeftMenuLinkContainer.general": "Genel",
|
||||||
"app.components.LeftMenuLinkContainer.installNewPlugin": "Mağaza",
|
"app.components.LeftMenuLinkContainer.installNewPlugin": "Mağaza",
|
||||||
"app.components.LeftMenuLinkContainer.listPlugins": "Eklentiler",
|
"app.components.LeftMenuLinkContainer.listPlugins": "Eklentiler",
|
||||||
"app.components.LeftMenuLinkContainer.contentTypes": "İçerik Tipi",
|
|
||||||
"app.components.LeftMenuLinkContainer.noPluginsInstalled": "Yüklenen eklenti bulunmamaktadır.",
|
"app.components.LeftMenuLinkContainer.noPluginsInstalled": "Yüklenen eklenti bulunmamaktadır.",
|
||||||
"app.components.LeftMenuLinkContainer.plugins": "Eklentiler",
|
"app.components.LeftMenuLinkContainer.plugins": "Eklentiler",
|
||||||
"app.components.LeftMenuLinkContainer.settings": "Ayarlar",
|
"app.components.LeftMenuLinkContainer.settings": "Ayarlar",
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
"app.components.LeftMenuLinkContainer.general": "常规",
|
"app.components.LeftMenuLinkContainer.general": "常规",
|
||||||
"app.components.LeftMenuLinkContainer.installNewPlugin": "市场",
|
"app.components.LeftMenuLinkContainer.installNewPlugin": "市场",
|
||||||
"app.components.LeftMenuLinkContainer.listPlugins": "插件",
|
"app.components.LeftMenuLinkContainer.listPlugins": "插件",
|
||||||
"app.components.LeftMenuLinkContainer.contentTypes": "Content Types",
|
"app.components.LeftMenuLinkContainer.collectionTypes": "Collection Types",
|
||||||
"app.components.LeftMenuLinkContainer.noPluginsInstalled": "还没有安装插件",
|
"app.components.LeftMenuLinkContainer.noPluginsInstalled": "还没有安装插件",
|
||||||
"app.components.LeftMenuLinkContainer.plugins": "插件",
|
"app.components.LeftMenuLinkContainer.plugins": "插件",
|
||||||
"app.components.LeftMenuLinkContainer.settings": "设置",
|
"app.components.LeftMenuLinkContainer.settings": "设置",
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { chain } from 'lodash';
|
||||||
import { request } from 'strapi-helper-plugin';
|
import { request } from 'strapi-helper-plugin';
|
||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
|
|
||||||
@ -21,22 +22,15 @@ const Initializer = ({ updatePlugin }) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await request(requestURL, { method: 'GET' });
|
const { data } = await request(requestURL, { method: 'GET' });
|
||||||
const menu = [
|
|
||||||
{
|
|
||||||
name: 'Content Types',
|
|
||||||
links: data.filter(
|
|
||||||
contentType => contentType.schema.kind === 'collectionType'
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Single Types',
|
|
||||||
links: data.filter(
|
|
||||||
contentType => contentType.schema.kind === 'singleType'
|
|
||||||
),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
ref.current(pluginId, 'leftMenuSections', menu);
|
ref.current(
|
||||||
|
pluginId,
|
||||||
|
'leftMenuSections',
|
||||||
|
chain(data)
|
||||||
|
.groupBy('schema.kind')
|
||||||
|
.map((value, key) => ({ name: key, links: value }))
|
||||||
|
.value()
|
||||||
|
);
|
||||||
ref.current(pluginId, 'isReady', true);
|
ref.current(pluginId, 'isReady', true);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
strapi.notification.error('content-manager.error.model.fetch');
|
strapi.notification.error('content-manager.error.model.fetch');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user