diff --git a/src/constants.js b/src/constants.js index afae1d5b..92cdbe41 100644 --- a/src/constants.js +++ b/src/constants.js @@ -1,4 +1,5 @@ const FEATURE_ENROLL_WITH_CODES = 'ENROLL_WITH_CODES'; +const FEATURE_LANGUAGE_FACET = 'LANGUAGE_FACET'; const ENTERPRISE_ADMIN = 'enterprise_admin'; const ENTERPRISE_CATALOG_ADMIN = 'enterprise_catalog_admin'; @@ -7,6 +8,7 @@ const ENTERPRISE_OPENEDX_OPERATOR = 'enterprise_openedx_operator'; export { FEATURE_ENROLL_WITH_CODES, + FEATURE_LANGUAGE_FACET, ENTERPRISE_ADMIN, ENTERPRISE_CATALOG_ADMIN, ENTERPRISE_LEARNER, diff --git a/src/course-search/config/index.js b/src/course-search/config/index.js index e276e623..32f1b034 100644 --- a/src/course-search/config/index.js +++ b/src/course-search/config/index.js @@ -1,6 +1,9 @@ import qs from 'query-string'; -import { FEATURE_ENROLL_WITH_CODES } from '../../constants'; +import { + FEATURE_ENROLL_WITH_CODES, + FEATURE_LANGUAGE_FACET, +} from '../../constants'; const hasFeatureFlagEnabled = (featureFlag) => { const { features } = qs.parse(window.location.search); @@ -8,9 +11,8 @@ const hasFeatureFlagEnabled = (featureFlag) => { }; const features = { - ENROLL_WITH_CODES: - process.env.FEATURE_ENROLL_WITH_CODES - || hasFeatureFlagEnabled(FEATURE_ENROLL_WITH_CODES), + ENROLL_WITH_CODES: process.env.FEATURE_ENROLL_WITH_CODES || hasFeatureFlagEnabled(FEATURE_ENROLL_WITH_CODES), + LANGUAGE_FACET: process.env.FEATURE_LANGUAGE_FACET || hasFeatureFlagEnabled(FEATURE_LANGUAGE_FACET), }; // eslint-disable-next-line import/prefer-default-export diff --git a/src/course-search/data/constants.js b/src/course-search/data/constants.js index 16aad3c9..8f0da2df 100644 --- a/src/course-search/data/constants.js +++ b/src/course-search/data/constants.js @@ -1,3 +1,5 @@ +import { features } from '../config'; + export const SHOW_ALL_NAME = 'showAll'; export const SEARCH_FACET_FILTERS = [ @@ -31,11 +33,15 @@ export const SEARCH_FACET_FILTERS = [ attribute: 'availability', title: 'Availability', }, - { +]; + +if (features.LANGUAGE_FACET) { + SEARCH_FACET_FILTERS.push({ attribute: 'language', title: 'Language', - }, -]; + isSortedAlphabetical: true, + }); +} export const BOOLEAN_FILTERS = [SHOW_ALL_NAME]; export const QUERY_PARAM_FOR_SEARCH_QUERY = 'q';