nocobase/packages/plugins/@nocobase/plugin-block-workbench/src/client/WorkbenchPopupActionSchemaInitializerItem.tsx
Katherine cf7131a36f
feat: add permission control for buttons with blacklist support (#6254)
* chore(versions): 😊 publish v1.6.0-alpha.24

* chore(versions): 😊 publish v1.6.0-alpha.25

* feat: support extending frontend filter operators (#6085)

* feat: operator extension

* fix: bug

* refactor: code improve

* fix: jsonLogic

---------

Co-authored-by: chenos <chenlinxh@gmail.com>

* refactor: remove registerOperators (#6224)

* refactor(plugin-workflow): trigger workflow action settings (#6143)

* refactor(plugin-workflow): move bind workflow settings to plugin

* refactor(plugin-block-workbench): move component to core

* refactor(plugin-block-workbench): adjust component api

* fix(plugin-workflow-action-trigger): fix test cases

* fix(plugin-workflow): fix component scope

* fix(plugin-workflow-action-trigger): fix test cases

* chore(versions): 😊 publish v1.6.0-alpha.26

* feat: support the extension of preset fields in collections (#6183)

* feat: support the extension of preset fields in collections

* fix: bug

* fix: bug

* fix: bug

* refactor: create collection

* fix: config

* fix: test case

* refactor: code improve

* refactor: code improve

* fix: bug

* fix: bug

---------

Co-authored-by: chenos <chenlinxh@gmail.com>

* feat: support for the extension of optional fields for Kanban, Calendar, and Formula Field plugins (#6076)

* feat: kanban field extention

* fix: bug

* fix: bug

* fix: bug

* fix: bug

* feat: calender title fields

* feat: background color fields

* fix: bug

* fix: bug

* feat: formula field expression support field

* feat: preset fields

* fix: bug

* fix: bug

* fix: bug

* fix: bug

* fix: bug

* fix: bug

* fix: bug

* fix: bug

* refactor: code improve

* fix: bug

* fix: bug

* fix: bug

* fix: bug

* refactor: code improve

* revert: preset fields

* refactor: code improve

* refactor: code improve

* fix: bug

* fix: bug

* fix: bug

* refactor: code improve

* fix: bug

* refactor: code improve

* refactor: code improve

* fix: bug

* fix: locale

* refactor: code improve

* fix: bug

* refactor: code improve

* refactor: code improve

* refactor: code improve

* refactor: locale

* fix: test

* fix: bug

* fix: test

* fix: test

---------

Co-authored-by: chenos <chenlinxh@gmail.com>

* chore(versions): 😊 publish v1.6.0-alpha.27

* fix(data-source-main): update order

* fix: improve code

* fix: getFontColor (#6241)

* chore(versions): 😊 publish v1.6.0-alpha.28

* feat: add permission control for buttons with blacklist support

* fix: print action e2e test (#6256)

* fix: print action e2e test

* fix: test

* fix: bug

* refactor: custom request

* fix: merge bug

* fix: merge bug

* fix: merge bug

* fix: merge bug

* fix: bug

* fix: bug

* fix: bug

* test: e2e test

* fix: bug

* test: e2e test

* fix: bug

* fix: bug

* fix: bug

* fix: bug

* fix: test

---------

Co-authored-by: nocobase[bot] <179432756+nocobase[bot]@users.noreply.github.com>
Co-authored-by: chenos <chenlinxh@gmail.com>
Co-authored-by: Junyi <mytharcher@users.noreply.github.com>
2025-02-26 17:19:25 +08:00

153 lines
4.1 KiB
TypeScript

/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import {
ButtonEditor,
SchemaSettingOpenModeSchemaItems,
SchemaSettings,
useSchemaInitializer,
useOpenModeContext,
ModalActionSchemaInitializerItem,
SchemaSettingAccessControl,
} from '@nocobase/client';
import React from 'react';
import { useTranslation } from 'react-i18next';
export const workbenchActionSettingsPopup = new SchemaSettings({
name: 'workbench:actionSettings:popup',
items: [
{
name: 'editButton',
Component: ButtonEditor,
useComponentProps() {
return { hasIconColor: true };
},
},
{
name: 'openMode',
Component: SchemaSettingOpenModeSchemaItems,
useComponentProps() {
const { t } = useTranslation();
const { hideOpenMode } = useOpenModeContext();
return {
openSize: !hideOpenMode,
modeOptions: hideOpenMode && [
{ label: t('Drawer'), value: 'drawer' },
{ label: t('Page'), value: 'page' },
],
};
},
},
{
...SchemaSettingAccessControl,
useVisible() {
return true;
},
},
{
sort: 800,
name: 'd1',
type: 'divider',
},
{
sort: 900,
type: 'remove',
name: 'remove',
},
],
});
export function WorkbenchPopupActionSchemaInitializerItem(props) {
// 调用插入功能
const { insert } = useSchemaInitializer();
const { t } = useTranslation();
const { isMobile } = useOpenModeContext();
return (
<ModalActionSchemaInitializerItem
title={t('Popup')}
modalSchema={{
title: t('Add popup', { ns: 'block-workbench' }),
properties: {
title: {
title: t('Title'),
required: true,
'x-component': 'Input',
'x-decorator': 'FormItem',
},
icon: {
title: t('Icon'),
required: true,
'x-component': 'IconPicker',
'x-decorator': 'FormItem',
},
iconColor: {
title: t('Color'),
required: true,
default: '#1677FF',
'x-component': 'ColorPicker',
'x-decorator': 'FormItem',
},
},
}}
onSubmit={(values) => {
insert({
type: 'void',
title: values.title,
'x-action': 'customize:popup',
'x-toolbar': 'ActionSchemaToolbar',
'x-settings': 'workbench:actionSettings:popup',
'x-component': 'WorkbenchAction',
'x-component-props': {
icon: values.icon,
iconColor: values.iconColor,
refreshDataBlockRequest: false,
},
properties: {
drawer: {
type: 'void',
title: values.title,
'x-component': 'Action.Container',
'x-component-props': {
className: 'nb-action-popup',
},
properties: {
tabs: {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',
title: '{{t("Details")}}',
'x-component': 'Tabs.TabPane',
'x-designer': 'Tabs.Designer',
'x-component-props': {},
properties: {
grid: {
type: 'void',
'x-component': 'Grid',
'x-initializer': isMobile ? 'mobile:addBlock' : 'page:addBlock',
properties: {},
},
},
},
},
},
},
},
},
});
}}
/>
);
}