-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from buttercup-pw/tree-root
Move Groups to Root
- Loading branch information
Showing
11 changed files
with
101 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
os: | ||
- osx | ||
#os: | ||
# - osx | ||
|
||
language: node_js | ||
|
||
node_js: | ||
- 7 | ||
|
||
script: ./script/travis.sh | ||
|
||
before_install: | ||
- rm yarn.lock | ||
|
||
branches: | ||
only: | ||
- master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,5 @@ fi | |
node --version | ||
npm --version | ||
|
||
npm run build && npm run release:mac | ||
npm run build | ||
npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,46 @@ | ||
import { remote } from 'electron'; | ||
|
||
const { Menu, MenuItem } = remote; | ||
const { Menu } = remote; | ||
const currentWindow = remote.getCurrentWindow(); | ||
|
||
export function createMenu(items = []) { | ||
const menu = new Menu(); | ||
const menuItems = items.map(item => new MenuItem(item)); | ||
menuItems.forEach(item => { | ||
menu.append(item); | ||
}); | ||
return menu; | ||
return Menu.buildFromTemplate(items); | ||
} | ||
|
||
export function showContextMenu(items = []) { | ||
const menu = createMenu(items); | ||
menu.popup(currentWindow); | ||
} | ||
|
||
export function createMenuFromGroups(groups = [], currentGroup, fn) { | ||
return createMenu(groups.filter(group => !group.isTrash).map(group => { | ||
if (group.type) { | ||
return group; | ||
} | ||
return { | ||
label: group.title, | ||
enabled: (group.id !== currentGroup || group.groups.length > 0), | ||
click: () => fn(group.id), | ||
submenu: group.groups.length > 0 ? | ||
createMenuFromGroups( | ||
[{ | ||
...group, | ||
title: `Move to ${group.title}`, | ||
groups: [] | ||
}, { | ||
type: 'separator' | ||
}] | ||
.concat(group.groups), currentGroup, fn) : | ||
null | ||
}; | ||
})); | ||
export function createMenuFromGroups(groups = [], currentGroup, fn, allowMoveToSelf = true) { | ||
return createMenu( | ||
groups | ||
.filter(group => { | ||
if (group.id === currentGroup && allowMoveToSelf === false) { | ||
return false; | ||
} | ||
return !group.isTrash; | ||
}) | ||
.map(group => { | ||
if (group.type) { | ||
return group; | ||
} | ||
return { | ||
label: group.title, | ||
enabled: (group.id !== currentGroup || group.groups.length > 0), | ||
click: () => fn(group.id), | ||
submenu: group.groups.length > 0 ? | ||
createMenuFromGroups( | ||
[{ | ||
...group, | ||
title: `Move to ${group.title}`, | ||
groups: [] | ||
}, { | ||
type: 'separator' | ||
}] | ||
.concat(group.groups), currentGroup, fn, allowMoveToSelf) : | ||
null | ||
}; | ||
}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters