refactor: unify tab initailizer naming (#3932)

* refactor: rename dialog to popup

* feat: add tabPaneInitializers

* refactor: rename TabPaneInitializers to popup:addTab

* refactor: rename TabPaneInitializersForCreateFormBlock to popup:addTab

* refactor: rename TabPaneInitializersForBulkEditFormBlock to popup:addTab

* chore: fix unit tests

* chore: fix e2e
This commit is contained in:
Zeke Zhang 2024-04-05 23:19:09 +08:00 committed by GitHub
parent 385ac5a488
commit b750cab942
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 61 additions and 35 deletions

View File

@ -396,7 +396,7 @@ export const recordPickerViewer = {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -29,7 +29,10 @@ export const CreateChildInitializer = (props) => {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializersForCreateFormBlock',
'x-initializer': 'popup:addTab',
'x-initializer-props': {
gridInitializer: 'popup:addNew:addBlock',
},
properties: {
tab1: {
type: 'void',

View File

@ -31,7 +31,10 @@ export const CreateActionInitializer = () => {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializersForCreateFormBlock',
'x-initializer': 'popup:addTab',
'x-initializer-props': {
gridInitializer: 'popup:addNew:addBlock',
},
properties: {
tab1: {
type: 'void',

View File

@ -27,7 +27,7 @@ export const CustomizeAddRecordActionInitializer = () => {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializersForCreateFormBlock',
'x-initializer': 'popup:addTab',
'x-initializer-props': {
gridInitializer: 'popup:addRecord:addBlock',
},

View File

@ -27,7 +27,7 @@ export const PopupActionInitializer = (props) => {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -27,7 +27,7 @@ export const UpdateActionInitializer = (props) => {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -26,7 +26,7 @@ export const ViewActionInitializer = (props) => {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -6,7 +6,7 @@ import {
oneFormBlockWithRolesFieldBasedUsers,
test,
} from '@nocobase/test/e2e';
import { tableWithRoles, tableWithUsers, tableWithInherit, tableWithInheritWithoutAssociation } from './templatesOfBug';
import { tableWithInherit, tableWithInheritWithoutAssociation, tableWithRoles, tableWithUsers } from './templatesOfBug';
test.describe('where to open a popup and what can be added to it', () => {
test('add new', async ({ page, mockPage }) => {
@ -16,7 +16,7 @@ test.describe('where to open a popup and what can be added to it', () => {
await page.getByLabel('action-Action-Add new-create-general-table').click();
// add a tab
await page.getByLabel('schema-initializer-Tabs-TabPaneInitializersForCreateFormBlock-general').click();
await page.getByLabel('schema-initializer-Tabs-').click();
await page.getByRole('textbox').click();
await page.getByRole('textbox').fill('test123');
await page.getByLabel('action-Action-Submit-general-table').click();
@ -41,7 +41,7 @@ test.describe('where to open a popup and what can be added to it', () => {
await page.getByLabel('action-Action-Add record-customize:create-general-table').click();
// add a tab
await page.getByLabel('schema-initializer-Tabs-TabPaneInitializersForCreateFormBlock-general').click();
await page.getByLabel('schema-initializer-Tabs-').click();
await page.getByRole('textbox').click();
await page.getByRole('textbox').fill('test7');
await page.getByLabel('action-Action-Submit-general-table').click();
@ -70,7 +70,7 @@ test.describe('where to open a popup and what can be added to it', () => {
await page.getByLabel('action-Action.Link-View-view-general-table-0').click();
// add a tab
await page.getByLabel('schema-initializer-Tabs-TabPaneInitializers-general').click();
await page.getByLabel('schema-initializer-Tabs-').click();
await page.getByRole('textbox').click();
await page.getByRole('textbox').fill('test8');
await page.getByLabel('action-Action-Submit-general-table-0').click();
@ -127,7 +127,7 @@ test.describe('where to open a popup and what can be added to it', () => {
// open dialog
await page.getByLabel('action-Action-Bulk edit-customize:bulkEdit-general-table').click();
await page.getByLabel('schema-initializer-Tabs-TabPaneInitializersForBulkEditFormBlock-general').click();
await page.getByLabel('schema-initializer-Tabs-').click();
await page.getByRole('textbox').click();
await page.getByRole('textbox').fill('test1');
await page.getByLabel('action-Action-Submit-general-table').click();
@ -156,7 +156,7 @@ test.describe('where to open a popup and what can be added to it', () => {
.click();
// add a tab
await page.getByLabel('schema-initializer-Tabs-TabPaneInitializers-general').click();
await page.getByLabel('schema-initializer-Tabs-').click();
await page.getByRole('textbox').click();
await page.getByRole('textbox').fill('test8');
await page.getByLabel('action-Action-Submit-general-details').click();

View File

@ -23,7 +23,10 @@ export default {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializersForCreateFormBlock',
'x-initializer': 'popup:addTab',
'x-initializer-props': {
gridInitializer: 'popup:addNew:addBlock',
},
properties: {
tab1: {
type: 'void',
@ -98,7 +101,7 @@ export default {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -4,7 +4,7 @@ import { SchemaComponent, useActionContext, useDesignable, useRecord } from '../
import { SchemaInitializer } from '../../application/schema-initializer/SchemaInitializer';
import { useGetAriaLabelOfSchemaInitializer } from '../hooks/useGetAriaLabelOfSchemaInitializer';
export const TabPaneInitializers = (props?: any) => {
const TabPaneInitializers = (props?: any) => {
const { designable, insertBeforeEnd } = useDesignable();
const { isCreate, isBulkEdit, options } = props;
const { gridInitializer } = options;
@ -130,25 +130,36 @@ export const TabPaneInitializers = (props?: any) => {
return <SchemaComponent schema={schema} />;
};
export const TabPaneInitializersForCreateFormBlock = (props) => {
const TabPaneInitializersForCreateFormBlock = (props) => {
return <TabPaneInitializers {...props} isCreate />;
};
export const TabPaneInitializersForBulkEditFormBlock = (props) => {
const TabPaneInitializersForBulkEditFormBlock = (props) => {
return <TabPaneInitializers {...props} isBulkEdit />;
};
const commonOptions = {
Component: TabPaneInitializers,
popover: false,
};
/**
* @deprecated
* use `tabPaneInitializers` instead
*/
export const tabPaneInitializers_deprecated = new SchemaInitializer({
name: 'TabPaneInitializers',
Component: TabPaneInitializers,
popover: false,
...commonOptions,
});
export const tabPaneInitializers = new SchemaInitializer({
name: 'popup:addTab',
...commonOptions,
});
/**
* @deprecated
* use `tabPaneInitializers` instead
*/
export const tabPaneInitializersForRecordBlock = new SchemaInitializer({
name: 'TabPaneInitializersForCreateFormBlock',
@ -158,6 +169,7 @@ export const tabPaneInitializersForRecordBlock = new SchemaInitializer({
/**
* @deprecated
* use `tabPaneInitializers` instead
*/
export const tabPaneInitializersForBulkEditFormBlock = new SchemaInitializer({
name: 'TabPaneInitializersForBulkEditFormBlock',

View File

@ -113,6 +113,7 @@ import {
recordBlockInitializers_deprecated,
subTableActionInitializers,
subTableActionInitializers_deprecated,
tabPaneInitializers,
tabPaneInitializersForBulkEditFormBlock,
tabPaneInitializersForRecordBlock,
tabPaneInitializers_deprecated,
@ -225,6 +226,7 @@ export class SchemaInitializerPlugin extends Plugin {
this.app.schemaInitializerManager.add(tableSelectorInitializers_deprecated);
this.app.schemaInitializerManager.add(tableSelectorInitializers);
this.app.schemaInitializerManager.add(tabPaneInitializers_deprecated);
this.app.schemaInitializerManager.add(tabPaneInitializers);
this.app.schemaInitializerManager.add(tabPaneInitializersForRecordBlock);
this.app.schemaInitializerManager.add(tabPaneInitializersForBulkEditFormBlock);
this.app.schemaInitializerManager.add(menuItemInitializer_deprecated);

View File

@ -27,7 +27,10 @@ export const BulkEditActionInitializer = () => {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializersForBulkEditFormBlock',
'x-initializer': 'popup:addTab',
'x-initializer-props': {
gridInitializer: 'popup:bulkEdit:addBlock',
},
properties: {
tab1: {
type: 'void',

View File

@ -26,7 +26,7 @@ export const DuplicateActionInitializer = (props) => {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -192,7 +192,7 @@ export const AuditLogsViewActionInitializer = () => {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -55,7 +55,7 @@ describe('createCalendarBlockSchema', () => {
"type": "void",
"x-component": "Tabs",
"x-component-props": {},
"x-initializer": "TabPaneInitializers",
"x-initializer": "popup:addTab",
"x-initializer-props": {
"gridInitializer": "popup:common:addBlock",
},

View File

@ -63,7 +63,7 @@ export const createCalendarBlockUISchema = (options: {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
'x-initializer-props': {
gridInitializer: 'popup:common:addBlock',
},

View File

@ -101,7 +101,7 @@ export const CalendarFormActionInitializers = new SchemaInitializer({
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -47,7 +47,7 @@ describe('createGanttBlockSchema', () => {
"type": "void",
"x-component": "Tabs",
"x-component-props": {},
"x-initializer": "TabPaneInitializers",
"x-initializer": "popup:addTab",
},
},
"title": "{{ t("View record") }}",

View File

@ -100,7 +100,7 @@ export const createGanttBlockUISchema = (options: {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -78,7 +78,7 @@ test('createKanbanBlockSchema should return an object with expected properties',
"type": "void",
"x-component": "Tabs",
"x-component-props": {},
"x-initializer": "TabPaneInitializers",
"x-initializer": "popup:addTab",
},
},
"title": "{{ t("View record") }}",

View File

@ -86,7 +86,7 @@ export const createKanbanBlockUISchema = (options: {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -55,7 +55,7 @@ test('createMapBlockSchema should return an object with expected properties', ()
"type": "void",
"x-component": "Tabs",
"x-component-props": {},
"x-initializer": "TabPaneInitializers",
"x-initializer": "popup:addTab",
},
},
"title": "{{ t("View record") }}",

View File

@ -54,7 +54,7 @@ export const createMapBlockUISchema = (options: {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -75,7 +75,7 @@ export const PageDesigner = (props) => {
name: 'tabs',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
'x-initializer-props': {
gridInitializer: 'mobilePage:addBlock',
},

View File

@ -78,7 +78,7 @@ const recordPickerViewer = {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
// 'x-initializer': 'TabPaneInitializers',
// 'x-initializer': 'popup:addTab',
properties: {
tab1: {
type: 'void',

View File

@ -531,7 +531,7 @@ export function SchemaConfig({ value, onChange }) {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'popup:addTab',
'x-initializer-props': {
gridInitializer: 'workflowManual:popup:configureUserInterface:addBlock',
},