99 shell ,
1010} from 'electron' ;
1111import prompt from 'custom-electron-prompt' ;
12+ import { satisfies } from 'semver' ;
1213
1314import { allPlugins } from 'virtual:plugins' ;
1415
@@ -23,6 +24,8 @@ import promptOptions from './providers/prompt-options';
2324import { getAllMenuTemplate , loadAllMenuPlugins } from './loader/menu' ;
2425import { setLanguage , t } from '@/i18n' ;
2526
27+ import packageJson from '../package.json' ;
28+
2629export type MenuTemplate = Electron . MenuItemConstructorOptions [ ] ;
2730
2831// True only if in-app-menu was loaded on launch
@@ -31,10 +34,14 @@ const inAppMenuActive = config.plugins.isEnabled('in-app-menu');
3134const pluginEnabledMenu = (
3235 plugin : string ,
3336 label = '' ,
37+ description : string | undefined = undefined ,
38+ isNew = false ,
3439 hasSubmenu = false ,
3540 refreshMenu : ( ( ) => void ) | undefined = undefined ,
3641) : Electron . MenuItemConstructorOptions => ( {
3742 label : label || plugin ,
43+ sublabel : isNew ? t ( 'main.menu.plugins.new' ) : undefined ,
44+ toolTip : description ,
3845 type : 'checkbox' ,
3946 checked : config . plugins . isEnabled ( plugin ) ,
4047 click ( item : Electron . MenuItem ) {
@@ -66,23 +73,30 @@ export const mainMenuTemplate = async (
6673
6774 const menuResult = Object . entries ( getAllMenuTemplate ( ) ) . map (
6875 ( [ id , template ] ) => {
69- const pluginLabel = allPlugins [ id ] ?. name ?.( ) ?? id ;
76+ const plugin = allPlugins [ id ] ;
77+ const pluginLabel = plugin ?. name ?.( ) ?? id ;
78+ const pluginDescription = plugin ?. description ?.( ) ?? undefined ;
79+ const isNew = plugin ?. addedVersion ? satisfies ( packageJson . version , plugin . addedVersion ) : false ;
7080
7181 if ( ! config . plugins . isEnabled ( id ) ) {
7282 return [
7383 id ,
74- pluginEnabledMenu ( id , pluginLabel , true , innerRefreshMenu ) ,
84+ pluginEnabledMenu ( id , pluginLabel , pluginDescription , isNew , true , innerRefreshMenu ) ,
7585 ] as const ;
7686 }
7787
7888 return [
7989 id ,
8090 {
8191 label : pluginLabel ,
92+ sublabel : isNew ? t ( 'main.menu.plugins.new' ) : undefined ,
93+ toolTip : pluginDescription ,
8294 submenu : [
8395 pluginEnabledMenu (
8496 id ,
8597 t ( 'main.menu.plugins.enabled' ) ,
98+ undefined ,
99+ false ,
86100 true ,
87101 innerRefreshMenu ,
88102 ) ,
@@ -106,9 +120,12 @@ export const mainMenuTemplate = async (
106120 const predefinedTemplate = menuResult . find ( ( it ) => it [ 0 ] === id ) ;
107121 if ( predefinedTemplate ) return predefinedTemplate [ 1 ] ;
108122
109- const pluginLabel = allPlugins [ id ] ?. name ?.( ) ?? id ;
123+ const plugin = allPlugins [ id ] ;
124+ const pluginLabel = plugin ?. name ?.( ) ?? id ;
125+ const pluginDescription = plugin ?. description ?.( ) ?? undefined ;
126+ const isNew = plugin ?. addedVersion ? satisfies ( packageJson . version , plugin . addedVersion ) : false ;
110127
111- return pluginEnabledMenu ( id , pluginLabel , true , innerRefreshMenu ) ;
128+ return pluginEnabledMenu ( id , pluginLabel , pluginDescription , isNew , true , innerRefreshMenu ) ;
112129 } ) ;
113130
114131 const availableLanguages = Object . keys ( languageResources ) ;
0 commit comments