refactor: remove unused codes, move blocks to /schema-initializer/blocks
This commit is contained in:
parent
59d2af69c3
commit
68025facb4
@ -2,7 +2,7 @@ import { SchemaSettingsItem } from '@nocobase/client';
|
|||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useTranslation } from '../../locale';
|
import { useTranslation } from '../../locale';
|
||||||
import { Modal } from 'antd';
|
import { Modal } from 'antd';
|
||||||
import { GroupBlockContext } from '../../schema-initializer/GroupBlockInitializer';
|
import { GroupBlockContext } from '../../schema-initializer/blocks/GroupBlockInitializer';
|
||||||
|
|
||||||
export const GroupBlockConfigure = (props) => {
|
export const GroupBlockConfigure = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -3,7 +3,7 @@ import { useDesignable, useFieldNames, useFilterBlock } from '@nocobase/client';
|
|||||||
import { App, Button, Flex, Input, Modal, Select } from 'antd';
|
import { App, Button, Flex, Input, Modal, Select } from 'antd';
|
||||||
import React, { useContext, useEffect, useState } from 'react';
|
import React, { useContext, useEffect, useState } from 'react';
|
||||||
import { useTranslation } from '../../locale';
|
import { useTranslation } from '../../locale';
|
||||||
import { GroupBlockContext } from '../../schema-initializer/GroupBlockInitializer';
|
import { GroupBlockContext } from '../../schema-initializer/blocks/GroupBlockInitializer';
|
||||||
import { transformers } from './transformers';
|
import { transformers } from './transformers';
|
||||||
import { DeleteOutlined, PullRequestOutlined } from '@ant-design/icons';
|
import { DeleteOutlined, PullRequestOutlined } from '@ant-design/icons';
|
||||||
import { uid } from '@formily/shared';
|
import { uid } from '@formily/shared';
|
||||||
|
@ -24,13 +24,12 @@ import {
|
|||||||
useSetFilterScopeVisible,
|
useSetFilterScopeVisible,
|
||||||
AfterSuccess,
|
AfterSuccess,
|
||||||
} from './schema-settings';
|
} from './schema-settings';
|
||||||
import { useCreateActionProps } from './hooks/useCreateActionProps';
|
import { useCreateActionProps } from './schema-initializer/actions/hooks/useCreateActionProps';
|
||||||
import { useCustomizeUpdateActionProps } from './hooks/useCustomizeUpdateActionProps';
|
import { useCustomizeUpdateActionProps } from './hooks/useCustomizeUpdateActionProps';
|
||||||
import { useFilterBlockActionProps } from './hooks/useFilterBlockActionProps';
|
import { useFilterBlockActionProps } from './hooks/useFilterBlockActionProps';
|
||||||
import { useFilterFormCustomProps } from './hooks/useFilterFormCustomProps';
|
import { useFilterFormCustomProps } from './hooks/useFilterFormCustomProps';
|
||||||
import { useGetCustomAssociatedComponents } from './hooks/useGetCustomAssociatedComponents';
|
import { useGetCustomAssociatedComponents } from './hooks/useGetCustomAssociatedComponents';
|
||||||
import { useGetCustomComponents } from './hooks/useGetCustomComponents';
|
import { useGetCustomComponents } from './hooks/useGetCustomComponents';
|
||||||
import { useOutboundActionProps } from './hooks/useOutboundActionProps';
|
|
||||||
import { AdminLayout, DetailsPage, HomePage, OutboundPage, PageLayout } from './pages';
|
import { AdminLayout, DetailsPage, HomePage, OutboundPage, PageLayout } from './pages';
|
||||||
import { Configuration, HomePageConfiguration, LinkManager } from './settings-manager-components';
|
import { Configuration, HomePageConfiguration, LinkManager } from './settings-manager-components';
|
||||||
import {
|
import {
|
||||||
@ -71,6 +70,7 @@ import {
|
|||||||
GroupBlockInitializer,
|
GroupBlockInitializer,
|
||||||
GroupBlockProvider,
|
GroupBlockProvider,
|
||||||
GroupBlockToolbar,
|
GroupBlockToolbar,
|
||||||
|
OutboundActionHelper,
|
||||||
OutboundButton,
|
OutboundButton,
|
||||||
OutboundLinkActionInitializer,
|
OutboundLinkActionInitializer,
|
||||||
PDFViewerBlockInitializer,
|
PDFViewerBlockInitializer,
|
||||||
@ -81,7 +81,13 @@ import {
|
|||||||
pdfViewActionInitializer,
|
pdfViewActionInitializer,
|
||||||
usePDFViewerPrintActionProps,
|
usePDFViewerPrintActionProps,
|
||||||
} from './schema-initializer';
|
} from './schema-initializer';
|
||||||
import { SheetBlock, SheetBlockInitializer, SheetBlockProvider, SheetBlockToolbar, sheetBlockSettings } from './schema-initializer/SheetBlockInitializer';
|
import {
|
||||||
|
SheetBlock,
|
||||||
|
SheetBlockInitializer,
|
||||||
|
SheetBlockProvider,
|
||||||
|
SheetBlockToolbar,
|
||||||
|
sheetBlockSettings,
|
||||||
|
} from './schema-initializer/blocks/SheetBlockInitializer';
|
||||||
export { usePDFViewerRef } from './schema-initializer';
|
export { usePDFViewerRef } from './schema-initializer';
|
||||||
export * from './components/custom-components/custom-components';
|
export * from './components/custom-components/custom-components';
|
||||||
|
|
||||||
@ -182,7 +188,6 @@ export class PluginCoreClient extends Plugin {
|
|||||||
useFilterFormCustomProps,
|
useFilterFormCustomProps,
|
||||||
useGetCustomAssociatedComponents,
|
useGetCustomAssociatedComponents,
|
||||||
useGetCustomComponents,
|
useGetCustomComponents,
|
||||||
useOutboundActionProps,
|
|
||||||
usePDFViewerPrintActionProps,
|
usePDFViewerPrintActionProps,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -216,8 +221,6 @@ export class PluginCoreClient extends Plugin {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
Designer: MenuDesigner,
|
Designer: MenuDesigner,
|
||||||
},
|
},
|
||||||
OutboundButton,
|
|
||||||
OutboundLinkActionInitializer,
|
|
||||||
PDFViewerBlockInitializer,
|
PDFViewerBlockInitializer,
|
||||||
PDFViewerPrintActionInitializer,
|
PDFViewerPrintActionInitializer,
|
||||||
PDFViewerProvider,
|
PDFViewerProvider,
|
||||||
@ -232,7 +235,6 @@ export class PluginCoreClient extends Plugin {
|
|||||||
SheetBlockProvider,
|
SheetBlockProvider,
|
||||||
SheetBlockToolbar,
|
SheetBlockToolbar,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async registerRouters() {
|
async registerRouters() {
|
||||||
@ -263,15 +265,6 @@ export class PluginCoreClient extends Plugin {
|
|||||||
title: '筛选区块添加一对一的引用',
|
title: '筛选区块添加一对一的引用',
|
||||||
Component: 'FilterAssociatedFields',
|
Component: 'FilterAssociatedFields',
|
||||||
};
|
};
|
||||||
const outboundItem = {
|
|
||||||
type: 'item',
|
|
||||||
name: 'enableActions.outbound',
|
|
||||||
title: '外链',
|
|
||||||
Component: 'OutboundLinkActionInitializer',
|
|
||||||
schema: {
|
|
||||||
'x-align': 'right',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const calendarBlockItem = {
|
const calendarBlockItem = {
|
||||||
name: 'calendarV2',
|
name: 'calendarV2',
|
||||||
title: '{{t("Calendar")}}',
|
title: '{{t("Calendar")}}',
|
||||||
@ -298,8 +291,6 @@ export class PluginCoreClient extends Plugin {
|
|||||||
Component: 'FilterFormItemCustom',
|
Component: 'FilterFormItemCustom',
|
||||||
};
|
};
|
||||||
this.schemaInitializerManager.add(pdfViewActionInitializer);
|
this.schemaInitializerManager.add(pdfViewActionInitializer);
|
||||||
this.app.schemaInitializerManager.addItem('TableActionInitializers', outboundItem.name, outboundItem);
|
|
||||||
this.app.schemaInitializerManager.get('ReadPrettyFormActionInitializers').add(outboundItem.name, outboundItem);
|
|
||||||
this.app.schemaInitializerManager.get('BlockInitializers').add(calendarBlockItem.name, calendarBlockItem);
|
this.app.schemaInitializerManager.get('BlockInitializers').add(calendarBlockItem.name, calendarBlockItem);
|
||||||
this.app.schemaInitializerManager.get('BlockInitializers').add(settingBlockItem.name, settingBlockItem);
|
this.app.schemaInitializerManager.get('BlockInitializers').add(settingBlockItem.name, settingBlockItem);
|
||||||
this.app.schemaInitializerManager.get('BlockInitializers').add('dataBlocks.groupBlock', {
|
this.app.schemaInitializerManager.get('BlockInitializers').add('dataBlocks.groupBlock', {
|
||||||
@ -311,7 +302,6 @@ export class PluginCoreClient extends Plugin {
|
|||||||
Component: 'SheetBlockInitializer',
|
Component: 'SheetBlockInitializer',
|
||||||
});
|
});
|
||||||
this.app.schemaInitializerManager.get('KanbanActionInitializers').add(refreshActionItem.name, refreshActionItem);
|
this.app.schemaInitializerManager.get('KanbanActionInitializers').add(refreshActionItem.name, refreshActionItem);
|
||||||
this.app.schemaInitializerManager.get('KanbanActionInitializers').add(outboundItem.name, outboundItem);
|
|
||||||
this.app.schemaInitializerManager.get('FilterFormItemInitializers').add(associationFields.name, associationFields);
|
this.app.schemaInitializerManager.get('FilterFormItemInitializers').add(associationFields.name, associationFields);
|
||||||
this.app.schemaInitializerManager.addItem('FilterFormItemInitializers', 'custom-item-divider', {
|
this.app.schemaInitializerManager.addItem('FilterFormItemInitializers', 'custom-item-divider', {
|
||||||
type: 'divider',
|
type: 'divider',
|
||||||
@ -364,6 +354,7 @@ export class PluginCoreClient extends Plugin {
|
|||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
this.locale = new Locale(this.app);
|
this.locale = new Locale(this.app);
|
||||||
|
await new OutboundActionHelper(this.app).load();
|
||||||
await this.registerTricks();
|
await this.registerTricks();
|
||||||
await this.registerScopesAndComponents();
|
await this.registerScopesAndComponents();
|
||||||
await this.registerSettings();
|
await this.registerSettings();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Application, useApp, tval as nTval } from '@nocobase/client';
|
import { Application, useApp, tval as nTval, i18n } from '@nocobase/client';
|
||||||
|
|
||||||
const NAMESPACE = '@hera/plugin-core';
|
const NAMESPACE = '@hera/plugin-core';
|
||||||
|
|
||||||
@ -21,3 +21,7 @@ export const useTranslation = (): any => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const tval = (key: string) => nTval(key, { ns: NAMESPACE });
|
export const tval = (key: string) => nTval(key, { ns: NAMESPACE });
|
||||||
|
|
||||||
|
export function lang(key: string) {
|
||||||
|
return i18n.t(key, { ns: NAMESPACE });
|
||||||
|
}
|
||||||
|
@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
|||||||
import { PDFViewer } from '../components/PDFViewer';
|
import { PDFViewer } from '../components/PDFViewer';
|
||||||
import { Space } from 'antd';
|
import { Space } from 'antd';
|
||||||
import { css } from '@nocobase/client';
|
import { css } from '@nocobase/client';
|
||||||
import { usePDFViewerRef } from '../schema-initializer/PDFVIewerBlockInitializer';
|
import { usePDFViewerRef } from '../schema-initializer/blocks/PDFVIewerBlockInitializer';
|
||||||
|
|
||||||
export const InternalPDFViewer = (props) => {
|
export const InternalPDFViewer = (props) => {
|
||||||
const { usePdfPath: useMaybePdfPath } = props;
|
const { usePdfPath: useMaybePdfPath } = props;
|
||||||
|
@ -1,147 +0,0 @@
|
|||||||
import { useCollection_deprecated } from '@nocobase/client';
|
|
||||||
|
|
||||||
const useVisibleCollection = () => {
|
|
||||||
const collection = useCollection_deprecated();
|
|
||||||
return (collection.template !== 'view' || collection?.writableView) && collection.template !== 'sql';
|
|
||||||
};
|
|
||||||
|
|
||||||
// 表单的操作配置
|
|
||||||
export const DetailsActionInitializers = {
|
|
||||||
title: '{{t("Configure actions")}}',
|
|
||||||
icon: 'SettingOutlined',
|
|
||||||
style: {
|
|
||||||
marginLeft: 8,
|
|
||||||
},
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
type: 'itemGroup',
|
|
||||||
title: '{{t("Enable actions")}}',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
type: 'item',
|
|
||||||
title: '{{t("Edit")}}',
|
|
||||||
component: 'UpdateActionInitializer',
|
|
||||||
schema: {
|
|
||||||
'x-component': 'Action',
|
|
||||||
'x-decorator': 'ACLActionProvider',
|
|
||||||
'x-component-props': {
|
|
||||||
type: 'primary',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'item',
|
|
||||||
title: '{{t("Delete")}}',
|
|
||||||
component: 'DestroyActionInitializer',
|
|
||||||
schema: {
|
|
||||||
'x-component': 'Action',
|
|
||||||
'x-decorator': 'ACLActionProvider',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'item',
|
|
||||||
title: '{{t("Duplicate")}}',
|
|
||||||
component: 'DuplicateActionInitializer',
|
|
||||||
schema: {
|
|
||||||
'x-component': 'Action',
|
|
||||||
'x-action': 'duplicate',
|
|
||||||
'x-decorator': 'ACLActionProvider',
|
|
||||||
'x-component-props': {
|
|
||||||
type: 'primary',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'divider',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'subMenu',
|
|
||||||
title: '{{t("Customize")}}',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
type: 'item',
|
|
||||||
title: '{{t("Popup")}}',
|
|
||||||
component: 'CustomizeActionInitializer',
|
|
||||||
schema: {
|
|
||||||
type: 'void',
|
|
||||||
title: '{{ t("Popup") }}',
|
|
||||||
'x-action': 'customize:popup',
|
|
||||||
'x-designer': 'Action.Designer',
|
|
||||||
'x-component': 'Action',
|
|
||||||
'x-component-props': {
|
|
||||||
openMode: 'drawer',
|
|
||||||
},
|
|
||||||
properties: {
|
|
||||||
drawer: {
|
|
||||||
type: 'void',
|
|
||||||
title: '{{ t("Popup") }}',
|
|
||||||
'x-component': 'Action.Container',
|
|
||||||
'x-component-props': {
|
|
||||||
className: 'nb-action-popup',
|
|
||||||
},
|
|
||||||
properties: {
|
|
||||||
tabs: {
|
|
||||||
type: 'void',
|
|
||||||
'x-component': 'Tabs',
|
|
||||||
'x-component-props': {},
|
|
||||||
'x-initializer': 'TabPaneInitializers',
|
|
||||||
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': 'RecordBlockInitializers',
|
|
||||||
properties: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'item',
|
|
||||||
title: '{{t("Update record")}}',
|
|
||||||
component: 'CustomizeActionInitializer',
|
|
||||||
schema: {
|
|
||||||
title: '{{ t("Update record") }}',
|
|
||||||
'x-component': 'Action',
|
|
||||||
'x-designer': 'Action.Designer',
|
|
||||||
'x-action': 'customize:update',
|
|
||||||
'x-decorator': 'ACLActionProvider',
|
|
||||||
'x-acl-action': 'update',
|
|
||||||
'x-action-settings': {
|
|
||||||
assignedValues: {},
|
|
||||||
onSuccess: {
|
|
||||||
manualClose: true,
|
|
||||||
redirecting: false,
|
|
||||||
successMessage: '{{t("Updated successfully")}}',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'x-component-props': {
|
|
||||||
useProps: '{{ useCustomizeUpdateActionProps }}',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
visible: useVisibleCollection,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'item',
|
|
||||||
title: '{{t("Custom request")}}',
|
|
||||||
component: 'CustomRequestInitializer',
|
|
||||||
visible: useVisibleCollection,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
@ -1,46 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { ActionInitializer } from '@nocobase/client';
|
|
||||||
import { Popover, Space, Button, Input } from 'antd';
|
|
||||||
import { useFieldSchema } from '@formily/react';
|
|
||||||
import { useProps } from '@nocobase/client';
|
|
||||||
import { ShareAltOutlined } from '@ant-design/icons';
|
|
||||||
|
|
||||||
export const OutboundLinkActionInitializer = (props) => {
|
|
||||||
const schema = {
|
|
||||||
title: '外链',
|
|
||||||
'x-action': 'outbound',
|
|
||||||
'x-component': 'OutboundButton',
|
|
||||||
'x-designer': 'Action.Designer',
|
|
||||||
'x-component-props': {
|
|
||||||
icon: 'ShareAltOutlined',
|
|
||||||
useProps: '{{ useOutboundActionProps }}',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
return <ActionInitializer {...props} schema={schema} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const OutboundButton = (props) => {
|
|
||||||
const { onClick } = useProps(props);
|
|
||||||
const schema = useFieldSchema();
|
|
||||||
const url = window.location.href.split('/', 3).join('/');
|
|
||||||
return (
|
|
||||||
<Popover
|
|
||||||
placement="bottomRight"
|
|
||||||
trigger="click"
|
|
||||||
autoAdjustOverflow
|
|
||||||
content={
|
|
||||||
<Space.Compact style={{ width: '100%' }}>
|
|
||||||
<Input defaultValue={`${url}/r/${schema['x-uid']}`} />
|
|
||||||
<Button type="primary" onClick={onClick}>
|
|
||||||
复制链接
|
|
||||||
</Button>
|
|
||||||
</Space.Compact>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Button>
|
|
||||||
<ShareAltOutlined />
|
|
||||||
外链
|
|
||||||
</Button>
|
|
||||||
</Popover>
|
|
||||||
);
|
|
||||||
};
|
|
@ -1,9 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ActionInitializer } from '@nocobase/client';
|
import { ActionInitializer, tval } from '@nocobase/client';
|
||||||
|
|
||||||
export const CreateSubmitActionInitializer = (props) => {
|
export const CreateSubmitActionInitializer: React.FC = (props) => {
|
||||||
const schema = {
|
const schema = {
|
||||||
title: '{{ t("Submit") }}',
|
title: tval('Submit'),
|
||||||
'x-action': 'submit',
|
'x-action': 'submit',
|
||||||
'x-component': 'Action',
|
'x-component': 'Action',
|
||||||
'x-designer': 'Action.Designer',
|
'x-designer': 'Action.Designer',
|
||||||
@ -20,3 +20,4 @@ export const CreateSubmitActionInitializer = (props) => {
|
|||||||
};
|
};
|
||||||
return <ActionInitializer {...props} schema={schema} />;
|
return <ActionInitializer {...props} schema={schema} />;
|
||||||
};
|
};
|
||||||
|
CreateSubmitActionInitializer.displayName = 'CreateSubmitActionInitializer';
|
@ -0,0 +1,78 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { ActionInitializer, Application } from '@nocobase/client';
|
||||||
|
import { Popover, Space, Button, Input } from 'antd';
|
||||||
|
import { useFieldSchema } from '@formily/react';
|
||||||
|
import { useProps } from '@nocobase/client';
|
||||||
|
import { ShareAltOutlined } from '@ant-design/icons';
|
||||||
|
import { lang, tval, useTranslation } from '../../locale';
|
||||||
|
import { useOutboundActionProps } from './hooks/useOutboundActionProps';
|
||||||
|
|
||||||
|
export class OutboundActionHelper {
|
||||||
|
constructor(private app: Application) {}
|
||||||
|
|
||||||
|
async load() {
|
||||||
|
this.app.addScopes({
|
||||||
|
useOutboundActionProps,
|
||||||
|
});
|
||||||
|
this.app.addComponents({
|
||||||
|
OutboundButton,
|
||||||
|
OutboundLinkActionInitializer,
|
||||||
|
});
|
||||||
|
const outboundItem = {
|
||||||
|
type: 'item',
|
||||||
|
name: 'enableActions.outbound',
|
||||||
|
title: lang('outbound'),
|
||||||
|
Component: 'OutboundLinkActionInitializer',
|
||||||
|
schema: {
|
||||||
|
'x-align': 'right',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
this.app.schemaInitializerManager.addItem('table:configureActions', outboundItem.name, outboundItem);
|
||||||
|
this.app.schemaInitializerManager.addItem('details:configureActions', outboundItem.name, outboundItem);
|
||||||
|
this.app.schemaInitializerManager.addItem('kanban:configureActions', outboundItem.name, outboundItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const OutboundLinkActionInitializer: React.FC = (props) => {
|
||||||
|
const schema = {
|
||||||
|
title: tval('outbound'),
|
||||||
|
'x-action': 'outbound',
|
||||||
|
'x-component': 'OutboundButton',
|
||||||
|
'x-designer': 'Action.Designer',
|
||||||
|
'x-component-props': {
|
||||||
|
icon: 'ShareAltOutlined',
|
||||||
|
useProps: '{{ useOutboundActionProps }}',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return <ActionInitializer {...props} schema={schema} />;
|
||||||
|
};
|
||||||
|
OutboundLinkActionInitializer.displayName = 'OutboundLinkActionInitializer';
|
||||||
|
|
||||||
|
export const OutboundButton: React.FC = (props) => {
|
||||||
|
const { onClick } = useProps(props);
|
||||||
|
const schema = useFieldSchema();
|
||||||
|
// FIXME 处理多应用情况
|
||||||
|
const url = window.location.href.split('/', 3).join('/');
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
|
<Popover
|
||||||
|
placement="bottomRight"
|
||||||
|
trigger="click"
|
||||||
|
autoAdjustOverflow
|
||||||
|
content={
|
||||||
|
<Space.Compact style={{ width: '100%' }}>
|
||||||
|
<Input defaultValue={`${url}/r/${schema['x-uid']}`} />
|
||||||
|
<Button type="primary" onClick={onClick}>
|
||||||
|
{t('Copy link')}
|
||||||
|
</Button>
|
||||||
|
</Space.Compact>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button>
|
||||||
|
<ShareAltOutlined />
|
||||||
|
{t('Outbound')}
|
||||||
|
</Button>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
OutboundButton.displayName = 'OutboundButton';
|
@ -19,14 +19,15 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { App, message } from 'antd';
|
import { App, message } from 'antd';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
import { isURL } from '@nocobase/utils/client';
|
import { isURL } from '@nocobase/utils/client';
|
||||||
import React, { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { tval } from '../../../locale';
|
||||||
|
|
||||||
const pageDetailsViewer = 'PageLayout';
|
const pageDetailsViewer = 'PageLayout';
|
||||||
|
|
||||||
const viewerSchema: ISchema = {
|
const viewerSchema: ISchema = {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title: '{{ t("View record") }}',
|
title: tval('View record'),
|
||||||
'x-component': pageDetailsViewer,
|
'x-component': pageDetailsViewer,
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
className: 'nb-action-popup',
|
className: 'nb-action-popup',
|
||||||
@ -34,7 +35,7 @@ const viewerSchema: ISchema = {
|
|||||||
properties: {
|
properties: {
|
||||||
page: {
|
page: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title: '详情页面',
|
title: tval('Detail page'),
|
||||||
'x-designer': 'Page.Designer',
|
'x-designer': 'Page.Designer',
|
||||||
'x-component': 'Page',
|
'x-component': 'Page',
|
||||||
'x-component-props': { disablePageHeader: true },
|
'x-component-props': { disablePageHeader: true },
|
@ -1,21 +1,24 @@
|
|||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import { useFieldSchema } from '@formily/react';
|
import { useFieldSchema } from '@formily/react';
|
||||||
import copy from 'copy-to-clipboard';
|
import copy from 'copy-to-clipboard';
|
||||||
|
import { useTranslation } from '../../../locale';
|
||||||
|
|
||||||
export const useOutboundActionProps = () => {
|
export const useOutboundActionProps = () => {
|
||||||
let schema = useFieldSchema();
|
let schema = useFieldSchema();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
while (!('x-decorator-props' in schema)) {
|
while (!('x-decorator-props' in schema)) {
|
||||||
schema = schema.parent;
|
schema = schema.parent;
|
||||||
}
|
}
|
||||||
|
// FIXME: 处理多应用路径
|
||||||
const url = window.location.href.split('/', 3).join('/');
|
const url = window.location.href.split('/', 3).join('/');
|
||||||
return {
|
return {
|
||||||
async onClick() {
|
async onClick() {
|
||||||
const c = copy(`${url}/r/${schema['x-uid']}`);
|
const c = copy(`${url}/r/${schema['x-uid']}`);
|
||||||
if (c) {
|
if (c) {
|
||||||
message.success('链接保存成功');
|
message.success(t('Save link successful'));
|
||||||
} else {
|
} else {
|
||||||
message.success('链接保存失败');
|
message.success(t('Save link failed'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
@ -13,7 +13,7 @@ import {
|
|||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { createCalendarBlockSchema } from './utils';
|
import { createCalendarBlockSchema } from '../utils';
|
||||||
|
|
||||||
export const CalendarBlockInitializer = () => {
|
export const CalendarBlockInitializer = () => {
|
||||||
const { insert } = useSchemaInitializer();
|
const { insert } = useSchemaInitializer();
|
@ -16,8 +16,8 @@ import {
|
|||||||
import React, { createContext, useState } from 'react';
|
import React, { createContext, useState } from 'react';
|
||||||
import { uid } from '@nocobase/utils/client';
|
import { uid } from '@nocobase/utils/client';
|
||||||
import { Checkbox, Spin } from 'antd';
|
import { Checkbox, Spin } from 'antd';
|
||||||
import { GroupBlockConfigure } from '../components/GroupBlockConfigure/GroupBlockConfigure';
|
import { GroupBlockConfigure } from '../../components/GroupBlockConfigure/GroupBlockConfigure';
|
||||||
import { GroupConfigure } from '../components/GroupBlockConfigure/GroupConfigure';
|
import { GroupConfigure } from '../../components/GroupBlockConfigure/GroupConfigure';
|
||||||
|
|
||||||
export const GroupBlockContext = createContext<any>({});
|
export const GroupBlockContext = createContext<any>({});
|
||||||
|
|
@ -12,7 +12,7 @@ import {
|
|||||||
useSchemaInitializerItem,
|
useSchemaInitializerItem,
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useTranslation } from '../locale';
|
import { tval, useTranslation } from '../../locale';
|
||||||
|
|
||||||
export const SettingBlockInitializer = () => {
|
export const SettingBlockInitializer = () => {
|
||||||
const { insert } = useSchemaInitializer();
|
const { insert } = useSchemaInitializer();
|
||||||
@ -41,7 +41,7 @@ export const SettingBlockInitializer = () => {
|
|||||||
schema={{
|
schema={{
|
||||||
properties: {
|
properties: {
|
||||||
id: {
|
id: {
|
||||||
title: t('Please select'),
|
title: tval('Please select'),
|
||||||
enum: result.data.data.map((item) => {
|
enum: result.data.data.map((item) => {
|
||||||
return {
|
return {
|
||||||
label: item[titleField],
|
label: item[titleField],
|
||||||
@ -68,7 +68,7 @@ export const SettingBlockInitializer = () => {
|
|||||||
collection: collection.name,
|
collection: collection.name,
|
||||||
action: 'get',
|
action: 'get',
|
||||||
filterByTk: values.id,
|
filterByTk: values.id,
|
||||||
actionInitializers: 'UpdateFormActionInitializers',
|
actionInitializers: 'editForm:configureActions',
|
||||||
});
|
});
|
||||||
insert(formSchema);
|
insert(formSchema);
|
||||||
}}
|
}}
|
@ -13,7 +13,7 @@ import {
|
|||||||
import React, { createContext, useRef } from 'react';
|
import React, { createContext, useRef } from 'react';
|
||||||
import { uid } from '@nocobase/utils/client';
|
import { uid } from '@nocobase/utils/client';
|
||||||
import { Button, Spin } from 'antd';
|
import { Button, Spin } from 'antd';
|
||||||
import Sheet, { SheetRef } from '../components/Sheet';
|
import Sheet, { SheetRef } from '../../components/Sheet';
|
||||||
|
|
||||||
export const SheetBlockContext = createContext<any>({});
|
export const SheetBlockContext = createContext<any>({});
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
export * from './FilterFormItemCustomInitializer/FilterFormItemCustom';
|
export * from './FilterFormItemCustomInitializer/FilterFormItemCustom';
|
||||||
export * from './CalendarBlockInitializer';
|
export * from './blocks/CalendarBlockInitializer';
|
||||||
export * from './PDFVIewerBlockInitializer';
|
export * from './blocks/PDFVIewerBlockInitializer';
|
||||||
export * from './OutboundLinkActionInitializer';
|
export * from './actions/OutboundLinkActionInitializer';
|
||||||
export * from './CreateSubmitActionInitializer';
|
export * from './actions/CreateSubmitActionInitializer';
|
||||||
export * from './FilterAssociatedFields';
|
export * from './FilterAssociatedFields';
|
||||||
export * from './SettingBlockInitializer';
|
export * from './blocks/SettingBlockInitializer';
|
||||||
export * from './GroupBlockInitializer';
|
export * from './blocks/GroupBlockInitializer';
|
||||||
|
Loading…
Reference in New Issue
Block a user