nocobase/packages/plugins/@nocobase/plugin-block-workbench/src/client/WorkbenchCustomRequestActionSchemaInitializerItem.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

110 lines
2.8 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,
SchemaSettings,
SchemaSettingsActionLinkItem,
useSchemaInitializer,
ModalActionSchemaInitializerItem,
SchemaSettingAccessControl,
} from '@nocobase/client';
import React from 'react';
import { useTranslation } from 'react-i18next';
export const workbenchActionSettingsCustomRequest = new SchemaSettings({
name: 'workbench:actionSettings:customRequest',
items: [
{
name: 'editButton',
Component: ButtonEditor,
useComponentProps() {
return { hasIconColor: true };
},
},
{
name: 'editLink',
Component: SchemaSettingsActionLinkItem,
},
{
...SchemaSettingAccessControl,
useVisible() {
return true;
},
},
{
sort: 800,
name: 'd1',
type: 'divider',
},
{
sort: 900,
type: 'remove',
name: 'remove',
},
],
});
export function WorkbenchCustomRequestActionSchemaInitializerItem(props) {
// 调用插入功能
const { insert } = useSchemaInitializer();
const { t } = useTranslation();
return (
<ModalActionSchemaInitializerItem
title={t('Custom request')}
modalSchema={{
title: t('Add custom request', { 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-component': 'WorkbenchAction',
'x-component-props': {
icon: values.icon,
iconColor: values.iconColor,
targetComponent: 'CustomRequestAction',
},
'x-action': 'customize:form:request',
'x-toolbar': 'ActionSchemaToolbar',
'x-settings': 'actionSettings:customRequest',
'x-decorator': 'CustomRequestAction.Decorator',
'x-action-settings': {
onSuccess: {
manualClose: false,
redirecting: false,
successMessage: '{{t("Request success")}}',
},
},
});
}}
/>
);
}