{"action":"created","comment":{"url":"https://api.github.com/repos/dcos/dcos-ui/pulls/comments/153485020","pull_request_review_id":79495790,"id":153485020,"diff_hunk":"@@ -0,0 +1,63 @@\n+import React, { Component } from \"react\";\n+\n+import Transaction from \"#SRC/js/structs/Transaction\";\n+import TransactionTypes from \"#SRC/js/constants/TransactionTypes\";\n+\n+export default class Batch extends Component {\n+  constructor() {\n+    super(...arguments);\n+\n+    this.handleChange = this.handleChange.bind(this);\n+    this.handleAddItem = this.handleAddItem.bind(this);\n+    this.handleRemoveItem = this.handleRemoveItem.bind(this);\n+  }\n+\n+  handleChange(event) {\n+    const fieldName = event.target.getAttribute(\"name\");\n+    if (!fieldName) {\n+      return;\n+    }\n+\n+    const value = event.target.type === \"checkbox\"\n+      ? event.target.checked\n+      : event.target.value;\n+\n+    const path = fieldName.split(\".\");\n+    const batch = this.props.batch.add(new Transaction(path, value));\n+\n+    this.props.onChange(batch, fieldName);\n+  }\n+\n+  handleAddItem(event) {\n+    const { value, path } = event;\n+\n+    const batch = this.props.batch.add(\n+      new Transaction(path.split(\".\"), value, TransactionTypes.ADD_ITEM)\n+    );\n+\n+    this.props.onChange(batch);\n+  }\n+\n+  handleRemoveItem(event) {\n+    const { value, path } = event;\n+\n+    const batch = this.props.batch.add(\n+      new Transaction(path.split(\".\"), value, TransactionTypes.REMOVE_ITEM)\n+    );\n+\n+    this.props.onChange(batch);\n+  }\n+\n+  render() {\n+    const { children } = this.props;\n+\n+    return (\n+      <div onChange={this.handleChange}>\n+        {React.cloneElement(children, {","path":"src/js/components/BatchContainer.js","position":56,"original_position":56,"commit_id":"29ebe8dd939e98f221902e23f585b696313e485f","original_commit_id":"f3e4c3453c1de376112e910e5df3fc9b38d89b31","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":"We can use react context - it's like props, but if you need to go deeper -_-\r\nBut this is the technique we're using all over the place in the router. We just clone elements and mix props we want to pass down.","created_at":"2017-11-28T13:05:51Z","updated_at":"2017-11-28T13:05:51Z","html_url":"https://github.com/dcos/dcos-ui/pull/2522#discussion_r153485020","pull_request_url":"https://api.github.com/repos/dcos/dcos-ui/pulls/2522","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/comments/153485020"},"html":{"href":"https://github.com/dcos/dcos-ui/pull/2522#discussion_r153485020"},"pull_request":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/2522"}},"in_reply_to_id":153212499},"pull_request":{"url":"https://api.github.com/repos/dcos/dcos-ui/pulls/2522","id":154388095,"html_url":"https://github.com/dcos/dcos-ui/pull/2522","diff_url":"https://github.com/dcos/dcos-ui/pull/2522.diff","patch_url":"https://github.com/dcos/dcos-ui/pull/2522.patch","issue_url":"https://api.github.com/repos/dcos/dcos-ui/issues/2522","number":2522,"state":"open","locked":false,"title":"DCOS-19559: Adapt placement constraints widget to the SDK form","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":"✅   Depends on #2516 \r\n\r\n1. Implement `BatchContainer` - a wrapper that takes care of the Batch even cycle\r\n2. Implement an adapter for the `PlacementConstraintPartial`\r\n3. Use the Adapter in the json-schema form \r\n\r\nWould be awesome to have a demo-universe to test this. @orlandohohmeier do you know how to put one together? We need a placement constraints with the media type `placement` and the json\r\n\r\nEdit @nlight\r\nThis is what I did:\r\n```\r\n+---------------------------------------------------+          \r\n|Adapter                    Batch               <------- String\r\n|                              |                    |          \r\n|  +---------------------------|----------------+   |          \r\n|  |BatchForm                  |                |   |          \r\n|  |                           ↓  Data |        |   |          \r\n|  |   +-------------------------------|------+ |   |          \r\n|  |   |Partial                        |      | |   |          \r\n|  |   |                               |      | |   |          \r\n|  |   |                               ↓      | |   |          \r\n|  |   |                                      | |   |          \r\n|  |   |                                      | |   |          \r\n|  |   |                                      | |   |          \r\n|  |   |                  |Events             | |   |          \r\n|  |   +------------------|-------------------+ |   |          \r\n|  |                      |                     |   |          \r\n|  |                      ↓     |Batch          |   |          \r\n|  +----------------------------|---------------+   |          \r\n|                               ↓                 -----> String\r\n+---------------------------------------------------+          \r\n\r\nmade with textik.com\r\n```","created_at":"2017-11-23T14:21:46Z","updated_at":"2017-11-28T13:05:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9dbbc67579b5ec274a9537a46012d83d4fef97ef","assignee":{"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},"assignees":[{"login":"Poltergeist","id":156010,"avatar_url":"https://avatars0.githubusercontent.com/u/156010?v=4","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":"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_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/dcos/dcos-ui/pulls/2522/commits","review_comments_url":"https://api.github.com/repos/dcos/dcos-ui/pulls/2522/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/2522/comments","statuses_url":"https://api.github.com/repos/dcos/dcos-ui/statuses/29ebe8dd939e98f221902e23f585b696313e485f","head":{"label":"dcos:drozhkov/dcos-19559-adapt-placement-constraints-widget-to-sdk-form","ref":"drozhkov/dcos-19559-adapt-placement-constraints-widget-to-sdk-form","sha":"29ebe8dd939e98f221902e23f585b696313e485f","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":"2017-11-28T10:37:17Z","pushed_at":"2017-11-28T11:05:56Z","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":28344,"stargazers_count":159,"watchers_count":159,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":61,"mirror_url":null,"archived":false,"open_issues_count":24,"forks":61,"open_issues":24,"watchers":159,"default_branch":"master"}},"base":{"label":"dcos:master","ref":"master","sha":"89977c66abdb4cda1444cd24464a54cc1c2380dc","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":"2017-11-28T10:37:17Z","pushed_at":"2017-11-28T11:05:56Z","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":28344,"stargazers_count":159,"watchers_count":159,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":61,"mirror_url":null,"archived":false,"open_issues_count":24,"forks":61,"open_issues":24,"watchers":159,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/2522"},"html":{"href":"https://github.com/dcos/dcos-ui/pull/2522"},"issue":{"href":"https://api.github.com/repos/dcos/dcos-ui/issues/2522"},"comments":{"href":"https://api.github.com/repos/dcos/dcos-ui/issues/2522/comments"},"review_comments":{"href":"https://api.github.com/repos/dcos/dcos-ui/pulls/2522/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/2522/commits"},"statuses":{"href":"https://api.github.com/repos/dcos/dcos-ui/statuses/29ebe8dd939e98f221902e23f585b696313e485f"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"nLight"}}