{"action":"created","comment":{"url":"https://api.github.com/repos/dcos/dcos-ui/pulls/comments/88641507","pull_request_review_id":9209590,"id":88641507,"diff_hunk":"@@ -0,0 +1,111 @@\n+import {EventEmitter} from 'events';\n+import {NAVIGATION_CHANGE} from './EventTypes';\n+\n+class NavigationService extends EventEmitter {\n+\n+  constructor() {\n+    super();\n+\n+    this.deferredTasks = [];\n+\n+    // The only default is root, so it goes first no matter what\n+    this.definition = [\n+      { category: 'root', children: [] }\n+    ];\n+\n+    this.on(\n+      NAVIGATION_CHANGE,\n+      this.processDeferred\n+    );\n+  }\n+\n+  getDefinition() {\n+    return this.definition.slice(0);\n+  }\n+\n+  processDeferred() {\n+    const tasks = this.deferredTasks.slice(0);\n+    this.deferredTasks = [];\n+\n+    // If Task is unable to resolve at this point of time it will re-defer itself\n+    tasks.forEach(({method, args}) => {\n+      this[method].apply(this, args);\n+    });\n+  }\n+\n+  defer(method, args) {\n+    this.deferredTasks.push({method, args});\n+  }\n+\n+  registerCategory(category) {\n+    if (!this.definition.find((element) => element.category === category)) {\n+      this.definition.push({\n+        category,\n+        children: []\n+      });\n+    }\n+\n+    this.emit(NAVIGATION_CHANGE);\n+  }\n+\n+  registerPrimary(path, link, options = {}) {\n+    const {category = 'root'} = options;\n+    const categoryElement = this.definition\n+      .find((element) => element.category === category);\n+\n+    if (!categoryElement) {\n+      return this.defer('registerPrimary', arguments);\n+    }\n+\n+    const existingElement = categoryElement.children.find((element) => {\n+      return element.path === path;\n+    });\n+\n+    if (existingElement) {","path":"foundation-ui/navigation/NavigationService.js","position":94,"original_position":64,"commit_id":"44d3cb3c12cc40302823aa449c7b06a60812cbda","original_commit_id":"3bc8cb61e18f69971863cd6820ef17c12240f239","user":{"login":"nLight","id":186223,"avatar_url":"https://avatars.githubusercontent.com/u/186223?v=3","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":"Done!","created_at":"2016-11-18T11:29:40Z","updated_at":"2016-11-18T11:29:40Z","html_url":"https://github.com/dcos/dcos-ui/pull/1334#discussion_r88641507","pull_request_url":"https://api.github.com/repos/dcos/dcos-ui/pulls/1334","_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/comments/88641507"},"html":{"href":"https://github.com/dcos/dcos-ui/pull/1334#discussion_r88641507"},"pull_request":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/1334"}}},"pull_request":{"url":"https://api.github.com/repos/dcos/dcos-ui/pulls/1334","id":92817401,"html_url":"https://github.com/dcos/dcos-ui/pull/1334","diff_url":"https://github.com/dcos/dcos-ui/pull/1334.diff","patch_url":"https://github.com/dcos/dcos-ui/pull/1334.patch","issue_url":"https://api.github.com/repos/dcos/dcos-ui/issues/1334","number":1334,"state":"open","locked":false,"title":"DCOS-11326: Implement Navigation Service","user":{"login":"nLight","id":186223,"avatar_url":"https://avatars.githubusercontent.com/u/186223?v=3","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":"ℹ️  ~~This PR is not feature complete yet, but you can get a feeling of how the API will look like.~~\r\n\r\n----\r\n\r\nThis PR introduces `NavigationService` module that lives in `foundation-ui` and will be used by packages to register themselves in the Navigation/Sidebar.\r\n\r\nIt's a simple EventEmitter that will emit change events so any other package could subscribe to it. ATM there will be only one _external_ listener - Sidebar.js\r\n\r\nThere's also a utility module `NavigationServiceUtil` that lives in DCOS-UI and maps application routes into NavigationService's API calls to support legacy until we migrate all the packages.\r\n\r\nI decided to go with a simple declarative API as I did in the `RoutingService`.\r\n\r\n🙇 ","created_at":"2016-11-08T16:57:46Z","updated_at":"2016-11-18T11:30:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"611195ddf4090ff91a05db86769cb92d0e5b31ad","assignee":{"login":"Poltergeist","id":156010,"avatar_url":"https://avatars.githubusercontent.com/u/156010?v=3","gravatar_id":"","url":"https://api.github.com/users/Poltergeist","html_url":"https://github.com/Poltergeist","followers_url":"https://api.github.com/users/Poltergeist/followers","following_url":"https://api.github.com/users/Poltergeist/following{/other_user}","gists_url":"https://api.github.com/users/Poltergeist/gists{/gist_id}","starred_url":"https://api.github.com/users/Poltergeist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Poltergeist/subscriptions","organizations_url":"https://api.github.com/users/Poltergeist/orgs","repos_url":"https://api.github.com/users/Poltergeist/repos","events_url":"https://api.github.com/users/Poltergeist/events{/privacy}","received_events_url":"https://api.github.com/users/Poltergeist/received_events","type":"User","site_admin":false},"assignees":[{"login":"Poltergeist","id":156010,"avatar_url":"https://avatars.githubusercontent.com/u/156010?v=3","gravatar_id":"","url":"https://api.github.com/users/Poltergeist","html_url":"https://github.com/Poltergeist","followers_url":"https://api.github.com/users/Poltergeist/followers","following_url":"https://api.github.com/users/Poltergeist/following{/other_user}","gists_url":"https://api.github.com/users/Poltergeist/gists{/gist_id}","starred_url":"https://api.github.com/users/Poltergeist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Poltergeist/subscriptions","organizations_url":"https://api.github.com/users/Poltergeist/orgs","repos_url":"https://api.github.com/users/Poltergeist/repos","events_url":"https://api.github.com/users/Poltergeist/events{/privacy}","received_events_url":"https://api.github.com/users/Poltergeist/received_events","type":"User","site_admin":false},{"login":"rcorral","id":843202,"avatar_url":"https://avatars.githubusercontent.com/u/843202?v=3","gravatar_id":"","url":"https://api.github.com/users/rcorral","html_url":"https://github.com/rcorral","followers_url":"https://api.github.com/users/rcorral/followers","following_url":"https://api.github.com/users/rcorral/following{/other_user}","gists_url":"https://api.github.com/users/rcorral/gists{/gist_id}","starred_url":"https://api.github.com/users/rcorral/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rcorral/subscriptions","organizations_url":"https://api.github.com/users/rcorral/orgs","repos_url":"https://api.github.com/users/rcorral/repos","events_url":"https://api.github.com/users/rcorral/events{/privacy}","received_events_url":"https://api.github.com/users/rcorral/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/dcos/dcos-ui/pulls/1334/commits","review_comments_url":"https://api.github.com/repos/dcos/dcos-ui/pulls/1334/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/1334/comments","statuses_url":"https://api.github.com/repos/dcos/dcos-ui/statuses/44d3cb3c12cc40302823aa449c7b06a60812cbda","head":{"label":"dcos:drozhkov/fix/DCOS-11326/navigation-service","ref":"drozhkov/fix/DCOS-11326/navigation-service","sha":"44d3cb3c12cc40302823aa449c7b06a60812cbda","user":{"login":"dcos","id":17648048,"avatar_url":"https://avatars.githubusercontent.com/u/17648048?v=3","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://avatars.githubusercontent.com/u/17648048?v=3","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":"2016-11-12T07:39:08Z","pushed_at":"2016-11-18T11:29:32Z","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":null,"size":23563,"stargazers_count":111,"watchers_count":111,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":29,"forks":31,"open_issues":29,"watchers":111,"default_branch":"master"}},"base":{"label":"dcos:master","ref":"master","sha":"dbc89b2372b3500f961d0e5e9d8dea5ac008c671","user":{"login":"dcos","id":17648048,"avatar_url":"https://avatars.githubusercontent.com/u/17648048?v=3","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://avatars.githubusercontent.com/u/17648048?v=3","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":"2016-11-12T07:39:08Z","pushed_at":"2016-11-18T11:29:32Z","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":null,"size":23563,"stargazers_count":111,"watchers_count":111,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":29,"forks":31,"open_issues":29,"watchers":111,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/1334"},"html":{"href":"https://github.com/dcos/dcos-ui/pull/1334"},"issue":{"href":"https://api.github.com/repos/dcos/dcos-ui/issues/1334"},"comments":{"href":"https://api.github.com/repos/dcos/dcos-ui/issues/1334/comments"},"review_comments":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/1334/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/1334/commits"},"statuses":{"href":"https://api.github.com/repos/dcos/dcos-ui/statuses/44d3cb3c12cc40302823aa449c7b06a60812cbda"}}}}
{"actor":{"display_login":"nLight"}}