Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor menu internals #1867

Merged
merged 6 commits into from
May 26, 2017
Merged

Refactor menu internals #1867

merged 6 commits into from
May 26, 2017

Conversation

ppot
Copy link
Contributor

@ppot ppot commented May 25, 2017

Keymaps sub implementation

Include menus refactor under /menus

@ppot ppot force-pushed the part1/keymap branch 2 times, most recently from 658c60c to 72e0cd0 Compare May 25, 2017 00:28
Copy link
Contributor

@chabou chabou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions

app/index.js Outdated
}
}));
const makeMenu = () => {
const menu = new AppMenu(createWindow, () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This menu should be decotated by plugins

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe when you call make()

app/config.js Outdated
let configDir = homedir();
if (isDev) {
let configDir = _paths.homeDir;
if (_paths.isDev) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it could be better to abstract this "config path if we are in dev mode" in config/paths. Strange to move isDev in it and not this dev path mechanism.
isDev is an environnement notion, not a path one. maybe better to separate it from paths

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chabou The DEV mechanism is part of the Global Keymaps. But for this I need to rework the whole config which is another part. See #1509 with config/paths.js

if (process.platform === 'darwin') {
this.darwinMenu = darwinMenu(accelerators, configFile);
} else {
this.editMenu.submenu.push(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be better to add this submenu directly in editMenu

}
);

this.helpMenu.submenu.push(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be better to add this submenu directly in helpMenu

const helpMenu = require('./menus/help');
const darwinMenu = require('./menus/darwin');

module.exports = class Menu {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you made a class here. Do you plan to extend it?

this.windowMenu = windowMenu(accelerators);
this.helpMenu = helpMenu(os, app, shell);

const configFile = path.resolve(config.getConfigDir(), _paths.conf);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe config/paths should know this absolutePath

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As my previous comment : see previous comment

@timothyis timothyis requested review from rauchg and chabou May 25, 2017 12:06
Copy link
Contributor

@chabou chabou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really better now! But some details should be changed

}

const menu = [].concat(
this.shellMenu,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid using this. I think it is ok to concat directly like:

const menu = [].concat(
  shellMenu(accelerators, createWindow),
  editMenu(accelerators, _paths.confPath),
  ...
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I kept this since it was in a class before.

@@ -0,0 +1,39 @@
const _paths = require('../config/paths');
const {accelerators} = require('../accelerators');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe submenus could require paths and accelerators directly when needed. I don't know. What is the advantage to do this here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this will only be a temp fix waiting keymaps commands.

@chabou chabou changed the title Keymaps part@1 Refactor menu internals May 26, 2017
@chabou chabou merged commit 3c1f359 into vercel:master May 26, 2017
@ppot ppot deleted the part1/keymap branch May 26, 2017 14:10
@albinekb albinekb mentioned this pull request May 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants