feat(client): plugin toolbar icons and translations

This commit is contained in:
chenos 2022-07-15 10:50:04 +08:00
parent 0f0f852fa7
commit c51c6c097f
4 changed files with 10 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import { SettingOutlined } from '@ant-design/icons'; import { FileOutlined } from '@ant-design/icons';
import { uid } from '@formily/shared'; import { uid } from '@formily/shared';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -31,7 +31,7 @@ export const FileStorageShortcut = () => {
onClick={() => { onClick={() => {
setVisible(true); setVisible(true);
}} }}
icon={<SettingOutlined />} icon={<FileOutlined />}
title={t('File storages')} title={t('File storages')}
/> />
<SchemaComponent components={{ StorageOptions }} schema={schema} /> <SchemaComponent components={{ StorageOptions }} schema={schema} />

View File

@ -552,4 +552,5 @@ export default {
"Subform": "Subform", "Subform": "Subform",
"Regular expression": "Pattern", "Regular expression": "Pattern",
"Enabled languages": "Enabled languages", "Enabled languages": "Enabled languages",
"View all plugins": "View all plugins",
} }

View File

@ -648,4 +648,5 @@ export default {
"Use the same time zone (GMT) for all users": "所有用户使用同一时区 (格林尼治标准时间)", "Use the same time zone (GMT) for all users": "所有用户使用同一时区 (格林尼治标准时间)",
"Province/city/area name": "省市区名称", "Province/city/area name": "省市区名称",
"Enabled languages": "启用的语言", "Enabled languages": "启用的语言",
"View all plugins": "查看所有插件",
} }

View File

@ -1,8 +1,9 @@
import { MoreOutlined, SettingOutlined } from '@ant-design/icons'; import { AppstoreOutlined, EllipsisOutlined } from '@ant-design/icons';
import { ConfigProvider, Menu, MenuItemProps, Spin, Tooltip } from 'antd'; import { ConfigProvider, Menu, MenuItemProps, Spin, Tooltip } from 'antd';
import cls from 'classnames'; import cls from 'classnames';
import { get } from 'lodash'; import { get } from 'lodash';
import React, { createContext, useContext } from 'react'; import React, { createContext, useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../api-client'; import { useAPIClient, useRequest } from '../api-client';
import { PluginManagerContext } from './context'; import { PluginManagerContext } from './context';
@ -52,6 +53,7 @@ PluginManager.Toolbar = (props: ToolbarProps) => {
const { components } = useContext(PluginManagerContext); const { components } = useContext(PluginManagerContext);
const { items = [] } = props; const { items = [] } = props;
const [pinned, unpinned] = splitItems(items); const [pinned, unpinned] = splitItems(items);
const { t } = useTranslation();
return ( return (
<div style={{ display: 'inline-block' }}> <div style={{ display: 'inline-block' }}>
<Menu style={{ width: '100%' }} selectable={false} mode={'horizontal'} theme={'dark'}> <Menu style={{ width: '100%' }} selectable={false} mode={'horizontal'} theme={'dark'}>
@ -66,7 +68,7 @@ PluginManager.Toolbar = (props: ToolbarProps) => {
); );
})} })}
{unpinned.length > 0 && ( {unpinned.length > 0 && (
<Menu.SubMenu popupClassName={'pm-sub-menu'} key={'more'} title={<MoreOutlined />}> <Menu.SubMenu popupClassName={'pm-sub-menu'} key={'more'} title={<EllipsisOutlined />}>
{unpinned.map((item, index) => { {unpinned.map((item, index) => {
const Action = get(components, item.component); const Action = get(components, item.component);
return ( return (
@ -78,8 +80,8 @@ PluginManager.Toolbar = (props: ToolbarProps) => {
); );
})} })}
{unpinned.length > 0 && <Menu.Divider key={'divider'}></Menu.Divider>} {unpinned.length > 0 && <Menu.Divider key={'divider'}></Menu.Divider>}
<Menu.Item key={'plugins'} disabled icon={<SettingOutlined />}> <Menu.Item key={'plugins'} disabled icon={<AppstoreOutlined />}>
{t('View all plugins')}
</Menu.Item> </Menu.Item>
</Menu.SubMenu> </Menu.SubMenu>
)} )}