Skip to content

Commit

Permalink
fix: language facet feature flag and sort it alphabetically (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz authored Mar 26, 2021
1 parent 74e5fea commit 584b765
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions src/course-search/config/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
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);
return features && features.split(',').includes(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
Expand Down
12 changes: 9 additions & 3 deletions src/course-search/data/constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { features } from '../config';

export const SHOW_ALL_NAME = 'showAll';

export const SEARCH_FACET_FILTERS = [
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 584b765

Please sign in to comment.