Skip to content
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

Updated frontend-build to v12 #270

Merged
merged 11 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
3,090 changes: 1,512 additions & 1,578 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/catalog-search/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const { createConfig } = require('@edx/frontend-build');
const extendESLintConfig = require('../../common/extendESLintConfig');

Expand Down
2 changes: 1 addition & 1 deletion packages/catalog-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"devDependencies": {
"@edx/browserslist-config": "1.1.0",
"@edx/frontend-build": "11.0.1",
"@edx/frontend-build": "^12.0.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we pin the version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: keep @edx/frontend-build pinned like the other dependencies.

"@edx/frontend-platform": "1.15.6",
"@edx/paragon": "19.25.1",
"@fortawesome/free-solid-svg-icons": "5.8.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/catalog-search/src/ClearCurrentRefinements.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { clearRefinementsAction } from './data/actions';

export const CLEAR_ALL_TEXT = 'clear all';

const ClearCurrentRefinements = ({ className, variant, ...props }) => {
function ClearCurrentRefinements({ className, variant, ...props }) {
const { refinements, dispatch } = useContext(SearchContext);
const hideCards = (refinements.hide_cards && refinements.hide_cards[0] === 'true');

Expand All @@ -33,7 +33,7 @@ const ClearCurrentRefinements = ({ className, variant, ...props }) => {
) }
</span>
);
};
}

