refactor: change name for add blocks menu

This commit is contained in:
Zeke Zhang 2024-07-29 15:42:14 +08:00
parent 0fb2cc7278
commit e45be71abc

View File

@ -20,6 +20,7 @@ import {
import _ from 'lodash'; import _ from 'lodash';
import React, { useEffect, useMemo, useState } from 'react'; import React, { useEffect, useMemo, useState } from 'react';
import { createPortal } from 'react-dom'; import { createPortal } from 'react-dom';
import { usePluginTranslation } from '../../locale';
import { useMobileActionPageStyle } from './MobileActionPage.style'; import { useMobileActionPageStyle } from './MobileActionPage.style';
import { MobileTabsForMobileActionPage } from './MobileTabsForMobileActionPage'; import { MobileTabsForMobileActionPage } from './MobileTabsForMobileActionPage';
@ -39,6 +40,7 @@ const useMobileBlockInitializersInSubpage = (
const [originalInitializers] = useState<SchemaInitializer>(() => const [originalInitializers] = useState<SchemaInitializer>(() =>
app.schemaInitializerManager.get('popup:common:addBlock'), app.schemaInitializerManager.get('popup:common:addBlock'),
); );
const { t } = usePluginTranslation();
const dataBlocks = originalInitializers.options.items.find((item) => item.name === 'dataBlocks'); const dataBlocks = originalInitializers.options.items.find((item) => item.name === 'dataBlocks');
const dataBlocksChildren = [...dataBlocks.useChildren(), ...dataBlocks.children]; const dataBlocksChildren = [...dataBlocks.useChildren(), ...dataBlocks.children];
@ -47,6 +49,7 @@ const useMobileBlockInitializersInSubpage = (
const options = _.cloneDeep(originalInitializers.options); const options = _.cloneDeep(originalInitializers.options);
options.items = options.items.filter((item) => { options.items = options.items.filter((item) => {
if (item.name === 'dataBlocks') { if (item.name === 'dataBlocks') {
item.title = t('Desktop data blocks');
item.children = dataBlocksChildren.filter((child) => { item.children = dataBlocksChildren.filter((child) => {
return supportsDataBlocks.includes(child.name); return supportsDataBlocks.includes(child.name);
}); });
@ -54,6 +57,10 @@ const useMobileBlockInitializersInSubpage = (
return true; return true;
} }
if (item.name === 'otherBlocks') {
item.title = t('Other desktop blocks');
}
return item.name !== 'filterBlocks'; return item.name !== 'filterBlocks';
}); });