{"action":"created","comment":{"url":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/comments/38788398","id":38788398,"diff_hunk":"@@ -499,6 +497,145 @@ define(function (require, exports) {\n     };\n     renameAsset.reads = [];\n     renameAsset.writes = [locks.CC_LIBRARIES, locks.JS_LIBRARIES];\n+    \n+    /**\n+     * Open the specified graphic asset for edit by creating a temp copy of the asset's document and open\n+     * in Photoshop. The library store will listen to the document save and close event. \n+     * \n+     * @param {AdobeLibraryElement} element\n+     * @return {Promise}\n+     */\n+    var openGraphicForEdit = function (element) {\n+        var representation = element.getPrimaryRepresentation();\n+        \n+        if (representation.type !== _REP_PHOTOSHOP_TYPE) {\n+            // Due to the limitation in DS, we only support editing psd file.\n+            log.debug(\"[CC Lib] unsupported graphic type: \" + representation.type);\n+            return Promise.resolve();\n+        }\n+        \n+        var tempFilePath,\n+            tempPreviewPath;\n+        \n+        return Promise\n+            .bind(this)\n+            .then(function () {\n+                var graphicEditStatus = this.flux.stores.library.getGraphicEditStatus(element);\n+                \n+                // If the element already have a temp file, update the temp file path.\n+                if (graphicEditStatus) {\n+                    tempFilePath = graphicEditStatus.documentPath;\n+                    tempPreviewPath = graphicEditStatus.previewPath;\n+                    return;\n+                }\n+                \n+                // Otherwise, create a temp copy of the element for edit.\n+                return _getTempPaths()\n+                    .bind(this)\n+                    .then(function (paths) {\n+                        var tempFilename = this.flux.stores.library.generateTempFilename(element);\n+                        \n+                        tempFilePath = paths.tempBasePath + pathUtil.sep + tempFilename;\n+                        tempPreviewPath = tempFilePath.replace(\".psd\", \"p.png\");\n+                    })\n+                    .then(function () {\n+                        return Promise.fromNode(function (done) {\n+                            element.getPrimaryRepresentation().getContentPath(done);\n+                        }).then(function (contentPath) {\n+                            if (!contentPath) {\n+                                return Promise.reject(\"Failed to fetch content of element: \" + element.name);\n+                            }\n+                            \n+                            return contentPath;\n+                        });\n+                    })\n+                    .then(function (contentPath) {\n+                        return this.flux.actions.export.copyFile(contentPath, tempFilePath);\n+                    });\n+            })\n+            .then(function () {\n+                var previewSetting = {\n+                    path: tempPreviewPath,\n+                    width: RENDITION_GRAPHIC_SIZE,\n+                    height: RENDITION_GRAPHIC_SIZE\n+                };\n+                \n+                // Open the graphic asset's temp file and tell PS to generate an updated \n+                // preview whenever the file is saved\n+                return this.flux.actions.documents.open(tempFilePath, {","path":"src/js/actions/libraries.js","position":118,"original_position":118,"commit_id":"6dd1b5ee2248fdcb04872a800f9e641f45bc94ba","original_commit_id":"6dd1b5ee2248fdcb04872a800f9e641f45bc94ba","user":{"login":"volfied","id":386714,"avatar_url":"https://avatars.githubusercontent.com/u/386714?v=3","gravatar_id":"","url":"https://api.github.com/users/volfied","html_url":"https://github.com/volfied","followers_url":"https://api.github.com/users/volfied/followers","following_url":"https://api.github.com/users/volfied/following{/other_user}","gists_url":"https://api.github.com/users/volfied/gists{/gist_id}","starred_url":"https://api.github.com/users/volfied/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/volfied/subscriptions","organizations_url":"https://api.github.com/users/volfied/orgs","repos_url":"https://api.github.com/users/volfied/repos","events_url":"https://api.github.com/users/volfied/events{/privacy}","received_events_url":"https://api.github.com/users/volfied/received_events","type":"User","site_admin":false},"body":"Also, with enqueuing, by the time next .then rolls around, you're not guaranteed that the document will be open.","created_at":"2015-09-04T19:54:52Z","updated_at":"2015-09-04T19:54:52Z","html_url":"https://github.com/adobe-photoshop/spaces-design/pull/2345#discussion_r38788398","pull_request_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/2345","_links":{"self":{"href":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/comments/38788398"},"html":{"href":"https://github.com/adobe-photoshop/spaces-design/pull/2345#discussion_r38788398"},"pull_request":{"href":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/2345"}}},"pull_request":{"url":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/2345","id":44238749,"html_url":"https://github.com/adobe-photoshop/spaces-design/pull/2345","diff_url":"https://github.com/adobe-photoshop/spaces-design/pull/2345.diff","patch_url":"https://github.com/adobe-photoshop/spaces-design/pull/2345.patch","issue_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/issues/2345","number":2345,"state":"open","locked":false,"title":"CC Libraries - support open-for-edit for graphic assets.","user":{"login":"shaoshing","id":118264,"avatar_url":"https://avatars.githubusercontent.com/u/118264?v=3","gravatar_id":"","url":"https://api.github.com/users/shaoshing","html_url":"https://github.com/shaoshing","followers_url":"https://api.github.com/users/shaoshing/followers","following_url":"https://api.github.com/users/shaoshing/following{/other_user}","gists_url":"https://api.github.com/users/shaoshing/gists{/gist_id}","starred_url":"https://api.github.com/users/shaoshing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaoshing/subscriptions","organizations_url":"https://api.github.com/users/shaoshing/orgs","repos_url":"https://api.github.com/users/shaoshing/repos","events_url":"https://api.github.com/users/shaoshing/events{/privacy}","received_events_url":"https://api.github.com/users/shaoshing/received_events","type":"User","site_admin":false},"body":"**require changes from the adapter and generator-space plugin, see bottom for setting up generator-space plugin**\r\n\r\nThis PR implements open-for-edit for graphic assets. You can double click on graphic asset's thumbnail to open the asset for editing. Some notes:\r\n\r\n* currently it only supports edit PSD file. The other file types require features that are not supported in DS yet.\r\n* switching back to standard PS will break the upload-after-save feature, but switch from standard PS to DS will maintain the functionality.\r\n* Close document will delete the temp files.\r\n\r\n![lib-edit](https://cloud.githubusercontent.com/assets/118264/9689208/61c790fa-52e9-11e5-8b61-cbbd98c988fc.gif)\r\n\r\n@volfied please review. \r\n@mcilroyc I made the change to import the file system commands, so could you review this PR?\r\n\r\n#### setup the generator-space plugin\r\n\r\n```\r\ncd PROJECTS\r\ngit clone git@github.com:adobe-photoshop/generator-spaces.git\r\ncd generator-spaces\r\ngit checkout shao/filesystem\r\nnpm install\r\n\r\ncd PS-DEV/Adobe\\ Photoshop\\ CC\\ 2015.app\r\nrm -rf Contents/Required/Plug-Ins/Generator/spaces.generate/\r\nln -s PROJECTS/generator-spaces Contents/Required/Plug-Ins/Generator/spaces.generate\r\nRESTART PS-DEV\r\n```","created_at":"2015-09-04T16:50:33Z","updated_at":"2015-09-04T19:54:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cc3084767368a78537a42fa8450f1c53cacdb8c0","assignee":{"login":"volfied","id":386714,"avatar_url":"https://avatars.githubusercontent.com/u/386714?v=3","gravatar_id":"","url":"https://api.github.com/users/volfied","html_url":"https://github.com/volfied","followers_url":"https://api.github.com/users/volfied/followers","following_url":"https://api.github.com/users/volfied/following{/other_user}","gists_url":"https://api.github.com/users/volfied/gists{/gist_id}","starred_url":"https://api.github.com/users/volfied/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/volfied/subscriptions","organizations_url":"https://api.github.com/users/volfied/orgs","repos_url":"https://api.github.com/users/volfied/repos","events_url":"https://api.github.com/users/volfied/events{/privacy}","received_events_url":"https://api.github.com/users/volfied/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/2345/commits","review_comments_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/2345/comments","review_comment_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/comments{/number}","comments_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/issues/2345/comments","statuses_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/statuses/6dd1b5ee2248fdcb04872a800f9e641f45bc94ba","head":{"label":"adobe-photoshop:shao/edit-asset","ref":"shao/edit-asset","sha":"6dd1b5ee2248fdcb04872a800f9e641f45bc94ba","user":{"login":"adobe-photoshop","id":4542585,"avatar_url":"https://avatars.githubusercontent.com/u/4542585?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe-photoshop","html_url":"https://github.com/adobe-photoshop","followers_url":"https://api.github.com/users/adobe-photoshop/followers","following_url":"https://api.github.com/users/adobe-photoshop/following{/other_user}","gists_url":"https://api.github.com/users/adobe-photoshop/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe-photoshop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe-photoshop/subscriptions","organizations_url":"https://api.github.com/users/adobe-photoshop/orgs","repos_url":"https://api.github.com/users/adobe-photoshop/repos","events_url":"https://api.github.com/users/adobe-photoshop/events{/privacy}","received_events_url":"https://api.github.com/users/adobe-photoshop/received_events","type":"Organization","site_admin":false},"repo":{"id":37291353,"name":"spaces-design","full_name":"adobe-photoshop/spaces-design","owner":{"login":"adobe-photoshop","id":4542585,"avatar_url":"https://avatars.githubusercontent.com/u/4542585?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe-photoshop","html_url":"https://github.com/adobe-photoshop","followers_url":"https://api.github.com/users/adobe-photoshop/followers","following_url":"https://api.github.com/users/adobe-photoshop/following{/other_user}","gists_url":"https://api.github.com/users/adobe-photoshop/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe-photoshop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe-photoshop/subscriptions","organizations_url":"https://api.github.com/users/adobe-photoshop/orgs","repos_url":"https://api.github.com/users/adobe-photoshop/repos","events_url":"https://api.github.com/users/adobe-photoshop/events{/privacy}","received_events_url":"https://api.github.com/users/adobe-photoshop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/adobe-photoshop/spaces-design","description":"Adobe Photoshop Design Space","fork":false,"url":"https://api.github.com/repos/adobe-photoshop/spaces-design","forks_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/forks","keys_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/teams","hooks_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/hooks","issue_events_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/issues/events{/number}","events_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/events","assignees_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/assignees{/user}","branches_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/branches{/branch}","tags_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/tags","blobs_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/git/refs{/sha}","trees_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/statuses/{sha}","languages_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/languages","stargazers_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/stargazers","contributors_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/contributors","subscribers_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/subscribers","subscription_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/subscription","commits_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/commits{/sha}","git_commits_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/git/commits{/sha}","comments_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/comments{/number}","issue_comment_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/issues/comments{/number}","contents_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/contents/{+path}","compare_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/merges","archive_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/downloads","issues_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/issues{/number}","pulls_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls{/number}","milestones_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/milestones{/number}","notifications_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/labels{/name}","releases_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/releases{/id}","created_at":"2015-06-11T23:23:47Z","updated_at":"2015-09-03T06:52:55Z","pushed_at":"2015-09-04T19:48:21Z","git_url":"git://github.com/adobe-photoshop/spaces-design.git","ssh_url":"git@github.com:adobe-photoshop/spaces-design.git","clone_url":"https://github.com/adobe-photoshop/spaces-design.git","svn_url":"https://github.com/adobe-photoshop/spaces-design","homepage":"http://adobe-photoshop.github.io/","size":20251,"stargazers_count":607,"watchers_count":607,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":43,"mirror_url":null,"open_issues_count":239,"forks":43,"open_issues":239,"watchers":607,"default_branch":"master"}},"base":{"label":"adobe-photoshop:master","ref":"master","sha":"0a0ca5c11b640527317cbeb5e73308dc15713ee3","user":{"login":"adobe-photoshop","id":4542585,"avatar_url":"https://avatars.githubusercontent.com/u/4542585?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe-photoshop","html_url":"https://github.com/adobe-photoshop","followers_url":"https://api.github.com/users/adobe-photoshop/followers","following_url":"https://api.github.com/users/adobe-photoshop/following{/other_user}","gists_url":"https://api.github.com/users/adobe-photoshop/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe-photoshop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe-photoshop/subscriptions","organizations_url":"https://api.github.com/users/adobe-photoshop/orgs","repos_url":"https://api.github.com/users/adobe-photoshop/repos","events_url":"https://api.github.com/users/adobe-photoshop/events{/privacy}","received_events_url":"https://api.github.com/users/adobe-photoshop/received_events","type":"Organization","site_admin":false},"repo":{"id":37291353,"name":"spaces-design","full_name":"adobe-photoshop/spaces-design","owner":{"login":"adobe-photoshop","id":4542585,"avatar_url":"https://avatars.githubusercontent.com/u/4542585?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe-photoshop","html_url":"https://github.com/adobe-photoshop","followers_url":"https://api.github.com/users/adobe-photoshop/followers","following_url":"https://api.github.com/users/adobe-photoshop/following{/other_user}","gists_url":"https://api.github.com/users/adobe-photoshop/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe-photoshop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe-photoshop/subscriptions","organizations_url":"https://api.github.com/users/adobe-photoshop/orgs","repos_url":"https://api.github.com/users/adobe-photoshop/repos","events_url":"https://api.github.com/users/adobe-photoshop/events{/privacy}","received_events_url":"https://api.github.com/users/adobe-photoshop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/adobe-photoshop/spaces-design","description":"Adobe Photoshop Design Space","fork":false,"url":"https://api.github.com/repos/adobe-photoshop/spaces-design","forks_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/forks","keys_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/teams","hooks_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/hooks","issue_events_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/issues/events{/number}","events_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/events","assignees_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/assignees{/user}","branches_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/branches{/branch}","tags_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/tags","blobs_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/git/refs{/sha}","trees_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/statuses/{sha}","languages_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/languages","stargazers_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/stargazers","contributors_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/contributors","subscribers_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/subscribers","subscription_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/subscription","commits_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/commits{/sha}","git_commits_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/git/commits{/sha}","comments_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/comments{/number}","issue_comment_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/issues/comments{/number}","contents_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/contents/{+path}","compare_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/merges","archive_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/downloads","issues_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/issues{/number}","pulls_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls{/number}","milestones_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/milestones{/number}","notifications_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/labels{/name}","releases_url":"https://api.github.com/repos/adobe-photoshop/spaces-design/releases{/id}","created_at":"2015-06-11T23:23:47Z","updated_at":"2015-09-03T06:52:55Z","pushed_at":"2015-09-04T19:48:21Z","git_url":"git://github.com/adobe-photoshop/spaces-design.git","ssh_url":"git@github.com:adobe-photoshop/spaces-design.git","clone_url":"https://github.com/adobe-photoshop/spaces-design.git","svn_url":"https://github.com/adobe-photoshop/spaces-design","homepage":"http://adobe-photoshop.github.io/","size":20251,"stargazers_count":607,"watchers_count":607,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":43,"mirror_url":null,"open_issues_count":239,"forks":43,"open_issues":239,"watchers":607,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/2345"},"html":{"href":"https://github.com/adobe-photoshop/spaces-design/pull/2345"},"issue":{"href":"https://api.github.com/repos/adobe-photoshop/spaces-design/issues/2345"},"comments":{"href":"https://api.github.com/repos/adobe-photoshop/spaces-design/issues/2345/comments"},"review_comments":{"href":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/2345/comments"},"review_comment":{"href":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/adobe-photoshop/spaces-design/pulls/2345/commits"},"statuses":{"href":"https://api.github.com/repos/adobe-photoshop/spaces-design/statuses/6dd1b5ee2248fdcb04872a800f9e641f45bc94ba"}}}}