Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

chore: add message debug test util (#401)

Wenzhao Hu2be3af3b2726
diff --git a/packages/sheets-plugin-debugger/src/commands/operations/message.operation.ts b/packages/sheets-plugin-debugger/src/commands/operations/message.operation.ts
new file mode 100644
index 0000000000..e3ca4f1fc6
--- /dev/null
+++ b/packages/sheets-plugin-debugger/src/commands/operations/message.operation.ts
@@ -0,0 +1,17 @@
+import { IMessageService, MessageType } from '@univerjs/base-ui';
+import { CommandType, ICommand } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+
+export const MessageOperation: ICommand = {
+ id: 'debugger.operation.message',
+ type: CommandType.OPERATION,
+ handler: async (accessor: IAccessor) => {
+ const messageService = accessor.get(IMessageService);
+ messageService.show({
+ type: MessageType.Error,
+ content: 'Demo message',
+ });
+
+ return true;
+ },
+};
diff --git a/packages/sheets-plugin-debugger/src/controllers/debugger.controller.ts b/packages/sheets-plugin-debugger/src/controllers/debugger.controller.ts
index 958e2c4a41..10fa969c52 100644
--- a/packages/sheets-plugin-debugger/src/controllers/debugger.controller.ts
+++ b/packages/sheets-plugin-debugger/src/controllers/debugger.controller.ts
@@ -1,16 +1,18 @@
-import { IMenuService } from '@univerjs/base-ui';
+import { IMenuItemFactory, IMenuService } from '@univerjs/base-ui';
import { Disposable, ICommandService } from '@univerjs/core';
import { Inject, Injector } from '@wendellhu/redi';
import { ConfirmOperation } from '../commands/operations/confirm.operation';
import { DialogOperation } from '../commands/operations/dialog.operation';
import { LocaleOperation } from '../commands/operations/locale.operation';
+import { MessageOperation } from '../commands/operations/message.operation';
import { NotificationOperation } from '../commands/operations/notification.operation';
import { ThemeOperation } from '../commands/operations/theme.operation';
import {
ConfirmMenuItemFactory,
DialogMenuItemFactory,
LocaleMenuItemFactory,
+ MessageMenuItemFactory,
NotificationMenuItemFactory,
ThemeMenuItemFactory,
} from './menu';
@@ -24,19 +26,27 @@ export class DebuggerController extends Disposable {
super();
this._initializeContextMenu();
- [LocaleOperation, ThemeOperation, NotificationOperation, DialogOperation, ConfirmOperation].forEach((command) =>
- this.disposeWithMe(this._commandService.registerCommand(command))
- );
+ [
+ LocaleOperation,
+ ThemeOperation,
+ NotificationOperation,
+ DialogOperation,
+ ConfirmOperation,
+ MessageOperation,
+ ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
}
private _initializeContextMenu() {
- [
- LocaleMenuItemFactory,
- ThemeMenuItemFactory,
- NotificationMenuItemFactory,
- DialogMenuItemFactory,
- ConfirmMenuItemFactory,
- ].forEach((factory) => {
+ (
+ [
+ LocaleMenuItemFactory,
+ ThemeMenuItemFactory,
+ MessageMenuItemFactory,
+ NotificationMenuItemFactory,
+ DialogMenuItemFactory,
+ ConfirmMenuItemFactory,
+ ] as IMenuItemFactory[]
+ ).forEach((factory) => {
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));
});
}
diff --git a/packages/sheets-plugin-debugger/src/controllers/menu.ts b/packages/sheets-plugin-debugger/src/controllers/menu.ts
index 3a9b86b7ff..3f5f54dd1d 100644
--- a/packages/sheets-plugin-debugger/src/controllers/menu.ts
+++ b/packages/sheets-plugin-debugger/src/controllers/menu.ts
@@ -6,6 +6,7 @@ import { IAccessor } from '@wendellhu/redi';
import { ConfirmOperation } from '../commands/operations/confirm.operation';
import { DialogOperation } from '../commands/operations/dialog.operation';
import { LocaleOperation } from '../commands/operations/locale.operation';
+import { MessageOperation } from '../commands/operations/message.operation';
import { NotificationOperation } from '../commands/operations/notification.operation';
import { ThemeOperation } from '../commands/operations/theme.operation';
@@ -108,3 +109,19 @@ export function ConfirmMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
],
};
}
+
+export function MessageMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
+ return {
+ id: MessageOperation.id,
+ title: 'debugger.message',
+ tooltip: 'debugger.message',
+ type: MenuItemType.SELECTOR,
+ positions: [MenuPosition.TOOLBAR_OTHERS],
+ selections: [
+ {
+ label: 'Open message',
+ value: '',
+ },
+ ],
+ };
+}
diff --git a/packages/sheets-plugin-debugger/src/locale/en-US.ts b/packages/sheets-plugin-debugger/src/locale/en-US.ts
index 2c8d4edb94..3ad1607708 100644
--- a/packages/sheets-plugin-debugger/src/locale/en-US.ts
+++ b/packages/sheets-plugin-debugger/src/locale/en-US.ts
@@ -4,6 +4,7 @@ export default {
title: 'Language',
tooltip: 'Language',
},
+ message: 'Message',
theme: {
title: 'Theme',
tooltip: 'Theme',
diff --git a/packages/sheets-plugin-debugger/src/locale/zh-CN.ts b/packages/sheets-plugin-debugger/src/locale/zh-CN.ts
index 31ae1e25fd..c2beaab3e8 100644
--- a/packages/sheets-plugin-debugger/src/locale/zh-CN.ts
+++ b/packages/sheets-plugin-debugger/src/locale/zh-CN.ts
@@ -4,6 +4,7 @@ export default {
title: '语言',
tooltip: '语言',
},
+ message: '消息通知',
theme: {
title: '主题',
tooltip: '主题',