diff --git a/app/controllers/app_groups_controller.rb b/app/controllers/app_groups_controller.rb index 73bb2d45..c3edccfb 100644 --- a/app/controllers/app_groups_controller.rb +++ b/app/controllers/app_groups_controller.rb @@ -44,6 +44,7 @@ def show @allow_set_status = policy(@new_app).toggle_status? @allow_manage_access = policy(@app_group).manage_access? @allow_see_infrastructure = policy(Infrastructure).show? + @allow_disable_app_tps = policy(@app_group).update? @allow_see_helm_infrastructure = policy(HelmInfrastructure).show? @allow_delete_barito_app = policy(@new_app).delete? @allow_add_barito_app = policy(@new_app).create? @@ -244,6 +245,10 @@ def update_redact_labels end def toggle_disable_app_tps + unless policy(@app_group).update? + return redirect_to app_group_path(@app_group) + end + @app_group.disable_app_tps = !@app_group.disable_app_tps @app_group.save! diff --git a/app/views/app_groups/_applications.html.slim b/app/views/app_groups/_applications.html.slim index 1a030346..b504bdad 100644 --- a/app/views/app_groups/_applications.html.slim +++ b/app/views/app_groups/_applications.html.slim @@ -4,7 +4,9 @@ h4.mb-3 All Applications table.table.table-hover.table-sm thead tr.d-flex - - if @show_log_and_cost_col || !@app_group.disable_app_tps + - if @show_log_and_cost_col && !@app_group.disable_app_tps + th.col-4 Name + - elsif @show_log_and_cost_col || !@app_group.disable_app_tps th.col-5 Name - else th.col-6 Name @@ -23,7 +25,9 @@ h4.mb-3 All Applications tbody - apps.each do |app| tr.d-flex - - if @show_log_and_cost_col || !@app_group.disable_app_tps + - if @show_log_and_cost_col && !@app_group.disable_app_tps + td.col-4= app.name + - elsif @show_log_and_cost_col || !@app_group.disable_app_tps td.col-5= app.name - else td.col-6= app.name diff --git a/app/views/app_groups/show.html.slim b/app/views/app_groups/show.html.slim index 250b6a22..a427a7ec 100644 --- a/app/views/app_groups/show.html.slim +++ b/app/views/app_groups/show.html.slim @@ -63,7 +63,7 @@ dt.col-sm-2 Disable App TPS: dd.col-sm-10 - - if @allow_set_status + - if @allow_disable_app_tps = check_box_tag "toggle_disable_app_tps_#{@app_group.id}", true, @app_group.disable_app_tps, data: { toggle: 'toggle', onstyle: 'success', on: 'Yes', off: 'No', id: @app_group.id, style: 'slow', size: 'small'}, onchange: "$('#form_toggle_disable_app_tps_#{@app_group.id}').submit();" = form_tag toggle_disable_app_tps_app_group_path(@app_group), method: :patch, data: {confirm: "Are you sure ?"}, id: "form_toggle_disable_app_tps_#{@app_group.id}" do = hidden_field_tag :toggle_disable_app_tps