From 2b43b263f8cd5cbd931d884bfa961a7dba7a4b9a Mon Sep 17 00:00:00 2001 From: radhika Date: Tue, 27 Oct 2015 09:23:24 -0400 Subject: [PATCH] 7453: do not display generic "add new" button in the groups, keep_disks, keep_services, links, nodes, and virtual_machines listing pages. --- apps/workbench/app/models/group.rb | 4 ++++ apps/workbench/app/models/keep_disk.rb | 2 +- apps/workbench/app/models/keep_service.rb | 2 +- apps/workbench/app/models/link.rb | 4 ++++ apps/workbench/app/models/node.rb | 2 +- apps/workbench/app/models/virtual_machine.rb | 7 ++++++- .../test/integration/application_layout_test.rb | 16 ++++++++-------- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/apps/workbench/app/models/group.rb b/apps/workbench/app/models/group.rb index 3f5da155c4..0d358603a8 100644 --- a/apps/workbench/app/models/group.rb +++ b/apps/workbench/app/models/group.rb @@ -32,4 +32,8 @@ class Group < ArvadosBase def textile_attributes [ 'description' ] end + + def self.creatable? + false + end end diff --git a/apps/workbench/app/models/keep_disk.rb b/apps/workbench/app/models/keep_disk.rb index 8ced4eb5f3..6438fc72d6 100644 --- a/apps/workbench/app/models/keep_disk.rb +++ b/apps/workbench/app/models/keep_disk.rb @@ -1,5 +1,5 @@ class KeepDisk < ArvadosBase def self.creatable? - current_user and current_user.is_admin + false end end diff --git a/apps/workbench/app/models/keep_service.rb b/apps/workbench/app/models/keep_service.rb index f27e369b86..0c998c4591 100644 --- a/apps/workbench/app/models/keep_service.rb +++ b/apps/workbench/app/models/keep_service.rb @@ -1,5 +1,5 @@ class KeepService < ArvadosBase def self.creatable? - current_user and current_user.is_admin + false end end diff --git a/apps/workbench/app/models/link.rb b/apps/workbench/app/models/link.rb index 271fa0f010..b1bbcff126 100644 --- a/apps/workbench/app/models/link.rb +++ b/apps/workbench/app/models/link.rb @@ -18,4 +18,8 @@ class Link < ArvadosBase result = arvados_api_client.api("permissions", "/#{uuid}") arvados_api_client.unpack_api_response(result) end + + def self.creatable? + false + end end diff --git a/apps/workbench/app/models/node.rb b/apps/workbench/app/models/node.rb index e66be83078..8bf98c6dec 100644 --- a/apps/workbench/app/models/node.rb +++ b/apps/workbench/app/models/node.rb @@ -1,6 +1,6 @@ class Node < ArvadosBase def self.creatable? - current_user and current_user.is_admin + false end def friendly_link_name lookup=nil (hostname && !hostname.empty?) ? hostname : uuid diff --git a/apps/workbench/app/models/virtual_machine.rb b/apps/workbench/app/models/virtual_machine.rb index 3b44397df5..e1a208c53d 100644 --- a/apps/workbench/app/models/virtual_machine.rb +++ b/apps/workbench/app/models/virtual_machine.rb @@ -1,20 +1,25 @@ class VirtualMachine < ArvadosBase attr_accessor :current_user_logins + def self.creatable? - current_user.andand.is_admin + false end + def attributes_for_display super.append ['current_user_logins', @current_user_logins] end + def editable_attributes super - %w(current_user_logins) end + def self.attribute_info merger = ->(k,a,b) { a.merge(b, &merger) } merger [nil, {current_user_logins: {column_heading: "logins", type: 'array'}}, super] end + def friendly_link_name lookup=nil (hostname && !hostname.empty?) ? hostname : uuid end diff --git a/apps/workbench/test/integration/application_layout_test.rb b/apps/workbench/test/integration/application_layout_test.rb index 61ba16294f..db072e496b 100644 --- a/apps/workbench/test/integration/application_layout_test.rb +++ b/apps/workbench/test/integration/application_layout_test.rb @@ -218,14 +218,14 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest end [ - ['Repositories',nil,'s0uqq'], - ['Virtual machines','virtual machine','current_user_logins'], - ['SSH keys',nil,'public_key'], - ['Links','link','link_class'], - ['Groups','group','group_class'], - ['Compute nodes','node','info[ping_secret'], - ['Keep services','keep service','service_ssl_flag'], - ['Keep disks', 'keep disk','bytes_free'], + ['Repositories', nil, 's0uqq'], + ['Virtual machines', nil, 'testvm.shell'], + ['SSH keys', nil, 'public_key'], + ['Links', nil, 'link_class'], + ['Groups', nil, 'All users'], + ['Compute nodes', nil, 'ping_secret'], + ['Keep services', nil, 'service_ssl_flag'], + ['Keep disks', nil, 'bytes_free'], ].each do |page_name, add_button_text, look_for| test "test system menu #{page_name} link" do visit page_with_token('admin') -- 2.30.2