Remove icon from ctb

Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
soupette 2021-10-22 14:30:30 +02:00
parent ec8a2e0ca8
commit fc42675233
10 changed files with 45 additions and 51 deletions

View File

@ -114,6 +114,10 @@ class StrapiApp {
link.Component && typeof link.Component === 'function',
`link.Component should be a valid React Component`
);
invariant(
link.icon && typeof link.icon === 'function',
`link.Icon should be a valid React Component`
);
this.menu.push(link);
};

View File

@ -23,13 +23,6 @@ import Logout from '@strapi/icons/Logout';
import { auth, usePersistentState, useAppInfos } from '@strapi/helper-plugin';
import useConfigurations from '../../hooks/useConfigurations';
// TODO: remove when font-awesome will be removed
const IconWrapper = styled.span`
svg.svg-inline--fa.fa-w-20 {
width: 1rem;
}
`;
const LinkUserWrapper = styled(Box)`
width: ${150 / 16}rem;
position: absolute;
@ -105,19 +98,15 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }) => {
{pluginsSectionLinks.length > 0 ? (
<NavSection label="Plugins">
{pluginsSectionLinks.map(link => (
<NavLink
to={link.to}
key={link.to}
icon={
<IconWrapper>
<FontAwesomeIcon icon={link.icon} />
</IconWrapper>
}
>
{formatMessage(link.intlLabel)}
</NavLink>
))}
{pluginsSectionLinks.map(link => {
const Icon = link.icon;
return (
<NavLink to={link.to} key={link.to} icon={<Icon />}>
{formatMessage(link.intlLabel)}
</NavLink>
);
})}
</NavSection>
) : null}

View File

@ -82,7 +82,7 @@ Providers.propTypes = {
menu: PropTypes.arrayOf(
PropTypes.shape({
to: PropTypes.string.isRequired,
icon: PropTypes.string,
icon: PropTypes.func.isRequired,
intlLabel: PropTypes.shape({
id: PropTypes.string.isRequired,
defaultMessage: PropTypes.string.isRequired,

View File

@ -1,18 +1,11 @@
class Plugin {
constructor(pluginConf) {
this.apis = pluginConf.apis || {};
this.description = pluginConf.description;
this.icon = pluginConf.icon;
this.initializer = pluginConf.initializer || null;
this.injectionZones = pluginConf.injectionZones || {};
this.isReady = pluginConf.isReady !== undefined ? pluginConf.isReady : true;
this.isRequired = pluginConf.isRequired;
// this.mainComponent = pluginConf.mainComponent || null;
// TODO
// this.menu = pluginConf.menu || null;
this.name = pluginConf.name;
this.pluginId = pluginConf.id;
this.pluginLogo = pluginConf.pluginLogo;
}
getInjectedComponents(containerName, blockName) {

View File

@ -10,11 +10,11 @@ import uploadPlugin from '../../../upload/strapi-admin';
const plugins = {
'@strapi/plugin-content-type-builder': ctbPlugin,
'@strapi/plugin-i18n': i18nPlugin,
'@strapi/plugin-email': emailPlugin,
'@strapi/plugin-upload': uploadPlugin,
'@strapi/plugin-users-permissions': usersPermissionsPlugin,
'@strapi/plugin-documentation': documentationPlugin,
// '@strapi/plugin-i18n': i18nPlugin,
// '@strapi/plugin-email': emailPlugin,
// '@strapi/plugin-upload': uploadPlugin,
// '@strapi/plugin-users-permissions': usersPermissionsPlugin,
// '@strapi/plugin-documentation': documentationPlugin,
// '@strapi/plugin-graphql': graphqlPlugin,
// '@strapi/plugin-sentry': sentryPlugin,
};

View File

@ -1 +0,0 @@
<svg width="30" height="30" xmlns="http://www.w3.org/2000/svg"><text transform="translate(-19 -4)" fill="#4B515A" fill-rule="evenodd" font-size="30" font-family="AppleColorEmoji, Apple Color Emoji"><tspan x="19" y="32">🏭</tspan></text></svg>

Before

Width:  |  Height:  |  Size: 244 B

View File

@ -0,0 +1,23 @@
/**
*
* PluginIcon
*
*/
import React from 'react';
import styled from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
const IconWrapper = styled.span`
svg.svg-inline--fa.fa-w-20 {
width: 1rem;
}
`;
const PluginIcon = () => (
<IconWrapper>
<FontAwesomeIcon icon="paint-brush" />
</IconWrapper>
);
export default PluginIcon;

View File

@ -1,19 +1,11 @@
// NOTE TO PLUGINS DEVELOPERS:
// If you modify this file by adding new options to the plugin entry point
// Here's the file: strapi/docs/3.0.0-beta.x/plugin-development/frontend-field-api.md
// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md
// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
import { prefixPluginTranslations } from '@strapi/helper-plugin';
import pluginPkg from '../../package.json';
import pluginLogo from './assets/images/logo.svg';
import pluginPermissions from './permissions';
import PluginIcon from './components/PluginIcon';
import pluginId from './pluginId';
import reducers from './reducers';
import formsAPI from './utils/formAPI';
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
const icon = pluginPkg.strapi.icon;
const name = pluginPkg.strapi.name;
export default {
@ -22,7 +14,7 @@ export default {
app.addMenuLink({
to: `/plugins/${pluginId}`,
icon,
icon: PluginIcon,
intlLabel: {
id: `${pluginId}.plugin.name`,
defaultMessage: 'Content Types Builder',
@ -38,13 +30,8 @@ export default {
});
app.registerPlugin({
description: pluginDescription,
icon,
id: pluginId,
isRequired: pluginPkg.strapi.required || false,
isReady: true,
name,
pluginLogo,
// Internal APIs exposed by the CTB for the other plugins to use
apis: {
forms: formsAPI,

View File

@ -5,7 +5,6 @@
"strapi": {
"name": "content-type-builder",
"displayName": "Content Type Builder",
"icon": "paint-brush",
"description": "content-type-builder.plugin.description",
"kind": "plugin"
},

View File

@ -40,7 +40,7 @@ StrapiAppProvider.propTypes = {
menu: PropTypes.arrayOf(
PropTypes.shape({
to: PropTypes.string.isRequired,
icon: PropTypes.string,
icon: PropTypes.func.isRequired,
intlLabel: PropTypes.shape({
id: PropTypes.string.isRequired,
defaultMessage: PropTypes.string.isRequired,