Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
actual-vt-capstone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danieljk
actual-vt-capstone
Commits
803289ee
Unverified
Commit
803289ee
authored
8 months ago
by
Michael Clark
Committed by
GitHub
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
:electron: Electron menu.js
menu.ts (#2978)
parent
76cdad4f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packages/desktop-electron/index.ts
+1
-1
1 addition, 1 deletion
packages/desktop-electron/index.ts
packages/desktop-electron/menu.ts
+70
-44
70 additions, 44 deletions
packages/desktop-electron/menu.ts
upcoming-release-notes/2978.md
+6
-0
6 additions, 0 deletions
upcoming-release-notes/2978.md
with
77 additions
and
45 deletions
packages/desktop-electron/index.ts
+
1
−
1
View file @
803289ee
...
@@ -17,7 +17,7 @@ import isDev from 'electron-is-dev';
...
@@ -17,7 +17,7 @@ import isDev from 'electron-is-dev';
import
promiseRetry
from
'
promise-retry
'
;
import
promiseRetry
from
'
promise-retry
'
;
import
about
from
'
./about
'
;
import
about
from
'
./about
'
;
import
getMenu
from
'
./menu
'
;
import
{
getMenu
}
from
'
./menu
'
;
import
updater
from
'
./updater
'
;
import
updater
from
'
./updater
'
;
import
{
import
{
get
as
getWindowState
,
get
as
getWindowState
,
...
...
This diff is collapsed.
Click to expand it.
packages/desktop-electron/menu.
j
s
→
packages/desktop-electron/menu.
t
s
+
70
−
44
View file @
803289ee
const
{
Menu
,
ipcMain
,
app
,
shell
}
=
require
(
'
electron
'
);
import
{
MenuItemConstructorOptions
,
Menu
,
ipcMain
,
app
,
shell
,
}
from
'
electron
'
;
function
getMenu
(
isDev
,
createWindow
,
budgetId
)
{
export
function
getMenu
(
const
template
=
[
isDev
:
boolean
,
createWindow
:
()
=>
Promise
<
void
>
,
budgetId
:
string
|
undefined
=
undefined
,
)
{
const
template
:
MenuItemConstructorOptions
[]
=
[
{
{
label
:
'
File
'
,
label
:
'
File
'
,
submenu
:
[
submenu
:
[
{
{
label
:
'
Load Backup...
'
,
label
:
'
Load Backup...
'
,
enabled
:
false
,
enabled
:
false
,
click
(
item
,
focusedWindow
)
{
click
(
_
item
,
focusedWindow
)
{
if
(
focusedWindow
&&
budgetId
)
{
if
(
focusedWindow
&&
budgetId
)
{
if
(
focusedWindow
.
webContents
.
getTitle
()
===
'
Actual
'
)
{
if
(
focusedWindow
.
webContents
.
getTitle
()
===
'
Actual
'
)
{
focusedWindow
.
webContents
.
executeJavaScript
(
focusedWindow
.
webContents
.
executeJavaScript
(
...
@@ -24,7 +34,7 @@ function getMenu(isDev, createWindow, budgetId) {
...
@@ -24,7 +34,7 @@ function getMenu(isDev, createWindow, budgetId) {
{
{
label
:
'
Manage files...
'
,
label
:
'
Manage files...
'
,
accelerator
:
'
CmdOrCtrl+O
'
,
accelerator
:
'
CmdOrCtrl+O
'
,
click
(
item
,
focusedWindow
)
{
click
(
_
item
,
focusedWindow
)
{
if
(
focusedWindow
)
{
if
(
focusedWindow
)
{
if
(
focusedWindow
.
webContents
.
getTitle
()
===
'
Actual
'
)
{
if
(
focusedWindow
.
webContents
.
getTitle
()
===
'
Actual
'
)
{
focusedWindow
.
webContents
.
executeJavaScript
(
focusedWindow
.
webContents
.
executeJavaScript
(
...
@@ -48,18 +58,26 @@ function getMenu(isDev, createWindow, budgetId) {
...
@@ -48,18 +58,26 @@ function getMenu(isDev, createWindow, budgetId) {
label
:
'
Undo
'
,
label
:
'
Undo
'
,
enabled
:
false
,
enabled
:
false
,
accelerator
:
'
CmdOrCtrl+Z
'
,
accelerator
:
'
CmdOrCtrl+Z
'
,
click
:
function
(
menuItem
,
focusedWin
)
{
click
:
function
(
_
menuItem
,
focusedWin
)
{
// Undo
// Undo
focusedWin
.
webContents
.
executeJavaScript
(
'
__actionsForMenu.undo()
'
);
if
(
focusedWin
)
{
focusedWin
.
webContents
.
executeJavaScript
(
'
__actionsForMenu.undo()
'
,
);
}
},
},
},
},
{
{
label
:
'
Redo
'
,
label
:
'
Redo
'
,
enabled
:
false
,
enabled
:
false
,
accelerator
:
'
Shift+CmdOrCtrl+Z
'
,
accelerator
:
'
Shift+CmdOrCtrl+Z
'
,
click
:
function
(
menuItem
,
focusedWin
)
{
click
:
function
(
_
menuItem
,
focusedWin
)
{
// Redo
// Redo
focusedWin
.
webContents
.
executeJavaScript
(
'
__actionsForMenu.redo()
'
);
if
(
focusedWin
)
{
focusedWin
.
webContents
.
executeJavaScript
(
'
__actionsForMenu.redo()
'
,
);
}
},
},
},
},
{
{
...
@@ -75,45 +93,49 @@ function getMenu(isDev, createWindow, budgetId) {
...
@@ -75,45 +93,49 @@ function getMenu(isDev, createWindow, budgetId) {
role
:
'
paste
'
,
role
:
'
paste
'
,
},
},
{
{
role
:
'
paste
a
nd
m
atch
s
tyle
'
,
role
:
'
paste
A
nd
M
atch
S
tyle
'
,
},
},
{
{
role
:
'
delete
'
,
role
:
'
delete
'
,
},
},
{
{
role
:
'
select
a
ll
'
,
role
:
'
select
A
ll
'
,
},
},
],
],
},
},
{
{
label
:
'
View
'
,
label
:
'
View
'
,
submenu
:
[
submenu
:
[
isDev
&&
{
isDev
label
:
'
Reload
'
,
?
{
accelerator
:
'
CmdOrCtrl+R
'
,
label
:
'
Reload
'
,
click
(
item
,
focusedWindow
)
{
accelerator
:
'
CmdOrCtrl+R
'
,
if
(
focusedWindow
)
focusedWindow
.
reload
();
click
(
_item
,
focusedWindow
)
{
},
if
(
focusedWindow
)
focusedWindow
.
reload
();
},
},
}
:
{
label
:
'
hidden
'
,
visible
:
false
},
{
{
label
:
'
Toggle Developer Tools
'
,
label
:
'
Toggle Developer Tools
'
,
accelerator
:
accelerator
:
process
.
platform
===
'
darwin
'
?
'
Alt+Command+I
'
:
'
Ctrl+Shift+I
'
,
process
.
platform
===
'
darwin
'
?
'
Alt+Command+I
'
:
'
Ctrl+Shift+I
'
,
click
(
item
,
focusedWindow
)
{
click
(
_
item
,
focusedWindow
)
{
if
(
focusedWindow
)
focusedWindow
.
webContents
.
toggleDevTools
();
if
(
focusedWindow
)
focusedWindow
.
webContents
.
toggleDevTools
();
},
},
},
},
isDev
&&
{
isDev
type
:
'
separator
'
,
?
{
},
type
:
'
separator
'
,
}
:
{
label
:
'
hidden
'
,
visible
:
false
},
{
{
role
:
'
reset
z
oom
'
,
role
:
'
reset
Z
oom
'
,
},
},
{
{
role
:
'
zoom
i
n
'
,
role
:
'
zoom
I
n
'
,
},
},
{
{
role
:
'
zoom
o
ut
'
,
role
:
'
zoom
O
ut
'
,
},
},
{
{
type
:
'
separator
'
,
type
:
'
separator
'
,
...
@@ -121,7 +143,7 @@ function getMenu(isDev, createWindow, budgetId) {
...
@@ -121,7 +143,7 @@ function getMenu(isDev, createWindow, budgetId) {
{
{
role
:
'
togglefullscreen
'
,
role
:
'
togglefullscreen
'
,
},
},
]
.
filter
(
x
=>
x
)
,
],
},
},
{
{
label
:
'
Tools
'
,
label
:
'
Tools
'
,
...
@@ -129,10 +151,12 @@ function getMenu(isDev, createWindow, budgetId) {
...
@@ -129,10 +151,12 @@ function getMenu(isDev, createWindow, budgetId) {
{
{
label
:
'
Find schedules
'
,
label
:
'
Find schedules
'
,
enabled
:
false
,
enabled
:
false
,
click
:
function
(
menuItem
,
focusedWin
)
{
click
:
function
(
_menuItem
,
focusedWin
)
{
focusedWin
.
webContents
.
executeJavaScript
(
if
(
focusedWin
)
{
'
window.__actionsForMenu && window.__actionsForMenu.pushModal("schedules-discover")
'
,
focusedWin
.
webContents
.
executeJavaScript
(
);
'
window.__actionsForMenu && window.__actionsForMenu.pushModal("schedules-discover")
'
,
);
}
},
},
},
},
],
],
...
@@ -160,7 +184,9 @@ function getMenu(isDev, createWindow, budgetId) {
...
@@ -160,7 +184,9 @@ function getMenu(isDev, createWindow, budgetId) {
if
(
process
.
platform
===
'
win32
'
)
{
if
(
process
.
platform
===
'
win32
'
)
{
// Add about to help menu on Windows
// Add about to help menu on Windows
template
[
template
.
length
-
1
].
submenu
.
unshift
({
(
template
[
template
.
length
-
1
].
submenu
as
MenuItemConstructorOptions
[]
).
unshift
({
label
:
'
About Actual
'
,
label
:
'
About Actual
'
,
click
()
{
click
()
{
ipcMain
.
emit
(
'
show-about
'
);
ipcMain
.
emit
(
'
show-about
'
);
...
@@ -177,12 +203,14 @@ function getMenu(isDev, createWindow, budgetId) {
...
@@ -177,12 +203,14 @@ function getMenu(isDev, createWindow, budgetId) {
ipcMain
.
emit
(
'
show-about
'
);
ipcMain
.
emit
(
'
show-about
'
);
},
},
},
},
isDev
&&
{
isDev
label
:
'
Screenshot
'
,
?
{
click
()
{
label
:
'
Screenshot
'
,
ipcMain
.
emit
(
'
screenshot
'
);
click
()
{
},
ipcMain
.
emit
(
'
screenshot
'
);
},
},
}
:
{
label
:
'
hidden
'
,
visible
:
false
},
{
{
type
:
'
separator
'
,
type
:
'
separator
'
,
},
},
...
@@ -197,7 +225,7 @@ function getMenu(isDev, createWindow, budgetId) {
...
@@ -197,7 +225,7 @@ function getMenu(isDev, createWindow, budgetId) {
role
:
'
hide
'
,
role
:
'
hide
'
,
},
},
{
{
role
:
'
hide
o
thers
'
,
role
:
'
hide
O
thers
'
,
},
},
{
{
role
:
'
unhide
'
,
role
:
'
unhide
'
,
...
@@ -208,11 +236,11 @@ function getMenu(isDev, createWindow, budgetId) {
...
@@ -208,11 +236,11 @@ function getMenu(isDev, createWindow, budgetId) {
{
{
role
:
'
quit
'
,
role
:
'
quit
'
,
},
},
]
.
filter
(
x
=>
x
)
,
],
});
});
// Edit menu.
// Edit menu.
const
editIdx
=
template
.
findIndex
(
t
=>
t
.
label
===
'
Edit
'
);
const
editIdx
=
template
.
findIndex
(
t
=>
t
.
label
===
'
Edit
'
);
template
[
editIdx
].
submenu
.
push
(
(
template
[
editIdx
].
submenu
as
MenuItemConstructorOptions
[])
.
push
(
{
{
type
:
'
separator
'
,
type
:
'
separator
'
,
},
},
...
@@ -220,10 +248,10 @@ function getMenu(isDev, createWindow, budgetId) {
...
@@ -220,10 +248,10 @@ function getMenu(isDev, createWindow, budgetId) {
label
:
'
Speech
'
,
label
:
'
Speech
'
,
submenu
:
[
submenu
:
[
{
{
role
:
'
start
s
peaking
'
,
role
:
'
start
S
peaking
'
,
},
},
{
{
role
:
'
stop
s
peaking
'
,
role
:
'
stop
S
peaking
'
,
},
},
],
],
},
},
...
@@ -257,5 +285,3 @@ function getMenu(isDev, createWindow, budgetId) {
...
@@ -257,5 +285,3 @@ function getMenu(isDev, createWindow, budgetId) {
return
Menu
.
buildFromTemplate
(
template
);
return
Menu
.
buildFromTemplate
(
template
);
}
}
module
.
exports
=
getMenu
;
This diff is collapsed.
Click to expand it.
upcoming-release-notes/2978.md
0 → 100644
+
6
−
0
View file @
803289ee
---
category
:
Maintenance
authors
:
[
MikesGlitch
]
---
Update Electron menu to use typescript
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment