diff --git a/package.json b/package.json index 48270ed454..b59524e96b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "extends @edx/browserslist-config" ], "scripts": { - "build": "sh run-build-for-gh-deps.sh", + "build": "fedx-scripts webpack", "i18n_extract": "fedx-scripts formatjs extract", "stylelint": "stylelint \"plugins/**/*.scss\" \"src/**/*.scss\" \"scss/**/*.scss\" --config .stylelintrc.json", "lint": "npm run stylelint && fedx-scripts eslint --ext .js --ext .jsx --ext .ts --ext .tsx .", diff --git a/run-build-for-gh-deps.sh b/run-build-for-gh-deps.sh deleted file mode 100644 index 996601553f..0000000000 --- a/run-build-for-gh-deps.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -# TODO: This file is temporary and will be removed after testing - -log() { - echo "=============================== $1 ===============================" -} - -run_command() { - echo "\$ $1" - eval $1 -} - -log "Starting deployment script" -run_command "pwd" - -# frontend-component-header -log "Processing frontend-component-header" -run_command "cd node_modules/@edx/" || exit -log "Current directory: $(pwd)" -run_command "rm -rf frontend-component-header" -run_command "mkdir frontend-component-header" || exit -run_command "git clone -b Peter_Kulko/use-SPA-functionality --single-branch https://github.com/raccoongang/frontend-component-header.git frontend-component-header-temp" -run_command "cd frontend-component-header-temp" || exit -log "Current directory: $(pwd)" -run_command "npm ci" || exit -run_command "npm run build" || exit -run_command "cp -r dist ../frontend-component-header/" || exit -run_command "cp -r package.json ../frontend-component-header/" || exit -run_command "cd .." -run_command "rm -rf frontend-component-header-temp" -run_command "cd ../.." || exit -log "Current directory: $(pwd)" - -# webpack -log "Running webpack" -run_command "fedx-scripts webpack" - -log "Deployment script finished." \ No newline at end of file diff --git a/src/course-outline/hooks.jsx b/src/course-outline/hooks.jsx index 9038a222be..739d599432 100644 --- a/src/course-outline/hooks.jsx +++ b/src/course-outline/hooks.jsx @@ -114,7 +114,7 @@ const useCourseOutline = ({ courseId }) => { }; const getUnitUrl = (locator) => { - if (getConfig().ENABLE_UNIT_PAGE === 'true' || waffleFlags.useNewUnitPage) { + if (getConfig().ENABLE_UNIT_PAGE === 'true' && waffleFlags.useNewUnitPage) { return `/course/${courseId}/container/${locator}`; } return `${getConfig().STUDIO_BASE_URL}/container/${locator}`; @@ -122,7 +122,7 @@ const useCourseOutline = ({ courseId }) => { const openUnitPage = (locator) => { const url = getUnitUrl(locator); - if (getConfig().ENABLE_UNIT_PAGE === 'true' || waffleFlags.useNewUnitPage) { + if (getConfig().ENABLE_UNIT_PAGE === 'true' && waffleFlags.useNewUnitPage) { navigate(url); } else { window.location.assign(url); diff --git a/src/data/slice.js b/src/data/slice.js index 6429ea4452..5953d6d3fa 100644 --- a/src/data/slice.js +++ b/src/data/slice.js @@ -20,7 +20,7 @@ const slice = createSlice({ useNewExportPage: true, useNewFilesUploadsPage: true, useNewVideoUploadsPage: true, - useNewCourseOutlinePage: false, + useNewCourseOutlinePage: true, useNewUnitPage: false, useNewCourseTeamPage: true, useNewCertificatesPage: true, diff --git a/src/data/thunks.js b/src/data/thunks.js index 9ef5a8219a..ffd9117380 100644 --- a/src/data/thunks.js +++ b/src/data/thunks.js @@ -33,16 +33,8 @@ export function fetchCourseDetail(courseId) { export function fetchWaffleFlags(courseId) { return async (dispatch) => { dispatch(updateStatus({ courseId, status: RequestStatus.IN_PROGRESS })); - - try { - const waffleFlags = await getWaffleFlags(courseId); - dispatch(updateStatus({ courseId, status: RequestStatus.SUCCESSFUL })); - dispatch(fetchWaffleFlagsSuccess({ waffleFlags })); - } catch (error) { - // If fetching the waffle flags is unsuccessful, - // the pages will still be accessible and display without any issues. - // eslint-disable-next-line no-console - console.error({ courseId, status: RequestStatus.NOT_FOUND }); - } + const waffleFlags = await getWaffleFlags(courseId); + dispatch(updateStatus({ courseId, status: RequestStatus.SUCCESSFUL })); + dispatch(fetchWaffleFlagsSuccess({ waffleFlags })); }; } diff --git a/src/studio-home/card-item/index.tsx b/src/studio-home/card-item/index.tsx index e899c1a70f..4d456c776e 100644 --- a/src/studio-home/card-item/index.tsx +++ b/src/studio-home/card-item/index.tsx @@ -63,9 +63,11 @@ const CardItem: React.FC = ({ } = useSelector(getStudioHomeData); const waffleFlags = useSelector(getWaffleFlags); - const destinationUrl: string = waffleFlags.useNewCourseOutlinePage - ? path ?? url - : path ?? new URL(url, getConfig().STUDIO_BASE_URL).toString(); + const destinationUrl: string = path ?? ( + waffleFlags.useNewCourseOutlinePage + ? url + : new URL(url, getConfig().STUDIO_BASE_URL).toString() + ); const subtitle = isLibraries ? `${org} / ${number}` : `${org} / ${number} / ${run}`; const readOnlyItem = !(lmsLink || rerunLink || url || path); const showActions = !(readOnlyItem || isLibraries); diff --git a/src/utils.js b/src/utils.js index d2ba7e54d3..5dc1b5417c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -4,7 +4,7 @@ import { useMediaQuery } from 'react-responsive'; import * as Yup from 'yup'; import { snakeCase } from 'lodash/string'; import moment from 'moment'; -import { getConfig, getPath } from '@edx/frontend-platform'; +import { getConfig } from '@edx/frontend-platform'; import { RequestStatus } from './data/constants'; import { getCourseAppSettingValue, getLoadingStatus } from './pages-and-resources/data/selectors'; @@ -95,27 +95,12 @@ export function parseArrayOrObjectValues(obj) { return result; } -/** - * Create a correct inner path depend on config PUBLIC_PATH. - * @param {string} checkPath - the internal route path that is validated - * @returns {string} - the correct internal route path - */ -export const createCorrectInternalRoute = (checkPath) => { - let basePath = getPath(getConfig().PUBLIC_PATH); - - if (basePath.endsWith('/')) { - basePath = basePath.slice(0, -1); - } - - return checkPath; -}; - export function getPagePath(courseId, isMfePageEnabled, urlParameter) { if (isMfePageEnabled === 'true') { if (urlParameter === 'tabs') { - return createCorrectInternalRoute(`/course/${courseId}/pages-and-resources`); + return `/course/${courseId}/pages-and-resources`; } - return createCorrectInternalRoute(`/course/${courseId}/${urlParameter}`); + return `/course/${courseId}/${urlParameter}`; } return `${getConfig().STUDIO_BASE_URL}/${urlParameter}/${courseId}`; } diff --git a/src/utils.test.js b/src/utils.test.js index e8dcaef20b..b1f23f266c 100644 --- a/src/utils.test.js +++ b/src/utils.test.js @@ -1,8 +1,5 @@ -import { getConfig, getPath } from '@edx/frontend-platform'; - import { getFileSizeToClosestByte, - createCorrectInternalRoute, convertObjectToSnakeCase, deepConvertingKeysToCamelCase, deepConvertingKeysToSnakeCase, @@ -53,53 +50,6 @@ describe('FilesAndUploads utils', () => { }); }); - describe('createCorrectInternalRoute', () => { - beforeEach(() => { - getConfig.mockReset(); - getPath.mockReset(); - }); - - it('returns the correct internal route when checkPath is not prefixed with basePath', () => { - getConfig.mockReturnValue({ PUBLIC_PATH: 'example.com' }); - getPath.mockReturnValue('/'); - - const checkPath = '/some/path'; - const result = createCorrectInternalRoute(checkPath); - - expect(result).toBe('/some/path'); - }); - - it('returns the input checkPath when it is already prefixed with basePath', () => { - getConfig.mockReturnValue({ PUBLIC_PATH: 'example.com' }); - getPath.mockReturnValue('/course-authoring'); - - const checkPath = '/course-authoring/some/path'; - const result = createCorrectInternalRoute(checkPath); - - expect(result).toBe('/course-authoring/some/path'); - }); - - it('handles basePath ending with a slash correctly', () => { - getConfig.mockReturnValue({ PUBLIC_PATH: 'example.com/' }); - getPath.mockReturnValue('/course-authoring/'); - - const checkPath = '/course-authoring/some/path'; - const result = createCorrectInternalRoute(checkPath); - - expect(result).toBe('/course-authoring/some/path'); - }); - - it('returns checkPath as is when basePath is part of checkPath', () => { - getConfig.mockReturnValue({ PUBLIC_PATH: 'example.com' }); - getPath.mockReturnValue('/example-base/'); - - const checkPath = '/example-base/some/path'; - const result = createCorrectInternalRoute(checkPath); - - expect(result).toBe(checkPath); - }); - }); - describe('convertObjectToSnakeCase', () => { it('converts object keys to snake_case', () => { const input = { firstName: 'John', lastName: 'Doe' };