{"action":"created","comment":{"url":"https://api.github.com/repos/dcos/dcos-ui/pulls/comments/186706287","pull_request_review_id":118333570,"id":186706287,"diff_hunk":"@@ -0,0 +1,80 @@\n+import { injectable, inject, named } from \"inversify\";\n+import { EventEmitter } from \"events\";\n+import { IExtensionProvider, ExtensionProvider } from \"plugin-baby\";\n+\n+const NAVIGATION_CHANGE = Symbol(\"NAVIGATION_CHANGE\");\n+\n+interface INavigationElement {\n+  children?: INavigationElement[],\n+  parent?: string,\n+  path?: string\n+}\n+\n+export const NavigationServiceExtension = Symbol(\"NavigationServiceExtension\");\n+\n+export interface INavigationExtension {\n+  getElements(): INavigationElement[];\n+}\n+\n+function unflatten(array: INavigationElement[], parent: INavigationElement = {}) {\n+  const children = array.filter((child: INavigationElement) =>\n+    child.parent === parent.path\n+  );\n+\n+  if (children.length !== 0) {\n+    if (parent.path) {\n+      parent.children = children;","path":"packages/dcos-sdk/src/NavigationService.ts","position":26,"original_position":26,"commit_id":"b0f5c277f6b09fe8a5cbbdeae831e59448d78392","original_commit_id":"b0f5c277f6b09fe8a5cbbdeae831e59448d78392","user":{"login":"DanielMSchmidt","id":1337046,"avatar_url":"https://avatars2.githubusercontent.com/u/1337046?v=4","gravatar_id":"","url":"https://api.github.com/users/DanielMSchmidt","html_url":"https://github.com/DanielMSchmidt","followers_url":"https://api.github.com/users/DanielMSchmidt/followers","following_url":"https://api.github.com/users/DanielMSchmidt/following{/other_user}","gists_url":"https://api.github.com/users/DanielMSchmidt/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielMSchmidt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielMSchmidt/subscriptions","organizations_url":"https://api.github.com/users/DanielMSchmidt/orgs","repos_url":"https://api.github.com/users/DanielMSchmidt/repos","events_url":"https://api.github.com/users/DanielMSchmidt/events{/privacy}","received_events_url":"https://api.github.com/users/DanielMSchmidt/received_events","type":"User","site_admin":false},"body":"I would love us move in a direction where we don't mutate so much anymore, could we refactor this?","created_at":"2018-05-08T12:15:39Z","updated_at":"2018-05-08T12:42:37Z","html_url":"https://github.com/dcos/dcos-ui/pull/2907#discussion_r186706287","pull_request_url":"https://api.github.com/repos/dcos/dcos-ui/pulls/2907","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/comments/186706287"},"html":{"href":"https://github.com/dcos/dcos-ui/pull/2907#discussion_r186706287"},"pull_request":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/2907"}}},"pull_request":{"url":"https://api.github.com/repos/dcos/dcos-ui/pulls/2907","id":182526380,"html_url":"https://github.com/dcos/dcos-ui/pull/2907","diff_url":"https://github.com/dcos/dcos-ui/pull/2907.diff","patch_url":"https://github.com/dcos/dcos-ui/pull/2907.patch","issue_url":"https://api.github.com/repos/dcos/dcos-ui/issues/2907","number":2907,"state":"open","locked":false,"title":"DCOS-21930: New Plugin System 🎉","user":{"login":"nLight","id":186223,"avatar_url":"https://avatars0.githubusercontent.com/u/186223?v=4","gravatar_id":"","url":"https://api.github.com/users/nLight","html_url":"https://github.com/nLight","followers_url":"https://api.github.com/users/nLight/followers","following_url":"https://api.github.com/users/nLight/following{/other_user}","gists_url":"https://api.github.com/users/nLight/gists{/gist_id}","starred_url":"https://api.github.com/users/nLight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nLight/subscriptions","organizations_url":"https://api.github.com/users/nLight/orgs","repos_url":"https://api.github.com/users/nLight/repos","events_url":"https://api.github.com/users/nLight/events{/privacy}","received_events_url":"https://api.github.com/users/nLight/received_events","type":"User","site_admin":false},"body":"# New shiny plugin system\r\n\r\nNew system is based on [Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) (DI) pattern. It utilizes [inversifyjs](http://inversify.io/)'s [Container Modules](https://github.com/inversify/InversifyJS/blob/master/wiki/container_modules.md) feature. \r\n\r\nContainer Modules allow splitting a code base into meaningful chunks, that, when loaded into a container, augment the container in the way that all module's bindings become available to everyone on the container.\r\n\r\nNew system consists of 3 parts:\r\n1. `plugin-baby` (name is a wip) - a general purpose library of primitives. The primitives allow implementing a plugin-based code splitting in a Javascript/Typescript application. Read its README for more info\r\n2. `dcos-sdk` package - core packages of dcos-ui like `NavigationService` and `RoutingService`. Implemented as `plugin-baby` compatible plugin. `NavigationService` feeds an application's menu system. `RoutingService` - lets you hook into the `react-router` flow and provide additional routing. More info in the respective README\r\n3. **Extracted TBD** module resolution plugin - will resolve new modules in the runtime, parameterize them if needed and load them into container.\r\n\r\n## Refactoring `foundation-ui`\r\n\r\nIt wasn't possible extracting this work without a substantial amount of work. Yet since the work is done - it should be accounted.\r\n\r\n[DCOS-18780](https://jira.mesosphere.com/browse/DCOS-18780) - `RoutingService`\r\n[DCOS-18781](https://jira.mesosphere.com/browse/DCOS-18781) - `NavigationService`\r\n\r\nBoth services have been refactored to become `plugin-baby` compatible `ExtensionProvider`s. Both found their place in the `dcos-sdk`.\r\n\r\n## Reference implementation\r\n\r\nI decided to continue with the `catalog` page as we chose it for the Data Layer as well. I moved all the code into `plugins/catalog` and wrapped it with a `plugin-baby` compatible module.\r\n\r\n**Dependencies**\r\n- https://github.com/mesosphere/dcos-ui-plugins-private/pull/794\r\n- #2946 \r\n\r\n**Checklist**\r\n- [x] Did you add a JIRA issue in a commit message or as part of the branch name?\r\n- [ ] Did you add new unit tests?\r\n- [ ] Did you add new integration tests?\r\n- [ ] If this is a regression, did you write a test to catch this in the future?\r\n\r\nCloses DCOS-21930, DCOS-18781, DCOS-18780","created_at":"2018-04-18T15:55:35Z","updated_at":"2018-05-08T12:42:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78a81bb239318dfb3f6148d13c29cf7c71dab243","assignee":null,"assignees":[],"requested_reviewers":[{"login":"orlandohohmeier","id":647035,"avatar_url":"https://avatars3.githubusercontent.com/u/647035?v=4","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}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dcos/dcos-ui/pulls/2907/commits","review_comments_url":"https://api.github.com/repos/dcos/dcos-ui/pulls/2907/comments","review_comment_url":"https://api.github.com/repos/dcos/dcos-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dcos/dcos-ui/issues/2907/comments","statuses_url":"https://api.github.com/repos/dcos/dcos-ui/statuses/b0f5c277f6b09fe8a5cbbdeae831e59448d78392","head":{"label":"dcos:drozhkov/dcos-21930-plugin-poc","ref":"drozhkov/dcos-21930-plugin-poc","sha":"b0f5c277f6b09fe8a5cbbdeae831e59448d78392","user":{"login":"dcos","id":17648048,"avatar_url":"https://avatars1.githubusercontent.com/u/17648048?v=4","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"repo":{"id":56547504,"name":"dcos-ui","full_name":"dcos/dcos-ui","owner":{"login":"dcos","id":17648048,"avatar_url":"https://avatars1.githubusercontent.com/u/17648048?v=4","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dcos/dcos-ui","description":"The UI for The Datacenter Operating System","fork":false,"url":"https://api.github.com/repos/dcos/dcos-ui","forks_url":"https://api.github.com/repos/dcos/dcos-ui/forks","keys_url":"https://api.github.com/repos/dcos/dcos-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dcos/dcos-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dcos/dcos-ui/teams","hooks_url":"https://api.github.com/repos/dcos/dcos-ui/hooks","issue_events_url":"https://api.github.com/repos/dcos/dcos-ui/issues/events{/number}","events_url":"https://api.github.com/repos/dcos/dcos-ui/events","assignees_url":"https://api.github.com/repos/dcos/dcos-ui/assignees{/user}","branches_url":"https://api.github.com/repos/dcos/dcos-ui/branches{/branch}","tags_url":"https://api.github.com/repos/dcos/dcos-ui/tags","blobs_url":"https://api.github.com/repos/dcos/dcos-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dcos/dcos-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dcos/dcos-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/dcos/dcos-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dcos/dcos-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/dcos/dcos-ui/languages","stargazers_url":"https://api.github.com/repos/dcos/dcos-ui/stargazers","contributors_url":"https://api.github.com/repos/dcos/dcos-ui/contributors","subscribers_url":"https://api.github.com/repos/dcos/dcos-ui/subscribers","subscription_url":"https://api.github.com/repos/dcos/dcos-ui/subscription","commits_url":"https://api.github.com/repos/dcos/dcos-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/dcos/dcos-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/dcos/dcos-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/dcos/dcos-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/dcos/dcos-ui/contents/{+path}","compare_url":"https://api.github.com/repos/dcos/dcos-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dcos/dcos-ui/merges","archive_url":"https://api.github.com/repos/dcos/dcos-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dcos/dcos-ui/downloads","issues_url":"https://api.github.com/repos/dcos/dcos-ui/issues{/number}","pulls_url":"https://api.github.com/repos/dcos/dcos-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/dcos/dcos-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/dcos/dcos-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dcos/dcos-ui/labels{/name}","releases_url":"https://api.github.com/repos/dcos/dcos-ui/releases{/id}","deployments_url":"https://api.github.com/repos/dcos/dcos-ui/deployments","created_at":"2016-04-18T22:48:06Z","updated_at":"2018-05-07T15:35:24Z","pushed_at":"2018-05-08T10:08:11Z","git_url":"git://github.com/dcos/dcos-ui.git","ssh_url":"git@github.com:dcos/dcos-ui.git","clone_url":"https://github.com/dcos/dcos-ui.git","svn_url":"https://github.com/dcos/dcos-ui","homepage":"https://dcos.io/","size":44426,"stargazers_count":176,"watchers_count":176,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":67,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":67,"open_issues":12,"watchers":176,"default_branch":"master"}},"base":{"label":"dcos:drozhkov/dcos-28735-adjust-jest-for-typescript","ref":"drozhkov/dcos-28735-adjust-jest-for-typescript","sha":"71ba061328f77a010ac723317a2ba76b420b225e","user":{"login":"dcos","id":17648048,"avatar_url":"https://avatars1.githubusercontent.com/u/17648048?v=4","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"repo":{"id":56547504,"name":"dcos-ui","full_name":"dcos/dcos-ui","owner":{"login":"dcos","id":17648048,"avatar_url":"https://avatars1.githubusercontent.com/u/17648048?v=4","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dcos/dcos-ui","description":"The UI for The Datacenter Operating System","fork":false,"url":"https://api.github.com/repos/dcos/dcos-ui","forks_url":"https://api.github.com/repos/dcos/dcos-ui/forks","keys_url":"https://api.github.com/repos/dcos/dcos-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dcos/dcos-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dcos/dcos-ui/teams","hooks_url":"https://api.github.com/repos/dcos/dcos-ui/hooks","issue_events_url":"https://api.github.com/repos/dcos/dcos-ui/issues/events{/number}","events_url":"https://api.github.com/repos/dcos/dcos-ui/events","assignees_url":"https://api.github.com/repos/dcos/dcos-ui/assignees{/user}","branches_url":"https://api.github.com/repos/dcos/dcos-ui/branches{/branch}","tags_url":"https://api.github.com/repos/dcos/dcos-ui/tags","blobs_url":"https://api.github.com/repos/dcos/dcos-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dcos/dcos-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dcos/dcos-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/dcos/dcos-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dcos/dcos-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/dcos/dcos-ui/languages","stargazers_url":"https://api.github.com/repos/dcos/dcos-ui/stargazers","contributors_url":"https://api.github.com/repos/dcos/dcos-ui/contributors","subscribers_url":"https://api.github.com/repos/dcos/dcos-ui/subscribers","subscription_url":"https://api.github.com/repos/dcos/dcos-ui/subscription","commits_url":"https://api.github.com/repos/dcos/dcos-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/dcos/dcos-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/dcos/dcos-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/dcos/dcos-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/dcos/dcos-ui/contents/{+path}","compare_url":"https://api.github.com/repos/dcos/dcos-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dcos/dcos-ui/merges","archive_url":"https://api.github.com/repos/dcos/dcos-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dcos/dcos-ui/downloads","issues_url":"https://api.github.com/repos/dcos/dcos-ui/issues{/number}","pulls_url":"https://api.github.com/repos/dcos/dcos-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/dcos/dcos-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/dcos/dcos-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dcos/dcos-ui/labels{/name}","releases_url":"https://api.github.com/repos/dcos/dcos-ui/releases{/id}","deployments_url":"https://api.github.com/repos/dcos/dcos-ui/deployments","created_at":"2016-04-18T22:48:06Z","updated_at":"2018-05-07T15:35:24Z","pushed_at":"2018-05-08T10:08:11Z","git_url":"git://github.com/dcos/dcos-ui.git","ssh_url":"git@github.com:dcos/dcos-ui.git","clone_url":"https://github.com/dcos/dcos-ui.git","svn_url":"https://github.com/dcos/dcos-ui","homepage":"https://dcos.io/","size":44426,"stargazers_count":176,"watchers_count":176,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":67,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":67,"open_issues":12,"watchers":176,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/2907"},"html":{"href":"https://github.com/dcos/dcos-ui/pull/2907"},"issue":{"href":"https://api.github.com/repos/dcos/dcos-ui/issues/2907"},"comments":{"href":"https://api.github.com/repos/dcos/dcos-ui/issues/2907/comments"},"review_comments":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/2907/comments"},"review_comment":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/2907/commits"},"statuses":{"href":"https://api.github.com/repos/dcos/dcos-ui/statuses/b0f5c277f6b09fe8a5cbbdeae831e59448d78392"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"DanielMSchmidt"}}