{"action":"created","comment":{"url":"https://api.github.com/repos/reactioncommerce/reaction/pulls/comments/51516057","id":51516057,"diff_hunk":"@@ -72,48 +72,104 @@ this.getProductsByTag = function (tag) {\n };\n \n /**\n- * maybeDeleteProduct\n- * @summary confirm product deletion, delete, and alert\n- * @todo - refactor this back into templates. this is bad.\n- * @param {Object} product - product Object\n- * @return {Object} - returns nothing, and alerts,happen here\n+ * publishProduct\n+ * @summary product publishing and alert\n+ * @param {Object} productOrArray - product Object\n+ * @returns {Function}\n  */\n-this.maybeDeleteProduct = function (product) {\n-  let productIds;\n-  let title;\n-  let confirmTitle = \"Delete this product?\";\n-\n-  if (_.isArray(product)) {\n-    if (product.length === 1) {\n-      title = product[0].title || \"the product\";\n-      productIds = [product[0]._id];\n-    } else {\n-      title = \"the selected products\";\n-      confirmTitle = \"Delete selected products?\";\n+this.publishProduct = function (productOrArray) {\n+  let products = (_.isArray(productOrArray) === false) ? [productOrArray] : productOrArray;\n+  for (let product of products) {\n+    Meteor.call(\"products/publishProduct\", product._id, function (error, result) {\n+      if (error) {\n+        Alerts.add(error, \"danger\", {\n+          placement: \"productGridItem\",\n+          id: self._id\n+        });\n+        return {};\n+      }\n+      if (result === true) {\n+        return Alerts.add(product.title + \" \" + i18n.t(\"productDetail.publishProductVisible\"), \"success\", {\n+          placement: \"productGridItem\",\n+          id: product._id,\n+          autoHide: true,\n+          dismissable: false\n+        });\n+      } else {\n+        return Alerts.add(product.title + \" \" + i18n.t(\"productDetail.publishProductHidden\"), \"warning\", {\n+          placement: \"productGridItem\",\n+          id: product._id,\n+          autoHide: true,\n+          dismissable: false\n+        });\n+      }\n+    });\n+  }\n+};\n \n-      productIds = _.map(product, (item) => {\n-        return item._id;\n+/**\n+ * cloneProduct\n+ * @summary product cloning and alert\n+ * @param {Object} productOrArray - product Object\n+ * @param {Boolean} redirect - shoud we do redirect after cloning?\n+ * @returns {any}\n+ */\n+this.cloneProduct = function(productOrArray, redirect) {","path":"packages/reaction-core/client/helpers/globals.js","position":65,"original_position":65,"commit_id":"a8be4c06020c4632fe7afbd2699d85b674423de8","original_commit_id":"a8be4c06020c4632fe7afbd2699d85b674423de8","user":{"login":"aaronjudd","id":439959,"avatar_url":"https://avatars.githubusercontent.com/u/439959?v=3","gravatar_id":"","url":"https://api.github.com/users/aaronjudd","html_url":"https://github.com/aaronjudd","followers_url":"https://api.github.com/users/aaronjudd/followers","following_url":"https://api.github.com/users/aaronjudd/following{/other_user}","gists_url":"https://api.github.com/users/aaronjudd/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronjudd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronjudd/subscriptions","organizations_url":"https://api.github.com/users/aaronjudd/orgs","repos_url":"https://api.github.com/users/aaronjudd/repos","events_url":"https://api.github.com/users/aaronjudd/events{/privacy}","received_events_url":"https://api.github.com/users/aaronjudd/received_events","type":"User","site_admin":false},"body":"`cloneProduct = function(productOrArray, redirect) {`","created_at":"2016-02-02T02:48:15Z","updated_at":"2016-02-02T02:48:15Z","html_url":"https://github.com/reactioncommerce/reaction/pull/749#discussion_r51516057","pull_request_url":"https://api.github.com/repos/reactioncommerce/reaction/pulls/749","_links":{"self":{"href":"https://api.github.com/repos/reactioncommerce/reaction/pulls/comments/51516057"},"html":{"href":"https://github.com/reactioncommerce/reaction/pull/749#discussion_r51516057"},"pull_request":{"href":"https://api.github.com/repos/reactioncommerce/reaction/pulls/749"}}},"pull_request":{"url":"https://api.github.com/repos/reactioncommerce/reaction/pulls/749","id":57783382,"html_url":"https://github.com/reactioncommerce/reaction/pull/749","diff_url":"https://github.com/reactioncommerce/reaction/pull/749.diff","patch_url":"https://github.com/reactioncommerce/reaction/pull/749.patch","issue_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/749","number":749,"state":"open","locked":false,"title":"Refactores publish, clone, delete actions from product grid - for DRY principle","user":{"login":"ramusus","id":76971,"avatar_url":"https://avatars.githubusercontent.com/u/76971?v=3","gravatar_id":"","url":"https://api.github.com/users/ramusus","html_url":"https://github.com/ramusus","followers_url":"https://api.github.com/users/ramusus/followers","following_url":"https://api.github.com/users/ramusus/following{/other_user}","gists_url":"https://api.github.com/users/ramusus/gists{/gist_id}","starred_url":"https://api.github.com/users/ramusus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramusus/subscriptions","organizations_url":"https://api.github.com/users/ramusus/orgs","repos_url":"https://api.github.com/users/ramusus/repos","events_url":"https://api.github.com/users/ramusus/events{/privacy}","received_events_url":"https://api.github.com/users/ramusus/received_events","type":"User","site_admin":false},"body":"fixed issues with Alerts during operations with group of selected products, cleaned the code for the sake of DRY principle.","created_at":"2016-01-31T22:55:10Z","updated_at":"2016-02-02T02:48:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"707c259c2d61a5f3b86d7d888c8e947bd2f42180","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/reactioncommerce/reaction/pulls/749/commits","review_comments_url":"https://api.github.com/repos/reactioncommerce/reaction/pulls/749/comments","review_comment_url":"https://api.github.com/repos/reactioncommerce/reaction/pulls/comments{/number}","comments_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/749/comments","statuses_url":"https://api.github.com/repos/reactioncommerce/reaction/statuses/a8be4c06020c4632fe7afbd2699d85b674423de8","head":{"label":"ramusus:publish_alerts","ref":"publish_alerts","sha":"a8be4c06020c4632fe7afbd2699d85b674423de8","user":{"login":"ramusus","id":76971,"avatar_url":"https://avatars.githubusercontent.com/u/76971?v=3","gravatar_id":"","url":"https://api.github.com/users/ramusus","html_url":"https://github.com/ramusus","followers_url":"https://api.github.com/users/ramusus/followers","following_url":"https://api.github.com/users/ramusus/following{/other_user}","gists_url":"https://api.github.com/users/ramusus/gists{/gist_id}","starred_url":"https://api.github.com/users/ramusus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramusus/subscriptions","organizations_url":"https://api.github.com/users/ramusus/orgs","repos_url":"https://api.github.com/users/ramusus/repos","events_url":"https://api.github.com/users/ramusus/events{/privacy}","received_events_url":"https://api.github.com/users/ramusus/received_events","type":"User","site_admin":false},"repo":{"id":29091937,"name":"reaction","full_name":"ramusus/reaction","owner":{"login":"ramusus","id":76971,"avatar_url":"https://avatars.githubusercontent.com/u/76971?v=3","gravatar_id":"","url":"https://api.github.com/users/ramusus","html_url":"https://github.com/ramusus","followers_url":"https://api.github.com/users/ramusus/followers","following_url":"https://api.github.com/users/ramusus/following{/other_user}","gists_url":"https://api.github.com/users/ramusus/gists{/gist_id}","starred_url":"https://api.github.com/users/ramusus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramusus/subscriptions","organizations_url":"https://api.github.com/users/ramusus/orgs","repos_url":"https://api.github.com/users/ramusus/repos","events_url":"https://api.github.com/users/ramusus/events{/privacy}","received_events_url":"https://api.github.com/users/ramusus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ramusus/reaction","description":"Reaction Commerce","fork":true,"url":"https://api.github.com/repos/ramusus/reaction","forks_url":"https://api.github.com/repos/ramusus/reaction/forks","keys_url":"https://api.github.com/repos/ramusus/reaction/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ramusus/reaction/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ramusus/reaction/teams","hooks_url":"https://api.github.com/repos/ramusus/reaction/hooks","issue_events_url":"https://api.github.com/repos/ramusus/reaction/issues/events{/number}","events_url":"https://api.github.com/repos/ramusus/reaction/events","assignees_url":"https://api.github.com/repos/ramusus/reaction/assignees{/user}","branches_url":"https://api.github.com/repos/ramusus/reaction/branches{/branch}","tags_url":"https://api.github.com/repos/ramusus/reaction/tags","blobs_url":"https://api.github.com/repos/ramusus/reaction/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ramusus/reaction/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ramusus/reaction/git/refs{/sha}","trees_url":"https://api.github.com/repos/ramusus/reaction/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ramusus/reaction/statuses/{sha}","languages_url":"https://api.github.com/repos/ramusus/reaction/languages","stargazers_url":"https://api.github.com/repos/ramusus/reaction/stargazers","contributors_url":"https://api.github.com/repos/ramusus/reaction/contributors","subscribers_url":"https://api.github.com/repos/ramusus/reaction/subscribers","subscription_url":"https://api.github.com/repos/ramusus/reaction/subscription","commits_url":"https://api.github.com/repos/ramusus/reaction/commits{/sha}","git_commits_url":"https://api.github.com/repos/ramusus/reaction/git/commits{/sha}","comments_url":"https://api.github.com/repos/ramusus/reaction/comments{/number}","issue_comment_url":"https://api.github.com/repos/ramusus/reaction/issues/comments{/number}","contents_url":"https://api.github.com/repos/ramusus/reaction/contents/{+path}","compare_url":"https://api.github.com/repos/ramusus/reaction/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ramusus/reaction/merges","archive_url":"https://api.github.com/repos/ramusus/reaction/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ramusus/reaction/downloads","issues_url":"https://api.github.com/repos/ramusus/reaction/issues{/number}","pulls_url":"https://api.github.com/repos/ramusus/reaction/pulls{/number}","milestones_url":"https://api.github.com/repos/ramusus/reaction/milestones{/number}","notifications_url":"https://api.github.com/repos/ramusus/reaction/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ramusus/reaction/labels{/name}","releases_url":"https://api.github.com/repos/ramusus/reaction/releases{/id}","deployments_url":"https://api.github.com/repos/ramusus/reaction/deployments","created_at":"2015-01-11T13:03:32Z","updated_at":"2016-01-07T19:43:39Z","pushed_at":"2016-02-01T19:23:22Z","git_url":"git://github.com/ramusus/reaction.git","ssh_url":"git@github.com:ramusus/reaction.git","clone_url":"https://github.com/ramusus/reaction.git","svn_url":"https://github.com/ramusus/reaction","homepage":"http://reactioncommerce.com","size":27301,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"reactioncommerce:development","ref":"development","sha":"1545520a3265f2683835c70a9cc6036170a89411","user":{"login":"reactioncommerce","id":5605462,"avatar_url":"https://avatars.githubusercontent.com/u/5605462?v=3","gravatar_id":"","url":"https://api.github.com/users/reactioncommerce","html_url":"https://github.com/reactioncommerce","followers_url":"https://api.github.com/users/reactioncommerce/followers","following_url":"https://api.github.com/users/reactioncommerce/following{/other_user}","gists_url":"https://api.github.com/users/reactioncommerce/gists{/gist_id}","starred_url":"https://api.github.com/users/reactioncommerce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reactioncommerce/subscriptions","organizations_url":"https://api.github.com/users/reactioncommerce/orgs","repos_url":"https://api.github.com/users/reactioncommerce/repos","events_url":"https://api.github.com/users/reactioncommerce/events{/privacy}","received_events_url":"https://api.github.com/users/reactioncommerce/received_events","type":"Organization","site_admin":false},"repo":{"id":12926963,"name":"reaction","full_name":"reactioncommerce/reaction","owner":{"login":"reactioncommerce","id":5605462,"avatar_url":"https://avatars.githubusercontent.com/u/5605462?v=3","gravatar_id":"","url":"https://api.github.com/users/reactioncommerce","html_url":"https://github.com/reactioncommerce","followers_url":"https://api.github.com/users/reactioncommerce/followers","following_url":"https://api.github.com/users/reactioncommerce/following{/other_user}","gists_url":"https://api.github.com/users/reactioncommerce/gists{/gist_id}","starred_url":"https://api.github.com/users/reactioncommerce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reactioncommerce/subscriptions","organizations_url":"https://api.github.com/users/reactioncommerce/orgs","repos_url":"https://api.github.com/users/reactioncommerce/repos","events_url":"https://api.github.com/users/reactioncommerce/events{/privacy}","received_events_url":"https://api.github.com/users/reactioncommerce/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/reactioncommerce/reaction","description":"Reaction Commerce","fork":false,"url":"https://api.github.com/repos/reactioncommerce/reaction","forks_url":"https://api.github.com/repos/reactioncommerce/reaction/forks","keys_url":"https://api.github.com/repos/reactioncommerce/reaction/keys{/key_id}","collaborators_url":"https://api.github.com/repos/reactioncommerce/reaction/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/reactioncommerce/reaction/teams","hooks_url":"https://api.github.com/repos/reactioncommerce/reaction/hooks","issue_events_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/events{/number}","events_url":"https://api.github.com/repos/reactioncommerce/reaction/events","assignees_url":"https://api.github.com/repos/reactioncommerce/reaction/assignees{/user}","branches_url":"https://api.github.com/repos/reactioncommerce/reaction/branches{/branch}","tags_url":"https://api.github.com/repos/reactioncommerce/reaction/tags","blobs_url":"https://api.github.com/repos/reactioncommerce/reaction/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/reactioncommerce/reaction/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/reactioncommerce/reaction/git/refs{/sha}","trees_url":"https://api.github.com/repos/reactioncommerce/reaction/git/trees{/sha}","statuses_url":"https://api.github.com/repos/reactioncommerce/reaction/statuses/{sha}","languages_url":"https://api.github.com/repos/reactioncommerce/reaction/languages","stargazers_url":"https://api.github.com/repos/reactioncommerce/reaction/stargazers","contributors_url":"https://api.github.com/repos/reactioncommerce/reaction/contributors","subscribers_url":"https://api.github.com/repos/reactioncommerce/reaction/subscribers","subscription_url":"https://api.github.com/repos/reactioncommerce/reaction/subscription","commits_url":"https://api.github.com/repos/reactioncommerce/reaction/commits{/sha}","git_commits_url":"https://api.github.com/repos/reactioncommerce/reaction/git/commits{/sha}","comments_url":"https://api.github.com/repos/reactioncommerce/reaction/comments{/number}","issue_comment_url":"https://api.github.com/repos/reactioncommerce/reaction/issues/comments{/number}","contents_url":"https://api.github.com/repos/reactioncommerce/reaction/contents/{+path}","compare_url":"https://api.github.com/repos/reactioncommerce/reaction/compare/{base}...{head}","merges_url":"https://api.github.com/repos/reactioncommerce/reaction/merges","archive_url":"https://api.github.com/repos/reactioncommerce/reaction/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/reactioncommerce/reaction/downloads","issues_url":"https://api.github.com/repos/reactioncommerce/reaction/issues{/number}","pulls_url":"https://api.github.com/repos/reactioncommerce/reaction/pulls{/number}","milestones_url":"https://api.github.com/repos/reactioncommerce/reaction/milestones{/number}","notifications_url":"https://api.github.com/repos/reactioncommerce/reaction/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/reactioncommerce/reaction/labels{/name}","releases_url":"https://api.github.com/repos/reactioncommerce/reaction/releases{/id}","deployments_url":"https://api.github.com/repos/reactioncommerce/reaction/deployments","created_at":"2013-09-18T15:30:36Z","updated_at":"2016-02-01T22:56:30Z","pushed_at":"2016-02-02T02:00:02Z","git_url":"git://github.com/reactioncommerce/reaction.git","ssh_url":"git@github.com:reactioncommerce/reaction.git","clone_url":"https://github.com/reactioncommerce/reaction.git","svn_url":"https://github.com/reactioncommerce/reaction","homepage":"https://reactioncommerce.com/","size":30258,"stargazers_count":1913,"watchers_count":1913,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":400,"mirror_url":null,"open_issues_count":178,"forks":400,"open_issues":178,"watchers":1913,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/reactioncommerce/reaction/pulls/749"},"html":{"href":"https://github.com/reactioncommerce/reaction/pull/749"},"issue":{"href":"https://api.github.com/repos/reactioncommerce/reaction/issues/749"},"comments":{"href":"https://api.github.com/repos/reactioncommerce/reaction/issues/749/comments"},"review_comments":{"href":"https://api.github.com/repos/reactioncommerce/reaction/pulls/749/comments"},"review_comment":{"href":"https://api.github.com/repos/reactioncommerce/reaction/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/reactioncommerce/reaction/pulls/749/commits"},"statuses":{"href":"https://api.github.com/repos/reactioncommerce/reaction/statuses/a8be4c06020c4632fe7afbd2699d85b674423de8"}}}}