From 45e00b28f2d62cf94311cfbee2ef60da533d10c6 Mon Sep 17 00:00:00 2001 From: Ashton South Date: Fri, 5 Jul 2024 13:17:25 -0400 Subject: [PATCH] Disable file and shell buttons when apps are unavailable (#3655) Remove file and shell buttons when the apps are not actually available. --- .../app/views/active_jobs/_extended_panel.html.erb | 4 +++- apps/dashboard/app/views/products/_product.html.erb | 8 ++++++-- apps/dashboard/app/views/products/index.html.erb | 8 ++++++-- apps/dashboard/app/views/products/show.html.erb | 8 ++++++-- apps/dashboard/config/configuration_singleton.rb | 4 ++++ 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/apps/dashboard/app/views/active_jobs/_extended_panel.html.erb b/apps/dashboard/app/views/active_jobs/_extended_panel.html.erb index 33b5ee7302..b6b96bfe3f 100644 --- a/apps/dashboard/app/views/active_jobs/_extended_panel.html.erb +++ b/apps/dashboard/app/views/active_jobs/_extended_panel.html.erb @@ -38,8 +38,10 @@ <% end %>
<% if CurrentUser.name == data.username %> + <% if Configuration.can_access_files? %> <%= link_to "#{fa_icon("folder-open", classes: nil)} Open in File Manager".html_safe, data.file_explorer_url, :class => "btn btn-outline-black", :target => "_blank", :style => "margin: 10px;" if data.file_explorer_url %> - <% if Configuration.ood_bc_ssh_to_compute_node %> + <% end %> + <% if Configuration.ood_bc_ssh_to_compute_node && Configuration.can_access_shell? %> <%= link_to "#{fa_icon("terminal", classes: nil)} Open in Terminal".html_safe, data.shell_url, :class => "btn btn-outline-black", :target => "_blank", :style => "margin: 10px;" if data.shell_url %> <% end %> <%= link_to "#{fa_icon("trash", classes: nil)} Delete".html_safe, delete_job_path(pbsid: data.pbsid, cluster: data.cluster), :class => "btn btn-outline-danger pull-right", :style => "margin: 10px;", data: { method: "delete", confirm: "Are you sure you want to delete #{data.pbsid}" } %> diff --git a/apps/dashboard/app/views/products/_product.html.erb b/apps/dashboard/app/views/products/_product.html.erb index 2ea80d3ec0..5d27042898 100644 --- a/apps/dashboard/app/views/products/_product.html.erb +++ b/apps/dashboard/app/views/products/_product.html.erb @@ -48,8 +48,12 @@
<%= link_to 'Details', product_path(product.name, type: @type), class: 'btn btn-info' %> - <%= link_to 'Shell', OodAppkit.shell.url(host: ENV['OOD_DEV_SSH_HOST'], path: product.router.path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> - <%= link_to 'Files', OodAppkit.files.url(path: product.router.path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> + <% if Configuration.can_access_shell? %> + <%= link_to 'Shell', OodAppkit.shell.url(host: ENV['OOD_DEV_SSH_HOST'], path: product.router.path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> + <% end %> + <% if Configuration.can_access_files? %> + <%= link_to 'Files', OodAppkit.files.url(path: product.router.path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> + <% end %>
diff --git a/apps/dashboard/app/views/products/index.html.erb b/apps/dashboard/app/views/products/index.html.erb index d07a1a2c3a..255453247e 100644 --- a/apps/dashboard/app/views/products/index.html.erb +++ b/apps/dashboard/app/views/products/index.html.erb @@ -7,8 +7,12 @@

<%= link_to 'New App', new_product_path(type: @type), class: 'btn btn-default' %> - <%= link_to 'Launch Shell', OodAppkit.shell.url(host: ENV['OOD_DEV_SSH_HOST'], path: product_class.router.base_path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> - <%= link_to 'Launch Files', OodAppkit.files.url(path: product_class.router.base_path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> + <% if Configuration.can_access_shell? %> + <%= link_to 'Launch Shell', OodAppkit.shell.url(host: ENV['OOD_DEV_SSH_HOST'], path: product_class.router.base_path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> + <% end %> + <% if Configuration.can_access_files? %> + <%= link_to 'Launch Files', OodAppkit.files.url(path: product_class.router.base_path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> + <% end %>

diff --git a/apps/dashboard/app/views/products/show.html.erb b/apps/dashboard/app/views/products/show.html.erb index 14dc09d895..4341051e52 100644 --- a/apps/dashboard/app/views/products/show.html.erb +++ b/apps/dashboard/app/views/products/show.html.erb @@ -72,8 +72,12 @@ <%= command_btn(title: "Rebuild App", key: "rebuild_passenger_rails_app", display: "RAILS_ENV=production bundle install --path=vendor/bundle && RAILS_ENV=production bin/rake assets:clobber && RAILS_ENV=production bin/rake assets:precompile && RAILS_ENV=production bin/rake tmp:clear && mkdir -p tmp && touch tmp/restart.txt", help: "Performs Bundle Install, Precompile Assets, and Restart App", color: "primary") if @type == :usr && @product.passenger_rails_app? %>
- <%= link_to 'Shell', OodAppkit.shell.url(host: ENV['OOD_DEV_SSH_HOST'], path: @product.router.path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> - <%= link_to 'Files', OodAppkit.files.url(path: @product.router.path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> + <% if Configuration.can_access_shell? %> + <%= link_to 'Shell', OodAppkit.shell.url(host: ENV['OOD_DEV_SSH_HOST'], path: @product.router.path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> + <% end %> + <% if Configuration.can_access_files? %> + <%= link_to 'Files', OodAppkit.files.url(path: @product.router.path.realdirpath).to_s, target: '_blank', class: 'btn btn-default' %> + <% end %>
diff --git a/apps/dashboard/config/configuration_singleton.rb b/apps/dashboard/config/configuration_singleton.rb index 4f4b0cd05c..8672bf7bf1 100644 --- a/apps/dashboard/config/configuration_singleton.rb +++ b/apps/dashboard/config/configuration_singleton.rb @@ -324,6 +324,10 @@ def can_access_system_status? can_access_core_app? 'system-status' end + def can_access_shell? + can_access_core_app? 'shell' + end + # Maximum file upload size that nginx will allow from clients in bytes # # @example No maximum upload size supplied.