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

fix: title siteName replaced with platformName #9

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"react": "16.14.0",
"react-dom": "16.14.0",
"react-helmet": "6.1.0",
"react-query": "^3.39.3",
"react-redux": "7.2.9",
"react-router": "5.2.1",
"react-router-dom": "5.3.0",
Expand Down
3 changes: 3 additions & 0 deletions src/assets/place-holders/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/constants/react-query-constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const REACT_QUERY_CONSTANTS = {
queries: {
// Set staleTime to 5 minutes
staleTime: 5 * 60 * 1000,
// Set cacheTime to 60 minutes
cacheTime: 60 * 60 * 1000,
// Set the retry count for queries here
retry: 1, // Set the retry count for queries here
},
mutations: {
retry: 1, // Set the retry count for mutations here
},
};

export default REACT_QUERY_CONSTANTS;
8 changes: 7 additions & 1 deletion src/courseware/course/Course.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import SidebarTriggers from './sidebar/SidebarTriggers';
import { useModel } from '../../generic/model-store';
import { getSessionStorage, setSessionStorage } from '../../data/sessionStorage';

import useGetConfig from '../../hooks/useGetConfig';

const Course = ({
courseId,
sequenceId,
Expand All @@ -44,6 +46,10 @@ const Course = ({
// Below the tabs, above the breadcrumbs alerts (appearing in the order listed here)
const dispatch = useDispatch();

const {
platformName,
} = useGetConfig();

const [firstSectionCelebrationOpen, setFirstSectionCelebrationOpen] = useState(false);
// If streakLengthToCelebrate is populated, that modal takes precedence. Wait til the next load to display
// the weekly goal celebration modal.
Expand Down Expand Up @@ -80,7 +86,7 @@ const Course = ({
return (
<SidebarProvider courseId={courseId} unitId={unitId}>
<Helmet>
<title>{`${pageTitleBreadCrumbs.join(' | ')} | ${getConfig().SITE_NAME}`}</title>
<title>{`${pageTitleBreadCrumbs.join(' | ')} | ${platformName || getConfig().siteName}`}</title>
</Helmet>
<div className="position-relative d-flex align-items-start">
<CourseBreadcrumbs
Expand Down
7 changes: 6 additions & 1 deletion src/courseware/course/course-exit/CourseCelebration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import SocialIcons from '../../social-share/SocialIcons';
import { logClick, logVisit } from './utils';
import { DashboardLink, IdVerificationSupportLink, ProfileLink } from '../../../shared/links';
import CourseRecommendations from './CourseRecommendations';
import useGetConfig from '../../../hooks/useGetConfig';

const LINKEDIN_BLUE = '#2867B2';

Expand Down Expand Up @@ -67,6 +68,10 @@ const CourseCelebration = ({ intl }) => {

const { administrator } = getAuthenticatedUser();

const {
platformName,
} = useGetConfig();

const dashboardLink = <DashboardLink />;
const idVerificationSupportLink = <IdVerificationSupportLink />;
const profileLink = <ProfileLink />;
Expand Down Expand Up @@ -278,7 +283,7 @@ const CourseCelebration = ({ intl }) => {
return (
<>
<Helmet>
<title>{`${intl.formatMessage(messages.congratulationsHeader)} | ${title} | ${getConfig().SITE_NAME}`}</title>
<title>{`${intl.formatMessage(messages.congratulationsHeader)} | ${title} | ${platformName || getConfig().siteName}`}</title>
</Helmet>
<div className="row w-100 mx-0 mb-4 px-5 py-4 border border-light">
<div className="col-12 p-0 h2 text-center">
Expand Down
7 changes: 6 additions & 1 deletion src/courseware/course/course-exit/CourseInProgress.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import CatalogSuggestion from './CatalogSuggestion';
import DashboardFootnote from './DashboardFootnote';
import messages from './messages';
import { logClick, logVisit } from './utils';
import useGetConfig from '../../../hooks/useGetConfig';

const CourseInProgress = ({ intl }) => {
const { courseId } = useSelector(state => state.courseware);
Expand All @@ -23,6 +24,10 @@ const CourseInProgress = ({ intl }) => {
} = useModel('courseHomeMeta', courseId);
const { administrator } = getAuthenticatedUser();

const {
platformName,
} = useGetConfig();

// Get dates tab link for 'view course schedule' button
const datesTab = tabs.find(tab => tab.slug === 'dates');
const datesTabLink = datesTab && datesTab.url;
Expand All @@ -32,7 +37,7 @@ const CourseInProgress = ({ intl }) => {
return (
<>
<Helmet>
<title>{`${intl.formatMessage(messages.endOfCourseTitle)} | ${title} | ${getConfig().SITE_NAME}`}</title>
<title>{`${intl.formatMessage(messages.endOfCourseTitle)} | ${title} | ${platformName || getConfig().siteName}`}</title>
</Helmet>
<div className="row w-100 mx-0 mb-4 px-5 py-4 border border-light justify-content-center">
<div className="col-12 p-0 h2 text-center">
Expand Down
7 changes: 6 additions & 1 deletion src/courseware/course/course-exit/CourseNonPassing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import CatalogSuggestion from './CatalogSuggestion';
import DashboardFootnote from './DashboardFootnote';
import messages from './messages';
import { logClick, logVisit } from './utils';
import useGetConfig from '../../../hooks/useGetConfig';

const CourseNonPassing = ({ intl }) => {
const { courseId } = useSelector(state => state.courseware);
Expand All @@ -23,6 +24,10 @@ const CourseNonPassing = ({ intl }) => {
} = useModel('courseHomeMeta', courseId);
const { administrator } = getAuthenticatedUser();

const {
platformName,
} = useGetConfig();

// Get progress tab link for 'view grades' button
const progressTab = tabs.find(tab => tab.slug === 'progress');
const progressLink = progressTab && progressTab.url;
Expand All @@ -32,7 +37,7 @@ const CourseNonPassing = ({ intl }) => {
return (
<>
<Helmet>
<title>{`${intl.formatMessage(messages.endOfCourseTitle)} | ${title} | ${getConfig().SITE_NAME}`}</title>
<title>{`${intl.formatMessage(messages.endOfCourseTitle)} | ${title} | ${platformName || getConfig().siteName}`}</title>
</Helmet>
<div className="row w-100 mx-0 mb-4 px-5 py-4 border border-light justify-content-center">
<div className="col-12 p-0 h2 text-center">
Expand Down
39 changes: 39 additions & 0 deletions src/hooks/useGetConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { getConfig } from '@edx/frontend-platform';
import { useQuery } from 'react-query';
import faviconPlaceholder from '../assets/place-holders/favicon.svg';

const useGetConfig = () => {
const fetchConfig = async ({ baseURL, instanceConfigAPIUrl }) => {
const response = await fetch(`${baseURL}${instanceConfigAPIUrl}`);
const result = await response.json();
return result;
};

const { data, isLoading, isError } = useQuery(
'headerLogo',
() => fetchConfig({
baseURL: getConfig().LMS_BASE_URL,
instanceConfigAPIUrl: getConfig().AC_INSTANCE_CONFIG_API_URL,
}),
{
enabled:
!!getConfig().LMS_BASE_URL && !!getConfig().AC_INSTANCE_CONFIG_API_URL,
},
);
const faviconVersion = Date.now(); // Update this version number when the favicon updates
const favicon = data?.favicon
? `${data.favicon}?v=${faviconVersion}`
: faviconPlaceholder;
return {
headerLogo: data?.logo,
hasBilling: data?.has_billing,
favicon,
platformName: data?.platform_name,
gtm: data?.gtm,
isTPAOnly: data?.use_tpa_only,
TPAQueryparam: data?.tpa_queryparam,
loading: isLoading,
isError,
};
};
export default useGetConfig;
126 changes: 68 additions & 58 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { Switch } from 'react-router-dom';

import { messages as footerMessages } from '@edx/frontend-component-footer';
import { messages as headerMessages } from '@edx/frontend-component-header';
import { QueryClient, QueryClientProvider } from 'react-query';
import REACT_QUERY_CONSTANTS from './constants/react-query-constants';
import { fetchDiscussionTab, fetchLiveTab } from './course-home/data/thunks';
import DiscussionTab from './course-home/discussion-tab/DiscussionTab';

Expand All @@ -38,67 +40,75 @@ import CourseAccessErrorPage from './generic/CourseAccessErrorPage';
import DecodePageRoute from './decode-page-route';

subscribe(APP_READY, () => {
const queryClient = new QueryClient({
defaultOptions: {
...REACT_QUERY_CONSTANTS,
},
});

ReactDOM.render(
<AppProvider store={initializeStore()}>
<PathFixesProvider>
<NoticesProvider>
<UserMessagesProvider>
<Switch>
<PageRoute exact path="/goal-unsubscribe/:token" component={GoalUnsubscribe} />
<PageRoute path="/redirect" component={CoursewareRedirectLandingPage} />
<DecodePageRoute path="/course/:courseId/access-denied" component={CourseAccessErrorPage} />
<DecodePageRoute path="/course/:courseId/home">
<TabContainer tab="outline" fetch={fetchOutlineTab} slice="courseHome">
<OutlineTab />
</TabContainer>
</DecodePageRoute>
<DecodePageRoute path="/course/:courseId/live">
<TabContainer tab="lti_live" fetch={fetchLiveTab} slice="courseHome">
<LiveTab />
</TabContainer>
</DecodePageRoute>
<DecodePageRoute path="/course/:courseId/dates">
<TabContainer tab="dates" fetch={fetchDatesTab} slice="courseHome">
<DatesTab />
</TabContainer>
</DecodePageRoute>
<DecodePageRoute path="/course/:courseId/discussion/:path*">
<TabContainer tab="discussion" fetch={fetchDiscussionTab} slice="courseHome">
<DiscussionTab />
</TabContainer>
</DecodePageRoute>
<DecodePageRoute
path={[
'/course/:courseId/progress/:targetUserId/',
'/course/:courseId/progress',
]}
render={({ match }) => (
<TabContainer
tab="progress"
fetch={(courseId) => fetchProgressTab(courseId, match.params.targetUserId)}
slice="courseHome"
>
<ProgressTab />
<QueryClientProvider client={queryClient}>
<PathFixesProvider>
<NoticesProvider>
<UserMessagesProvider>
<Switch>
<PageRoute exact path="/goal-unsubscribe/:token" component={GoalUnsubscribe} />
<PageRoute path="/redirect" component={CoursewareRedirectLandingPage} />
<DecodePageRoute path="/course/:courseId/access-denied" component={CourseAccessErrorPage} />
<DecodePageRoute path="/course/:courseId/home">
<TabContainer tab="outline" fetch={fetchOutlineTab} slice="courseHome">
<OutlineTab />
</TabContainer>
</DecodePageRoute>
<DecodePageRoute path="/course/:courseId/live">
<TabContainer tab="lti_live" fetch={fetchLiveTab} slice="courseHome">
<LiveTab />
</TabContainer>
</DecodePageRoute>
<DecodePageRoute path="/course/:courseId/dates">
<TabContainer tab="dates" fetch={fetchDatesTab} slice="courseHome">
<DatesTab />
</TabContainer>
</DecodePageRoute>
<DecodePageRoute path="/course/:courseId/discussion/:path*">
<TabContainer tab="discussion" fetch={fetchDiscussionTab} slice="courseHome">
<DiscussionTab />
</TabContainer>
</DecodePageRoute>
<DecodePageRoute
path={[
'/course/:courseId/progress/:targetUserId/',
'/course/:courseId/progress',
]}
render={({ match }) => (
<TabContainer
tab="progress"
fetch={(courseId) => fetchProgressTab(courseId, match.params.targetUserId)}
slice="courseHome"
>
<ProgressTab />
</TabContainer>
)}
/>
<DecodePageRoute path="/course/:courseId/course-end">
<TabContainer tab="courseware" fetch={fetchCourse} slice="courseware">
<CourseExit />
</TabContainer>
)}
/>
<DecodePageRoute path="/course/:courseId/course-end">
<TabContainer tab="courseware" fetch={fetchCourse} slice="courseware">
<CourseExit />
</TabContainer>
</DecodePageRoute>
<DecodePageRoute
path={[
'/course/:courseId/:sequenceId/:unitId',
'/course/:courseId/:sequenceId',
'/course/:courseId',
]}
component={CoursewareContainer}
/>
</Switch>
</UserMessagesProvider>
</NoticesProvider>
</PathFixesProvider>
</DecodePageRoute>
<DecodePageRoute
path={[
'/course/:courseId/:sequenceId/:unitId',
'/course/:courseId/:sequenceId',
'/course/:courseId',
]}
component={CoursewareContainer}
/>
</Switch>
</UserMessagesProvider>
</NoticesProvider>
</PathFixesProvider>
</QueryClientProvider>
</AppProvider>,
document.getElementById('root'),
);
Expand Down
7 changes: 6 additions & 1 deletion src/tab-page/LoadedTabPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import useEnrollmentAlert from '../alerts/enrollment-alert';
import useLogistrationAlert from '../alerts/logistration-alert';

import ProductTours from '../product-tours/ProductTours';
import useGetConfig from '../hooks/useGetConfig';

const LoadedTabPage = ({
activeTabSlug,
Expand All @@ -36,6 +37,10 @@ const LoadedTabPage = ({
const logistrationAlert = useLogistrationAlert(courseId);
const enrollmentAlert = useEnrollmentAlert(courseId);

const {
platformName,
} = useGetConfig();

const activeTab = tabs.filter(tab => tab.slug === activeTabSlug)[0];

const streakLengthToCelebrate = celebrations && celebrations.streakLengthToCelebrate;
Expand All @@ -51,7 +56,7 @@ const LoadedTabPage = ({
org={org}
/>
<Helmet>
<title>{`${activeTab ? `${activeTab.title} | ` : ''}${title} | ${getConfig().SITE_NAME}`}</title>
<title>{`${activeTab ? `${activeTab.title} | ` : ''}${title} | ${platformName || getConfig().siteName}`}</title>
</Helmet>
{originalUserIsStaff && (
<InstructorToolbar
Expand Down
Loading