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

feat: library home page bare bones (TEMP) #37

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
4191ecb
feat: Add lib v2/legacy tabs in studio home
yusuf-musleh May 27, 2024
15c678b
feat: Add `LIBRARY_MODE` config variable
yusuf-musleh May 28, 2024
14b8b3a
feat: Add url paths/navigation for each tab
yusuf-musleh May 28, 2024
515cc71
feat: LibraryV2 redirect to lib mfe or placeholder
yusuf-musleh May 30, 2024
9c6e1e6
feat: Add pagination support for lib v2s
yusuf-musleh May 30, 2024
da189c1
fix: Redirect to placeholder create lib in v2/mixed disabled mfe
yusuf-musleh Jun 3, 2024
85d9ff2
temp: This removes TS code to get tests to run
yusuf-musleh Jun 3, 2024
c6b7bf8
test: Update existing tests to support changes
yusuf-musleh Jun 3, 2024
14933d2
temp: Rename .tsx -> .jsx & .ts -> .js for tests
yusuf-musleh Jun 3, 2024
8b96268
fix: Fix lint issues
yusuf-musleh Jun 3, 2024
f8db853
feat: library home page bare bones
rpenido Jun 4, 2024
7a8488d
test: Add tests for new functionality
yusuf-musleh Jun 4, 2024
7842ce0
fix: update search modal for new library urls
rpenido Jun 5, 2024
462cda9
feat: Add lib v2/legacy tabs in studio home
yusuf-musleh May 27, 2024
be8b2f4
feat: Add `LIBRARY_MODE` config variable
yusuf-musleh May 28, 2024
27b2581
feat: Add url paths/navigation for each tab
yusuf-musleh May 28, 2024
4ffd651
feat: LibraryV2 redirect to lib mfe or placeholder
yusuf-musleh May 30, 2024
7f97243
feat: Add pagination support for lib v2s
yusuf-musleh May 30, 2024
c86b85a
fix: Redirect to placeholder create lib in v2/mixed disabled mfe
yusuf-musleh Jun 3, 2024
efbc625
temp: This removes TS code to get tests to run
yusuf-musleh Jun 3, 2024
21da6f8
test: Update existing tests to support changes
yusuf-musleh Jun 3, 2024
79e6516
temp: Rename .tsx -> .jsx & .ts -> .js for tests
yusuf-musleh Jun 3, 2024
262cb3f
fix: Fix lint issues
yusuf-musleh Jun 3, 2024
1ea229f
test: Add tests for new functionality
yusuf-musleh Jun 4, 2024
a0a30b7
refactor: Change /legacy-libraries -> /libraries-v1
yusuf-musleh Jun 6, 2024
4deaea9
fix: add i18n messages
rpenido Jun 6, 2024
c2bdecf
fix: libraryAuthoring enabled check
rpenido Jun 6, 2024
5213eff
Merge branch 'yusuf-musleh/lib-v2-tab-studio-home' into rpenido/fal-3…
rpenido Jun 6, 2024
a24b3ba
fix: add Create Library placeholder
rpenido Jun 6, 2024
2859741
refactor: Remove hardcoded mfe path
yusuf-musleh Jun 6, 2024
d853f29
refactor: rename .ts files to .js
rpenido Jun 6, 2024
567dcb4
feat: Add function to construct Lib Auth MFE URL
yusuf-musleh Jun 6, 2024
094086e
feat: Make URL /library-v1 when referencing legacy
yusuf-musleh Jun 6, 2024
a95c990
fix: Add missing part of path
yusuf-musleh Jun 6, 2024
e3ebc55
fix: type and lint errors
rpenido Jun 6, 2024
8ed168d
fix: Issue with destinationUrl
yusuf-musleh Jun 6, 2024
beda37f
test: Add checks for Tab.eventKey in tests
yusuf-musleh Jun 6, 2024
2e3fa43
fix: Revert card item url changes to keep simple
yusuf-musleh Jun 7, 2024
72edfac
fix: add tests
rpenido Jun 7, 2024
8086ebf
Merge branch 'yusuf-musleh/lib-v2-tab-studio-home' into rpenido/fal-3…
rpenido Jun 7, 2024
91443e9
fix: removing unused file
rpenido Jun 7, 2024
a29cf7e
fix: add ts-check
rpenido Jun 7, 2024
4deab76
fix: removing deleted file references
rpenido Jun 7, 2024
e8bca34
chore: trigger CI
rpenido Jun 7, 2024
388c40e
fix: fixes from review
rpenido Jun 13, 2024
7d6096e
fix: fix default parameter syntax
rpenido Jun 14, 2024
c63bc2f
fix: new library redirect
rpenido Jun 18, 2024
efe0bed
Revert "fix: new library redirect"
rpenido Jun 19, 2024
942cbff
chore: trigger CI
rpenido Jun 19, 2024
2d3be09
fix: new library redirect
rpenido Jun 20, 2024
e8f9f78
fix: remove warning on library home
rpenido Jun 20, 2024
f9920f4
fix: remove unused import
rpenido Jun 20, 2024
088a01d
feat: Add lib v2/legacy tabs in studio home (#1050)
yusuf-musleh Jun 20, 2024
7fd6c27
Merge branch 'master' into rpenido/fal-3753-library-home-page-bare-bones
rpenido Jun 20, 2024
94f483b
fix: merging nits
rpenido Jun 20, 2024
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ AI_TRANSLATIONS_BASE_URL=''
ENABLE_HOME_PAGE_COURSE_API_V2=false
ENABLE_CHECKLIST_QUALITY=''
ENABLE_GRADING_METHOD_IN_PROBLEMS=false
LIBRARY_MODE="v1 only"
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ AI_TRANSLATIONS_BASE_URL='http://localhost:18760'
ENABLE_HOME_PAGE_COURSE_API_V2=false
ENABLE_CHECKLIST_QUALITY=true
ENABLE_GRADING_METHOD_IN_PROBLEMS=false
LIBRARY_MODE="mixed"
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ INVITE_STUDENTS_EMAIL_TO="[email protected]"
ENABLE_HOME_PAGE_COURSE_API_V2=true
ENABLE_CHECKLIST_QUALITY=true
ENABLE_GRADING_METHOD_IN_PROBLEMS=false
LIBRARY_MODE="mixed"
14 changes: 14 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@ In additional to the standard settings, the following local configuration items
Tagging/Taxonomy functionality.


Feature: Libraries V2/Legacy Tabs
=================================

Configuration
-------------

In additional to the standard settings, the following local configurations can be set to switch between different library modes:

* ``LIBRARY_MODE``: can be set to ``mixed`` (default for development), ``v1 only`` (default for production) and ``v2 only``.

* ``mixed``: Shows 2 tabs, "Libraries" that lists the v2 libraries and "Legacy Libraries" that lists the v1 libraries. When creating a new library in this mode it will create a new v2 library.
* ``v1 only``: Shows only 1 tab, "Libraries" that lists v1 libraries only. When creating a new library in this mode it will create a new v1 library.
* ``v2 only``: Shows only 1 tab, "Libraries" that lists v2 libraries only. When creating a new library in this mode it will create a new v2 library.

Developing
**********

Expand Down
33 changes: 5 additions & 28 deletions src/CourseAuthoringPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,6 @@ import { getCourseAppsApiStatus } from './pages-and-resources/data/selectors';
import { RequestStatus } from './data/constants';
import Loading from './generic/Loading';

const AppHeader = ({
courseNumber, courseOrg, courseTitle, courseId,
}) => (
<Header
courseNumber={courseNumber}
courseOrg={courseOrg}
courseTitle={courseTitle}
courseId={courseId}
/>
);

AppHeader.propTypes = {
courseId: PropTypes.string.isRequired,
courseNumber: PropTypes.string,
courseOrg: PropTypes.string,
courseTitle: PropTypes.string.isRequired,
};

AppHeader.defaultProps = {
courseNumber: null,
courseOrg: null,
};

const CourseAuthoringPage = ({ courseId, children }) => {
const dispatch = useDispatch();

Expand Down Expand Up @@ -74,11 +51,11 @@ const CourseAuthoringPage = ({ courseId, children }) => {
This functionality will be removed in TNL-9591 */}
{inProgress ? !isEditor && <Loading />
: (!isEditor && (
<AppHeader
courseNumber={courseNumber}
courseOrg={courseOrg}
courseTitle={courseTitle}
courseId={courseId}
<Header
number={courseNumber}
org={courseOrg}
title={courseTitle}
contentId={courseId}
/>
)
)}
Expand Down
51 changes: 27 additions & 24 deletions src/header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,58 @@ import { useIntl } from '@edx/frontend-platform/i18n';
import { StudioHeader } from '@edx/frontend-component-header';
import { useToggle } from '@openedx/paragon';

import SearchModal from '../search-modal/SearchModal';
import { SearchModal } from '../search-modal';
import { getContentMenuItems, getSettingMenuItems, getToolsMenuItems } from './utils';
import messages from './messages';

const Header = ({
courseId,
courseOrg,
courseNumber,
courseTitle,
contentId,
org,
number,
title,
isHiddenMainMenu,
isLibrary,
}) => {
const intl = useIntl();

const [isShowSearchModalOpen, openSearchModal, closeSearchModal] = useToggle(false);

const studioBaseUrl = getConfig().STUDIO_BASE_URL;
const meiliSearchEnabled = [true, 'true'].includes(getConfig().MEILISEARCH_ENABLED);
const mainMenuDropdowns = [
const mainMenuDropdowns = !isLibrary ? [
{
id: `${intl.formatMessage(messages['header.links.content'])}-dropdown-menu`,
buttonTitle: intl.formatMessage(messages['header.links.content']),
items: getContentMenuItems({ studioBaseUrl, courseId, intl }),
items: getContentMenuItems({ studioBaseUrl, courseId: contentId, intl }),
},
{
id: `${intl.formatMessage(messages['header.links.settings'])}-dropdown-menu`,
buttonTitle: intl.formatMessage(messages['header.links.settings']),
items: getSettingMenuItems({ studioBaseUrl, courseId, intl }),
items: getSettingMenuItems({ studioBaseUrl, courseId: contentId, intl }),
},
{
id: `${intl.formatMessage(messages['header.links.tools'])}-dropdown-menu`,
buttonTitle: intl.formatMessage(messages['header.links.tools']),
items: getToolsMenuItems({ studioBaseUrl, courseId, intl }),
items: getToolsMenuItems({ studioBaseUrl, courseId: contentId, intl }),
},
];
const outlineLink = `${studioBaseUrl}/course/${courseId}`;
] : [];
const outlineLink = !isLibrary ? `${studioBaseUrl}/course/${contentId}` : `${studioBaseUrl}/library/${contentId}`;

return (
<>
<StudioHeader
org={courseOrg}
number={courseNumber}
title={courseTitle}
org={org}
number={number}
title={title}
isHiddenMainMenu={isHiddenMainMenu}
mainMenuDropdowns={mainMenuDropdowns}
outlineLink={outlineLink}
searchButtonAction={meiliSearchEnabled && openSearchModal}
searchButtonAction={meiliSearchEnabled ? openSearchModal : undefined}
/>
{ meiliSearchEnabled && (
<SearchModal
isOpen={isShowSearchModalOpen}
courseId={courseId}
courseId={isLibrary ? undefined : contentId}
onClose={closeSearchModal}
/>
)}
Expand All @@ -65,19 +66,21 @@ const Header = ({
};

Header.propTypes = {
courseId: PropTypes.string,
courseNumber: PropTypes.string,
courseOrg: PropTypes.string,
courseTitle: PropTypes.string,
contentId: PropTypes.string,
number: PropTypes.string,
org: PropTypes.string,
title: PropTypes.string,
isHiddenMainMenu: PropTypes.bool,
isLibrary: PropTypes.bool,
};

Header.defaultProps = {
courseId: '',
courseNumber: '',
courseOrg: '',
courseTitle: '',
contentId: '',
number: '',
org: '',
title: '',
isHiddenMainMenu: false,
isLibrary: false,
};

export default Header;
6 changes: 6 additions & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { initializeHotjar } from '@edx/frontend-enterprise-hotjar';
import { logError } from '@edx/frontend-platform/logging';
import messages from './i18n';

import { CreateLibrary, LibraryAuthoringPage } from './library-authoring';
import initializeStore from './store';
import CourseAuthoringRoutes from './CourseAuthoringRoutes';
import Head from './head/Head';
Expand Down Expand Up @@ -52,6 +53,10 @@ const App = () => {
createRoutesFromElements(
<Route>
<Route path="/home" element={<StudioHome />} />
<Route path="/libraries" element={<StudioHome />} />
<Route path="/libraries-v1" element={<StudioHome />} />
<Route path="/library/create" element={<CreateLibrary />} />
<Route path="/library/:libraryId/*" element={<LibraryAuthoringPage />} />
<Route path="/course/:courseId/*" element={<CourseAuthoringRoutes />} />
<Route path="/course_rerun/:courseId" element={<CourseRerun />} />
{getConfig().ENABLE_ACCESSIBILITY_PAGE === 'true' && (
Expand Down Expand Up @@ -125,6 +130,7 @@ initialize({
ENABLE_HOME_PAGE_COURSE_API_V2: process.env.ENABLE_HOME_PAGE_COURSE_API_V2 === 'true',
ENABLE_CHECKLIST_QUALITY: process.env.ENABLE_CHECKLIST_QUALITY || 'true',
ENABLE_GRADING_METHOD_IN_PROBLEMS: process.env.ENABLE_GRADING_METHOD_IN_PROBLEMS === 'true',
LIBRARY_MODE: process.env.LIBRARY_MODE || 'v1 only',
}, 'CourseAuthoringConfig');
},
},
Expand Down
29 changes: 29 additions & 0 deletions src/library-authoring/CreateLibrary.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @ts-check
/* eslint-disable react/prop-types */
import React from 'react';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { Container } from '@openedx/paragon';

import Header from '../header';
import SubHeader from '../generic/sub-header/SubHeader';

import messages from './messages';

/* istanbul ignore next This is only a placeholder component */
const CreateLibrary = () => (
<>
<Header isHiddenMainMenu />
<Container size="xl" className="p-4 mt-3">
<SubHeader
title={<FormattedMessage {...messages.createLibrary} />}
/>
<div className="d-flex my-6 justify-content-center">
<FormattedMessage
{...messages.createLibraryTempPlaceholder}
/>
</div>
</Container>
</>
);

export default CreateLibrary;
24 changes: 24 additions & 0 deletions src/library-authoring/EmptyStates.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @ts-check
import React from 'react';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import {
Button, Stack,
} from '@openedx/paragon';
import { Add } from '@openedx/paragon/icons';

import messages from './messages';

export const NoComponents = () => (
<Stack direction="horizontal" gap={3} className="mt-6 justify-content-center">
<FormattedMessage {...messages.noComponents} />
<Button iconBefore={Add}>
<FormattedMessage {...messages.addComponent} />
</Button>
</Stack>
);

export const NoSearchResults = () => (
<div className="d-flex mt-6 justify-content-center">
<FormattedMessage {...messages.noSearchResults} />
</div>
);
Loading