Skip to content

Commit

Permalink
Disable file and shell buttons when apps are unavailable (#3655)
Browse files Browse the repository at this point in the history
Remove file and shell buttons when the apps are not actually available.
  • Loading branch information
ashton22305 authored Jul 5, 2024
1 parent 9ef9b09 commit 45e00b2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
<% end %>
<div class="card-body">
<% 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}" } %>
Expand Down
8 changes: 6 additions & 2 deletions apps/dashboard/app/views/products/_product.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@
<td>
<div class="d-grid gap-2">
<%= 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 %>
</div>
</td>
<td>
Expand Down
8 changes: 6 additions & 2 deletions apps/dashboard/app/views/products/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
<p>
<%= link_to 'New App', new_product_path(type: @type), class: 'btn btn-default' %>
<span class="float-end">
<%= 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 %>
</span>
</p>

Expand Down
8 changes: 6 additions & 2 deletions apps/dashboard/app/views/products/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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? %>
</div><!-- /.col-md-2 -->
<div class="d-grid gap-2 col-md-2 col-xs-6 mb-auto">
<%= 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 %>
</div><!-- /.col-md-2 -->

</div><!-- /.row -->
Expand Down
4 changes: 4 additions & 0 deletions apps/dashboard/config/configuration_singleton.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 45e00b2

Please sign in to comment.