ClearCurrentRefinements.propTypes = {
variant: PropTypes.string.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions packages/catalog-search/src/CurrentRefinements.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import { SearchContext } from './SearchContext';
import { removeFromRefinementArray, deleteRefinementAction } from './data/actions';

export const CurrentRefinementsBase = ({ items, variant }) => {
export function CurrentRefinementsBase({ items, variant }) {
if (!items || !items.length) {
return null;
}
Expand Down Expand Up @@ -130,7 +130,7 @@ export const CurrentRefinementsBase = ({ items, variant }) => {
</li>
</ul>
);
};
}

CurrentRefinementsBase.defaultProps = {
variant: STYLE_VARIANTS.inverse,
Expand Down
42 changes: 22 additions & 20 deletions packages/catalog-search/src/FacetDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,33 @@ import { Dropdown } from '@edx/paragon';

import { STYLE_VARIANTS } from './data/constants';

const FacetDropdown = ({
function FacetDropdown({
title,
items,
isBold,
className,
variant,
}) => (
<div className="facet-list">
<Dropdown autoClose="outside" className={classNames('mb-0 mr-md-3', className)}>
<Dropdown.Toggle
id="{title}-{variant}"
variant={classNames({
'inverse-primary': variant === STYLE_VARIANTS.inverse,
'outline-primary': variant === STYLE_VARIANTS.default,
})}
className={classNames({ 'font-weight-bold': isBold })}
>
{title}
</Dropdown.Toggle>
<Dropdown.Menu>
{items}
</Dropdown.Menu>
</Dropdown>
</div>
);
}) {
return (
<div className="facet-list">
<Dropdown autoClose="outside" className={classNames('mb-0 mr-md-3', className)}>
<Dropdown.Toggle
id="{title}-{variant}"
variant={classNames({
'inverse-primary': variant === STYLE_VARIANTS.inverse,
'outline-primary': variant === STYLE_VARIANTS.default,
})}
className={classNames({ 'font-weight-bold': isBold })}
>
{title}
</Dropdown.Toggle>
<Dropdown.Menu>
{items}
</Dropdown.Menu>
</Dropdown>
</div>
);
}

FacetDropdown.defaultProps = {
className: '',
Expand Down
34 changes: 18 additions & 16 deletions packages/catalog-search/src/FacetItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ import classNames from 'classnames';

import { STYLE_VARIANTS } from './data/constants';

const FacetItem = ({
function FacetItem({
handleInputOnChange, item, isChecked, variant, showBadge,
}) => (
<Dropdown.Item as="label" className="mb-0 py-3 d-flex align-items-center">
<Input
type="checkbox"
checked={isChecked}
onChange={() => handleInputOnChange(item)}
className="facet-item position-relative mr-2 mb-2"
/>
<span className={classNames('facet-item-label', { 'is-refined': isChecked })}>
{item.label}
</span>
{showBadge && (
}) {
return (
<Dropdown.Item as="label" className="mb-0 py-3 d-flex align-items-center">
<Input
type="checkbox"
checked={isChecked}
onChange={() => handleInputOnChange(item)}
className="facet-item position-relative mr-2 mb-2"
/>
<span className={classNames('facet-item-label', { 'is-refined': isChecked })}>
{item.label}
</span>
{showBadge && (
<Badge
pill
className={classNames(
Expand All @@ -28,9 +29,10 @@ const FacetItem = ({
>
{item.count}
</Badge>
)}
</Dropdown.Item>
);
)}
</Dropdown.Item>
);
}

FacetItem.defaultProps = {
variant: STYLE_VARIANTS.inverse,
Expand Down
6 changes: 3 additions & 3 deletions packages/catalog-search/src/FacetListBase.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
addToRefinementArray, setRefinementAction, deleteRefinementAction, removeFromRefinementArray,
} from './data/actions';

const FacetListBase = ({
function FacetListBase({
attribute,
facetValueType,
isBold,
Expand All @@ -25,7 +25,7 @@ const FacetListBase = ({
doRefinement,
customAttribute,
showBadge,
}) => {
}) {
const { refinements, dispatch } = useContext(SearchContext);

/**
Expand Down Expand Up @@ -113,7 +113,7 @@ const FacetListBase = ({
variant={variant}
/>
);
};
}

FacetListBase.defaultProps = {
isCheckedField: null,
Expand Down
18 changes: 10 additions & 8 deletions packages/catalog-search/src/FacetListRefinement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import PropTypes from 'prop-types';
import { connectRefinementList } from 'react-instantsearch-dom';
import FacetListBase from './FacetListBase';

export const FacetListRefinementBase = ({
export function FacetListRefinementBase({
currentRefinement, ...props
}) => (
<FacetListBase
isBold={currentRefinement.length > 0}
isCheckedField="isRefined"
{...props}
/>
);
}) {
return (
<FacetListBase
isBold={currentRefinement.length > 0}
isCheckedField="isRefined"
{...props}
/>
);
}

FacetListRefinementBase.propTypes = {
attribute: PropTypes.string.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions packages/catalog-search/src/LearningTypeRadioFacet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { features } from './config';
import { LEARNING_TYPE_COURSE, LEARNING_TYPE_PROGRAM, LEARNING_TYPE_PATHWAY } from './data/constants';

const LearningTypeRadioFacet = () => {
function LearningTypeRadioFacet() {
const { refinements, dispatch } = useContext(SearchContext);
// only bold the dropdown title if the learning type is Course or Program
const typeCourseSelected = refinements.content_type && refinements.content_type.includes(LEARNING_TYPE_COURSE);
Expand Down Expand Up @@ -91,6 +91,6 @@ const LearningTypeRadioFacet = () => {
</Dropdown>
</div>
);
};
}

export default LearningTypeRadioFacet;
4 changes: 2 additions & 2 deletions packages/catalog-search/src/MobileFilterMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ClearCurrentRefinements from './ClearCurrentRefinements';

import { useActiveRefinementsAsFlatArray } from './data/hooks';

export const MobileFilterMenuBase = ({ children, className, items }) => {
export function MobileFilterMenuBase({ children, className, items }) {
const [isOpen, setIsOpen] = useState(false);

const activeRefinementsAsFlatArray = useActiveRefinementsAsFlatArray(items);
Expand Down Expand Up @@ -86,7 +86,7 @@ export const MobileFilterMenuBase = ({ children, className, items }) => {
</div>
</div>
);
};
}

MobileFilterMenuBase.propTypes = {
children: PropTypes.node.isRequired,
Expand Down
6 changes: 3 additions & 3 deletions packages/catalog-search/src/SearchBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const searchText = 'Search courses';
export const SEARCH_EVENT_NAME_PREFIX = 'edx.enterprise';
export const QUERY_SUBMITTED_EVENT = 'catalog_search.query_submitted';

export const SearchBoxBase = ({
export function SearchBoxBase({
className,
defaultRefinement,
variant,
Expand All @@ -44,7 +44,7 @@ export const SearchBoxBase = ({
enterpriseSlug,
suggestionSubmitOverride,
disableSuggestionRedirect,
}) => {
}) {
const { dispatch, trackingName } = useContext(SearchContext);

const [autocompleteHits, setAutocompleteHits] = useState([]);
Expand Down Expand Up @@ -180,7 +180,7 @@ export const SearchBoxBase = ({
)}
</div>
);
};
}

SearchBoxBase.propTypes = {
defaultRefinement: PropTypes.string,
Expand Down
4 changes: 2 additions & 2 deletions packages/catalog-search/src/SearchContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const getRefinementsToSet = (queryParams, activeFacetAttributes) => {
return refinementsToSet;
};

const SearchData = ({ children, searchFacetFilters, trackingName }) => {
function SearchData({ children, searchFacetFilters, trackingName }) {
const [refinements, dispatch] = useReducer(
refinementsReducer,
{},
Expand Down Expand Up @@ -87,7 +87,7 @@ const SearchData = ({ children, searchFacetFilters, trackingName }) => {
return (
<SearchContext.Provider value={value}>{children}</SearchContext.Provider>
);
};
}

SearchData.defaultProps = {
searchFacetFilters: SEARCH_FACET_FILTERS,
Expand Down
4 changes: 2 additions & 2 deletions packages/catalog-search/src/SearchFilters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import LearningTypeRadioFacet from './LearningTypeRadioFacet';

export const FREE_ALL_TITLE = 'Free / All';

const SearchFilters = ({ variant }) => {
function SearchFilters({ variant }) {
const { refinements, searchFacetFilters } = useContext(SearchContext);
const freeAllItems = useMemo(() => [
{
Expand Down Expand Up @@ -96,7 +96,7 @@ const SearchFilters = ({ variant }) => {
</MediaQuery>
</>
);
};
}

SearchFilters.defaultProps = {
variant: STYLE_VARIANTS.inverse,
Expand Down
6 changes: 3 additions & 3 deletions packages/catalog-search/src/SearchHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { SearchContext } from './SearchContext';
export const searchBoxColTestId = 'search-box-col';
export const filtersColTestId = 'filters-col';

const SearchHeader = ({
function SearchHeader({
variant,
containerSize,
headerTitle,
Expand All @@ -22,7 +22,7 @@ const SearchHeader = ({
suggestionSubmitOverride,
enterpriseConfig: { slug },
disableSuggestionRedirect,
}) => {
}) {
const { refinements } = useContext(SearchContext);
let searchQueryFromRefinements;
// Sometimes the query is set to an array of one string instead of just the string
Expand Down Expand Up @@ -66,7 +66,7 @@ const SearchHeader = ({
</Container>
</div>
);
};
}

SearchHeader.defaultProps = {
variant: STYLE_VARIANTS.inverse,
Expand Down
6 changes: 3 additions & 3 deletions packages/catalog-search/src/SearchPagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { Pagination } from '@edx/paragon';
import { SearchContext } from './SearchContext';
import { setRefinementAction, deleteRefinementAction } from './data/actions';

export const SearchPaginationBase = ({
export function SearchPaginationBase({
nbPages,
currentRefinement,
maxPagesDisplayed,
}) => {
}) {
const { dispatch } = useContext(SearchContext);

const icons = useMemo(
Expand Down Expand Up @@ -63,7 +63,7 @@ export const SearchPaginationBase = ({
}}
/>
);
};
}

SearchPaginationBase.propTypes = {
nbPages: PropTypes.number.isRequired,
Expand Down
8 changes: 4 additions & 4 deletions packages/catalog-search/src/SearchSuggestionItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';

const SearchSuggestionItem = ({
function SearchSuggestionItem({
url, suggestionItemHandler, hit, disableSuggestionRedirect,
}) => {
}) {
const authoringOrganization = hit.key && hit.key.split('+')[0];
// If the disable redirect bool is provided, prevent the redirect from happening and instead call the provided submit
// handler
Expand Down Expand Up @@ -36,7 +36,7 @@ const SearchSuggestionItem = ({
}
</Link>
);
};
}

SearchSuggestionItem.propTypes = {
url: PropTypes.string.isRequired,
Expand All @@ -45,7 +45,7 @@ SearchSuggestionItem.propTypes = {
key: PropTypes.string,
title: PropTypes.string,
program_type: PropTypes.string,
authoring_organizations: PropTypes.array,
authoring_organizations: PropTypes.shape([]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PropTypes.shape is usually reserved for an object prop, not an array. Should this be PropTypes.arrayOf(PropTypes.shape()) instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related, is this hit.authoring_organizations actually used in this component? If not, is it necessary to include in the prop types definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authoring_organizations is not used in this component. Removed it from prop types definition

_highlightResult: PropTypes.shape({ title: PropTypes.shape({ value: PropTypes.string }) }),
}).isRequired,
disableSuggestionRedirect: PropTypes.bool.isRequired,
Expand Down
Loading