{"action":"created","issue":{"url":"https://api.github.com/repos/dcos/dcos-ui/issues/1247","repository_url":"https://api.github.com/repos/dcos/dcos-ui","labels_url":"https://api.github.com/repos/dcos/dcos-ui/issues/1247/labels{/name}","comments_url":"https://api.github.com/repos/dcos/dcos-ui/issues/1247/comments","events_url":"https://api.github.com/repos/dcos/dcos-ui/issues/1247/events","html_url":"https://github.com/dcos/dcos-ui/pull/1247","id":183109273,"number":1247,"title":"[Form Refactor]: The base structs and utils for the new form workflow","user":{"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},"labels":[],"state":"open","locked":false,"assignee":{"login":"mlunoe","id":1097941,"avatar_url":"https://avatars.githubusercontent.com/u/1097941?v=3","gravatar_id":"","url":"https://api.github.com/users/mlunoe","html_url":"https://github.com/mlunoe","followers_url":"https://api.github.com/users/mlunoe/followers","following_url":"https://api.github.com/users/mlunoe/following{/other_user}","gists_url":"https://api.github.com/users/mlunoe/gists{/gist_id}","starred_url":"https://api.github.com/users/mlunoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlunoe/subscriptions","organizations_url":"https://api.github.com/users/mlunoe/orgs","repos_url":"https://api.github.com/users/mlunoe/repos","events_url":"https://api.github.com/users/mlunoe/events{/privacy}","received_events_url":"https://api.github.com/users/mlunoe/received_events","type":"User","site_admin":false},"assignees":[{"login":"mlunoe","id":1097941,"avatar_url":"https://avatars.githubusercontent.com/u/1097941?v=3","gravatar_id":"","url":"https://api.github.com/users/mlunoe","html_url":"https://github.com/mlunoe","followers_url":"https://api.github.com/users/mlunoe/followers","following_url":"https://api.github.com/users/mlunoe/following{/other_user}","gists_url":"https://api.github.com/users/mlunoe/gists{/gist_id}","starred_url":"https://api.github.com/users/mlunoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlunoe/subscriptions","organizations_url":"https://api.github.com/users/mlunoe/orgs","repos_url":"https://api.github.com/users/mlunoe/repos","events_url":"https://api.github.com/users/mlunoe/events{/privacy}","received_events_url":"https://api.github.com/users/mlunoe/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-10-14T17:42:13Z","updated_at":"2016-10-21T13:08:24Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dcos/dcos-ui/pulls/1247","html_url":"https://github.com/dcos/dcos-ui/pull/1247","diff_url":"https://github.com/dcos/dcos-ui/pull/1247.diff","patch_url":"https://github.com/dcos/dcos-ui/pull/1247.patch"},"body":"This does contain the structs and also the utils for the form refactoring. This is a basic implementation I hope it does explain how everything is working together.\r\n\r\n```JS\r\nlet batch = new Batch();\r\n\r\n// Create Reducer here with a object. These could also be deep nested but each \r\n// level does need to be generated.\r\nlet reducer = ReducerUtil.combineReducer({\r\n  id: function (state = '', action) {\r\n    if (action.type === 'SET' && action.path.join === 'id') {\r\n      return action.value;\r\n    }\r\n    return state;\r\n  },\r\n  vip: function (state = '', action) {\r\n    if (action.type === 'SET' && action.path.join === 'id') {\r\n      this.id = id;\r\n    }\r\n    if (action.type === 'SET' && action.path.join === 'port') {\r\n      this.port = port;\r\n    }\r\n    if (this.port != null && this.id != null) {\r\n      return `${this.id}:${this.port}`;\r\n    }\r\n    return state;\r\n  }\r\n});\r\n\r\n// Two events are getting added to the Batch.\r\nbatch.add(new SetAction(['id'], 'abcd');\r\nbatch.add(new SetAction(['port'], '8080');\r\n\r\nlet state = batch.reduce(reducer, {});\r\n\r\nconsole.log(state); // output: {id: 'abcd', vip: 'abcd:8080'}\r\n```\r\n\r\n@mlunoe could you please look over this and let me know what you think so far.\r\n\r\nAlso Thanks to @orlandohohmeier @nLight @wavesoft for the input and support while pairing. It was a pleasure."},"comment":{"url":"https://api.github.com/repos/dcos/dcos-ui/issues/comments/255371951","html_url":"https://github.com/dcos/dcos-ui/pull/1247#issuecomment-255371951","issue_url":"https://api.github.com/repos/dcos/dcos-ui/issues/1247","id":255371951,"user":{"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},"created_at":"2016-10-21T13:08:24Z","updated_at":"2016-10-21T13:08:24Z","body":"@mlunoe @orlandohohmeier @MatApple \r\n\r\nI am trying to put up a to do list for this. If I missed something please add it here.\r\n\r\n- [ ] Decide if the formAction should live in the structs or somewhere else.\r\n\r\n\r\nAlso in another PR I will be adding: \r\n\r\n- [ ] Type validation for formActions\r\n- [ ] FormActionTypes constants"}}
{"actor":{"display_login":"Poltergeist"}}