{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/2069","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/2069/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/2069/comments","events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/2069/events","html_url":"https://github.com/Automattic/wp-calypso/pull/2069","id":124758855,"number":2069,"title":"Editor: Contact Form Dialog State","user":{"login":"rodrigoi","id":233601,"avatar_url":"https://avatars.githubusercontent.com/u/233601?v=3","gravatar_id":"","url":"https://api.github.com/users/rodrigoi","html_url":"https://github.com/rodrigoi","followers_url":"https://api.github.com/users/rodrigoi/followers","following_url":"https://api.github.com/users/rodrigoi/following{/other_user}","gists_url":"https://api.github.com/users/rodrigoi/gists{/gist_id}","starred_url":"https://api.github.com/users/rodrigoi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rodrigoi/subscriptions","organizations_url":"https://api.github.com/users/rodrigoi/orgs","repos_url":"https://api.github.com/users/rodrigoi/repos","events_url":"https://api.github.com/users/rodrigoi/events{/privacy}","received_events_url":"https://api.github.com/users/rodrigoi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/Editor","name":"Editor","color":"006b75"},{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/[Status]%20Needs%20Review","name":"[Status] Needs Review","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-04T13:28:45Z","updated_at":"2016-01-23T01:02:29Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/2069","html_url":"https://github.com/Automattic/wp-calypso/pull/2069","diff_url":"https://github.com/Automattic/wp-calypso/pull/2069.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/2069.patch"},"body":"As part of the implementation of the contact form builder dialog on the editor, a very small Redux store has been implemented.\r\n\r\nThis implementation has the following features:\r\n\r\n- Can work with multiple forms on the same document.\r\n- The state is updated with manual changes on the contact form shortcode.\r\n- Only _add_ and _remove_ operations on the form fields are supported.\r\n\r\nThe TinyMCE plugin acts a the container view, creating an instance of a Redux store when the plugin is loaded. The dialog window uses `connect`.\r\nWhen the user clicks on the _Add Contact Form_ button on the toolbar, the store is initialized with the default fields, but when the user clicks the _Edit_ button on an existing contact form, the state is overwritten with the fields and settings deserialized from the shortcode.\r\n\r\nThe state is essentially persisted on the document, and the shortcode always has the latest version of the contact form. And the same store is reused for every dialog window.\r\n\r\nThe challenge here is to incorporate this state into the global store.\r\n\r\nDepends on #2085 for accessing store using React context and TinyMCE params."},"comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments/174101367","html_url":"https://github.com/Automattic/wp-calypso/pull/2069#issuecomment-174101367","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/2069","id":174101367,"user":{"login":"rodrigoi","id":233601,"avatar_url":"https://avatars.githubusercontent.com/u/233601?v=3","gravatar_id":"","url":"https://api.github.com/users/rodrigoi","html_url":"https://github.com/rodrigoi","followers_url":"https://api.github.com/users/rodrigoi/followers","following_url":"https://api.github.com/users/rodrigoi/following{/other_user}","gists_url":"https://api.github.com/users/rodrigoi/gists{/gist_id}","starred_url":"https://api.github.com/users/rodrigoi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rodrigoi/subscriptions","organizations_url":"https://api.github.com/users/rodrigoi/orgs","repos_url":"https://api.github.com/users/rodrigoi/repos","events_url":"https://api.github.com/users/rodrigoi/events{/privacy}","received_events_url":"https://api.github.com/users/rodrigoi/received_events","type":"User","site_admin":false},"created_at":"2016-01-23T01:02:29Z","updated_at":"2016-01-23T01:02:29Z","body":"@aduth I've made the flow a bit more explicit by adding a _clear form_ action and checking for `content`. `content` can either be `null` if no form is selected or contain the form's shortcode. Because the same dialog is reused if a new form is added or if an existing form is edited, we have to clear the state or load the deserialized shortcode respectively.\r\n\r\nLet me know if you have any comments and thanks a lot for your time reviewing this!"}}