( context: MainMenuContext = currentMainMenuContext, )
| 611 | } |
| 612 | |
| 613 | function createMainMenuTemplate( |
| 614 | context: MainMenuContext = currentMainMenuContext, |
| 615 | ): MenuItemConstructorOptions[] { |
| 616 | const fileMenuItems = createFileMenuItems(context) |
| 617 | const historyMenuItems = createHistoryMenuItems() |
| 618 | const viewMenuItems = createViewMenuItems(context) |
| 619 | const editorMenuItems = createEditorMenuItems(context) |
| 620 | |
| 621 | const template: MenuItemConstructorOptions[] = [ |
| 622 | { |
| 623 | label: i18n.t('menu:app.label'), |
| 624 | submenu: createPlatformMenuItems(appMenuItems), |
| 625 | }, |
| 626 | { |
| 627 | role: 'editMenu', |
| 628 | submenu: createPlatformMenuItems(editMenuItems), |
| 629 | }, |
| 630 | { |
| 631 | label: i18n.t('menu:history.label'), |
| 632 | submenu: createPlatformMenuItems(historyMenuItems), |
| 633 | }, |
| 634 | { |
| 635 | role: 'windowMenu', |
| 636 | }, |
| 637 | { |
| 638 | label: i18n.t('menu:help.label'), |
| 639 | submenu: createPlatformMenuItems(helpMenuItems), |
| 640 | }, |
| 641 | ] |
| 642 | |
| 643 | if (fileMenuItems.length) { |
| 644 | template.splice(1, 0, { |
| 645 | label: i18n.t('menu:file.label'), |
| 646 | submenu: createPlatformMenuItems(fileMenuItems), |
| 647 | }) |
| 648 | } |
| 649 | |
| 650 | const viewInsertIndex = template.findIndex( |
| 651 | item => item.role === 'windowMenu', |
| 652 | ) |
| 653 | |
| 654 | if (viewMenuItems.length) { |
| 655 | template.splice(viewInsertIndex, 0, { |
| 656 | label: i18n.t('menu:view.label'), |
| 657 | submenu: createPlatformMenuItems(viewMenuItems), |
| 658 | }) |
| 659 | } |
| 660 | |
| 661 | if (editorMenuItems.length) { |
| 662 | const insertIndex = template.findIndex( |
| 663 | item => item.role === 'windowMenu', |
| 664 | ) |
| 665 | template.splice(insertIndex, 0, { |
| 666 | label: i18n.t('menu:editor.label'), |
| 667 | submenu: createPlatformMenuItems(editorMenuItems), |
| 668 | }) |
| 669 | } |
| 670 |
no test coverage detected