diff --git a/apps/dashboard/app/apps/nav_config.rb b/apps/dashboard/app/apps/nav_config.rb deleted file mode 100644 index 03fd4c47e6..0000000000 --- a/apps/dashboard/app/apps/nav_config.rb +++ /dev/null @@ -1,8 +0,0 @@ -class NavConfig - class << self - attr_accessor :categories, :categories_whitelist - alias_method :categories_whitelist?, :categories_whitelist - end - self.categories = ["Apps", "Files", "Jobs", "Clusters", "Interactive Apps"] - self.categories_whitelist = false -end diff --git a/apps/dashboard/app/models/user_configuration.rb b/apps/dashboard/app/models/user_configuration.rb index be74c9c368..1fe33ea7d6 100644 --- a/apps/dashboard/app/models/user_configuration.rb +++ b/apps/dashboard/app/models/user_configuration.rb @@ -122,14 +122,14 @@ def announcement_path end end - # 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. + DEFAULT_NAV_CATEGORIES = ["Apps", "Files", "Jobs", "Clusters", "Interactive Apps"].freeze + def filter_nav_categories? - fetch(:nav_categories, nil).nil? ? NavConfig.categories_whitelist? : true + !!fetch(:nav_categories, nil) end def nav_categories - fetch(:nav_categories, nil) || NavConfig.categories + fetch(:nav_categories, DEFAULT_NAV_CATEGORIES) end # Create support ticket service class based on the configuration diff --git a/apps/dashboard/test/integration/dashboard_controller_test.rb b/apps/dashboard/test/integration/dashboard_controller_test.rb index e5289701cd..c3863e315a 100644 --- a/apps/dashboard/test/integration/dashboard_controller_test.rb +++ b/apps/dashboard/test/integration/dashboard_controller_test.rb @@ -148,55 +148,9 @@ def teardown assert_select "nav a[href='#{batch_connect_sessions_path}']", 0 end - test 'should not create app menus if NavConfig.categories is empty and whitelist is enabled' do + test 'UserConfiguration.categories should filter and order the navigation' 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 - - 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 - - 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 - - test 'UserConfiguration.categories should filter and order the navigation and have precedence over NavConfig' 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']) stub_user_configuration({ nav_categories: ['Files', 'Interactive Apps', 'Clusters'] @@ -213,8 +167,6 @@ def teardown test 'should not create app menus if UserConfiguration.categories is empty' 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']) stub_user_configuration({ nav_categories: [] @@ -226,32 +178,9 @@ def teardown assert_select dropdown_link(1), text: 'Help' # ensure is Help end - test 'verify default values for NavConfig' do - refute NavConfig.categories_whitelist? - assert NavConfig - end - - 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 - 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')) OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) - NavConfig.stubs(:categories_whitelist?).returns(false) get root_path diff --git a/apps/dashboard/test/models/user_configuration_test.rb b/apps/dashboard/test/models/user_configuration_test.rb index 89f3b67ca6..d5308034f1 100644 --- a/apps/dashboard/test/models/user_configuration_test.rb +++ b/apps/dashboard/test/models/user_configuration_test.rb @@ -177,12 +177,11 @@ def teardown assert_equal true, UserConfiguration.new.filter_nav_categories? end - test "filter_nav_categories? should return default value NavConfig.categories_whitelist? when categories is not set in config" do + test "filter_nav_categories? should return false when nav_categories is nil" do Configuration.stubs(:config).returns({}) - NavConfig.stubs(:categories_whitelist?).returns(false) assert_equal false, UserConfiguration.new.filter_nav_categories? - NavConfig.stubs(:categories_whitelist?).returns(true) + Configuration.stubs(:config).returns({nav_categories: []}) assert_equal true, UserConfiguration.new.filter_nav_categories? end