Skip to content

Commit

Permalink
feat: Add LIBRARY_MODE config variable
Browse files Browse the repository at this point in the history
This is to switch between different library modes.
  • Loading branch information
yusuf-musleh committed May 29, 2024
1 parent 418e561 commit 4e52f8f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 10 deletions.
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"
16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,22 @@ In additional to the standard settings, the following local configuration items
Tagging/Taxonomy functionality.


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

.. image:: ./docs/readme-images/feature-v2-and-legacy-libs.png

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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,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
5 changes: 2 additions & 3 deletions src/studio-home/StudioHome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const StudioHome = ({ intl }) => {
dispatch,
} = useStudioHome(isPaginationCoursesEnabled);

// TODO: this should be a flag in the backend
const LIB_MODE = 'mixed';
const libMode = getConfig().LIBRARY_MODE;

const {
userIsActive,
Expand Down Expand Up @@ -82,7 +81,7 @@ const StudioHome = ({ intl }) => {
}

let libraryHref = `${getConfig().STUDIO_BASE_URL}/home_library`;
if (isMixedOrV2LibrariesMode(LIB_MODE)) {
if (isMixedOrV2LibrariesMode(libMode)) {
libraryHref = `${libraryAuthoringMfeUrl}create`;
}

Expand Down
11 changes: 4 additions & 7 deletions src/studio-home/tabs-section/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ const TabsSection = ({
isPaginationCoursesEnabled,
}) => {
const navigate = useNavigate();

// TODO: this should be a flag in the backend
const LIB_MODE = 'mixed';

const libMode = getConfig().LIBRARY_MODE;
const TABS_LIST = {
courses: 'courses',
libraries: 'libraries',
Expand Down Expand Up @@ -94,7 +91,7 @@ const TabsSection = ({
}

if (librariesEnabled) {
if (isMixedOrV2LibrariesMode(LIB_MODE)) {
if (isMixedOrV2LibrariesMode(libMode)) {
tabs.push(
<Tab
key={TABS_LIST.libraries}
Expand All @@ -106,13 +103,13 @@ const TabsSection = ({
);
}

if (isMixedOrV1LibrariesMode(LIB_MODE)) {
if (isMixedOrV1LibrariesMode(libMode)) {
tabs.push(
<Tab
key={TABS_LIST.legacyLibraries}
eventKey={TABS_LIST.legacyLibraries}
title={intl.formatMessage(
LIB_MODE === 'v1 only'
libMode === 'v1 only'
? messages.librariesTabTitle
: messages.legacyLibrariesTabTitle,
)}
Expand Down

0 comments on commit 4e52f8f

Please sign in to comment.