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

[FC-0059] Components tab #41

Closed
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
81 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
0078c0e
feat: Initial structure of ComponentCard
ChrisChV Jun 13, 2024
388c40e
fix: fixes from review
rpenido Jun 13, 2024
7d6096e
fix: fix default parameter syntax
rpenido Jun 14, 2024
19b2935
feat: Connect TagCount, Colors and Icons with library components card
ChrisChV Jun 17, 2024
c87c481
feat: Infinite scroll implemented on Components tab
ChrisChV Jun 18, 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
7560fa2
style: Style nits on card component
ChrisChV 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
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
b455f97
fix: change version to slug in header
rpenido Jun 20, 2024
3ae6fe8
fix: header outline link for libraries
rpenido Jun 20, 2024
bd12510
style: Add fetchNextPage to infinite scroll useEffect
ChrisChV Jun 20, 2024
d611d29
feat: Variant added to LibraryComponents to show full components or a…
ChrisChV Jun 20, 2024
499aced
style: Nits on lints and code
ChrisChV Jun 20, 2024
da1c2e0
refactor: Create block-type-utils with block type constants
ChrisChV Jun 20, 2024
c8bc5fc
fix: Issues on course-unit tests
ChrisChV Jun 21, 2024
0843a1e
refactor: Calculate tagCount in LibraryComponents instead on serach i…
ChrisChV Jun 21, 2024
e972fb0
Merge branch 'master' into rpenido/fal-3753-library-home-page-bare-bones
rpenido Jun 21, 2024
55acb06
refactor: test renaming to ts
rpenido Jun 21, 2024
a1a0ad8
refactor: renaming files js -> ts
rpenido Jun 24, 2024
87358b7
fix: update typescript code
rpenido Jun 24, 2024
0b4e90e
Merge branch 'master' into rpenido/fal-3753-library-home-page-bare-bones
rpenido Jun 24, 2024
5687b76
test: Added for LibraryComponents
ChrisChV Jun 24, 2024
51d36ce
fix: remove @ts-check
rpenido Jun 25, 2024
fbd418d
fix: remove unused file
rpenido Jun 25, 2024
8d9b86b
chore: Fix merge conflicts
ChrisChV Jun 26, 2024
dee7c0b
Merge branch 'master' into rpenido/fal-3753-library-home-page-bare-bones
rpenido Jun 30, 2024
2a5d42b
fix: optional parameters
rpenido Jun 30, 2024
62fe7f5
chore: trigger CI
rpenido Jun 30, 2024
31012df
refactor: Migrate block-type-utils to TS
ChrisChV Jul 1, 2024
1534b61
chore: Fix merge conflicts
ChrisChV Jul 1, 2024
42f2666
test: Fixt LibraryAuthoringPage test
ChrisChV Jul 1, 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
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
2 changes: 1 addition & 1 deletion src/course-unit/add-component/AddComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useIntl } from '@edx/frontend-platform/i18n';
import { useToggle } from '@openedx/paragon';

import { getCourseSectionVertical } from '../data/selectors';
import { COMPONENT_TYPES } from '../constants';
import { COMPONENT_TYPES } from '../../generic/block-type-utils/constants';
import ComponentModalView from './add-component-modals/ComponentModalView';
import AddComponentButton from './add-component-btn';
import messages from './messages';
Expand Down
2 changes: 1 addition & 1 deletion src/course-unit/add-component/AddComponent.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { executeThunk } from '../../utils';
import { fetchCourseSectionVerticalData } from '../data/thunk';
import { getCourseSectionVerticalApiUrl } from '../data/api';
import { courseSectionVerticalMock } from '../__mocks__';
import { COMPONENT_TYPES } from '../constants';
import { COMPONENT_TYPES } from '../../generic/block-type-utils/constants';
import AddComponent from './AddComponent';
import messages from './messages';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import { Icon } from '@openedx/paragon';
import { EditNote as EditNoteIcon } from '@openedx/paragon/icons';

import { COMPONENT_TYPES, COMPONENT_TYPE_ICON_MAP } from '../../constants';
import { COMPONENT_TYPES, COMPONENT_TYPE_ICON_MAP } from '../../../generic/block-type-utils/constants';

