@@ -25,6 +25,61 @@ import {
25
25
} from './notice-document-helpers' ;
26
26
import { UserSettings } from './user-settings' ;
27
27
28
+ const INITIALLY_DISABLED_MENU_ITEMS = [
29
+ 'save' ,
30
+ 'projectMetadata' ,
31
+ 'projectStatistics' ,
32
+ 'followUp' ,
33
+ 'compactComponentList' ,
34
+ 'detailedComponentList' ,
35
+ 'spdxYAML' ,
36
+ 'spdxJSON' ,
37
+ 'selectAll' ,
38
+ 'searchAttributions' ,
39
+ 'searchSignals' ,
40
+ 'searchResourcesAll' ,
41
+ 'searchResourceLinked' ,
42
+ ] as const ;
43
+
44
+ type Item = { label : string ; id : string } ;
45
+
46
+ const INITIALLY_DISABLED_ITEMS_INFO : Record <
47
+ ( typeof INITIALLY_DISABLED_MENU_ITEMS ) [ number ] ,
48
+ Item
49
+ > = {
50
+ save : { label : 'Save' , id : 'save' } ,
51
+ followUp : { label : 'Follow-Up' , id : 'follow-up' } ,
52
+ compactComponentList : {
53
+ label : 'Compact component list' ,
54
+ id : 'compact-list' ,
55
+ } ,
56
+ detailedComponentList : {
57
+ label : 'Detailed component list' ,
58
+ id : 'detailed-list' ,
59
+ } ,
60
+ spdxYAML : { label : 'SPDX (yaml)' , id : 'spdx-yaml' } ,
61
+ spdxJSON : { label : 'SPDX (json)' , id : 'spdx-json' } ,
62
+ projectMetadata : { label : 'Project Metadata' , id : 'project-metadata' } ,
63
+ projectStatistics : {
64
+ label : 'Project Statistics' ,
65
+ id : 'project-statistics' ,
66
+ } ,
67
+ selectAll : { label : 'Select All' , id : 'select-all' } ,
68
+ searchAttributions : {
69
+ label : 'Search Attributions' ,
70
+ id : 'search-attributions' ,
71
+ } ,
72
+ searchSignals : { label : 'Search Signals' , id : 'search-signals' } ,
73
+ searchResourcesAll : {
74
+ label : 'Search All Resources' ,
75
+ id : 'search-resources-all' ,
76
+ } ,
77
+ searchResourceLinked : {
78
+ label : 'Search Linked Resources' ,
79
+ id : 'search-resources-linked' ,
80
+ } ,
81
+ } ;
82
+
28
83
export async function createMenu ( mainWindow : BrowserWindow ) : Promise < Menu > {
29
84
const webContents = mainWindow . webContents ;
30
85
const qaMode = await UserSettings . get ( 'qaMode' ) ;
@@ -49,13 +104,15 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
49
104
'icons/save-white.png' ,
50
105
'icons/save-black.png' ,
51
106
) ,
52
- label : 'Save' ,
107
+ label : INITIALLY_DISABLED_ITEMS_INFO . save . label ,
53
108
accelerator : 'CmdOrCtrl+S' ,
54
109
click : ( ) => {
55
110
webContents . send ( AllowedFrontendChannels . SaveFileRequest , {
56
111
saveFile : true ,
57
112
} ) ;
58
113
} ,
114
+ id : INITIALLY_DISABLED_ITEMS_INFO . save . id ,
115
+ enabled : false ,
59
116
} ,
60
117
{
61
118
label : 'Export' ,
@@ -65,7 +122,7 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
65
122
) ,
66
123
submenu : [
67
124
{
68
- label : 'Follow-Up' ,
125
+ label : INITIALLY_DISABLED_ITEMS_INFO . followUp . label ,
69
126
icon : getIconBasedOnTheme (
70
127
'icons/follow-up-white.png' ,
71
128
'icons/follow-up-black.png' ,
@@ -78,13 +135,15 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
78
135
ExportType . FollowUp ,
79
136
) ;
80
137
} ,
138
+ id : INITIALLY_DISABLED_ITEMS_INFO . followUp . id ,
139
+ enabled : false ,
81
140
} ,
82
141
{
83
142
icon : getIconBasedOnTheme (
84
143
'icons/com-list-white.png' ,
85
144
'icons/com-list-black.png' ,
86
145
) ,
87
- label : 'Compact component list' ,
146
+ label : INITIALLY_DISABLED_ITEMS_INFO . compactComponentList . label ,
88
147
click : ( ) => {
89
148
setLoadingState ( mainWindow . webContents , true ) ;
90
149
logger . info ( 'Preparing data for compact component list export' ) ;
@@ -93,13 +152,15 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
93
152
ExportType . CompactBom ,
94
153
) ;
95
154
} ,
155
+ id : INITIALLY_DISABLED_ITEMS_INFO . compactComponentList . id ,
156
+ enabled : false ,
96
157
} ,
97
158
{
98
159
icon : getIconBasedOnTheme (
99
160
'icons/det-list-white.png' ,
100
161
'icons/det-list-black.png' ,
101
162
) ,
102
- label : 'Detailed component list' ,
163
+ label : INITIALLY_DISABLED_ITEMS_INFO . detailedComponentList . label ,
103
164
click : ( ) => {
104
165
setLoadingState ( mainWindow . webContents , true ) ;
105
166
logger . info (
@@ -110,13 +171,15 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
110
171
ExportType . DetailedBom ,
111
172
) ;
112
173
} ,
174
+ id : INITIALLY_DISABLED_ITEMS_INFO . detailedComponentList . id ,
175
+ enabled : false ,
113
176
} ,
114
177
{
115
178
icon : getIconBasedOnTheme (
116
179
'icons/yaml-white.png' ,
117
180
'icons/yaml-black.png' ,
118
181
) ,
119
- label : 'SPDX (yaml)' ,
182
+ label : INITIALLY_DISABLED_ITEMS_INFO . spdxYAML . label ,
120
183
click : ( ) => {
121
184
setLoadingState ( mainWindow . webContents , true ) ;
122
185
logger . info ( 'Preparing data for SPDX (yaml) export' ) ;
@@ -125,13 +188,15 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
125
188
ExportType . SpdxDocumentYaml ,
126
189
) ;
127
190
} ,
191
+ id : INITIALLY_DISABLED_ITEMS_INFO . spdxYAML . id ,
192
+ enabled : false ,
128
193
} ,
129
194
{
130
195
icon : getIconBasedOnTheme (
131
196
'icons/json-white.png' ,
132
197
'icons/json-black.png' ,
133
198
) ,
134
- label : 'SPDX (json)' ,
199
+ label : INITIALLY_DISABLED_ITEMS_INFO . spdxJSON . label ,
135
200
click : ( ) => {
136
201
setLoadingState ( mainWindow . webContents , true ) ;
137
202
logger . info ( 'Preparing data for SPDX (json) export' ) ;
@@ -140,6 +205,8 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
140
205
ExportType . SpdxDocumentJson ,
141
206
) ;
142
207
} ,
208
+ id : INITIALLY_DISABLED_ITEMS_INFO . spdxJSON . id ,
209
+ enabled : false ,
143
210
} ,
144
211
] ,
145
212
} ,
@@ -148,7 +215,7 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
148
215
'icons/about-white.png' ,
149
216
'icons/about-black.png' ,
150
217
) ,
151
- label : 'Project Metadata' ,
218
+ label : INITIALLY_DISABLED_ITEMS_INFO . projectMetadata . label ,
152
219
click : ( ) => {
153
220
if ( isFileLoaded ( getGlobalBackendState ( ) ) ) {
154
221
webContents . send (
@@ -159,13 +226,15 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
159
226
) ;
160
227
}
161
228
} ,
229
+ id : INITIALLY_DISABLED_ITEMS_INFO . projectMetadata . id ,
230
+ enabled : false ,
162
231
} ,
163
232
{
164
233
icon : getIconBasedOnTheme (
165
234
'icons/statictics-white.png' ,
166
235
'icons/statictics-black.png' ,
167
236
) ,
168
- label : 'Project Statistics' ,
237
+ label : INITIALLY_DISABLED_ITEMS_INFO . projectStatistics . label ,
169
238
click : ( ) => {
170
239
if ( isFileLoaded ( getGlobalBackendState ( ) ) ) {
171
240
webContents . send (
@@ -176,6 +245,8 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
176
245
) ;
177
246
}
178
247
} ,
248
+ id : INITIALLY_DISABLED_ITEMS_INFO . projectStatistics . id ,
249
+ enabled : false ,
179
250
} ,
180
251
{
181
252
icon : getIconBasedOnTheme (
@@ -254,62 +325,72 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
254
325
'icons/select-all-white.png' ,
255
326
'icons/select-all-black.png' ,
256
327
) ,
257
- label : 'Select All' ,
328
+ label : INITIALLY_DISABLED_ITEMS_INFO . selectAll . label ,
258
329
accelerator : 'CmdOrCtrl+A' ,
259
330
role : 'selectAll' ,
331
+ id : INITIALLY_DISABLED_ITEMS_INFO . selectAll . id ,
332
+ enabled : false ,
260
333
} ,
261
334
{ type : 'separator' } ,
262
335
{
263
336
icon : getIconBasedOnTheme (
264
337
'icons/magnifying-glass-white.png' ,
265
338
'icons/magnifying-glass-black.png' ,
266
339
) ,
267
- label : 'Search Attributions' ,
340
+ label : INITIALLY_DISABLED_ITEMS_INFO . searchAttributions . label ,
268
341
accelerator : 'CmdOrCtrl+Shift+A' ,
269
342
click : ( ) => {
270
343
if ( isFileLoaded ( getGlobalBackendState ( ) ) ) {
271
344
webContents . send ( AllowedFrontendChannels . SearchAttributions ) ;
272
345
}
273
346
} ,
347
+ id : INITIALLY_DISABLED_ITEMS_INFO . searchAttributions . id ,
348
+ enabled : false ,
274
349
} ,
275
350
{
276
351
icon : getIconBasedOnTheme (
277
352
'icons/magnifying-glass-white.png' ,
278
353
'icons/magnifying-glass-black.png' ,
279
354
) ,
280
- label : 'Search Signals' ,
355
+ label : INITIALLY_DISABLED_ITEMS_INFO . searchSignals . label ,
281
356
accelerator : 'CmdOrCtrl+Shift+S' ,
282
357
click : ( ) => {
283
358
if ( isFileLoaded ( getGlobalBackendState ( ) ) ) {
284
359
webContents . send ( AllowedFrontendChannels . SearchSignals ) ;
285
360
}
286
361
} ,
362
+ id : INITIALLY_DISABLED_ITEMS_INFO . searchSignals . id ,
363
+ enabled : false ,
287
364
} ,
288
365
{
289
366
icon : getIconBasedOnTheme (
290
367
'icons/search-white.png' ,
291
368
'icons/search-black.png' ,
292
369
) ,
293
- label : 'Search All Resources' ,
370
+ label : INITIALLY_DISABLED_ITEMS_INFO . searchResourcesAll . label ,
294
371
accelerator : 'CmdOrCtrl+Shift+R' ,
295
372
click : ( ) => {
296
373
if ( isFileLoaded ( getGlobalBackendState ( ) ) ) {
297
374
webContents . send ( AllowedFrontendChannels . SearchResources ) ;
298
375
}
299
376
} ,
377
+ id : INITIALLY_DISABLED_ITEMS_INFO . searchResourcesAll . id ,
378
+ enabled : false ,
300
379
} ,
301
380
{
302
381
icon : getIconBasedOnTheme (
303
382
'icons/search-white.png' ,
304
383
'icons/search-black.png' ,
305
384
) ,
306
- label : 'Search Linked Resources' ,
385
+ label : INITIALLY_DISABLED_ITEMS_INFO . searchResourceLinked . label ,
307
386
accelerator : 'CmdOrCtrl+Shift+L' ,
308
387
click : ( ) => {
309
388
if ( isFileLoaded ( getGlobalBackendState ( ) ) ) {
310
389
webContents . send ( AllowedFrontendChannels . SearchLinkedResources ) ;
311
390
}
312
391
} ,
392
+ id : INITIALLY_DISABLED_ITEMS_INFO . searchResourceLinked . id ,
393
+ enabled : false ,
313
394
} ,
314
395
] ,
315
396
} ,
@@ -450,3 +531,15 @@ export async function createMenu(mainWindow: BrowserWindow): Promise<Menu> {
450
531
} ,
451
532
] ) ;
452
533
}
534
+
535
+ export function activateMenuItems ( ) : void {
536
+ const menu = Menu . getApplicationMenu ( ) ;
537
+ INITIALLY_DISABLED_MENU_ITEMS . forEach ( ( key ) => {
538
+ const menuItem = menu ?. getMenuItemById (
539
+ INITIALLY_DISABLED_ITEMS_INFO [ key ] . id ,
540
+ ) ;
541
+ if ( menuItem ) {
542
+ menuItem . enabled = true ;
543
+ }
544
+ } ) ;
545
+ }
0 commit comments