{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/85387025","pull_request_review_id":6107462,"id":85387025,"diff_hunk":"@@ -75,15 +80,110 @@ class EditorMediaModalDetailItem extends Component {\n \n \t\treturn (\n \t\t\t<Button\n-\t\t\t\tclassName={ classNames( 'editor-media-modal-detail__edit', className ) }\n+\t\t\t\tclassName=\"editor-media-modal-detail__edit\"\n \t\t\t\tonClick={ onEdit }\n-\t\t\t\tdisabled={ isItemBeingUploaded( item ) }\n+\t\t\t\tdisabled={ isItemBeingUploaded( item ) || item.original_loaded }\n \t\t\t>\n \t\t\t\t<Gridicon icon=\"pencil\" size={ 36 } /> { translate( 'Edit Image' ) }\n \t\t\t</Button>\n \t\t);\n \t}\n \n+\trenderRestoreButton() {\n+\t\tconst {\n+\t\t\titem,\n+\t\t\tonRestore,\n+\t\t\tonRestoreApply,\n+\t\t\ttranslate\n+\t\t} = this.props;\n+\n+\t\tconst isLoading = item.loading_original;\n+\t\tconst isReadyToRestore = item.original_loaded;\n+\n+\t\tconst handleRestoringMethod = event => {\n+\t\t\tif ( isReadyToRestore ) {\n+\t\t\t\treturn onRestoreApply( item, event );\n+\t\t\t}\n+\n+\t\t\treturn onRestore( item, event );\n+\t\t};\n+\n+\t\tconst buttonText = isReadyToRestore ? translate( 'Apply' ) : translate( 'Restore Original' );\n+\n+\t\treturn (\n+\t\t\t<Button\n+\t\t\t\tclassName={ classNames(\n+\t\t\t\t\t'editor-media-modal-detail__restore',\n+\t\t\t\t\t{ 'is-loading': isLoading },\n+\t\t\t\t\t{ 'is-ready': isReadyToRestore },\n+\t\t\t\t) }\n+\t\t\t\tdisabled={ isLoading }\n+\t\t\t\tonClick={ handleRestoringMethod }\n+\t\t\t>\n+\t\t\t\t<Gridicon\n+\t\t\t\t\ticon={ isReadyToRestore ? 'checkmark' : 'refresh' }\n+\t\t\t\t\tsize={ 36 } />\n+\t\t\t\t\t&nbsp;{ buttonText }\n+\t\t\t</Button>\n+\t\t);\n+\t}\n+\n+\trenderDiscardRestoreButton() {\n+\t\tconst {\n+\t\t\titem,\n+\t\t\tonRestoreDiscard,\n+\t\t\ttranslate\n+\t\t} = this.props;\n+\n+\t\tconst handleCancelRestoringMethod = event => {\n+\t\t\tonRestoreDiscard( item, event );\n+\t\t};\n+\n+\t\treturn (\n+\t\t\t<Button\n+\t\t\t\tclassName=\"editor-media-modal-detail__cancel_restore\"\n+\t\t\t\tonClick={ handleCancelRestoringMethod }\n+\t\t\t>\n+\t\t\t\t<Gridicon icon=\"trash\" size={ 36 } /> { translate( 'Discard' ) }\n+\t\t\t</Button>\n+\t\t);\n+\t}\n+\n+\trenderEditionBar( item, classname = 'is-desktop' ) {\n+\t\tconst { site } = this.props;\n+\n+\t\t// Do not render edit button for private sites\n+\t\tif ( site.is_private ) {\n+\t\t\tdebug( 'Do not show `Restore button` for private sites' );\n+\n+\t\t\treturn null;\n+\t\t}\n+\n+\t\tif (\n+\t\t\t! config.isEnabled( 'post-editor/image-editor' ) ||\n+\t\t\tisJetpack( site ) ||\n+\t\t\t! item\n+\t\t) {\n+\t\t\treturn null;\n+\t\t}\n+\n+\t\tconst hasOriginal = item.revision_history &&\n+\t\t\titem.revision_history.original &&\n+\t\t\titem.revision_history.original.URL;\n+\n+\t\tconst originalWasLoaded = ! item.loading_original && item.original_loaded;\n+\n+\t\tconst classes = classNames( 'editor-media-modal-detail__edition-bar', classname );\n+\n+\t\treturn (\n+\t\t\t<div className={ classes }>\n+\t\t\t\t{ originalWasLoaded && this.renderDiscardRestoreButton( classname ) }\n+\t\t\t\t{ hasOriginal && this.renderRestoreButton( classname ) }\n+\t\t\t\t{ this.renderEditButton( classname ) }","path":"client/post-editor/media-modal/detail/detail-item.jsx","position":141,"original_position":141,"commit_id":"e9f7f11e3ee07fd5e70b607b59db97786278f994","original_commit_id":"e9f7f11e3ee07fd5e70b607b59db97786278f994","user":{"login":"gwwar","id":1270189,"avatar_url":"https://avatars.githubusercontent.com/u/1270189?v=3","gravatar_id":"","url":"https://api.github.com/users/gwwar","html_url":"https://github.com/gwwar","followers_url":"https://api.github.com/users/gwwar/followers","following_url":"https://api.github.com/users/gwwar/following{/other_user}","gists_url":"https://api.github.com/users/gwwar/gists{/gist_id}","starred_url":"https://api.github.com/users/gwwar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwwar/subscriptions","organizations_url":"https://api.github.com/users/gwwar/orgs","repos_url":"https://api.github.com/users/gwwar/repos","events_url":"https://api.github.com/users/gwwar/events{/privacy}","received_events_url":"https://api.github.com/users/gwwar/received_events","type":"User","site_admin":false},"body":"classname here won't be passed through, since we ignore this above","created_at":"2016-10-27T17:27:09Z","updated_at":"2016-10-27T17:27:09Z","html_url":"https://github.com/Automattic/wp-calypso/pull/8982#discussion_r85387025","pull_request_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/8982","_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/85387025"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/8982#discussion_r85387025"},"pull_request":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/8982"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/8982","id":91231808,"html_url":"https://github.com/Automattic/wp-calypso/pull/8982","diff_url":"https://github.com/Automattic/wp-calypso/pull/8982.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/8982.patch","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/8982","number":8982,"state":"open","locked":false,"title":"ImageEditor: restore original media file","user":{"login":"retrofox","id":77539,"avatar_url":"https://avatars.githubusercontent.com/u/77539?v=3","gravatar_id":"","url":"https://api.github.com/users/retrofox","html_url":"https://github.com/retrofox","followers_url":"https://api.github.com/users/retrofox/followers","following_url":"https://api.github.com/users/retrofox/following{/other_user}","gists_url":"https://api.github.com/users/retrofox/gists{/gist_id}","starred_url":"https://api.github.com/users/retrofox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/retrofox/subscriptions","organizations_url":"https://api.github.com/users/retrofox/orgs","repos_url":"https://api.github.com/users/retrofox/repos","events_url":"https://api.github.com/users/retrofox/events{/privacy}","received_events_url":"https://api.github.com/users/retrofox/received_events","type":"User","site_admin":false},"body":"This PR tries to achieve the functionality to restoring the original media file once the media was edited.\r\n\r\nAlthough we already have some description for this implementation I've had to implement some behaviors using my own criteria. 😨 \r\nFor this reason, I would like to know the opinion of @adambbecker and @mtias. Here an animation:\r\n\r\n![calypso-image-editor-14](https://cloud.githubusercontent.com/assets/77539/19775158/e4be8170-9c45-11e6-9ee0-725681cbab75.gif)\r\n\r\nKeep in mind that this PR belongs to [Editor V1 project](https://github.com/Automattic/wp-calypso/projects/4), and we have thought to continue with [Editor V2](https://github.com/Automattic/wp-calypso/projects/5) immediately once V1 is ready. Thus I'm pretty sure that, although this implementation is ok at least in my opinion, it's very probable that it will be updated soon according to new improvements.\r\n\r\n### Testing\r\n\r\nA picture is worth a thousand words. Take a look at the animation above.","created_at":"2016-10-27T16:05:03Z","updated_at":"2016-10-27T17:27:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2eaf01ea805dcc9b377675e56f8be694db073f8e","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/Automattic/wp-calypso/milestones/107","html_url":"https://github.com/Automattic/wp-calypso/milestones/Image%20Editor","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones/107/labels","id":1872811,"number":107,"title":"Image Editor","description":null,"creator":{"login":"gwwar","id":1270189,"avatar_url":"https://avatars.githubusercontent.com/u/1270189?v=3","gravatar_id":"","url":"https://api.github.com/users/gwwar","html_url":"https://github.com/gwwar","followers_url":"https://api.github.com/users/gwwar/followers","following_url":"https://api.github.com/users/gwwar/following{/other_user}","gists_url":"https://api.github.com/users/gwwar/gists{/gist_id}","starred_url":"https://api.github.com/users/gwwar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwwar/subscriptions","organizations_url":"https://api.github.com/users/gwwar/orgs","repos_url":"https://api.github.com/users/gwwar/repos","events_url":"https://api.github.com/users/gwwar/events{/privacy}","received_events_url":"https://api.github.com/users/gwwar/received_events","type":"User","site_admin":false},"open_issues":14,"closed_issues":65,"state":"open","created_at":"2016-07-08T18:51:46Z","updated_at":"2016-10-27T16:09:14Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/8982/commits","review_comments_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/8982/comments","review_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/8982/comments","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/e9f7f11e3ee07fd5e70b607b59db97786278f994","head":{"label":"Automattic:update/restore-edited-image","ref":"update/restore-edited-image","sha":"e9f7f11e3ee07fd5e70b607b59db97786278f994","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2016-10-27T16:57:00Z","pushed_at":"2016-10-27T17:04:37Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":149939,"stargazers_count":7977,"watchers_count":7977,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1005,"mirror_url":null,"open_issues_count":1479,"forks":1005,"open_issues":1479,"watchers":7977,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"1950f5c1e2309643edd66b38e68c45123b436a6f","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2016-10-27T16:57:00Z","pushed_at":"2016-10-27T17:04:37Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":149939,"stargazers_count":7977,"watchers_count":7977,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1005,"mirror_url":null,"open_issues_count":1479,"forks":1005,"open_issues":1479,"watchers":7977,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/8982"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/8982"},"issue":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/8982"},"comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/8982/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/8982/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/8982/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/wp-calypso/statuses/e9f7f11e3ee07fd5e70b607b59db97786278f994"}}}}
{"actor":{"display_login":"gwwar"}}