{"action":"created","comment":{"url":"https://api.github.com/repos/Katello/katello/pulls/comments/31233819","id":31233819,"diff_hunk":"@@ -63,22 +67,52 @@ angular.module('Bastion.content-views').controller('ContentViewPromotionControll\n             if (envIds.indexOf(env.id) !== -1) {\n                 //if version is already promoted to the environment\n                 enabled = false;\n-            } else if (env.library) {\n-                //allow library for all versions\n-                enabled = true;\n-            } else if (envIds.length !== 0 && envIds.indexOf(env.prior.id) !== -1) {\n-                //if environment is a successor an existing environment\n+            } else {\n                 enabled = true;\n             }\n \n             return !enabled;\n         };\n \n+        $scope.checkSuggested = function (env, environments) {\n+            var suggest = false,\n+                envIds = _.pluck(environments, 'id');\n+\n+            // if version is not promoted to the environment\n+            if (envIds.indexOf(env.id) === -1) {\n+                // if version not yet promoted to any environment, and environment is in library or if version is promoted to prior environment\n+                if ((environments.length === 0 && env.library) || (env.prior && envIds.indexOf(env.prior.id) !== -1)) {\n+                    suggest = true;\n+                    $scope.suggestedEnvironments.push(env);\n+                }\n+            }\n+            return suggest;\n+        };\n+\n         $scope.promote = function () {\n             $scope.promoting = true;\n-            ContentViewVersion.promote({id: $scope.version.id, 'environment_id': $scope.selectedEnvironment.id},\n+            ContentViewVersion.promote({id: $scope.version.id, 'environment_id': $scope.selectedEnvironment.id, force: true},\n                 success, failure);\n         };\n \n+        $scope.verifySelection = function () {\n+            if ($scope.suggestedEnvironments.indexOf($scope.selectedEnvironment) !== -1) {\n+                $scope.promote();\n+            } else {\n+                $scope.openModal();\n+            }\n+        };\n+\n+        $scope.suggestedEnvironmentMessage = function () {\n+            var envs = _.uniq(_.pluck($scope.suggestedEnvironments, 'name'));\n+\n+            if (envs.length === 0) {\n+                return \"There are no environments suggested in the promotion path.\";\n+            } else if (envs.length === 1) {\n+                return \"Suggested environment is: \".concat(envs[0]);\n+            } else {\n+                return \"Suggested environments are: \".concat(envs.join(', '));\n+            }","path":"engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/content-view-promotion.controller.js","position":73,"original_position":73,"commit_id":"ce45cec1d6c45f1906d2609da7ff6c7643720fde","original_commit_id":"ce45cec1d6c45f1906d2609da7ff6c7643720fde","user":{"login":"ehelms","id":293363,"avatar_url":"https://avatars.githubusercontent.com/u/293363?v=3","gravatar_id":"","url":"https://api.github.com/users/ehelms","html_url":"https://github.com/ehelms","followers_url":"https://api.github.com/users/ehelms/followers","following_url":"https://api.github.com/users/ehelms/following{/other_user}","gists_url":"https://api.github.com/users/ehelms/gists{/gist_id}","starred_url":"https://api.github.com/users/ehelms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehelms/subscriptions","organizations_url":"https://api.github.com/users/ehelms/orgs","repos_url":"https://api.github.com/users/ehelms/repos","events_url":"https://api.github.com/users/ehelms/events{/privacy}","received_events_url":"https://api.github.com/users/ehelms/received_events","type":"User","site_admin":false},"body":"We often try to limit a function to a single return. So you could set the strings inside the if-else to a variable and then have the function return that variable at the end.","created_at":"2015-05-28T13:44:39Z","updated_at":"2015-05-28T13:44:39Z","html_url":"https://github.com/Katello/katello/pull/5216#discussion_r31233819","pull_request_url":"https://api.github.com/repos/Katello/katello/pulls/5216","_links":{"self":{"href":"https://api.github.com/repos/Katello/katello/pulls/comments/31233819"},"html":{"href":"https://github.com/Katello/katello/pull/5216#discussion_r31233819"},"pull_request":{"href":"https://api.github.com/repos/Katello/katello/pulls/5216"}}},"pull_request":{"url":"https://api.github.com/repos/Katello/katello/pulls/5216","id":35044501,"html_url":"https://github.com/Katello/katello/pull/5216","diff_url":"https://github.com/Katello/katello/pull/5216.diff","patch_url":"https://github.com/Katello/katello/pull/5216.patch","issue_url":"https://api.github.com/repos/Katello/katello/issues/5216","number":5216,"state":"open","locked":false,"title":"fixes #10351 - Fixes issue with CVV restrictive promotion sequence in UI, BZ1169876","user":{"login":"cfouant","id":5577256,"avatar_url":"https://avatars.githubusercontent.com/u/5577256?v=3","gravatar_id":"","url":"https://api.github.com/users/cfouant","html_url":"https://github.com/cfouant","followers_url":"https://api.github.com/users/cfouant/followers","following_url":"https://api.github.com/users/cfouant/following{/other_user}","gists_url":"https://api.github.com/users/cfouant/gists{/gist_id}","starred_url":"https://api.github.com/users/cfouant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfouant/subscriptions","organizations_url":"https://api.github.com/users/cfouant/orgs","repos_url":"https://api.github.com/users/cfouant/repos","events_url":"https://api.github.com/users/cfouant/events{/privacy}","received_events_url":"https://api.github.com/users/cfouant/received_events","type":"User","site_admin":false},"body":"Depends upon https://github.com/Katello/bastion/pull/64","created_at":"2015-05-08T20:35:58Z","updated_at":"2015-05-28T13:44:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"afd9842a29f681f4fc2699ecba79b328b2b9d895","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Katello/katello/pulls/5216/commits","review_comments_url":"https://api.github.com/repos/Katello/katello/pulls/5216/comments","review_comment_url":"https://api.github.com/repos/Katello/katello/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Katello/katello/issues/5216/comments","statuses_url":"https://api.github.com/repos/Katello/katello/statuses/ce45cec1d6c45f1906d2609da7ff6c7643720fde","head":{"label":"cfouant:cv-promotion","ref":"cv-promotion","sha":"ce45cec1d6c45f1906d2609da7ff6c7643720fde","user":{"login":"cfouant","id":5577256,"avatar_url":"https://avatars.githubusercontent.com/u/5577256?v=3","gravatar_id":"","url":"https://api.github.com/users/cfouant","html_url":"https://github.com/cfouant","followers_url":"https://api.github.com/users/cfouant/followers","following_url":"https://api.github.com/users/cfouant/following{/other_user}","gists_url":"https://api.github.com/users/cfouant/gists{/gist_id}","starred_url":"https://api.github.com/users/cfouant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfouant/subscriptions","organizations_url":"https://api.github.com/users/cfouant/orgs","repos_url":"https://api.github.com/users/cfouant/repos","events_url":"https://api.github.com/users/cfouant/events{/privacy}","received_events_url":"https://api.github.com/users/cfouant/received_events","type":"User","site_admin":false},"repo":{"id":20066363,"name":"katello","full_name":"cfouant/katello","owner":{"login":"cfouant","id":5577256,"avatar_url":"https://avatars.githubusercontent.com/u/5577256?v=3","gravatar_id":"","url":"https://api.github.com/users/cfouant","html_url":"https://github.com/cfouant","followers_url":"https://api.github.com/users/cfouant/followers","following_url":"https://api.github.com/users/cfouant/following{/other_user}","gists_url":"https://api.github.com/users/cfouant/gists{/gist_id}","starred_url":"https://api.github.com/users/cfouant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfouant/subscriptions","organizations_url":"https://api.github.com/users/cfouant/orgs","repos_url":"https://api.github.com/users/cfouant/repos","events_url":"https://api.github.com/users/cfouant/events{/privacy}","received_events_url":"https://api.github.com/users/cfouant/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cfouant/katello","description":"Katello integrates open source systems management tools into a single solution for controlling the lifecycle of your machines.","fork":true,"url":"https://api.github.com/repos/cfouant/katello","forks_url":"https://api.github.com/repos/cfouant/katello/forks","keys_url":"https://api.github.com/repos/cfouant/katello/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cfouant/katello/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cfouant/katello/teams","hooks_url":"https://api.github.com/repos/cfouant/katello/hooks","issue_events_url":"https://api.github.com/repos/cfouant/katello/issues/events{/number}","events_url":"https://api.github.com/repos/cfouant/katello/events","assignees_url":"https://api.github.com/repos/cfouant/katello/assignees{/user}","branches_url":"https://api.github.com/repos/cfouant/katello/branches{/branch}","tags_url":"https://api.github.com/repos/cfouant/katello/tags","blobs_url":"https://api.github.com/repos/cfouant/katello/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cfouant/katello/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cfouant/katello/git/refs{/sha}","trees_url":"https://api.github.com/repos/cfouant/katello/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cfouant/katello/statuses/{sha}","languages_url":"https://api.github.com/repos/cfouant/katello/languages","stargazers_url":"https://api.github.com/repos/cfouant/katello/stargazers","contributors_url":"https://api.github.com/repos/cfouant/katello/contributors","subscribers_url":"https://api.github.com/repos/cfouant/katello/subscribers","subscription_url":"https://api.github.com/repos/cfouant/katello/subscription","commits_url":"https://api.github.com/repos/cfouant/katello/commits{/sha}","git_commits_url":"https://api.github.com/repos/cfouant/katello/git/commits{/sha}","comments_url":"https://api.github.com/repos/cfouant/katello/comments{/number}","issue_comment_url":"https://api.github.com/repos/cfouant/katello/issues/comments{/number}","contents_url":"https://api.github.com/repos/cfouant/katello/contents/{+path}","compare_url":"https://api.github.com/repos/cfouant/katello/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cfouant/katello/merges","archive_url":"https://api.github.com/repos/cfouant/katello/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cfouant/katello/downloads","issues_url":"https://api.github.com/repos/cfouant/katello/issues{/number}","pulls_url":"https://api.github.com/repos/cfouant/katello/pulls{/number}","milestones_url":"https://api.github.com/repos/cfouant/katello/milestones{/number}","notifications_url":"https://api.github.com/repos/cfouant/katello/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cfouant/katello/labels{/name}","releases_url":"https://api.github.com/repos/cfouant/katello/releases{/id}","created_at":"2014-05-22T15:27:07Z","updated_at":"2015-05-08T13:44:57Z","pushed_at":"2015-05-27T20:11:08Z","git_url":"git://github.com/cfouant/katello.git","ssh_url":"git@github.com:cfouant/katello.git","clone_url":"https://github.com/cfouant/katello.git","svn_url":"https://github.com/cfouant/katello","homepage":"katello.org","size":72909,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Katello:master","ref":"master","sha":"43a4cf32d3807216da68c2fb5432acaa706d3298","user":{"login":"Katello","id":1316386,"avatar_url":"https://avatars.githubusercontent.com/u/1316386?v=3","gravatar_id":"","url":"https://api.github.com/users/Katello","html_url":"https://github.com/Katello","followers_url":"https://api.github.com/users/Katello/followers","following_url":"https://api.github.com/users/Katello/following{/other_user}","gists_url":"https://api.github.com/users/Katello/gists{/gist_id}","starred_url":"https://api.github.com/users/Katello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Katello/subscriptions","organizations_url":"https://api.github.com/users/Katello/orgs","repos_url":"https://api.github.com/users/Katello/repos","events_url":"https://api.github.com/users/Katello/events{/privacy}","received_events_url":"https://api.github.com/users/Katello/received_events","type":"Organization","site_admin":false},"repo":{"id":4007018,"name":"katello","full_name":"Katello/katello","owner":{"login":"Katello","id":1316386,"avatar_url":"https://avatars.githubusercontent.com/u/1316386?v=3","gravatar_id":"","url":"https://api.github.com/users/Katello","html_url":"https://github.com/Katello","followers_url":"https://api.github.com/users/Katello/followers","following_url":"https://api.github.com/users/Katello/following{/other_user}","gists_url":"https://api.github.com/users/Katello/gists{/gist_id}","starred_url":"https://api.github.com/users/Katello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Katello/subscriptions","organizations_url":"https://api.github.com/users/Katello/orgs","repos_url":"https://api.github.com/users/Katello/repos","events_url":"https://api.github.com/users/Katello/events{/privacy}","received_events_url":"https://api.github.com/users/Katello/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Katello/katello","description":"Katello integrates open source systems management tools into a single solution for controlling the lifecycle of your machines.","fork":false,"url":"https://api.github.com/repos/Katello/katello","forks_url":"https://api.github.com/repos/Katello/katello/forks","keys_url":"https://api.github.com/repos/Katello/katello/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Katello/katello/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Katello/katello/teams","hooks_url":"https://api.github.com/repos/Katello/katello/hooks","issue_events_url":"https://api.github.com/repos/Katello/katello/issues/events{/number}","events_url":"https://api.github.com/repos/Katello/katello/events","assignees_url":"https://api.github.com/repos/Katello/katello/assignees{/user}","branches_url":"https://api.github.com/repos/Katello/katello/branches{/branch}","tags_url":"https://api.github.com/repos/Katello/katello/tags","blobs_url":"https://api.github.com/repos/Katello/katello/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Katello/katello/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Katello/katello/git/refs{/sha}","trees_url":"https://api.github.com/repos/Katello/katello/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Katello/katello/statuses/{sha}","languages_url":"https://api.github.com/repos/Katello/katello/languages","stargazers_url":"https://api.github.com/repos/Katello/katello/stargazers","contributors_url":"https://api.github.com/repos/Katello/katello/contributors","subscribers_url":"https://api.github.com/repos/Katello/katello/subscribers","subscription_url":"https://api.github.com/repos/Katello/katello/subscription","commits_url":"https://api.github.com/repos/Katello/katello/commits{/sha}","git_commits_url":"https://api.github.com/repos/Katello/katello/git/commits{/sha}","comments_url":"https://api.github.com/repos/Katello/katello/comments{/number}","issue_comment_url":"https://api.github.com/repos/Katello/katello/issues/comments{/number}","contents_url":"https://api.github.com/repos/Katello/katello/contents/{+path}","compare_url":"https://api.github.com/repos/Katello/katello/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Katello/katello/merges","archive_url":"https://api.github.com/repos/Katello/katello/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Katello/katello/downloads","issues_url":"https://api.github.com/repos/Katello/katello/issues{/number}","pulls_url":"https://api.github.com/repos/Katello/katello/pulls{/number}","milestones_url":"https://api.github.com/repos/Katello/katello/milestones{/number}","notifications_url":"https://api.github.com/repos/Katello/katello/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Katello/katello/labels{/name}","releases_url":"https://api.github.com/repos/Katello/katello/releases{/id}","created_at":"2012-04-12T16:59:08Z","updated_at":"2015-05-19T09:16:30Z","pushed_at":"2015-05-27T21:49:30Z","git_url":"git://github.com/Katello/katello.git","ssh_url":"git@github.com:Katello/katello.git","clone_url":"https://github.com/Katello/katello.git","svn_url":"https://github.com/Katello/katello","homepage":"katello.org","size":236158,"stargazers_count":157,"watchers_count":157,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":109,"mirror_url":null,"open_issues_count":99,"forks":109,"open_issues":99,"watchers":157,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Katello/katello/pulls/5216"},"html":{"href":"https://github.com/Katello/katello/pull/5216"},"issue":{"href":"https://api.github.com/repos/Katello/katello/issues/5216"},"comments":{"href":"https://api.github.com/repos/Katello/katello/issues/5216/comments"},"review_comments":{"href":"https://api.github.com/repos/Katello/katello/pulls/5216/comments"},"review_comment":{"href":"https://api.github.com/repos/Katello/katello/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Katello/katello/pulls/5216/commits"},"statuses":{"href":"https://api.github.com/repos/Katello/katello/statuses/ce45cec1d6c45f1906d2609da7ff6c7643720fde"}}}}