From 1e1137519fc5b7f6791a6f042925ca1407802a01 Mon Sep 17 00:00:00 2001 From: Beni Budiharto Date: Fri, 4 Oct 2024 14:34:24 +0700 Subject: [PATCH 1/2] hotfix: ui & authz on disable app tps --- app/controllers/app_groups_controller.rb | 5 +++++ app/views/app_groups/_applications.html.slim | 4 +++- app/views/app_groups/show.html.slim | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) 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..aa097ea2 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 diff --git a/app/views/app_groups/show.html.slim b/app/views/app_groups/show.html.slim index 250b6a22..39cc43d4 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_see_infrastructure = 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 From 1682d5f1b64716f44b8987e042c1a1661fd317e4 Mon Sep 17 00:00:00 2001 From: Beni Budiharto Date: Mon, 7 Oct 2024 09:42:56 +0700 Subject: [PATCH 2/2] fix UI --- app/views/app_groups/_applications.html.slim | 4 +++- app/views/app_groups/show.html.slim | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/app_groups/_applications.html.slim b/app/views/app_groups/_applications.html.slim index aa097ea2..b504bdad 100644 --- a/app/views/app_groups/_applications.html.slim +++ b/app/views/app_groups/_applications.html.slim @@ -25,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 39cc43d4..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_see_infrastructure + - 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