Skip to content

Commit

Permalink
Move old and new pages, refactor _new out of everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
Redande committed Oct 7, 2023
1 parent e7028b2 commit 35e8b23
Show file tree
Hide file tree
Showing 130 changed files with 1,446 additions and 1,411 deletions.
2 changes: 1 addition & 1 deletion frontend/components/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function Breadcrumbs() {
const router = useRouter()
const { breadcrumbs } = useBreadcrumbContext()

const isHomePage = !!RegExp(/^(?:\/_new)?\/?$/).exec(
const isHomePage = !!RegExp(/^(?:\/_old)?\/?$/).exec(
router?.asPath?.replace(/#(.*)/, ""),
)

Expand Down
2 changes: 1 addition & 1 deletion frontend/components/CreateAccountForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class CreateAccountForm extends Component<CreateAccountFormProps> {
const t = getSignUpTranslator(
(this.props.router.locale ?? "fi") as LanguageKey,
)
const baseUrl = this.props.router.asPath.includes("_new") ? "/_new" : ""
const baseUrl = this.props.router.asPath.includes("_old") ? "/_old" : ""

return (
<StyledPaper>
Expand Down
7 changes: 6 additions & 1 deletion frontend/components/CreateEmailTemplateDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import ErrorMessage from "./ErrorMessage"
import CustomSnackbar from "/components/CustomSnackbar"
import Spinner from "/components/Spinner"
import useIsOld from "/hooks/useIsOld"
import { EmailTemplateType } from "/types/emailTemplates"
import { isDefinedAndNotEmpty } from "/util/guards"

Expand Down Expand Up @@ -60,6 +61,9 @@ const CreateEmailTemplateDialog = ({
UpdateOrganizationEmailTemplateDocument,
)

const isOld = useIsOld()
const baseUrl = isOld ? "/_old" : "/admin"

const handleDialogClickOpen = () => {
setOpenDialog(true)
}
Expand Down Expand Up @@ -140,7 +144,8 @@ const CreateEmailTemplateDialog = ({
}

const url =
"/email-templates/" + addEmailTemplateData!.addEmailTemplate!.id
`${baseUrl}/email-templates/` +
addEmailTemplateData!.addEmailTemplate!.id
Router.push(url)
} catch {
setIsErrorSnackbarOpen(true)
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/Dashboard/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ButtonWithPaddingAndMargin as StyledButton } from "/components/Buttons/
import CourseImage from "/components/CourseImage"
import { CardTitle } from "/components/Text/headers"
import { useFilterContext } from "/contexts/FilterContext"
import useIsNew from "/hooks/useIsNew"
import useIsOld from "/hooks/useIsOld"
import { useTranslator } from "/hooks/useTranslator"
import CoursesTranslations from "/translations/courses"
import { formatDateTime } from "/util/dataFormatFunctions"
Expand Down Expand Up @@ -174,8 +174,8 @@ interface CourseCardProps {

const CourseCard = ({ course, loading, isNew }: CourseCardProps) => {
const t = useTranslator(CoursesTranslations)
const isNewLayout = useIsNew()
const baseUrl = isNewLayout ? "/_new/admin" : ""
const isOldLayout = useIsOld()
const baseUrl = isOldLayout ? "/_old" : "/admin"

const { onStatusClick } = useFilterContext()
const courseFound = !loading && !!course
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/Dashboard/StudyModules/ModuleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { css, styled } from "@mui/material/styles"
import { ButtonWithPaddingAndMargin } from "/components/Buttons/ButtonWithPaddingAndMargin"
import LoaderImage from "/components/LoaderImage"
import { ClickableDiv } from "/components/Surfaces/ClickableCard"
import useIsNew from "/hooks/useIsNew"
import useIsOld from "/hooks/useIsOld"
import { useTranslator } from "/hooks/useTranslator"
import StudyModulesTranslations from "/translations/study-modules"

Expand Down Expand Up @@ -118,8 +118,8 @@ interface ModuleCardProps {

function ModuleCard({ studyModule, image, loading }: ModuleCardProps) {
const t = useTranslator(StudyModulesTranslations)
const isNew = useIsNew()
const baseUrl = isNew ? "/_new/admin" : ""
const isOld = useIsOld()
const baseUrl = isOld ? "/_old" : "/admin"
const moduleFound = !loading && studyModule
const moduleNotFound = !loading && !studyModule

Expand Down
6 changes: 3 additions & 3 deletions frontend/components/Dashboard/Users/Search/MobileGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { styled } from "@mui/material/styles"
import InfoRow from "../InfoRow"
import Pagination from "./Pagination"
import UserSearchContext from "/contexts/UserSearchContext"
import useIsNew from "/hooks/useIsNew"
import useIsOld from "/hooks/useIsOld"
import { useTranslator } from "/hooks/useTranslator"
import UsersTranslations from "/translations/users"

Expand Down Expand Up @@ -114,8 +114,8 @@ interface DataCardProps {
}

const DataCard = ({ row }: DataCardProps) => {
const isNew = useIsNew()
const baseUrl = isNew ? "/_new/admin" : ""
const isOld = useIsOld()
const baseUrl = isOld ? "/_old" : "/admin"
const t = useTranslator(UsersTranslations)

const fields = useMemo(() => {
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/Dashboard/Users/Search/WideGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { styled } from "@mui/material/styles"

import Pagination from "./Pagination"
import UserSearchContext from "/contexts/UserSearchContext"
import useIsNew from "/hooks/useIsNew"
import useIsOld from "/hooks/useIsOld"
import { useTranslator } from "/hooks/useTranslator"
import UsersTranslations from "/translations/users"

Expand Down Expand Up @@ -96,8 +96,8 @@ const WideGrid = () => {
}

const RenderResults = () => {
const isNew = useIsNew()
const baseUrl = isNew ? "/_new/admin" : ""
const isOld = useIsOld()
const baseUrl = isOld ? "/_old" : "/admin"
const t = useTranslator(UsersTranslations)
const { data, loading, meta } = useContext(UserSearchContext)
const isVeryWide = useMediaQuery("(min-width: 1200px)")
Expand Down
8 changes: 4 additions & 4 deletions frontend/components/DynamicLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { memo } from "react"

import dynamic from "next/dynamic"

const OriginalLayout = dynamic(() => import("../pages/_layout"), {
const OriginalLayout = dynamic(() => import("../pages/_old/_layout"), {
loading: () => null,
})
const NewLayout = dynamic(() => import("../pages/_new/_layout"), {
const NewLayout = dynamic(() => import("../pages/_layout"), {
loading: () => null,
})

const DynamicLayout = ({ isNew, ...props }: any) => {
return isNew ? <NewLayout {...props} /> : <OriginalLayout {...props} />
const DynamicLayout = ({ isOld, ...props }: any) => {
return isOld ? <OriginalLayout {...props} /> : <NewLayout {...props} />
}

export default memo(DynamicLayout)
4 changes: 2 additions & 2 deletions frontend/components/HeaderBar/UserOptionsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ const UserOptionsMenu = () => {
return (
<>
<HeaderMenuButton
href="/sign-in"
href="/_old/sign-in"
color="inherit"
variant="text"
onClick={onLoginClick}
>
{t("loginShort")}
</HeaderMenuButton>
<HeaderMenuButton href="/sign-up" color="inherit" variant="text">
<HeaderMenuButton href="/_old/sign-up" color="inherit" variant="text">
{t("signUp")}
</HeaderMenuButton>
</>
Expand Down
8 changes: 4 additions & 4 deletions frontend/components/NewLayout/Admin/Links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export const Links = () => {

return (
<Container>
<Link href="/_new/admin/courses">{t("courses")}</Link>
<Link href="/_new/admin/study-modules">{t("modules")}</Link>
<Link href="/_new/admin/email-templates">{t("emailTemplates")}</Link>
<Link href="/_new/admin/users/search">{t("userSearch")}</Link>
<Link href="/admin/courses">{t("courses")}</Link>
<Link href="/admin/study-modules">{t("modules")}</Link>
<Link href="/admin/email-templates">{t("emailTemplates")}</Link>
<Link href="/admin/users/search">{t("userSearch")}</Link>
</Container>
)
}
2 changes: 1 addition & 1 deletion frontend/components/NewLayout/Courses/CourseGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ function CourseGrid() {
if (
!course.name
.toLocaleLowerCase(locale)
.includes(searchString.toLocaleLowerCase(locale)) ||
.includes(searchString.toLocaleLowerCase(locale)) &&
!course.description
?.toLocaleLowerCase(locale)
.includes(searchString.toLocaleLowerCase(locale))
Expand Down
10 changes: 1 addition & 9 deletions frontend/components/NewLayout/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,7 @@ const Footer = () => {
</FooterLink>
)}
<FooterBaseCopy>
This site is maintained by the{" "}
<Link
aria-label="Rage research group homepage"
href="https://www.helsinki.fi/en/researchgroups/data-driven-education"
target="_blank"
rel="noopener noreferrer"
>
RAGE research group
</Link>
This site is maintained by the University of Helsinki's MOOC center
</FooterBaseCopy>
</FooterBaseRight>
</FooterBase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const ModuleCard = ({
<CardBody>
<CardDescription>{description}</CardDescription>
<CardActions>
<CTALink href={`/_new/study-modules/#${slug}`}>
<CTALink href={`/study-modules/#${slug}`}>
{t("moduleInformation")}
</CTALink>
</CardActions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function ModuleNavigation() {
<Introduction title={t("studyModulesTitle")} />
<ContentWrapper>
<ModuleNaviList modules={data?.study_modules} loading={loading} />
<CTAButton href="/_new/study-modules">{t("showAllModules")}</CTAButton>
<CTAButton href="/study-modules">{t("showAllModules")}</CTAButton>
</ContentWrapper>
</section>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function SelectedCourses() {
<CommonCourseCard key={course.id} course={course} />
))}
</CoursesGrid>
<CTAButton href="/_new/courses">{t("showAllCourses")}</CTAButton>
<CTAButton href="/courses">{t("showAllCourses")}</CTAButton>
</ContentWrapper>
</section>
)
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/NewLayout/Header/MoocLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const MoocLogoLink = styled(Link)`
}
`
const MoocLogo = () => (
<MoocLogoLink href="/_new" aria-label="MOOC.fi homepage">
<MoocLogoLink href="/" aria-label="MOOC.fi homepage">
<MoocLogoFilled sx={{ fontSize: "3rem", marginRight: "0.5rem" }} />
<MoocLogoText>MOOC.fi</MoocLogoText>
</MoocLogoLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export function ListItem({
{ended.length > 0 && (
<EndedCoursesLinkContainer>
<StyledCTALink
href={`/_new/courses/?tag=${studyModule.slug}&status=${CourseStatus.Ended}`}
href={`/courses/?tag=${studyModule.slug}&status=${CourseStatus.Ended}`}
>
{t("showEndedCourses")}
</StyledCTALink>
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/NewLayout/Navigation/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const Breadcrumbs = () => {
const { asPath } = useRouter()
const { breadcrumbs } = useBreadcrumbContext()

const isHomePage = !!RegExp(/^(?:\/_new)?\/?$/).exec(
const isHomePage = !!RegExp(/^(?:\/_old)?\/?$/).exec(
asPath?.replace(/#(.*)/, ""),
)

Expand All @@ -115,7 +115,7 @@ const Breadcrumbs = () => {
aria-label="breadcrumb"
>
<BreadcrumbList>
<BreadcrumbItem translation="home" href="/_new" key="home" />
<BreadcrumbItem translation="home" href="/" key="home" />
{breadcrumbs.map((breadcrumb, index) => (
<BreadcrumbItem
key={breadcrumb.href ?? breadcrumb.label ?? `breadcrumb-${index}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const UserOptionsMenu = () => {
<NavigationLinks
items={[
{
href: "/_new/profile",
href: "/profile",
label: t("myProfile"),
items: [
{
Expand All @@ -86,11 +86,11 @@ const UserOptionsMenu = () => {
<NavigationLinks
items={[
{
href: "/_new/sign-in",
href: "/sign-in",
label: t("loginShort"),
},
{
href: "/_new/sign-up",
href: "/sign-up",
label: t("signUp"),
},
]}
Expand Down
18 changes: 11 additions & 7 deletions frontend/components/NewLayout/Navigation/MobileNavigationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ const MobileMenuItem = ({ item, level = 0 }: MobileMenuItemProps) => {
const { pathname } = useRouter()

const hasSubmenu = isSubmenuItem(item)
const { href, label } = item
const onClick = useEventCallback(() => {
const { href, label, onClick } = item
const onItemClick = useEventCallback(() => {
setBreadcrumbs((prev) => [...prev, item])
setCurrentLevel(level + 1)
})
Expand All @@ -369,13 +369,17 @@ const MobileMenuItem = ({ item, level = 0 }: MobileMenuItemProps) => {
isActive={pathname === href}
className={level > 0 ? "submenu" : undefined}
>
<MobileMenuListItemButton variant="text" href={href}>
<MobileMenuListItemButton
variant="text"
href={href}
onClick={onClick ? onClick : undefined}
>
{level > 0 && <CaretRightIcon sx={{ fontSize: 10 }} />}
<span>{label}</span>
</MobileMenuListItemButton>
{hasSubmenu && (
<>
<MobileMenuListItemSubmenuButton onClick={onClick}>
<MobileMenuListItemSubmenuButton onClick={onItemClick}>
<CaretRightIcon />
</MobileMenuListItemSubmenuButton>
<MobileMenuLevelContainer
Expand Down Expand Up @@ -498,7 +502,7 @@ const MobileNavigationMenu = ({
...(loggedIn
? [
{
href: "/_new/profile",
href: "/profile",
label: t("myProfile"),
},
{
Expand All @@ -509,11 +513,11 @@ const MobileNavigationMenu = ({
]
: [
{
href: "/_new/sign-in",
href: "/sign-in",
label: t("loginShort"),
},
{
href: "/_new/sign-up",
href: "/sign-up",
label: t("signUp"),
},
]),
Expand Down
14 changes: 7 additions & 7 deletions frontend/components/NewLayout/Navigation/NavigationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@ const NavigationMenu = () => {
[
{
label: t("courses"),
href: "/_new/courses",
href: "/courses",
},
{
label: t("modules"),
href: "/_new/study-modules",
href: "/study-modules",
},
admin
? {
label: "Admin",
href: "/_new/admin",
href: "/admin",
items: [
{
href: "/_new/admin/courses",
href: "/admin/courses",
label: t("courses"),
},
{
href: "/_new/admin/study-modules",
href: "/admin/study-modules",
label: t("modules"),
},
{
href: "/_new/admin/email-templates",
href: "/admin/email-templates",
label: t("emailTemplates"),
},
{
href: "/_new/admin/users/search",
href: "/admin/users/search",
label: t("userSearch"),
},
],
Expand Down
Loading

0 comments on commit 35e8b23

Please sign in to comment.