GitHub PullRequestEvent at 2014-09-30 22:38:59
Repository: atom
Actor: nathansobo
Payload: {"action":"closed","number":3658,"pull_request":{"url":"https://api.github.com/repos/atom/atom/pulls/3658","id":21971203,"html_url":"https://github.com/atom/atom/pull/3658","diff_url":"https://github.com/atom/atom/pull/3658.diff","patch_url":"https://github.com/atom/atom/pull/3658.patch","issue_url":"https://api.github.com/repos/atom/atom/issues/3658","number":3658,"state":"closed","locked":false,"title":"Clean up context menu API","user":{"login":"nathansobo","id":1789,"avatar_url":"https://avatars.githubusercontent.com/u/1789?v=2","gravatar_id":"","url":"https://api.github.com/users/nathansobo","html_url":"https://github.com/nathansobo","followers_url":"https://api.github.com/users/nathansobo/followers","following_url":"https://api.github.com/users/nathansobo/following{/other_user}","gists_url":"https://api.github.com/users/nathansobo/gists{/gist_id}","starred_url":"https://api.github.com/users/nathansobo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathansobo/subscriptions","organizations_url":"https://api.github.com/users/nathansobo/orgs","repos_url":"https://api.github.com/users/nathansobo/repos","events_url":"https://api.github.com/users/nathansobo/events{/privacy}","received_events_url":"https://api.github.com/users/nathansobo/received_events","type":"User","site_admin":true},"body":"## Consistent API\r\n\r\nI initially set out to return `Disposable` instances from `atom.contextMenu.add`, but then I noticed that the format for expressing items didn't match up with `atom.menu.add`. This PR corrects that. You can now add context menus with the same format as adding application menus, with selectors mapping to arrays containing menu items as follows:\r\n\r\n```coffee\r\natom.contextMenu.add '.editor': [\r\n  {label: 'Undo', command: 'core:undo'}\r\n  {label: 'Redo', command: 'core:redo'}\r\n  {label: 'Other', submenu: [\r\n    {label: 'Transpose', command: 'editor:transpose'}\r\n    ]\r\n  }\r\n]\r\n```\r\n\r\n## Created and Should Display Hooks\r\n\r\nThere's also a new `shouldDisplay` hook to address a use case I saw in color-picker, which is currently digging into `ContextMenuManager` internals to conditionally display a menu item. This is a sketch of how the API could be used, but not real code from the actual color-picker.\r\n\r\n```coffee\r\natom.contextMenu.add '.editor': [{\r\n  label: 'Pick Color',\r\n  command: 'color-picker:',\r\n  shouldDisplay: (event) -> # use the right click event to decide...\r\n}]\r\n```\r\n\r\nThe `executeAtBuild` hook has been replaced with `created`. I couldn't find anyone using this other than us because it wasn't exposed in our API, so I went ahead and just renamed it without shimming. Here's the `created` hook being used to add the `x` and `y` of the click event to the command.\r\n\r\n```coffee\r\natom.contextMenu.add '.workspace': [{\r\n  label: 'Inspect Element'\r\n  command: 'application:inspect'\r\n  devMode: true\r\n  created: (event) ->\r\n    {pageX, pageY} = event\r\n    @commandOptions = {x: pageX, y: pageY}\r\n}]\r\n```\r\n\r\n## Dev Mode\r\n\r\nDev-mode-only items were formerly expressed with a trailing options hash on the entire call to `::add`. Now each individual item can contain a `devMode` field indicating whether it should only display in dev mode. You can see this in the `Inspect Element` example above.\r\n\r\n## Disposables\r\n\r\nFinally, `::add` now returns a disposable on which `::dispose` can be called to remove the added item descriptors.\r\n\r\n## Outreach\r\n\r\nWe should probably talk to the author of color-picker and any other packages that dig into context menu internals to get them to switch to the new API. We may even want to send them a PR before merging this if the number is manageable.\r\n\r\n/cc @atom/core ","created_at":"2014-09-29T23:00:04Z","updated_at":"2014-09-30T22:38:58Z","closed_at":"2014-09-30T22:38:58Z","merged_at":"2014-09-30T22:38:58Z","merge_commit_sha":"86c231c82e6d4378d918177109228361717e5d87","assignee":{"login":"nathansobo","id":1789,"avatar_url":"https://avatars.githubusercontent.com/u/1789?v=2","gravatar_id":"","url":"https://api.github.com/users/nathansobo","html_url":"https://github.com/nathansobo","followers_url":"https://api.github.com/users/nathansobo/followers","following_url":"https://api.github.com/users/nathansobo/following{/other_user}","gists_url":"https://api.github.com/users/nathansobo/gists{/gist_id}","starred_url":"https://api.github.com/users/nathansobo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathansobo/subscriptions","organizations_url":"https://api.github.com/users/nathansobo/orgs","repos_url":"https://api.github.com/users/nathansobo/repos","events_url":"https://api.github.com/users/nathansobo/events{/privacy}","received_events_url":"https://api.github.com/users/nathansobo/received_events","type":"User","site_admin":true},"milestone":null,"commits_url":"https://api.github.com/repos/atom/atom/pulls/3658/commits","review_comments_url":"https://api.github.com/repos/atom/atom/pulls/3658/comments","review_comment_url":"https://api.github.com/repos/atom/atom/pulls/comments/{number}","comments_url":"https://api.github.com/repos/atom/atom/issues/3658/comments","statuses_url":"https://api.github.com/repos/atom/atom/statuses/72538891ddc464be037dbcd4dcd4782924f0efd7","head":{"label":"atom:ns-context-menu-cleanup","ref":"ns-context-menu-cleanup","sha":"72538891ddc464be037dbcd4dcd4782924f0efd7","user":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=2","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"repo":{"id":3228505,"name":"atom","full_name":"atom/atom","owner":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=2","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atom/atom","description":"The hackable editor","fork":false,"url":"https://api.github.com/repos/atom/atom","forks_url":"https://api.github.com/repos/atom/atom/forks","keys_url":"https://api.github.com/repos/atom/atom/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atom/atom/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atom/atom/teams","hooks_url":"https://api.github.com/repos/atom/atom/hooks","issue_events_url":"https://api.github.com/repos/atom/atom/issues/events{/number}","events_url":"https://api.github.com/repos/atom/atom/events","assignees_url":"https://api.github.com/repos/atom/atom/assignees{/user}","branches_url":"https://api.github.com/repos/atom/atom/branches{/branch}","tags_url":"https://api.github.com/repos/atom/atom/tags","blobs_url":"https://api.github.com/repos/atom/atom/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atom/atom/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atom/atom/git/refs{/sha}","trees_url":"https://api.github.com/repos/atom/atom/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atom/atom/statuses/{sha}","languages_url":"https://api.github.com/repos/atom/atom/languages","stargazers_url":"https://api.github.com/repos/atom/atom/stargazers","contributors_url":"https://api.github.com/repos/atom/atom/contributors","subscribers_url":"https://api.github.com/repos/atom/atom/subscribers","subscription_url":"https://api.github.com/repos/atom/atom/subscription","commits_url":"https://api.github.com/repos/atom/atom/commits{/sha}","git_commits_url":"https://api.github.com/repos/atom/atom/git/commits{/sha}","comments_url":"https://api.github.com/repos/atom/atom/comments{/number}","issue_comment_url":"https://api.github.com/repos/atom/atom/issues/comments/{number}","contents_url":"https://api.github.com/repos/atom/atom/contents/{+path}","compare_url":"https://api.github.com/repos/atom/atom/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atom/atom/merges","archive_url":"https://api.github.com/repos/atom/atom/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atom/atom/downloads","issues_url":"https://api.github.com/repos/atom/atom/issues{/number}","pulls_url":"https://api.github.com/repos/atom/atom/pulls{/number}","milestones_url":"https://api.github.com/repos/atom/atom/milestones{/number}","notifications_url":"https://api.github.com/repos/atom/atom/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atom/atom/labels{/name}","releases_url":"https://api.github.com/repos/atom/atom/releases{/id}","created_at":"2012-01-20T18:18:21Z","updated_at":"2014-09-30T21:29:32Z","pushed_at":"2014-09-30T22:38:58Z","git_url":"git://github.com/atom/atom.git","ssh_url":"git@github.com:atom/atom.git","clone_url":"https://github.com/atom/atom.git","svn_url":"https://github.com/atom/atom","homepage":"https://atom.io/","size":348831,"stargazers_count":8713,"watchers_count":8713,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1240,"mirror_url":null,"open_issues_count":501,"forks":1240,"open_issues":501,"watchers":8713,"default_branch":"master"}},"base":{"label":"atom:master","ref":"master","sha":"73f6904ab754d86af13dbf15332971029301d730","user":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=2","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"repo":{"id":3228505,"name":"atom","full_name":"atom/atom","owner":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=2","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atom/atom","description":"The hackable editor","fork":false,"url":"https://api.github.com/repos/atom/atom","forks_url":"https://api.github.com/repos/atom/atom/forks","keys_url":"https://api.github.com/repos/atom/atom/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atom/atom/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atom/atom/teams","hooks_url":"https://api.github.com/repos/atom/atom/hooks","issue_events_url":"https://api.github.com/repos/atom/atom/issues/events{/number}","events_url":"https://api.github.com/repos/atom/atom/events","assignees_url":"https://api.github.com/repos/atom/atom/assignees{/user}","branches_url":"https://api.github.com/repos/atom/atom/branches{/branch}","tags_url":"https://api.github.com/repos/atom/atom/tags","blobs_url":"https://api.github.com/repos/atom/atom/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atom/atom/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atom/atom/git/refs{/sha}","trees_url":"https://api.github.com/repos/atom/atom/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atom/atom/statuses/{sha}","languages_url":"https://api.github.com/repos/atom/atom/languages","stargazers_url":"https://api.github.com/repos/atom/atom/stargazers","contributors_url":"https://api.github.com/repos/atom/atom/contributors","subscribers_url":"https://api.github.com/repos/atom/atom/subscribers","subscription_url":"https://api.github.com/repos/atom/atom/subscription","commits_url":"https://api.github.com/repos/atom/atom/commits{/sha}","git_commits_url":"https://api.github.com/repos/atom/atom/git/commits{/sha}","comments_url":"https://api.github.com/repos/atom/atom/comments{/number}","issue_comment_url":"https://api.github.com/repos/atom/atom/issues/comments/{number}","contents_url":"https://api.github.com/repos/atom/atom/contents/{+path}","compare_url":"https://api.github.com/repos/atom/atom/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atom/atom/merges","archive_url":"https://api.github.com/repos/atom/atom/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atom/atom/downloads","issues_url":"https://api.github.com/repos/atom/atom/issues{/number}","pulls_url":"https://api.github.com/repos/atom/atom/pulls{/number}","milestones_url":"https://api.github.com/repos/atom/atom/milestones{/number}","notifications_url":"https://api.github.com/repos/atom/atom/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atom/atom/labels{/name}","releases_url":"https://api.github.com/repos/atom/atom/releases{/id}","created_at":"2012-01-20T18:18:21Z","updated_at":"2014-09-30T21:29:32Z","pushed_at":"2014-09-30T22:38:58Z","git_url":"git://github.com/atom/atom.git","ssh_url":"git@github.com:atom/atom.git","clone_url":"https://github.com/atom/atom.git","svn_url":"https://github.com/atom/atom","homepage":"https://atom.io/","size":348831,"stargazers_count":8713,"watchers_count":8713,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1240,"mirror_url":null,"open_issues_count":501,"forks":1240,"open_issues":501,"watchers":8713,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/atom/atom/pulls/3658"},"html":{"href":"https://github.com/atom/atom/pull/3658"},"issue":{"href":"https://api.github.com/repos/atom/atom/issues/3658"},"comments":{"href":"https://api.github.com/repos/atom/atom/issues/3658/comments"},"review_comments":{"href":"https://api.github.com/repos/atom/atom/pulls/3658/comments"},"review_comment":{"href":"https://api.github.com/repos/atom/atom/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/atom/atom/pulls/3658/commits"},"statuses":{"href":"https://api.github.com/repos/atom/atom/statuses/72538891ddc464be037dbcd4dcd4782924f0efd7"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"nathansobo","id":1789,"avatar_url":"https://avatars.githubusercontent.com/u/1789?v=2","gravatar_id":"","url":"https://api.github.com/users/nathansobo","html_url":"https://github.com/nathansobo","followers_url":"https://api.github.com/users/nathansobo/followers","following_url":"https://api.github.com/users/nathansobo/following{/other_user}","gists_url":"https://api.github.com/users/nathansobo/gists{/gist_id}","starred_url":"https://api.github.com/users/nathansobo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathansobo/subscriptions","organizations_url":"https://api.github.com/users/nathansobo/orgs","repos_url":"https://api.github.com/users/nathansobo/repos","events_url":"https://api.github.com/users/nathansobo/events{/privacy}","received_events_url":"https://api.github.com/users/nathansobo/received_events","type":"User","site_admin":true},"comments":5,"review_comments":2,"commits":22,"additions":415,"deletions":340,"changed_files":14}}