Skip to content

Commit

Permalink
refactor: begin using new frontend-enterprise npm packages (#264)
Browse files Browse the repository at this point in the history
* refactor: begin using new frontend-enterprise npm packages

* chore: upgrade frontend-platform
  • Loading branch information
adamstankiewicz authored May 11, 2021
1 parent 945df36 commit f6ca7c6
Show file tree
Hide file tree
Showing 13 changed files with 877 additions and 1,789 deletions.
2,538 changes: 848 additions & 1,690 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
"dependencies": {
"@edx/brand": "npm:@edx/[email protected]",
"@edx/frontend-component-footer": "10.1.0",
"@edx/frontend-enterprise": "5.5.1",
"@edx/frontend-platform": "1.9.4",
"@edx/frontend-enterprise-catalog-search": "^0.1.6",
"@edx/frontend-enterprise-logistration": "^0.1.5",
"@edx/frontend-enterprise-utils": "^0.1.5",
"@edx/frontend-platform": "^1.9.6",
"@edx/paragon": "14.6.1",
"@fortawesome/fontawesome-svg-core": "1.2.32",
"@fortawesome/free-brands-svg-icons": "5.15.1",
Expand Down
16 changes: 15 additions & 1 deletion src/components/app/AuthenticatedPage.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import React from 'react';
import PropTypes from 'prop-types';
import Cookies from 'universal-cookie';
import { LoginRedirect } from '@edx/frontend-enterprise-logistration';
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { getConfig } from '@edx/frontend-platform/config';

import { EnterprisePage } from '../enterprise-page';
import { EnterpriseBanner } from '../enterprise-banner';
import { Layout } from '../layout';
import { LoginRedirect } from '../login-redirect';

export default function AuthenticatedPage({ children, useEnterpriseConfigCache }) {
const config = getConfig();
const user = getAuthenticatedUser();

if (!user) {
// if user is not authenticated, remove cookie that controls whether the user will see
// the integration warning modal on their next visit. the expected behavior is to only
// see the modal once per authenticated session.
const cookies = new Cookies();
cookies.remove(config.INTEGRATION_WARNING_DISMISSED_COOKIE_NAME);
}

return (
<LoginRedirect>
<EnterprisePage useEnterpriseConfigCache={useEnterpriseConfigCache}>
Expand Down
37 changes: 0 additions & 37 deletions src/components/login-redirect/LoginRedirect.jsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/login-redirect/index.js

This file was deleted.

48 changes: 0 additions & 48 deletions src/components/login-redirect/tests/LoginRedirect.test.jsx

This file was deleted.

4 changes: 1 addition & 3 deletions src/components/search/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import algoliasearch from 'algoliasearch/lite';
import { Configure, InstantSearch } from 'react-instantsearch-dom';
import { AppContext } from '@edx/frontend-platform/react';
import { getConfig } from '@edx/frontend-platform/config';
import {
SearchHeader,
} from '@edx/frontend-enterprise';
import { SearchHeader } from '@edx/frontend-enterprise-catalog-search';
import { useDefaultSearchFilters } from './data/hooks';

import { NUM_RESULTS_PER_PAGE } from './constants';
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/SearchPage.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { SearchData } from '@edx/frontend-enterprise-catalog-search';

import { SearchData } from '@edx/frontend-enterprise';
import Search from './Search';
import AuthenticatedUserSubsidyPage from '../app/AuthenticatedUserSubsidyPage';

Expand Down
4 changes: 3 additions & 1 deletion src/components/search/SearchResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import React, { useContext, useMemo } from 'react';
import PropTypes from 'prop-types';
import { connectStateResults, Hits } from 'react-instantsearch-dom';
import Skeleton from 'react-loading-skeleton';
import { useNbHitsFromSearchResults, SearchContext, SearchPagination } from '@edx/frontend-enterprise';
import {
useNbHitsFromSearchResults, SearchContext, SearchPagination,
} from '@edx/frontend-enterprise-catalog-search';
import { Container, Row } from '@edx/paragon';

import SearchCourseCard from './SearchCourseCard';
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/data/hooks.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext, useMemo, useEffect } from 'react';
import {
SearchContext, getCatalogString, SHOW_ALL_NAME, setRefinementAction,
} from '@edx/frontend-enterprise';
} from '@edx/frontend-enterprise-catalog-search';
import { features } from '../../../config';
import { LICENSE_STATUS } from '../../enterprise-user-subsidy/data/constants';

Expand Down
2 changes: 1 addition & 1 deletion src/components/search/data/tests/hooks.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { renderHook } from '@testing-library/react-hooks';
import '@testing-library/jest-dom/extend-expect';
import {
getCatalogString, SearchContext, SearchData, SHOW_ALL_NAME,
} from '@edx/frontend-enterprise';
} from '@edx/frontend-enterprise-catalog-search';
import {
useDefaultSearchFilters,
} from '../hooks';
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/popular-courses/PopularCourses.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Hits, connectStateResults } from 'react-instantsearch-dom';
import Skeleton from 'react-loading-skeleton';

import { useNbHitsFromSearchResults } from '@edx/frontend-enterprise';
import { useNbHitsFromSearchResults } from '@edx/frontend-enterprise-catalog-search';
import SearchCourseCard from '../SearchCourseCard';
import SearchError from '../SearchError';

Expand Down
4 changes: 2 additions & 2 deletions src/index.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@import "@edx/brand/paragon/fonts";
@import "@edx/brand/paragon/variables";
@import "@edx/paragon/scss/core/core";
// frontend-enterprise must come before the paragon overrides for correct styling
@import "~@edx/frontend-enterprise";
// frontend-enterprise-* imports must come before the paragon overrides for correct styling
@import "~@edx/frontend-enterprise-catalog-search";
@import "@edx/brand/paragon/overrides";

$fa-font-path: "~font-awesome/fonts";
Expand Down

0 comments on commit f6ca7c6

Please sign in to comment.