diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-17 12:45:31 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-17 12:45:31 +0200 |
commit | 6cdbb27ec3cf72ce6728986909aa3df54b7a26c6 (patch) | |
tree | b989b826e119a382e1bc0fde590e312c8d3bbcda /app/controllers | |
parent | 7aea16b64624eb681a1c134759a8f4fa1e5b2a78 (diff) | |
download | gitlab-ce-6cdbb27ec3cf72ce6728986909aa3df54b7a26c6.tar.gz |
Refactor code to use available and stopped statuses and refactor views to use separate renders
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 2ec316a1ebd..40da5be2e49 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -10,8 +10,8 @@ class Projects::EnvironmentsController < Projects::ApplicationController @all_environments = project.environments @environments = case @scope - when 'closed' then @all_environments.closed - else @all_environments.opened + when 'stopped' then @all_environments.stopped + else @all_environments.available end end @@ -45,7 +45,9 @@ class Projects::EnvironmentsController < Projects::ApplicationController end def stop - + action = @environment.stop_action + new_action = action.active? ? action : action.play(current_user) + redirect_to [project.namespace.become(Namespace), project, new_action] end def destroy diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 1c1938f957b..86e12660c23 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -416,7 +416,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController id: environment.id, name: environment.name, url: namespace_project_environment_path(project.namespace, project, environment), - stop_url: (stop_namespace_project_environment_path(project.namespace, project, environment) if environment.closeable?), + stop_url: (stop_namespace_project_environment_path(project.namespace, project, environment) if environment.stoppable?), external_url: environment.external_url, external_url_formatted: environment.formatted_external_url, deployed_at: deployment.try(:created_at), |