{"action":"created","comment":{"url":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/comments/52458396","id":52458396,"diff_hunk":"@@ -1,78 +1,122 @@\n import {EventEmitter} from \"events\";\n \n import AppDispatcher from \"../AppDispatcher\";\n-import PluginDispatcher from \"../plugin/external/PluginDispatcher\";\n+import Util from \"../helpers/Util\";\n import DialogActions from \"../actions/DialogActions\";\n import DialogSeverity from \"../constants/DialogSeverity\";\n import PluginActions from \"../actions/PluginActions\";\n import PluginEvents from \"../events/PluginEvents\";\n+import PluginModules from \"../constants/PluginModules\";\n+import States from \"../constants/States\";\n+import pluginScheme from \"../stores/schemes/pluginScheme\";\n \n-import Util from \"../helpers/Util\";\n+var plugins = [];\n+\n+function addPlugin(data) {\n+  if (data.id == null && !Util.isObject(data.info) &&\n+      getPluginById(data.id) != null) {\n+    return;\n+  }\n \n-var pluginsMetaData = [];\n-var pluginsToLoad = [];\n-var pluginsStarted = [];\n-var pluginsErrored = [];\n+  plugins.push(Util.extendObject(pluginScheme, data.info, {id: data.id}));\n+}\n \n-var bootstrapComplete = false;\n+function getPluginById(id) {\n+  return plugins.find((plugin) => plugin.id === id);\n+}\n \n-function loadNextPlugin() {\n-  if (pluginsToLoad.length === 0) {\n+function updatePluginState(id, state) {\n+  var plugin = getPluginById(id);\n+  if (plugin == null) {\n     return;\n   }\n-  PluginActions.requestPlugin(pluginsToLoad.shift());\n+\n+  plugin.state = state;\n }\n \n-function checkForStartupCompleteAndEmit() {\n-  let allStarted = pluginsMetaData.every(plugin => {\n-    return pluginsStarted.includes(plugin.id) ||\n-      pluginsErrored.some(errored => errored.id === plugin.id);\n+function loadPlugins() {\n+  plugins.filter(plugin => {\n+    return plugin.modules.includes(PluginModules.UI) &&\n+      plugin.state === States.STATE_INITIAL;\n+  })\n+  .forEach(plugin => {\n+    plugin.state = States.STATE_LOADING;\n+    PluginActions.loadPlugin(plugin.id);\n   });\n-\n-  if (allStarted) {\n-    bootstrapComplete = true;\n-    PluginStore.emit(PluginEvents.BOOTSTRAP_COMPLETE);\n-  }\n }\n \n-var PluginStore = Util.extendObject(EventEmitter.prototype, {\n-  bootstrap: function () {\n-    PluginActions.requestMetaInfo();\n+var PluginStore = Util.extendObject({\n+  get pluginLoadingState() {","path":"src/js/stores/PluginStore.js","position":71,"original_position":71,"commit_id":"1dba74ee5dae07e6fed8907a0ca22748c9fbff69","original_commit_id":"1dba74ee5dae07e6fed8907a0ca22748c9fbff69","user":{"login":"orlandohohmeier","id":647035,"avatar_url":"https://avatars.githubusercontent.com/u/647035?v=3","gravatar_id":"","url":"https://api.github.com/users/orlandohohmeier","html_url":"https://github.com/orlandohohmeier","followers_url":"https://api.github.com/users/orlandohohmeier/followers","following_url":"https://api.github.com/users/orlandohohmeier/following{/other_user}","gists_url":"https://api.github.com/users/orlandohohmeier/gists{/gist_id}","starred_url":"https://api.github.com/users/orlandohohmeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orlandohohmeier/subscriptions","organizations_url":"https://api.github.com/users/orlandohohmeier/orgs","repos_url":"https://api.github.com/users/orlandohohmeier/repos","events_url":"https://api.github.com/users/orlandohohmeier/events{/privacy}","received_events_url":"https://api.github.com/users/orlandohohmeier/received_events","type":"User","site_admin":false},"body":"Yep. :)","created_at":"2016-02-10T13:49:47Z","updated_at":"2016-02-10T13:49:47Z","html_url":"https://github.com/mesosphere/marathon-ui/pull/609#discussion_r52458396","pull_request_url":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/609","_links":{"self":{"href":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/comments/52458396"},"html":{"href":"https://github.com/mesosphere/marathon-ui/pull/609#discussion_r52458396"},"pull_request":{"href":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/609"}}},"pull_request":{"url":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/609","id":58117717,"html_url":"https://github.com/mesosphere/marathon-ui/pull/609","diff_url":"https://github.com/mesosphere/marathon-ui/pull/609.diff","patch_url":"https://github.com/mesosphere/marathon-ui/pull/609.patch","issue_url":"https://api.github.com/repos/mesosphere/marathon-ui/issues/609","number":609,"state":"open","locked":false,"title":"Plugin loading mechanism","user":{"login":"orlandohohmeier","id":647035,"avatar_url":"https://avatars.githubusercontent.com/u/647035?v=3","gravatar_id":"","url":"https://api.github.com/users/orlandohohmeier","html_url":"https://github.com/orlandohohmeier","followers_url":"https://api.github.com/users/orlandohohmeier/followers","following_url":"https://api.github.com/users/orlandohohmeier/following{/other_user}","gists_url":"https://api.github.com/users/orlandohohmeier/gists{/gist_id}","starred_url":"https://api.github.com/users/orlandohohmeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orlandohohmeier/subscriptions","organizations_url":"https://api.github.com/users/orlandohohmeier/orgs","repos_url":"https://api.github.com/users/orlandohohmeier/repos","events_url":"https://api.github.com/users/orlandohohmeier/events{/privacy}","received_events_url":"https://api.github.com/users/orlandohohmeier/received_events","type":"User","site_admin":false},"body":"Add modules to load and register plugins. It's using the Marathon Plugin mechanism, as documented in mesosphere/marathon#2827 to load plugins. It also features a loader which loads plugins in \"isolation\" to avoid collisions.\r\n\r\n**Loading procedure**\r\n\r\n1. *Marathon UI:* Request a list of installed plugins (plugin_dir, plugin_conf) via `/v2/plugins` as introduced in mesosphere/marathon/pull/3106\r\n2. *Marathon UI:*  Filter plugins by info.modules identifier and load plugin (e.g. `/v2/plugins/example/main.js`) \r\n3. *Marathon UI:*  Inject the `PluginDisptacher` (proxied) into the plugin and wait for the plugin registration/start up event\r\n4. *Plugin:* Get the injected `PluginDisptacher`\r\n5. *Plugin:* Do the necessary bootstrapping and dispatch the registration/start up event (`PluginHelper.registerMe()`)\r\n5. *Marathon UI:* Update the PluginStore accordingly \r\n\r\n## AC\r\n\r\n* [ ] Use the Marathon plugin mechanism to configure and load plugins (mesosphere/marathon#3106) \r\n* [ ] Move the plugin interface and example plugin implementation to their own repositories: \r\n\t* [mesosphere/marathon-ui-plugin-sdk](https://github.com/mesosphere/mesosphere/marathon-ui-plugin-sdk)  \r\n\t* [mesosphere/marathon-ui-example-plugin](https://github.com/mesosphere/marathon-ui-example-plugin)\r\n* [ ] *Isolates* plugins to avoid collisions \r\n* [ ] Provide a test environment *(including a custom Marathon build for the latest plugin adjustments)*\r\n\r\nCloses mesosphere/marathon#3108 and partially mesosphere/marathon#2827","created_at":"2016-02-03T10:29:26Z","updated_at":"2016-02-10T13:49:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1bbd09c2ef21fe032b3b6b171ef059846a16acd2","assignee":{"login":"aldipower","id":859154,"avatar_url":"https://avatars.githubusercontent.com/u/859154?v=3","gravatar_id":"","url":"https://api.github.com/users/aldipower","html_url":"https://github.com/aldipower","followers_url":"https://api.github.com/users/aldipower/followers","following_url":"https://api.github.com/users/aldipower/following{/other_user}","gists_url":"https://api.github.com/users/aldipower/gists{/gist_id}","starred_url":"https://api.github.com/users/aldipower/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aldipower/subscriptions","organizations_url":"https://api.github.com/users/aldipower/orgs","repos_url":"https://api.github.com/users/aldipower/repos","events_url":"https://api.github.com/users/aldipower/events{/privacy}","received_events_url":"https://api.github.com/users/aldipower/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/609/commits","review_comments_url":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/609/comments","review_comment_url":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mesosphere/marathon-ui/issues/609/comments","statuses_url":"https://api.github.com/repos/mesosphere/marathon-ui/statuses/1dba74ee5dae07e6fed8907a0ca22748c9fbff69","head":{"label":"mesosphere:feature/3108-plugin-loading-mechanism","ref":"feature/3108-plugin-loading-mechanism","sha":"1dba74ee5dae07e6fed8907a0ca22748c9fbff69","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":36859608,"name":"marathon-ui","full_name":"mesosphere/marathon-ui","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/marathon-ui","description":"The web-ui for Marathon (https://github.com/mesosphere/marathon)","fork":false,"url":"https://api.github.com/repos/mesosphere/marathon-ui","forks_url":"https://api.github.com/repos/mesosphere/marathon-ui/forks","keys_url":"https://api.github.com/repos/mesosphere/marathon-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/marathon-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/marathon-ui/teams","hooks_url":"https://api.github.com/repos/mesosphere/marathon-ui/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/marathon-ui/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/marathon-ui/events","assignees_url":"https://api.github.com/repos/mesosphere/marathon-ui/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/marathon-ui/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/marathon-ui/tags","blobs_url":"https://api.github.com/repos/mesosphere/marathon-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/marathon-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/marathon-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/marathon-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/marathon-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/marathon-ui/languages","stargazers_url":"https://api.github.com/repos/mesosphere/marathon-ui/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/marathon-ui/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/marathon-ui/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/marathon-ui/subscription","commits_url":"https://api.github.com/repos/mesosphere/marathon-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/marathon-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/marathon-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/marathon-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/marathon-ui/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/marathon-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/marathon-ui/merges","archive_url":"https://api.github.com/repos/mesosphere/marathon-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/marathon-ui/downloads","issues_url":"https://api.github.com/repos/mesosphere/marathon-ui/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/marathon-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/marathon-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/marathon-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/marathon-ui/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/marathon-ui/releases{/id}","deployments_url":"https://api.github.com/repos/mesosphere/marathon-ui/deployments","created_at":"2015-06-04T09:00:20Z","updated_at":"2016-02-09T19:36:15Z","pushed_at":"2016-02-10T10:43:48Z","git_url":"git://github.com/mesosphere/marathon-ui.git","ssh_url":"git@github.com:mesosphere/marathon-ui.git","clone_url":"https://github.com/mesosphere/marathon-ui.git","svn_url":"https://github.com/mesosphere/marathon-ui","homepage":"","size":10722,"stargazers_count":47,"watchers_count":47,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":10,"forks":29,"open_issues":10,"watchers":47,"default_branch":"master"}},"base":{"label":"mesosphere:feature/3107-plugin-interfaces","ref":"feature/3107-plugin-interfaces","sha":"559c04f4ee6961bb0c14e5a4b02f38e411898958","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":36859608,"name":"marathon-ui","full_name":"mesosphere/marathon-ui","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/marathon-ui","description":"The web-ui for Marathon (https://github.com/mesosphere/marathon)","fork":false,"url":"https://api.github.com/repos/mesosphere/marathon-ui","forks_url":"https://api.github.com/repos/mesosphere/marathon-ui/forks","keys_url":"https://api.github.com/repos/mesosphere/marathon-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/marathon-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/marathon-ui/teams","hooks_url":"https://api.github.com/repos/mesosphere/marathon-ui/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/marathon-ui/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/marathon-ui/events","assignees_url":"https://api.github.com/repos/mesosphere/marathon-ui/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/marathon-ui/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/marathon-ui/tags","blobs_url":"https://api.github.com/repos/mesosphere/marathon-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/marathon-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/marathon-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/marathon-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/marathon-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/marathon-ui/languages","stargazers_url":"https://api.github.com/repos/mesosphere/marathon-ui/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/marathon-ui/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/marathon-ui/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/marathon-ui/subscription","commits_url":"https://api.github.com/repos/mesosphere/marathon-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/marathon-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/marathon-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/marathon-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/marathon-ui/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/marathon-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/marathon-ui/merges","archive_url":"https://api.github.com/repos/mesosphere/marathon-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/marathon-ui/downloads","issues_url":"https://api.github.com/repos/mesosphere/marathon-ui/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/marathon-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/marathon-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/marathon-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/marathon-ui/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/marathon-ui/releases{/id}","deployments_url":"https://api.github.com/repos/mesosphere/marathon-ui/deployments","created_at":"2015-06-04T09:00:20Z","updated_at":"2016-02-09T19:36:15Z","pushed_at":"2016-02-10T10:43:48Z","git_url":"git://github.com/mesosphere/marathon-ui.git","ssh_url":"git@github.com:mesosphere/marathon-ui.git","clone_url":"https://github.com/mesosphere/marathon-ui.git","svn_url":"https://github.com/mesosphere/marathon-ui","homepage":"","size":10722,"stargazers_count":47,"watchers_count":47,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":10,"forks":29,"open_issues":10,"watchers":47,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/609"},"html":{"href":"https://github.com/mesosphere/marathon-ui/pull/609"},"issue":{"href":"https://api.github.com/repos/mesosphere/marathon-ui/issues/609"},"comments":{"href":"https://api.github.com/repos/mesosphere/marathon-ui/issues/609/comments"},"review_comments":{"href":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/609/comments"},"review_comment":{"href":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mesosphere/marathon-ui/pulls/609/commits"},"statuses":{"href":"https://api.github.com/repos/mesosphere/marathon-ui/statuses/1dba74ee5dae07e6fed8907a0ca22748c9fbff69"}}}}