Skip to content

Commit

Permalink
refactor: display File-about only on Windows
Browse files Browse the repository at this point in the history
refs #134
  • Loading branch information
pyphilia authored and juancarlosfarah committed Aug 5, 2019
1 parent 02b40b5 commit ca9b781
Showing 1 changed file with 57 additions and 66 deletions.
123 changes: 57 additions & 66 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,68 +139,63 @@ const createWindow = () => {
});
};

// const handleLoad = () => {
// logger.info('load');
// };
const macAppMenu = [
{
label: app.getName(),
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' },
],
},
];
const standardAppMenu = [];
const macFileSubmenu = [{ role: 'close' }];
const standardFileSubmenu = [{
label: 'About',
click: () => {
openAboutWindow({
// asset for icon is in the public/assets folder
base_path: escapeEscapeCharacter(app.getAppPath()),
icon_path: path.join(__dirname, ICON_PATH),
copyright: 'Copyright © 2019 React',
product_name: PRODUCT_NAME,
use_version_info: false,
adjust_window_size: true,
win_options: {
parent: mainWindow,
resizable: false,
minimizable: false,
maximizable: false,
movable: true,
frame: true,
},
// automatically show info from package.json
package_json_dir: path.join(__dirname, '../'),
bug_link_text: 'Report a Bug/Issue',
});
},
},
{ role: 'quit' },
];

const learnMoreLink = 'https://github.com/react-epfl/graasp-desktop/blob/master/README.md';
const fileIssueLink = 'https://github.com/react-epfl/graasp-desktop/issues';

const generateMenu = () => {
const isMac = process.platform === 'darwin';
const template = [
...(isMac
? [
{
label: app.getName(),
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' },
],
},
]
: []),
...(isMac ? macAppMenu : standardAppMenu),
{
label: 'File',
submenu: [
// {
// label: 'Load Space',
// click() {
// handleLoad();
// },
// },
{
label: 'About',
click: () => {
openAboutWindow({
// asset for icon is in the public/assets folder
base_path: escapeEscapeCharacter(app.getAppPath()),
icon_path: path.join(__dirname, ICON_PATH),
copyright: 'Copyright © 2019 React',
product_name: PRODUCT_NAME,
use_version_info: false,
adjust_window_size: true,
win_options: {
parent: mainWindow,
resizable: false,
minimizable: false,
maximizable: false,
movable: true,
frame: true,
},
// ? automatically showing info from package.json is nice but not translated into different languages
package_json_dir: path.join(__dirname, '../'),
bug_link_text: 'Report a Bug/Issue',
// ? nor is a close button
// show_close_button: 'Close',
});
},
},
isMac ? { role: 'close' } : { role: 'quit' },
...(isMac ? macFileSubmenu : standardFileSubmenu),
],
},
{ type: 'separator' },
Expand Down Expand Up @@ -237,11 +232,11 @@ const generateMenu = () => {
{ role: 'zoom' },
...(isMac
? [
{ type: 'separator' },
{ role: 'front' },
{ type: 'separator' },
{ role: 'window' },
]
{ type: 'separator' },
{ role: 'front' },
{ type: 'separator' },
{ role: 'window' },
]
: [{ role: 'close' }]),
],
},
Expand All @@ -251,18 +246,14 @@ const generateMenu = () => {
{
click() {
// eslint-disable-next-line
require('electron').shell.openExternal(
'https://github.com/react-epfl/graasp-desktop/blob/master/README.md'
);
require('electron').shell.openExternal(learnMoreLink);
},
label: 'Learn More',
},
{
click() {
// eslint-disable-next-line
require('electron').shell.openExternal(
'https://github.com/react-epfl/graasp-desktop/issues'
);
require('electron').shell.openExternal(fileIssueLink);
},
label: 'File Issue on GitHub',
},
Expand Down

0 comments on commit ca9b781

Please sign in to comment.