Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix: ui & authz on disable app tps #307

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/controllers/app_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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!

Expand Down
4 changes: 3 additions & 1 deletion app/views/app_groups/_applications.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we need to align the values in tbody as well if we change the alignment of label columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated ya @Abhinav1299

th.col-4 Name
- elsif @show_log_and_cost_col || !@app_group.disable_app_tps
th.col-5 Name
- else
th.col-6 Name
Expand Down
2 changes: 1 addition & 1 deletion app/views/app_groups/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down