Merge pull request 'chore: using plugin locale' (#383) from audit_logs into @hera/dev
Reviewed-on: daoyoucloud/tachycode#383
This commit is contained in:
commit
ccabd6a849
@ -7,11 +7,11 @@ import {
|
||||
useSchemaInitializerItem,
|
||||
} from '@nocobase/client';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useAuditLogsTranslation } from './locale';
|
||||
|
||||
export const AuditLogsBlockInitializer = () => {
|
||||
const { insert } = useSchemaInitializer();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useAuditLogsTranslation();
|
||||
const itemConfig = useSchemaInitializerItem();
|
||||
|
||||
const schema = createTableBlockSchema({
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { ExtendCollectionsProvider, TableBlockProvider } from '@nocobase/client';
|
||||
import React from 'react';
|
||||
import { ExtendCollectionsProvider, TableBlockProvider } from '@nocobase/client';
|
||||
import { useAuditChangesCollection, useAuditLogsCollection, useCollectionsCollection } from './collections';
|
||||
|
||||
export const AuditLogsBlockProvider: React.FC = ({ children, ...restProps }) => {
|
||||
const auditChangesCollection = useAuditChangesCollection();
|
||||
const auditLogsCollection = useAuditLogsCollection();
|
||||
const collectionsCollection = useCollectionsCollection();
|
||||
console.log('audit logs blocks');
|
||||
|
||||
return (
|
||||
<ExtendCollectionsProvider collections={[auditLogsCollection, auditChangesCollection, collectionsCollection]}>
|
||||
|
@ -3,7 +3,7 @@ import { useAuditLogsTranslation } from './locale';
|
||||
export const useAuditLogsCollection = () => {
|
||||
return {
|
||||
name: 'auditLogs',
|
||||
title: '{{t("Audit logs")}}',
|
||||
title: tval('Audit logs'),
|
||||
fields: [
|
||||
{
|
||||
name: 'createdAt',
|
||||
@ -11,7 +11,7 @@ export const useAuditLogsCollection = () => {
|
||||
interface: 'createdAt',
|
||||
uiSchema: {
|
||||
type: 'datetime',
|
||||
title: '{{t("Created at")}}',
|
||||
title: tval('Created at'),
|
||||
'x-component': 'DatePicker',
|
||||
'x-component-props': {
|
||||
showTime: true,
|
||||
@ -26,14 +26,14 @@ export const useAuditLogsCollection = () => {
|
||||
interface: 'select',
|
||||
uiSchema: {
|
||||
type: 'string',
|
||||
title: '{{t("Action type")}}',
|
||||
title: tval('Action type'),
|
||||
'x-component': 'Select',
|
||||
'x-component-props': { ellipsis: true },
|
||||
'x-read-pretty': true,
|
||||
enum: [
|
||||
{ label: '{{t("Create record")}}', value: 'create', color: 'lime' },
|
||||
{ label: '{{t("Update record")}}', value: 'update', color: 'gold' },
|
||||
{ label: '{{t("Delete record")}}', value: 'destroy', color: 'magenta' },
|
||||
{ label: tval('Create record'), value: 'create', color: 'lime' },
|
||||
{ label: tval('Update record'), value: 'update', color: 'gold' },
|
||||
{ label: tval('Delete record'), value: 'destroy', color: 'magenta' },
|
||||
],
|
||||
},
|
||||
},
|
||||
@ -42,7 +42,7 @@ export const useAuditLogsCollection = () => {
|
||||
type: 'string',
|
||||
interface: 'input',
|
||||
uiSchema: {
|
||||
title: '{{t("Record ID")}}',
|
||||
title: tval('Record ID'),
|
||||
type: 'string',
|
||||
'x-component': 'Input',
|
||||
'x-component-props': { ellipsis: true },
|
||||
@ -59,7 +59,7 @@ export const useAuditLogsCollection = () => {
|
||||
foreignKey: 'collectionName',
|
||||
uiSchema: {
|
||||
type: 'object',
|
||||
title: '{{t("Collection")}}',
|
||||
title: tval('Collection'),
|
||||
'x-component': 'AssociationField',
|
||||
'x-component-props': { fieldNames: { value: 'name', label: 'title' }, ellipsis: true },
|
||||
'x-read-pretty': true,
|
||||
@ -75,7 +75,7 @@ export const useAuditLogsCollection = () => {
|
||||
target: 'users',
|
||||
uiSchema: {
|
||||
type: 'object',
|
||||
title: '{{t("User")}}',
|
||||
title: tval('User'),
|
||||
'x-component': 'AssociationField',
|
||||
'x-component-props': { fieldNames: { value: 'id', label: 'nickname' }, ellipsis: true },
|
||||
'x-read-pretty': true,
|
||||
@ -101,14 +101,14 @@ export const useAuditLogsCollection = () => {
|
||||
export const useAuditChangesCollection = () => {
|
||||
return {
|
||||
name: 'auditChanges',
|
||||
title: '{{t("Audit Changes")}}',
|
||||
title: tval('Audit Changes'),
|
||||
fields: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'json',
|
||||
interface: 'input',
|
||||
uiSchema: {
|
||||
title: '{{t("Field")}}',
|
||||
title: tval('Field'),
|
||||
'x-component': 'AuditLogsField',
|
||||
},
|
||||
},
|
||||
@ -117,7 +117,7 @@ export const useAuditChangesCollection = () => {
|
||||
name: 'before',
|
||||
interface: 'input',
|
||||
uiSchema: {
|
||||
title: '{{t("Before change")}}',
|
||||
title: tval('Before change'),
|
||||
'x-component': 'AuditLogsValue',
|
||||
},
|
||||
},
|
||||
@ -126,7 +126,7 @@ export const useAuditChangesCollection = () => {
|
||||
name: 'after',
|
||||
interface: 'input',
|
||||
uiSchema: {
|
||||
title: '{{t("After change")}}',
|
||||
title: tval('After change'),
|
||||
'x-component': 'AuditLogsValue',
|
||||
},
|
||||
},
|
||||
@ -137,14 +137,14 @@ export const useAuditChangesCollection = () => {
|
||||
export const useCollectionsCollection = () => {
|
||||
return {
|
||||
name: 'collections',
|
||||
title: '{{t("Collections")}}',
|
||||
title: tval('Collections'),
|
||||
fields: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
interface: 'input',
|
||||
uiSchema: {
|
||||
title: '{{t("Collection name")}}',
|
||||
title: tval('Collection name'),
|
||||
type: 'string',
|
||||
'x-component': 'Input',
|
||||
'x-component-props': { ellipsis: true },
|
||||
@ -155,7 +155,7 @@ export const useCollectionsCollection = () => {
|
||||
type: 'string',
|
||||
interface: 'input',
|
||||
uiSchema: {
|
||||
title: '{{t("Collection display name")}}',
|
||||
title: tval('Collection display name'),
|
||||
type: 'string',
|
||||
'x-component': 'Input',
|
||||
'x-component-props': { ellipsis: true },
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { ActionInitializer } from '@nocobase/client';
|
||||
import React from 'react';
|
||||
import { tval } from '../locale';
|
||||
|
||||
export const AuditLogsViewActionInitializer = () => {
|
||||
const schema = {
|
||||
type: 'void',
|
||||
title: '{{ t("View") }}',
|
||||
title: tval('View'),
|
||||
'x-action': 'view',
|
||||
// 'x-designer': 'Action.Designer',
|
||||
'x-toolbar': 'ActionSchemaToolbar',
|
||||
'x-settings': 'actionSettings:view',
|
||||
'x-component': 'Action',
|
||||
@ -16,7 +16,7 @@ export const AuditLogsViewActionInitializer = () => {
|
||||
properties: {
|
||||
drawer: {
|
||||
type: 'void',
|
||||
title: '{{ t("View record") }}',
|
||||
title: tval('View record'),
|
||||
'x-component': 'Action.Container',
|
||||
'x-component-props': {
|
||||
className: 'nb-action-popup',
|
||||
@ -29,7 +29,7 @@ export const AuditLogsViewActionInitializer = () => {
|
||||
properties: {
|
||||
tab1: {
|
||||
type: 'void',
|
||||
title: '{{t("Details")}}',
|
||||
title: tval('Details'),
|
||||
'x-component': 'Tabs.TabPane',
|
||||
'x-designer': 'Tabs.Designer',
|
||||
'x-component-props': {},
|
||||
@ -184,7 +184,7 @@ export const AuditLogsViewActionInitializer = () => {
|
||||
properties: {
|
||||
viewer: {
|
||||
type: 'void',
|
||||
title: '{{ t("View record") }}',
|
||||
title: tval('View record'),
|
||||
'x-component': 'RecordPicker.Viewer',
|
||||
'x-component-props': {
|
||||
className: 'nb-action-popup',
|
||||
@ -198,7 +198,7 @@ export const AuditLogsViewActionInitializer = () => {
|
||||
properties: {
|
||||
tab1: {
|
||||
type: 'void',
|
||||
title: '{{t("Details")}}',
|
||||
title: tval('Details'),
|
||||
'x-component': 'Tabs.TabPane',
|
||||
'x-designer': 'Tabs.Designer',
|
||||
'x-component-props': {},
|
||||
|
@ -11,10 +11,11 @@ import {
|
||||
} from '@nocobase/client';
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { AuditLogsDesigner } from './AuditLogsDesigner';
|
||||
import { tval } from '../locale';
|
||||
|
||||
const collection = {
|
||||
name: 'auditLogs',
|
||||
title: '{{t("Audit logs")}}',
|
||||
title: tval('Audit logs'),
|
||||
fields: [
|
||||
{
|
||||
name: 'createdAt',
|
||||
@ -22,7 +23,7 @@ const collection = {
|
||||
interface: 'createdAt',
|
||||
uiSchema: {
|
||||
type: 'datetime',
|
||||
title: '{{t("Created at")}}',
|
||||
title: tval('Created at'),
|
||||
'x-component': 'DatePicker',
|
||||
'x-component-props': {
|
||||
showTime: true,
|
||||
@ -36,13 +37,13 @@ const collection = {
|
||||
interface: 'select',
|
||||
uiSchema: {
|
||||
type: 'string',
|
||||
title: '{{t("Action type")}}',
|
||||
title: tval('Action type'),
|
||||
'x-component': 'Select',
|
||||
'x-read-pretty': true,
|
||||
enum: [
|
||||
{ label: '{{t("Create record")}}', value: 'create', color: 'lime' },
|
||||
{ label: '{{t("Update record")}}', value: 'update', color: 'gold' },
|
||||
{ label: '{{t("Delete record")}}', value: 'destroy', color: 'magenta' },
|
||||
{ label: tval('Create record'), value: 'create', color: 'lime' },
|
||||
{ label: tval('Update record'), value: 'update', color: 'gold' },
|
||||
{ label: tval('Delete record'), value: 'destroy', color: 'magenta' },
|
||||
],
|
||||
},
|
||||
},
|
||||
@ -112,7 +113,7 @@ export const AuditLogs: any = () => {
|
||||
ext['column31'] = {
|
||||
type: 'void',
|
||||
'x-component': 'TableV2.Column',
|
||||
title: '{{t("Record ID")}}',
|
||||
title: tval('Record ID'),
|
||||
properties: {
|
||||
recordId: {
|
||||
'x-component': 'Input',
|
||||
@ -141,7 +142,7 @@ export const AuditLogs: any = () => {
|
||||
properties: {
|
||||
filter: {
|
||||
type: 'void',
|
||||
title: '{{ t("Filter") }}',
|
||||
title: tval('Filter'),
|
||||
'x-action': 'filter',
|
||||
// 'x-designer': 'Filter.Action.Designer',
|
||||
'x-component': 'Filter.Action',
|
||||
@ -166,7 +167,7 @@ export const AuditLogs: any = () => {
|
||||
properties: {
|
||||
actions: {
|
||||
type: 'void',
|
||||
title: '{{ t("Actions") }}',
|
||||
title: tval('Actions'),
|
||||
'x-action-column': 'actions',
|
||||
'x-decorator': 'TableV2.Column.ActionBar',
|
||||
'x-component': 'TableV2.Column',
|
||||
@ -251,7 +252,7 @@ export const AuditLogs: any = () => {
|
||||
properties: {
|
||||
collection: {
|
||||
type: 'string',
|
||||
title: '{{t("Collection display name")}}',
|
||||
title: tval('Collection display name'),
|
||||
'x-component': 'Collection',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-read-pretty': true,
|
||||
@ -306,7 +307,7 @@ export const AuditLogs: any = () => {
|
||||
properties: {
|
||||
user: {
|
||||
type: 'string',
|
||||
title: '{{t("User")}}',
|
||||
title: tval('User'),
|
||||
'x-component': 'Username',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-read-pretty': true,
|
||||
@ -325,7 +326,7 @@ export const AuditLogs: any = () => {
|
||||
properties: {
|
||||
changes: {
|
||||
type: 'array',
|
||||
title: '{{t("Field value changes")}}',
|
||||
title: tval('Field value changes'),
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'ArrayTable',
|
||||
'x-component-props': {
|
||||
@ -340,7 +341,7 @@ export const AuditLogs: any = () => {
|
||||
'x-component': 'ArrayTable.Column',
|
||||
'x-component-props': {
|
||||
width: 200,
|
||||
title: '{{t("Field")}}',
|
||||
title: tval('Field'),
|
||||
},
|
||||
properties: {
|
||||
field: {
|
||||
@ -355,7 +356,7 @@ export const AuditLogs: any = () => {
|
||||
'x-component': 'ArrayTable.Column',
|
||||
'x-component-props': {
|
||||
width: 200,
|
||||
title: '{{t("Before change")}}',
|
||||
title: tval('Before change'),
|
||||
},
|
||||
properties: {
|
||||
before: {
|
||||
@ -370,7 +371,7 @@ export const AuditLogs: any = () => {
|
||||
'x-component': 'ArrayTable.Column',
|
||||
'x-component-props': {
|
||||
width: 200,
|
||||
title: '{{t("After change")}}',
|
||||
title: tval('After change'),
|
||||
},
|
||||
properties: {
|
||||
after: {
|
||||
@ -432,7 +433,7 @@ export const AuditLogs: any = () => {
|
||||
column3: {
|
||||
type: 'void',
|
||||
'x-component': 'TableV2.Column',
|
||||
title: '{{t("Collection display name")}}',
|
||||
title: tval('Collection display name'),
|
||||
properties: {
|
||||
collection: {
|
||||
'x-component': 'Collection',
|
||||
@ -444,7 +445,7 @@ export const AuditLogs: any = () => {
|
||||
column4: {
|
||||
type: 'void',
|
||||
'x-component': 'TableV2.Column',
|
||||
title: '{{t("User")}}',
|
||||
title: tval('User'),
|
||||
properties: {
|
||||
user: {
|
||||
'x-component': 'Username',
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
useTableBlockContext,
|
||||
} from '@nocobase/client';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useAuditLogsTranslation } from '../locale';
|
||||
|
||||
export const AuditLogsDesigner = () => {
|
||||
const { name, title } = useCollection_deprecated();
|
||||
@ -19,7 +19,7 @@ export const AuditLogsDesigner = () => {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { form } = useFormBlockContext();
|
||||
const { service } = useTableBlockContext();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useAuditLogsTranslation();
|
||||
const { dn } = useDesignable();
|
||||
return (
|
||||
<GeneralSchemaDesigner title={title || name}>
|
||||
|
@ -1,34 +1,23 @@
|
||||
import { Plugin, SchemaInitializerItemType } from '@nocobase/client';
|
||||
import { AuditLogsProvider } from './AuditLogsProvider';
|
||||
import {
|
||||
auditLogsTableActionColumnInitializers,
|
||||
auditLogsTableActionColumnInitializers_deprecated,
|
||||
} from './initializers/AuditLogsTableActionColumnInitializers';
|
||||
import {
|
||||
auditLogsTableActionInitializers,
|
||||
auditLogsTableActionInitializers_deprecated,
|
||||
} from './initializers/AuditLogsTableActionInitializers';
|
||||
import {
|
||||
auditLogsTableColumnInitializers,
|
||||
auditLogsTableColumnInitializers_deprecated,
|
||||
} from './initializers/AuditLogsTableColumnInitializers';
|
||||
import { auditLogsTableActionColumnInitializers } from './initializers/AuditLogsTableActionColumnInitializers';
|
||||
import { auditLogsTableActionInitializers } from './initializers/AuditLogsTableActionInitializers';
|
||||
import { auditLogsTableColumnInitializers } from './initializers/AuditLogsTableColumnInitializers';
|
||||
import { tval } from './locale';
|
||||
export * from './AuditLogsBlockInitializer';
|
||||
export * from './AuditLogsProvider';
|
||||
|
||||
export class AuditLogsPlugin extends Plugin {
|
||||
async load() {
|
||||
this.app.use(AuditLogsProvider);
|
||||
this.app.schemaInitializerManager.add(auditLogsTableActionInitializers_deprecated);
|
||||
this.app.schemaInitializerManager.add(auditLogsTableActionInitializers);
|
||||
this.app.schemaInitializerManager.add(auditLogsTableActionColumnInitializers_deprecated);
|
||||
this.app.schemaInitializerManager.add(auditLogsTableActionColumnInitializers);
|
||||
this.app.schemaInitializerManager.add(auditLogsTableColumnInitializers_deprecated);
|
||||
this.app.schemaInitializerManager.add(auditLogsTableColumnInitializers);
|
||||
|
||||
const blockInitializers = this.app.schemaInitializerManager.get('page:addBlock');
|
||||
const recordBlockInitializers = this.app.schemaInitializerManager.get('popup:common:addBlock');
|
||||
const auditLogs: Omit<SchemaInitializerItemType, 'name'> = {
|
||||
title: '{{t("Audit logs")}}',
|
||||
title: tval('Audit logs'),
|
||||
Component: 'AuditLogsBlockInitializer',
|
||||
};
|
||||
blockInitializers.add('otherBlocks.auditLogs', auditLogs);
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { InitializerWithSwitch, useSchemaInitializerItem } from '@nocobase/client';
|
||||
import React from 'react';
|
||||
import { tval } from '../locale';
|
||||
|
||||
export const AuditLogsTableActionColumnInitializer = () => {
|
||||
const schema = {
|
||||
type: 'void',
|
||||
title: '{{ t("Actions") }}',
|
||||
title: tval('Actions'),
|
||||
'x-decorator': 'TableV2.Column.ActionBar',
|
||||
'x-component': 'TableV2.Column',
|
||||
'x-designer': 'TableV2.ActionColumnDesigner',
|
||||
|
@ -1,27 +1,18 @@
|
||||
import { MenuOutlined } from '@ant-design/icons';
|
||||
import { useFieldSchema } from '@formily/react';
|
||||
import {
|
||||
CompatibleSchemaInitializer,
|
||||
createDesignable,
|
||||
Resizable,
|
||||
useAPIClient,
|
||||
useDesignable,
|
||||
} from '@nocobase/client';
|
||||
import { createDesignable, Resizable, SchemaInitializer, useAPIClient, useDesignable } from '@nocobase/client';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { tval, useAuditLogsTranslation } from '../locale';
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export const auditLogsTableActionColumnInitializers_deprecated = new CompatibleSchemaInitializer({
|
||||
name: 'AuditLogsTableActionColumnInitializers',
|
||||
export const auditLogsTableActionColumnInitializers = new SchemaInitializer({
|
||||
name: 'auditLogsTable:configureItemActions',
|
||||
insertPosition: 'beforeEnd',
|
||||
Component: (props: any) => <MenuOutlined {...props} style={{ cursor: 'pointer' }} />,
|
||||
useInsert() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const api = useAPIClient();
|
||||
const { refresh } = useDesignable();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useAuditLogsTranslation();
|
||||
|
||||
return (schema) => {
|
||||
const spaceSchema = fieldSchema.reduceProperties((buf, schema) => {
|
||||
@ -47,12 +38,12 @@ export const auditLogsTableActionColumnInitializers_deprecated = new CompatibleS
|
||||
{
|
||||
name: 'enableActions',
|
||||
type: 'itemGroup',
|
||||
title: '{{t("Enable actions")}}',
|
||||
title: tval('Enable actions'),
|
||||
children: [
|
||||
{
|
||||
name: 'view',
|
||||
type: 'item',
|
||||
title: '{{t("View")}}',
|
||||
title: tval('View'),
|
||||
Component: 'AuditLogsViewActionInitializer',
|
||||
schema: {
|
||||
'x-component': 'Action.Link',
|
||||
@ -69,73 +60,8 @@ export const auditLogsTableActionColumnInitializers_deprecated = new CompatibleS
|
||||
{
|
||||
name: 'columnWidth',
|
||||
type: 'item',
|
||||
title: '{{t("Column width")}}',
|
||||
title: tval('Column width'),
|
||||
Component: Resizable,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export const auditLogsTableActionColumnInitializers = new CompatibleSchemaInitializer(
|
||||
{
|
||||
name: 'auditLogsTable:configureItemActions',
|
||||
insertPosition: 'beforeEnd',
|
||||
Component: (props: any) => <MenuOutlined {...props} style={{ cursor: 'pointer' }} />,
|
||||
useInsert() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const api = useAPIClient();
|
||||
const { refresh } = useDesignable();
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (schema) => {
|
||||
const spaceSchema = fieldSchema.reduceProperties((buf, schema) => {
|
||||
if (schema['x-component'] === 'Space') {
|
||||
return schema;
|
||||
}
|
||||
return buf;
|
||||
}, null);
|
||||
if (!spaceSchema) {
|
||||
return;
|
||||
}
|
||||
const dn = createDesignable({
|
||||
t,
|
||||
api,
|
||||
refresh,
|
||||
current: spaceSchema,
|
||||
});
|
||||
dn.loadAPIClientEvents();
|
||||
dn.insertBeforeEnd(schema);
|
||||
};
|
||||
},
|
||||
items: [
|
||||
{
|
||||
name: 'enableActions',
|
||||
type: 'itemGroup',
|
||||
title: '{{t("Enable actions")}}',
|
||||
children: [
|
||||
{
|
||||
name: 'view',
|
||||
type: 'item',
|
||||
title: '{{t("View")}}',
|
||||
Component: 'AuditLogsViewActionInitializer',
|
||||
schema: {
|
||||
'x-component': 'Action.Link',
|
||||
'x-action': 'view',
|
||||
'x-decorator': 'ACLActionProvider',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'divider',
|
||||
type: 'divider',
|
||||
},
|
||||
{
|
||||
name: 'columnWidth',
|
||||
type: 'item',
|
||||
title: '{{t("Column width")}}',
|
||||
Component: Resizable,
|
||||
},
|
||||
],
|
||||
},
|
||||
auditLogsTableActionColumnInitializers_deprecated,
|
||||
);
|
||||
|
@ -1,12 +1,9 @@
|
||||
import { CompatibleSchemaInitializer } from '@nocobase/client';
|
||||
import { SchemaInitializer } from '@nocobase/client';
|
||||
import { tval } from '../locale';
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* 操作记录表格操作配置
|
||||
*/
|
||||
export const auditLogsTableActionInitializers_deprecated = new CompatibleSchemaInitializer({
|
||||
name: 'AuditLogsTableActionInitializers',
|
||||
title: "{{t('Configure actions')}}",
|
||||
export const auditLogsTableActionInitializers = new SchemaInitializer({
|
||||
name: 'auditLogsTable:configureActions',
|
||||
title: tval('Configure actions'),
|
||||
icon: 'SettingOutlined',
|
||||
style: {
|
||||
marginLeft: 8,
|
||||
@ -14,12 +11,12 @@ export const auditLogsTableActionInitializers_deprecated = new CompatibleSchemaI
|
||||
items: [
|
||||
{
|
||||
type: 'itemGroup',
|
||||
title: "{{t('Enable actions')}}",
|
||||
title: tval('Enable actions'),
|
||||
name: 'enableActions',
|
||||
children: [
|
||||
{
|
||||
name: 'filter',
|
||||
title: "{{t('Filter')}}",
|
||||
title: tval('Filter'),
|
||||
Component: 'FilterActionInitializer',
|
||||
schema: {
|
||||
'x-align': 'left',
|
||||
@ -27,7 +24,7 @@ export const auditLogsTableActionInitializers_deprecated = new CompatibleSchemaI
|
||||
},
|
||||
{
|
||||
name: 'refresh',
|
||||
title: "{{t('Refresh')}}",
|
||||
title: tval('Refresh'),
|
||||
Component: 'RefreshActionInitializer',
|
||||
schema: {
|
||||
'x-align': 'right',
|
||||
@ -37,40 +34,3 @@ export const auditLogsTableActionInitializers_deprecated = new CompatibleSchemaI
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export const auditLogsTableActionInitializers = new CompatibleSchemaInitializer(
|
||||
{
|
||||
name: 'auditLogsTable:configureActions',
|
||||
title: "{{t('Configure actions')}}",
|
||||
icon: 'SettingOutlined',
|
||||
style: {
|
||||
marginLeft: 8,
|
||||
},
|
||||
items: [
|
||||
{
|
||||
type: 'itemGroup',
|
||||
title: "{{t('Enable actions')}}",
|
||||
name: 'enableActions',
|
||||
children: [
|
||||
{
|
||||
name: 'filter',
|
||||
title: "{{t('Filter')}}",
|
||||
Component: 'FilterActionInitializer',
|
||||
schema: {
|
||||
'x-align': 'left',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'refresh',
|
||||
title: "{{t('Refresh')}}",
|
||||
Component: 'RefreshActionInitializer',
|
||||
schema: {
|
||||
'x-align': 'right',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
auditLogsTableActionInitializers_deprecated,
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {
|
||||
CompatibleSchemaInitializer,
|
||||
SchemaInitializer,
|
||||
SchemaInitializerChildren,
|
||||
useAssociatedTableColumnInitializerFields,
|
||||
useCompile,
|
||||
@ -7,12 +7,12 @@ import {
|
||||
useTableColumnInitializerFields,
|
||||
} from '@nocobase/client';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { tval, useAuditLogsTranslation } from '../locale';
|
||||
|
||||
// 表格列配置
|
||||
const ParentCollectionFields = () => {
|
||||
const inheritFields = useInheritsTableColumnInitializerFields();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useAuditLogsTranslation();
|
||||
const compile = useCompile();
|
||||
if (!inheritFields?.length) return null;
|
||||
const res = [];
|
||||
@ -30,7 +30,7 @@ const ParentCollectionFields = () => {
|
||||
|
||||
const AssociatedFields = () => {
|
||||
const associatedFields = useAssociatedTableColumnInitializerFields();
|
||||
const { t } = useTranslation();
|
||||
const { t } = useAuditLogsTranslation();
|
||||
|
||||
if (!associatedFields?.length) return null;
|
||||
const schema: any = [
|
||||
@ -44,14 +44,11 @@ const AssociatedFields = () => {
|
||||
return <SchemaInitializerChildren>{schema}</SchemaInitializerChildren>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export const auditLogsTableColumnInitializers_deprecated = new CompatibleSchemaInitializer({
|
||||
name: 'AuditLogsTableColumnInitializers',
|
||||
export const auditLogsTableColumnInitializers = new SchemaInitializer({
|
||||
name: 'auditLogsTable:configureColumns',
|
||||
insertPosition: 'beforeEnd',
|
||||
icon: 'SettingOutlined',
|
||||
title: '{{t("Configure columns")}}',
|
||||
title: tval('Configure columns'),
|
||||
wrap(s) {
|
||||
if (s['x-action-column']) {
|
||||
return s;
|
||||
@ -72,7 +69,7 @@ export const auditLogsTableColumnInitializers_deprecated = new CompatibleSchemaI
|
||||
{
|
||||
name: 'displayFields',
|
||||
type: 'itemGroup',
|
||||
title: '{{t("Display fields")}}',
|
||||
title: tval('Display fields'),
|
||||
useChildren: useTableColumnInitializerFields,
|
||||
},
|
||||
{
|
||||
@ -85,55 +82,8 @@ export const auditLogsTableColumnInitializers_deprecated = new CompatibleSchemaI
|
||||
},
|
||||
{
|
||||
name: 'actionColumn',
|
||||
title: '{{t("Action column")}}',
|
||||
title: tval('Action column'),
|
||||
Component: 'AuditLogsTableActionColumnInitializer',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export const auditLogsTableColumnInitializers = new CompatibleSchemaInitializer(
|
||||
{
|
||||
name: 'auditLogsTable:configureColumns',
|
||||
insertPosition: 'beforeEnd',
|
||||
icon: 'SettingOutlined',
|
||||
title: '{{t("Configure columns")}}',
|
||||
wrap(s) {
|
||||
if (s['x-action-column']) {
|
||||
return s;
|
||||
}
|
||||
return {
|
||||
type: 'void',
|
||||
'x-decorator': 'TableV2.Column.Decorator',
|
||||
'x-designer': 'TableV2.Column.Designer',
|
||||
'x-component': 'TableV2.Column',
|
||||
properties: {
|
||||
[s.name]: {
|
||||
...s,
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
items: [
|
||||
{
|
||||
name: 'displayFields',
|
||||
type: 'itemGroup',
|
||||
title: '{{t("Display fields")}}',
|
||||
useChildren: useTableColumnInitializerFields,
|
||||
},
|
||||
{
|
||||
name: 'parentCollectionFields',
|
||||
Component: ParentCollectionFields,
|
||||
},
|
||||
{
|
||||
name: 'associationFields',
|
||||
Component: AssociatedFields,
|
||||
},
|
||||
{
|
||||
name: 'actionColumn',
|
||||
title: '{{t("Action column")}}',
|
||||
Component: 'AuditLogsTableActionColumnInitializer',
|
||||
},
|
||||
],
|
||||
},
|
||||
auditLogsTableColumnInitializers_deprecated,
|
||||
);
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { uid } from '@formily/shared';
|
||||
import { tval } from './locale';
|
||||
|
||||
export const createSchema = () => {
|
||||
const filterSchema = {
|
||||
@ -7,7 +8,7 @@ export const createSchema = () => {
|
||||
popover: true,
|
||||
},
|
||||
type: 'void',
|
||||
title: '{{t("Filter")}}',
|
||||
title: tval('Filter'),
|
||||
properties: {
|
||||
popover: {
|
||||
type: 'void',
|
||||
@ -44,7 +45,7 @@ export const createSchema = () => {
|
||||
},
|
||||
cancel: {
|
||||
type: 'void',
|
||||
title: '{{t("Cancel")}}',
|
||||
title: tval('Cancel'),
|
||||
'x-component': 'Action',
|
||||
'x-component-props': {
|
||||
useAction: '{{cm.useCancelFilterAction}}',
|
||||
@ -52,7 +53,7 @@ export const createSchema = () => {
|
||||
},
|
||||
submit: {
|
||||
type: 'void',
|
||||
title: '{{t("Submit")}}',
|
||||
title: tval('Submit'),
|
||||
'x-component': 'Action',
|
||||
'x-component-props': {
|
||||
type: 'primary',
|
||||
@ -110,7 +111,7 @@ export const createSchema = () => {
|
||||
properties: {
|
||||
column1: {
|
||||
type: 'void',
|
||||
title: "{{t('Created at')}}",
|
||||
title: tval('Created at'),
|
||||
'x-component': 'Table.Column',
|
||||
properties: {
|
||||
created_at: {
|
||||
@ -125,7 +126,7 @@ export const createSchema = () => {
|
||||
},
|
||||
column2: {
|
||||
type: 'void',
|
||||
title: "{{t('Created by')}}",
|
||||
title: tval('Created by'),
|
||||
'x-component': 'Table.Column',
|
||||
properties: {
|
||||
'user.nickname': {
|
||||
@ -137,7 +138,7 @@ export const createSchema = () => {
|
||||
},
|
||||
column3: {
|
||||
type: 'void',
|
||||
title: "{{t('Collection display name')}}",
|
||||
title: tval('Collection display name'),
|
||||
'x-component': 'Table.Column',
|
||||
properties: {
|
||||
'collection.title': {
|
||||
@ -149,7 +150,7 @@ export const createSchema = () => {
|
||||
},
|
||||
column4: {
|
||||
type: 'void',
|
||||
title: "{{t('Action type')}}",
|
||||
title: tval('Action type'),
|
||||
'x-component': 'Table.Column',
|
||||
properties: {
|
||||
type: {
|
||||
@ -166,7 +167,7 @@ export const createSchema = () => {
|
||||
},
|
||||
[uid()]: {
|
||||
type: 'void',
|
||||
title: "{{t('Actions')}}",
|
||||
title: tval('Actions'),
|
||||
'x-component': 'Table.Column',
|
||||
'x-component-props': {
|
||||
width: 60,
|
||||
@ -192,7 +193,7 @@ export const createSchema = () => {
|
||||
properties: {
|
||||
created_at: {
|
||||
type: 'string',
|
||||
title: "{{t('Created at')}}",
|
||||
title: tval('Created at'),
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'DatePicker',
|
||||
'x-read-pretty': true,
|
||||
@ -202,37 +203,37 @@ export const createSchema = () => {
|
||||
},
|
||||
'user.nickname': {
|
||||
type: 'string',
|
||||
title: "{{t('Created by')}}",
|
||||
title: tval('Created by'),
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Input',
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
'collection.title': {
|
||||
type: 'string',
|
||||
title: "{{t('Collection display name')}}",
|
||||
title: tval('Collection display name'),
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Input',
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
title: "{{t('Action type')}}",
|
||||
title: tval('Action type'),
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Select',
|
||||
'x-read-pretty': true,
|
||||
enum: [
|
||||
{
|
||||
label: "{{t('Insert')}}",
|
||||
label: tval('Insert'),
|
||||
value: 'create',
|
||||
color: 'green',
|
||||
},
|
||||
{
|
||||
label: "{{t('Update')}}",
|
||||
label: tval('Update'),
|
||||
value: 'update',
|
||||
color: 'blue',
|
||||
},
|
||||
{
|
||||
label: "{{t('Delete')}}",
|
||||
label: tval('Delete'),
|
||||
value: 'destroy',
|
||||
color: 'red',
|
||||
},
|
||||
@ -240,7 +241,7 @@ export const createSchema = () => {
|
||||
},
|
||||
changes: {
|
||||
type: 'array',
|
||||
title: "{{t('Data changes')}}",
|
||||
title: tval('Data changes'),
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Table.Array',
|
||||
'x-component-props': {
|
||||
@ -253,7 +254,7 @@ export const createSchema = () => {
|
||||
column1: {
|
||||
type: 'void',
|
||||
'x-component': 'Table.Column',
|
||||
'x-component-props': { title: "{{t('Field display name')}}" },
|
||||
'x-component-props': { title: tval('Field display name') },
|
||||
properties: {
|
||||
field: {
|
||||
type: 'string',
|
||||
|
Loading…
Reference in New Issue
Block a user