{"action":"created","comment":{"url":"https://api.github.com/repos/LLK/scratch-vm/pulls/comments/171937104","pull_request_review_id":100882062,"id":171937104,"diff_hunk":"@@ -242,8 +242,34 @@ class ExtensionManager {\n             }\n             return result;\n         }, []);\n+        extensionInfo.menus = extensionInfo.menus || [];\n+        extensionInfo.menus = this._prepareMenuInfo(serviceName, extensionInfo.menus);\n         return extensionInfo;\n     }\n+    \n+    /**\n+     * Prepare extension menus. e.g. setup binding for dynamic menu functions.\n+     * @param {string} serviceName - the name of the service hosting this extension block\n+     * @param {Array.<MenuInfo>} menus - the menu defined by the extension.\n+     * @returns {Array.<MenuInfo>} - a menuInfo object with all preprocessing done.\n+     * @private\n+     */\n+    _prepareMenuInfo (serviceName, menus) {\n+        const menuNames = Object.getOwnPropertyNames(menus);\n+        for (let i = 0; i < menuNames.length; i++) {\n+            const item = menuNames[i];\n+            // If the value is a string, it should be the name of a function in the\n+            // extension object to call to populate the menu whenever it is opened.\n+            // Set up the binding for the function object here so\n+            // we can use it later when converting the menu for Scratch Blocks.\n+            if (typeof menus[item] === 'string') {\n+                const serviceObject = dispatch.services[serviceName];\n+                const menuFunc = serviceObject[menus[item]].bind(serviceObject);","path":"src/extension-support/extension-manager.js","position":null,"original_position":26,"commit_id":"16ecaab1be8d44e96e151524c16f0b7d6e864615","original_commit_id":"1910968b1395fb23b1613886663d838dd877cb3f","user":{"login":"picklesrus","id":15675877,"avatar_url":"https://avatars0.githubusercontent.com/u/15675877?v=4","gravatar_id":"","url":"https://api.github.com/users/picklesrus","html_url":"https://github.com/picklesrus","followers_url":"https://api.github.com/users/picklesrus/followers","following_url":"https://api.github.com/users/picklesrus/following{/other_user}","gists_url":"https://api.github.com/users/picklesrus/gists{/gist_id}","starred_url":"https://api.github.com/users/picklesrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/picklesrus/subscriptions","organizations_url":"https://api.github.com/users/picklesrus/orgs","repos_url":"https://api.github.com/users/picklesrus/repos","events_url":"https://api.github.com/users/picklesrus/events{/privacy}","received_events_url":"https://api.github.com/users/picklesrus/received_events","type":"User","site_admin":false},"body":"As discussed, punting on this for now since scratch-blocks doesn't currently accept the promise or have a mechanism to update the menu outside of the function called when the menu is clicked. Added a TODO.","created_at":"2018-03-02T19:14:17Z","updated_at":"2018-03-02T19:14:17Z","html_url":"https://github.com/LLK/scratch-vm/pull/934#discussion_r171937104","pull_request_url":"https://api.github.com/repos/LLK/scratch-vm/pulls/934","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/LLK/scratch-vm/pulls/comments/171937104"},"html":{"href":"https://github.com/LLK/scratch-vm/pull/934#discussion_r171937104"},"pull_request":{"href":"https://api.github.com/repos/LLK/scratch-vm/pulls/934"}},"in_reply_to_id":168843656},"pull_request":{"url":"https://api.github.com/repos/LLK/scratch-vm/pulls/934","id":168730564,"html_url":"https://github.com/LLK/scratch-vm/pull/934","diff_url":"https://github.com/LLK/scratch-vm/pull/934.diff","patch_url":"https://github.com/LLK/scratch-vm/pull/934.patch","issue_url":"https://api.github.com/repos/LLK/scratch-vm/issues/934","number":934,"state":"open","locked":false,"title":"Extensions dynamic menu","user":{"login":"picklesrus","id":15675877,"avatar_url":"https://avatars0.githubusercontent.com/u/15675877?v=4","gravatar_id":"","url":"https://api.github.com/users/picklesrus","html_url":"https://github.com/picklesrus","followers_url":"https://api.github.com/users/picklesrus/followers","following_url":"https://api.github.com/users/picklesrus/following{/other_user}","gists_url":"https://api.github.com/users/picklesrus/gists{/gist_id}","starred_url":"https://api.github.com/users/picklesrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/picklesrus/subscriptions","organizations_url":"https://api.github.com/users/picklesrus/orgs","repos_url":"https://api.github.com/users/picklesrus/repos","events_url":"https://api.github.com/users/picklesrus/events{/privacy}","received_events_url":"https://api.github.com/users/picklesrus/received_events","type":"User","site_admin":false},"body":"### Resolves\r\n\r\nI didn't see a feature request for this. Let me know if there is one!\r\n\r\n### Proposed Changes\r\n\r\nAdd support for dynamic menus in extensions.  \r\n\r\n### Reason for Changes\r\n\r\nResolving a TODO.\r\n\r\n### Test Coverage\r\n\r\nI added integration level tests for both 2 types of menus.","created_at":"2018-02-13T01:12:52Z","updated_at":"2018-03-02T19:14:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"681c6da3e6fd12d5abed3d941887f3f4064daf28","assignee":{"login":"cwillisf","id":7019101,"avatar_url":"https://avatars0.githubusercontent.com/u/7019101?v=4","gravatar_id":"","url":"https://api.github.com/users/cwillisf","html_url":"https://github.com/cwillisf","followers_url":"https://api.github.com/users/cwillisf/followers","following_url":"https://api.github.com/users/cwillisf/following{/other_user}","gists_url":"https://api.github.com/users/cwillisf/gists{/gist_id}","starred_url":"https://api.github.com/users/cwillisf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cwillisf/subscriptions","organizations_url":"https://api.github.com/users/cwillisf/orgs","repos_url":"https://api.github.com/users/cwillisf/repos","events_url":"https://api.github.com/users/cwillisf/events{/privacy}","received_events_url":"https://api.github.com/users/cwillisf/received_events","type":"User","site_admin":false},"assignees":[{"login":"cwillisf","id":7019101,"avatar_url":"https://avatars0.githubusercontent.com/u/7019101?v=4","gravatar_id":"","url":"https://api.github.com/users/cwillisf","html_url":"https://github.com/cwillisf","followers_url":"https://api.github.com/users/cwillisf/followers","following_url":"https://api.github.com/users/cwillisf/following{/other_user}","gists_url":"https://api.github.com/users/cwillisf/gists{/gist_id}","starred_url":"https://api.github.com/users/cwillisf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cwillisf/subscriptions","organizations_url":"https://api.github.com/users/cwillisf/orgs","repos_url":"https://api.github.com/users/cwillisf/repos","events_url":"https://api.github.com/users/cwillisf/events{/privacy}","received_events_url":"https://api.github.com/users/cwillisf/received_events","type":"User","site_admin":false},{"login":"picklesrus","id":15675877,"avatar_url":"https://avatars0.githubusercontent.com/u/15675877?v=4","gravatar_id":"","url":"https://api.github.com/users/picklesrus","html_url":"https://github.com/picklesrus","followers_url":"https://api.github.com/users/picklesrus/followers","following_url":"https://api.github.com/users/picklesrus/following{/other_user}","gists_url":"https://api.github.com/users/picklesrus/gists{/gist_id}","starred_url":"https://api.github.com/users/picklesrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/picklesrus/subscriptions","organizations_url":"https://api.github.com/users/picklesrus/orgs","repos_url":"https://api.github.com/users/picklesrus/repos","events_url":"https://api.github.com/users/picklesrus/events{/privacy}","received_events_url":"https://api.github.com/users/picklesrus/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":364575266,"url":"https://api.github.com/repos/LLK/scratch-vm/labels/pr%20-%20needs%20work","name":"pr - needs work","color":"ee0701","default":false}],"milestone":{"url":"https://api.github.com/repos/LLK/scratch-vm/milestones/27","html_url":"https://github.com/LLK/scratch-vm/milestone/27","labels_url":"https://api.github.com/repos/LLK/scratch-vm/milestones/27/labels","id":3019890,"number":27,"title":"March 2018","description":"","creator":{"login":"thisandagain","id":747641,"avatar_url":"https://avatars3.githubusercontent.com/u/747641?v=4","gravatar_id":"","url":"https://api.github.com/users/thisandagain","html_url":"https://github.com/thisandagain","followers_url":"https://api.github.com/users/thisandagain/followers","following_url":"https://api.github.com/users/thisandagain/following{/other_user}","gists_url":"https://api.github.com/users/thisandagain/gists{/gist_id}","starred_url":"https://api.github.com/users/thisandagain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thisandagain/subscriptions","organizations_url":"https://api.github.com/users/thisandagain/orgs","repos_url":"https://api.github.com/users/thisandagain/repos","events_url":"https://api.github.com/users/thisandagain/events{/privacy}","received_events_url":"https://api.github.com/users/thisandagain/received_events","type":"User","site_admin":false},"open_issues":25,"closed_issues":1,"state":"open","created_at":"2018-01-08T15:00:06Z","updated_at":"2018-03-01T22:34:40Z","due_on":"2018-03-31T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/LLK/scratch-vm/pulls/934/commits","review_comments_url":"https://api.github.com/repos/LLK/scratch-vm/pulls/934/comments","review_comment_url":"https://api.github.com/repos/LLK/scratch-vm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LLK/scratch-vm/issues/934/comments","statuses_url":"https://api.github.com/repos/LLK/scratch-vm/statuses/16ecaab1be8d44e96e151524c16f0b7d6e864615","head":{"label":"picklesrus:extensions-dynamic-menu","ref":"extensions-dynamic-menu","sha":"16ecaab1be8d44e96e151524c16f0b7d6e864615","user":{"login":"picklesrus","id":15675877,"avatar_url":"https://avatars0.githubusercontent.com/u/15675877?v=4","gravatar_id":"","url":"https://api.github.com/users/picklesrus","html_url":"https://github.com/picklesrus","followers_url":"https://api.github.com/users/picklesrus/followers","following_url":"https://api.github.com/users/picklesrus/following{/other_user}","gists_url":"https://api.github.com/users/picklesrus/gists{/gist_id}","starred_url":"https://api.github.com/users/picklesrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/picklesrus/subscriptions","organizations_url":"https://api.github.com/users/picklesrus/orgs","repos_url":"https://api.github.com/users/picklesrus/repos","events_url":"https://api.github.com/users/picklesrus/events{/privacy}","received_events_url":"https://api.github.com/users/picklesrus/received_events","type":"User","site_admin":false},"repo":{"id":79481160,"name":"scratch-vm","full_name":"picklesrus/scratch-vm","owner":{"login":"picklesrus","id":15675877,"avatar_url":"https://avatars0.githubusercontent.com/u/15675877?v=4","gravatar_id":"","url":"https://api.github.com/users/picklesrus","html_url":"https://github.com/picklesrus","followers_url":"https://api.github.com/users/picklesrus/followers","following_url":"https://api.github.com/users/picklesrus/following{/other_user}","gists_url":"https://api.github.com/users/picklesrus/gists{/gist_id}","starred_url":"https://api.github.com/users/picklesrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/picklesrus/subscriptions","organizations_url":"https://api.github.com/users/picklesrus/orgs","repos_url":"https://api.github.com/users/picklesrus/repos","events_url":"https://api.github.com/users/picklesrus/events{/privacy}","received_events_url":"https://api.github.com/users/picklesrus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/picklesrus/scratch-vm","description":"Virtual Machine used to represent, run, and maintain the state of programs for Scratch 3.0","fork":true,"url":"https://api.github.com/repos/picklesrus/scratch-vm","forks_url":"https://api.github.com/repos/picklesrus/scratch-vm/forks","keys_url":"https://api.github.com/repos/picklesrus/scratch-vm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/picklesrus/scratch-vm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/picklesrus/scratch-vm/teams","hooks_url":"https://api.github.com/repos/picklesrus/scratch-vm/hooks","issue_events_url":"https://api.github.com/repos/picklesrus/scratch-vm/issues/events{/number}","events_url":"https://api.github.com/repos/picklesrus/scratch-vm/events","assignees_url":"https://api.github.com/repos/picklesrus/scratch-vm/assignees{/user}","branches_url":"https://api.github.com/repos/picklesrus/scratch-vm/branches{/branch}","tags_url":"https://api.github.com/repos/picklesrus/scratch-vm/tags","blobs_url":"https://api.github.com/repos/picklesrus/scratch-vm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/picklesrus/scratch-vm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/picklesrus/scratch-vm/git/refs{/sha}","trees_url":"https://api.github.com/repos/picklesrus/scratch-vm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/picklesrus/scratch-vm/statuses/{sha}","languages_url":"https://api.github.com/repos/picklesrus/scratch-vm/languages","stargazers_url":"https://api.github.com/repos/picklesrus/scratch-vm/stargazers","contributors_url":"https://api.github.com/repos/picklesrus/scratch-vm/contributors","subscribers_url":"https://api.github.com/repos/picklesrus/scratch-vm/subscribers","subscription_url":"https://api.github.com/repos/picklesrus/scratch-vm/subscription","commits_url":"https://api.github.com/repos/picklesrus/scratch-vm/commits{/sha}","git_commits_url":"https://api.github.com/repos/picklesrus/scratch-vm/git/commits{/sha}","comments_url":"https://api.github.com/repos/picklesrus/scratch-vm/comments{/number}","issue_comment_url":"https://api.github.com/repos/picklesrus/scratch-vm/issues/comments{/number}","contents_url":"https://api.github.com/repos/picklesrus/scratch-vm/contents/{+path}","compare_url":"https://api.github.com/repos/picklesrus/scratch-vm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/picklesrus/scratch-vm/merges","archive_url":"https://api.github.com/repos/picklesrus/scratch-vm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/picklesrus/scratch-vm/downloads","issues_url":"https://api.github.com/repos/picklesrus/scratch-vm/issues{/number}","pulls_url":"https://api.github.com/repos/picklesrus/scratch-vm/pulls{/number}","milestones_url":"https://api.github.com/repos/picklesrus/scratch-vm/milestones{/number}","notifications_url":"https://api.github.com/repos/picklesrus/scratch-vm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/picklesrus/scratch-vm/labels{/name}","releases_url":"https://api.github.com/repos/picklesrus/scratch-vm/releases{/id}","deployments_url":"https://api.github.com/repos/picklesrus/scratch-vm/deployments","created_at":"2017-01-19T18:15:45Z","updated_at":"2017-01-19T18:15:48Z","pushed_at":"2018-03-02T19:07:46Z","git_url":"git://github.com/picklesrus/scratch-vm.git","ssh_url":"git@github.com:picklesrus/scratch-vm.git","clone_url":"https://github.com/picklesrus/scratch-vm.git","svn_url":"https://github.com/picklesrus/scratch-vm","homepage":"http://llk.github.io/scratch-vm","size":10817,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"LLK:develop","ref":"develop","sha":"9675a1b8cfc326143a8d698604a6b8a778d8d420","user":{"login":"LLK","id":3420800,"avatar_url":"https://avatars1.githubusercontent.com/u/3420800?v=4","gravatar_id":"","url":"https://api.github.com/users/LLK","html_url":"https://github.com/LLK","followers_url":"https://api.github.com/users/LLK/followers","following_url":"https://api.github.com/users/LLK/following{/other_user}","gists_url":"https://api.github.com/users/LLK/gists{/gist_id}","starred_url":"https://api.github.com/users/LLK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LLK/subscriptions","organizations_url":"https://api.github.com/users/LLK/orgs","repos_url":"https://api.github.com/users/LLK/repos","events_url":"https://api.github.com/users/LLK/events{/privacy}","received_events_url":"https://api.github.com/users/LLK/received_events","type":"Organization","site_admin":false},"repo":{"id":55796146,"name":"scratch-vm","full_name":"LLK/scratch-vm","owner":{"login":"LLK","id":3420800,"avatar_url":"https://avatars1.githubusercontent.com/u/3420800?v=4","gravatar_id":"","url":"https://api.github.com/users/LLK","html_url":"https://github.com/LLK","followers_url":"https://api.github.com/users/LLK/followers","following_url":"https://api.github.com/users/LLK/following{/other_user}","gists_url":"https://api.github.com/users/LLK/gists{/gist_id}","starred_url":"https://api.github.com/users/LLK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LLK/subscriptions","organizations_url":"https://api.github.com/users/LLK/orgs","repos_url":"https://api.github.com/users/LLK/repos","events_url":"https://api.github.com/users/LLK/events{/privacy}","received_events_url":"https://api.github.com/users/LLK/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LLK/scratch-vm","description":"Virtual Machine used to represent, run, and maintain the state of programs for Scratch 3.0","fork":false,"url":"https://api.github.com/repos/LLK/scratch-vm","forks_url":"https://api.github.com/repos/LLK/scratch-vm/forks","keys_url":"https://api.github.com/repos/LLK/scratch-vm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LLK/scratch-vm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LLK/scratch-vm/teams","hooks_url":"https://api.github.com/repos/LLK/scratch-vm/hooks","issue_events_url":"https://api.github.com/repos/LLK/scratch-vm/issues/events{/number}","events_url":"https://api.github.com/repos/LLK/scratch-vm/events","assignees_url":"https://api.github.com/repos/LLK/scratch-vm/assignees{/user}","branches_url":"https://api.github.com/repos/LLK/scratch-vm/branches{/branch}","tags_url":"https://api.github.com/repos/LLK/scratch-vm/tags","blobs_url":"https://api.github.com/repos/LLK/scratch-vm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LLK/scratch-vm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LLK/scratch-vm/git/refs{/sha}","trees_url":"https://api.github.com/repos/LLK/scratch-vm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LLK/scratch-vm/statuses/{sha}","languages_url":"https://api.github.com/repos/LLK/scratch-vm/languages","stargazers_url":"https://api.github.com/repos/LLK/scratch-vm/stargazers","contributors_url":"https://api.github.com/repos/LLK/scratch-vm/contributors","subscribers_url":"https://api.github.com/repos/LLK/scratch-vm/subscribers","subscription_url":"https://api.github.com/repos/LLK/scratch-vm/subscription","commits_url":"https://api.github.com/repos/LLK/scratch-vm/commits{/sha}","git_commits_url":"https://api.github.com/repos/LLK/scratch-vm/git/commits{/sha}","comments_url":"https://api.github.com/repos/LLK/scratch-vm/comments{/number}","issue_comment_url":"https://api.github.com/repos/LLK/scratch-vm/issues/comments{/number}","contents_url":"https://api.github.com/repos/LLK/scratch-vm/contents/{+path}","compare_url":"https://api.github.com/repos/LLK/scratch-vm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LLK/scratch-vm/merges","archive_url":"https://api.github.com/repos/LLK/scratch-vm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LLK/scratch-vm/downloads","issues_url":"https://api.github.com/repos/LLK/scratch-vm/issues{/number}","pulls_url":"https://api.github.com/repos/LLK/scratch-vm/pulls{/number}","milestones_url":"https://api.github.com/repos/LLK/scratch-vm/milestones{/number}","notifications_url":"https://api.github.com/repos/LLK/scratch-vm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LLK/scratch-vm/labels{/name}","releases_url":"https://api.github.com/repos/LLK/scratch-vm/releases{/id}","deployments_url":"https://api.github.com/repos/LLK/scratch-vm/deployments","created_at":"2016-04-08T17:08:04Z","updated_at":"2018-02-27T00:02:39Z","pushed_at":"2018-03-02T19:07:48Z","git_url":"git://github.com/LLK/scratch-vm.git","ssh_url":"git@github.com:LLK/scratch-vm.git","clone_url":"https://github.com/LLK/scratch-vm.git","svn_url":"https://github.com/LLK/scratch-vm","homepage":"http://llk.github.io/scratch-vm","size":65806,"stargazers_count":231,"watchers_count":231,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":174,"mirror_url":null,"archived":false,"open_issues_count":110,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause"},"forks":174,"open_issues":110,"watchers":231,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/LLK/scratch-vm/pulls/934"},"html":{"href":"https://github.com/LLK/scratch-vm/pull/934"},"issue":{"href":"https://api.github.com/repos/LLK/scratch-vm/issues/934"},"comments":{"href":"https://api.github.com/repos/LLK/scratch-vm/issues/934/comments"},"review_comments":{"href":"https://api.github.com/repos/LLK/scratch-vm/pulls/934/comments"},"review_comment":{"href":"https://api.github.com/repos/LLK/scratch-vm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LLK/scratch-vm/pulls/934/commits"},"statuses":{"href":"https://api.github.com/repos/LLK/scratch-vm/statuses/16ecaab1be8d44e96e151524c16f0b7d6e864615"}},"author_association":"NONE"}}
{"actor":{"display_login":"picklesrus"}}