const AddComponentIcon = ({ type }) => {
const icon = COMPONENT_TYPE_ICON_MAP[type] || EditNoteIcon;
Expand Down
47 changes: 0 additions & 47 deletions src/course-unit/constants.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,6 @@
import {
BackHand as BackHandIcon,
BookOpen as BookOpenIcon,
Edit as EditIcon,
EditNote as EditNoteIcon,
FormatListBulleted as FormatListBulletedIcon,
HelpOutline as HelpOutlineIcon,
LibraryAdd as LibraryIcon,
Lock as LockIcon,
QuestionAnswerOutline as QuestionAnswerOutlineIcon,
Science as ScienceIcon,
TextFields as TextFieldsIcon,
VideoCamera as VideoCameraIcon,
} from '@openedx/paragon/icons';

import messages from './sidebar/messages';
import addComponentMessages from './add-component/messages';

export const UNIT_ICON_TYPES = ['video', 'other', 'vertical', 'problem', 'lock'];

export const COMPONENT_TYPES = {
advanced: 'advanced',
discussion: 'discussion',
library: 'library',
html: 'html',
openassessment: 'openassessment',
problem: 'problem',
video: 'video',
dragAndDrop: 'drag-and-drop-v2',
};

export const TYPE_ICONS_MAP = {
video: VideoCameraIcon,
other: BookOpenIcon,
vertical: FormatListBulletedIcon,
problem: EditIcon,
lock: LockIcon,
};

export const COMPONENT_TYPE_ICON_MAP = {
[COMPONENT_TYPES.advanced]: ScienceIcon,
[COMPONENT_TYPES.discussion]: QuestionAnswerOutlineIcon,
[COMPONENT_TYPES.library]: LibraryIcon,
[COMPONENT_TYPES.html]: TextFieldsIcon,
[COMPONENT_TYPES.openassessment]: EditNoteIcon,
[COMPONENT_TYPES.problem]: HelpOutlineIcon,
[COMPONENT_TYPES.video]: VideoCameraIcon,
[COMPONENT_TYPES.dragAndDrop]: BackHandIcon,
};

export const getUnitReleaseStatus = (intl) => ({
release: intl.formatMessage(messages.releaseStatusTitle),
released: intl.formatMessage(messages.releasedStatusTitle),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import { Icon } from '@openedx/paragon';
import { BookOpen as BookOpenIcon } from '@openedx/paragon/icons';

import { TYPE_ICONS_MAP, UNIT_ICON_TYPES } from '../../constants';
import { TYPE_ICONS_MAP, UNIT_ICON_TYPES } from '../../../generic/block-type-utils/constants';

const UnitIcon = ({ type }) => {
const icon = TYPE_ICONS_MAP[type] || BookOpenIcon;
Expand Down
2 changes: 1 addition & 1 deletion src/course-unit/course-xblock/CourseXBlock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import SortableItem from '../../generic/drag-helper/SortableItem';
import { scrollToElement } from '../../course-outline/utils';
import { COURSE_BLOCK_NAMES } from '../../constants';
import { copyToClipboard } from '../../generic/data/thunks';
import { COMPONENT_TYPES } from '../constants';
import { COMPONENT_TYPES } from '../../generic/block-type-utils/constants';
import XBlockMessages from './xblock-messages/XBlockMessages';
import messages from './messages';

Expand Down
3 changes: 2 additions & 1 deletion src/course-unit/course-xblock/CourseXBlock.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { getCourseSectionVerticalApiUrl, getXBlockBaseApiUrl } from '../data/api
import { fetchCourseSectionVerticalData } from '../data/thunk';
import { executeThunk } from '../../utils';
import { getCourseId } from '../data/selectors';
import { PUBLISH_TYPES, COMPONENT_TYPES } from '../constants';
import { PUBLISH_TYPES } from '../constants';
import { COMPONENT_TYPES } from '../../generic/block-type-utils/constants';
import { courseSectionVerticalMock, courseVerticalChildrenMock } from '../__mocks__';
import CourseXBlock from './CourseXBlock';
import messages from './messages';
Expand Down
68 changes: 68 additions & 0 deletions src/generic/block-type-utils/constants.js
ChrisChV marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import {
BackHand as BackHandIcon,
BookOpen as BookOpenIcon,
Edit as EditIcon,
EditNote as EditNoteIcon,
FormatListBulleted as FormatListBulletedIcon,
HelpOutline as HelpOutlineIcon,
LibraryAdd as LibraryIcon,
Lock as LockIcon,
QuestionAnswerOutline as QuestionAnswerOutlineIcon,
Science as ScienceIcon,
TextFields as TextFieldsIcon,
VideoCamera as VideoCameraIcon,
Folder,
} from '@openedx/paragon/icons';

export const UNIT_ICON_TYPES = ['video', 'other', 'vertical', 'problem', 'lock'];

export const COMPONENT_TYPES = {
advanced: 'advanced',
discussion: 'discussion',
library: 'library',
html: 'html',
openassessment: 'openassessment',
problem: 'problem',
video: 'video',
dragAndDrop: 'drag-and-drop-v2',
};

export const TYPE_ICONS_MAP = {
video: VideoCameraIcon,
other: BookOpenIcon,
vertical: FormatListBulletedIcon,
problem: EditIcon,
lock: LockIcon,
};

export const COMPONENT_TYPE_ICON_MAP = {
[COMPONENT_TYPES.advanced]: ScienceIcon,
[COMPONENT_TYPES.discussion]: QuestionAnswerOutlineIcon,
[COMPONENT_TYPES.library]: LibraryIcon,
[COMPONENT_TYPES.html]: TextFieldsIcon,
[COMPONENT_TYPES.openassessment]: EditNoteIcon,
[COMPONENT_TYPES.problem]: HelpOutlineIcon,
[COMPONENT_TYPES.video]: VideoCameraIcon,
[COMPONENT_TYPES.dragAndDrop]: BackHandIcon,
};

export const STRUCTURAL_TYPE_ICONS = {
vertical: TYPE_ICONS_MAP.vertical,
sequential: Folder,
chapter: Folder,
};

export const COMPONENT_TYPE_COLOR_MAP = {
[COMPONENT_TYPES.advanced]: 'bg-other',
[COMPONENT_TYPES.discussion]: 'bg-component',
[COMPONENT_TYPES.library]: 'bg-component',
[COMPONENT_TYPES.html]: 'bg-html',
[COMPONENT_TYPES.openassessment]: 'bg-component',
[COMPONENT_TYPES.problem]: 'bg-component',
[COMPONENT_TYPES.video]: 'bg-video',
[COMPONENT_TYPES.dragAndDrop]: 'bg-component',
vertical: 'bg-vertical',
sequential: 'bg-component',
chapter: 'bg-component',
collection: 'bg-collection',
};
19 changes: 19 additions & 0 deletions src/generic/block-type-utils/index.jsx
ChrisChV marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// @ts-check
import {
Article,
} from '@openedx/paragon/icons';
import {
COMPONENT_TYPE_ICON_MAP,
STRUCTURAL_TYPE_ICONS,
COMPONENT_TYPE_COLOR_MAP,
} from './constants';

/** @param {string} blockType */
export function getItemIcon(blockType) {
return STRUCTURAL_TYPE_ICONS[blockType] ?? COMPONENT_TYPE_ICON_MAP[blockType] ?? Article;
}

/** @param {string} blockType */
export function getComponentColor(blockType) {
return COMPONENT_TYPE_COLOR_MAP[blockType] ?? 'bg-component';
}
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}` : `/course-authoring/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;
5 changes: 3 additions & 2 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ 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';
import { StudioHome } from './studio-home';
import LibraryV2Placeholder from './studio-home/tabs-section/LibraryV2Placeholder';
import CourseRerun from './course-rerun';
import { TaxonomyLayout, TaxonomyDetailPage, TaxonomyListPage } from './taxonomy';
import { ContentTagsDrawer } from './content-tags-drawer';
Expand Down Expand Up @@ -55,7 +55,8 @@ const App = () => {
<Route path="/home" element={<StudioHome />} />
<Route path="/libraries" element={<StudioHome />} />
<Route path="/libraries-v1" element={<StudioHome />} />
<Route path="/library/:libraryId" element={<LibraryV2Placeholder />} />
<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
1 change: 1 addition & 0 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
@import "search-modal/SearchModal";
@import "certificates/scss/Certificates";
@import "group-configurations/GroupConfigurations";
@import "library-authoring";

// To apply the glow effect to the selected Section/Subsection, in the Course Outline
div.row:has(> div > div.highlight) {
Expand Down
Loading
Loading