Skip to content

Commit

Permalink
Small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
HazelGrant committed Apr 9, 2024
1 parent d554aec commit 27c9a51
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 77 deletions.
9 changes: 3 additions & 6 deletions apps/dashboard/app/models/user_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,14 @@ def announcement_path
end
end

CATEGORIES = ["Apps", "Files", "Jobs", "Clusters", "Interactive Apps"].freeze
CATEGORIES_WHITELIST = false
DEFAULT_NAV_CATEGORIES = ["Apps", "Files", "Jobs", "Clusters", "Interactive Apps"].freeze

# Filtering is controlled with NavConfig.categories_allowlist? unless the configuration property categories is defined.
# If categories are defined, filter_nav_categories? will always be true.
def filter_nav_categories?
fetch(:nav_categories, nil).nil? ? CATEGORIES_WHITELIST : true
fetch(:nav_categories, nil)
end

def nav_categories
fetch(:nav_categories, nil) || CATEGORIES
fetch(:nav_categories, DEFAULT_NAV_CATEGORIES)
end

# Create support ticket service class based on the configuration
Expand Down
71 changes: 0 additions & 71 deletions apps/dashboard/test/integration/dashboard_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,53 +147,6 @@ def teardown
assert_response :success
assert_select "nav a[href='#{batch_connect_sessions_path}']", 0
end
=begin
test 'should not create app menus if NavConfig.categories is empty and whitelist is enabled' do
SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps'))
OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d'))
NavConfig.stubs(:categories_whitelist?).returns(true)
NavConfig.stubs(:categories).returns([])
get root_path
assert_response :success
assert_select dropdown_links, 1 # +1 here is 'Help'
assert_select dropdown_link(1), text: 'Help' # ensure is Help
end
=end
=begin
test 'should exclude gateway apps if NavConfig.categories is set to default and whitelist is enabled' do
SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps'))
OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d'))
NavConfig.stubs(:categories_whitelist?).returns(true)
NavConfig.stubs(:categories).returns(['Files', 'Jobs', 'Clusters', 'Interactive Apps'])
get root_path
assert_response :success
assert_select dropdown_links, 5 # +1 here is 'Help'
assert_select dropdown_link(1), text: 'Files'
assert_select dropdown_link(2), text: 'Jobs'
assert_select dropdown_link(3), text: 'Clusters'
assert_select dropdown_link(4), text: 'Interactive Apps'
assert_select dropdown_link(5), text: 'Help'
end
=end
=begin
test 'uses NavConfig.categories as sort order if whitelist is false' do
SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps'))
OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d'))
NavConfig.stubs(:categories_whitelist?).returns(false)
NavConfig.stubs(:categories).returns(['Jobs', 'Interactive Apps', 'Files', 'Clusters'])
get root_path
assert_response :success
assert_select dropdown_links, 6 # +1 here is 'Help'
assert_select dropdown_link(1), text: 'Jobs'
assert_select dropdown_link(2), text: 'Interactive Apps'
assert_select dropdown_link(3), text: 'Files'
assert_select dropdown_link(4), text: 'Clusters'
assert_select dropdown_link(5), text: 'Gateway Apps'
end
=end

test 'UserConfiguration.categories should filter and order the navigation' do
SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps'))
Expand Down Expand Up @@ -224,30 +177,6 @@ def teardown
assert_select dropdown_links, 1 # +1 here is 'Help'
assert_select dropdown_link(1), text: 'Help' # ensure is Help
end
=begin
test 'verify default values for NavConfig' do
refute NavConfig.categories_whitelist?
assert NavConfig
end
=end
=begin
test 'display all app menus in alphabetical order if NavConfig.whitelist false & NavConfig.categories nil or []' do
SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps'))
OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d'))
NavConfig.stubs(:categories_whitelist?).returns(false)
NavConfig.stubs(:categories).returns([])
get root_path
assert_response :success
assert_select dropdown_links, 6 # +1 here is 'Help'
assert_select dropdown_link(1), text: 'Clusters'
assert_select dropdown_link(2), text: 'Files'
assert_select dropdown_link(3), text: 'Gateway Apps'
assert_select dropdown_link(4), text: 'Interactive Apps'
assert_select dropdown_link(5), text: 'Jobs'
end
=end

test 'apps with no category should not appear in menu' do
SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps'))
Expand Down

0 comments on commit 27c9a51

Please sign in to comment.