Skip to content

feat: Add config to hide non-clickable badges #1943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import * as React from 'react';

import { getBadgeConfig } from 'config/config-utils';
import { getBadgeConfig, hideNonClickableBadges } from 'config/config-utils';
import { BadgeStyle, BadgeStyleConfig } from 'config/config-types';

import { convertText, CaseType } from 'utils/textUtils';
Expand Down Expand Up @@ -82,7 +82,11 @@ export default class BadgeList extends React.Component<BadgeListProps> {
badgeConfig = getBadgeConfig(badge.badge_name);
}

if (badge.badge_name && badge.category === COLUMN_BADGE_CATEGORY) {
if (
badge.badge_name &&
badge.category === COLUMN_BADGE_CATEGORY &&
!hideNonClickableBadges()
) {
return (
<StaticBadge
style={badgeConfig.style}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const configCustom: AppConfigCustom = {
curatedTags: [],
showAllTags: true,
showBadgesInHome: true,
hideNonClickableBadges: false,
},
analytics: {
plugins: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const configDefault: AppConfig = {
curatedTags: [],
showAllTags: true,
showBadgesInHome: true,
hideNonClickableBadges: false,
},
date: {
default: 'MMM DD, YYYY',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ export interface AnalyticsConfig {
*
* curatedTags - An array of tags to show in a separate section at the top.
* showAllTags - Shows all tags when true, or only curated tags if false
* showBadgesInHome - Shows all badges in the homepage when true
* hideNonClickableBadges - Hides non-clickable badges in the homepage if true
*/
interface BrowseConfig {
curatedTags: Array<string>;
showAllTags: boolean;
showBadgesInHome: boolean;
hideNonClickableBadges: boolean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ export function getBadgeConfig(badgeName: string): BadgeStyleConfig {
};
}

/**
* Returns whether non-clickable badges should be hidden on the homepage
*/
export function hideNonClickableBadges(): boolean {
return AppConfig.browse.hideNonClickableBadges;
}

/**
* Returns whether or not feedback features should be enabled
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,15 @@ describe('getCuratedTags', () => {
});
});

describe('hideNonClickableBadges', () => {
it('returns whether to hide non-clickable badges', () => {
AppConfig.browse.hideNonClickableBadges = true;
expect(ConfigUtils.hideNonClickableBadges()).toBe(
AppConfig.browse.hideNonClickableBadges
);
});
});

describe('exploreEnabled', () => {
it('returns whether the explore function is enabled', () => {
AppConfig.tableProfile.isExploreEnabled = true;
Expand Down