Skip to content

Commit 0e4c18e

Browse files
Remove some unused exports from ol-components (#1844)
* chore: remove unused exports * remove muidialog from ol-components * remove box usage * remove mui cards * fix a test * remove testing id
1 parent b8157d0 commit 0e4c18e

File tree

15 files changed

+174
-115
lines changed

15 files changed

+174
-115
lines changed

frontends/main/src/app-pages/ChannelPage/UnitChannelTemplate.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useMemo } from "react"
22
import {
33
styled,
44
Container,
5-
Box,
65
Breadcrumbs,
76
Stack,
87
BannerBackground,
@@ -147,8 +146,7 @@ const UnitChannelTemplate: React.FC<UnitChannelTemplateProps> = ({
147146
{displayConfiguration?.sub_heading}
148147
</Typography>
149148
</Stack>
150-
<Box
151-
display="flex"
149+
<Stack
152150
flexDirection="row"
153151
alignItems="end"
154152
sx={{
@@ -172,7 +170,7 @@ const UnitChannelTemplate: React.FC<UnitChannelTemplateProps> = ({
172170
/>
173171
) : null}
174172
</ChannelControls>
175-
</Box>
173+
</Stack>
176174
</Stack>
177175
{channel.data ? <ChannelDetails channel={channel.data} /> : null}
178176
</BannerContent>

frontends/main/src/app-pages/ErrorPage/ErrorPageTemplate.tsx

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
11
import React from "react"
2-
import {
3-
Container,
4-
MuiCard,
5-
CardContent,
6-
CardActions,
7-
ButtonLink,
8-
} from "ol-components"
2+
import { Container, ButtonLink, Typography, styled } from "ol-components"
93
import { HOME } from "@/common/urls"
104

115
type ErrorPageTemplateProps = {
126
title: string
137
children: React.ReactNode
148
}
159

16-
const ErrorPageTemplate: React.FC<ErrorPageTemplateProps> = ({ children }) => {
10+
const ErrorContainer = styled(Container)(({ theme }) => ({
11+
backgroundColor: theme.custom.colors.white,
12+
borderRadius: "8px",
13+
marginTop: "4rem",
14+
padding: "16px",
15+
boxShadow:
16+
"1px 2px 1px -1px rgba(0,0,0,0.2),0px 1px 1px 0px rgba(0,0,0,0.14),0px 1px 3px 0px rgba(0,0,0,0.12)",
17+
}))
18+
const Footer = styled.div({
19+
marginTop: "16px",
20+
})
21+
22+
const ErrorPageTemplate: React.FC<ErrorPageTemplateProps> = ({
23+
children,
24+
title,
25+
}) => {
1726
return (
18-
<Container maxWidth="sm">
19-
<MuiCard sx={{ marginTop: "4rem" }}>
20-
<CardContent>{children}</CardContent>
21-
<CardActions>
22-
<ButtonLink variant="secondary" href={HOME}>
23-
Home
24-
</ButtonLink>
25-
</CardActions>
26-
</MuiCard>
27-
</Container>
27+
<ErrorContainer maxWidth="sm">
28+
<Typography variant="h3" component="h1">
29+
{title}
30+
</Typography>
31+
{children}
32+
<Footer>
33+
<ButtonLink variant="secondary" href={HOME}>
34+
Home
35+
</ButtonLink>
36+
</Footer>
37+
</ErrorContainer>
2838
)
2939
}
3040

frontends/main/src/app-pages/ErrorPage/FallbackErrorPage.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
import React from "react"
44
import ErrorPageTemplate from "./ErrorPageTemplate"
5-
import { Typography } from "ol-components"
65

76
const FallbackErrorPage = ({ error }: { error: Pick<Error, "message"> }) => {
87
return (
9-
<ErrorPageTemplate title="Unexpected Error">
10-
<Typography variant="h3" component="h1">
11-
Something went wrong.
12-
</Typography>
8+
<ErrorPageTemplate title="Something went wrong.">
139
{error.message}
1410
</ErrorPageTemplate>
1511
)

frontends/main/src/app-pages/ErrorPage/ForbiddenPage.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useEffect } from "react"
22
import ErrorPageTemplate from "./ErrorPageTemplate"
33
import { useUserMe } from "api/hooks/user"
4-
import { Typography } from "ol-components"
54
import { redirect } from "next/navigation"
65
import * as urls from "@/common/urls"
76

@@ -16,9 +15,6 @@ const ForbiddenPage: React.FC = () => {
1615
}, [user])
1716
return (
1817
<ErrorPageTemplate title="Not Allowed">
19-
<Typography variant="h3" component="h1">
20-
Not Allowed
21-
</Typography>
2218
You do not have permission to access this resource.
2319
</ErrorPageTemplate>
2420
)

frontends/main/src/app-pages/ErrorPage/NotFoundPage.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
import React from "react"
44
import ErrorPageTemplate from "./ErrorPageTemplate"
5-
import { Typography } from "ol-components"
65

76
const NotFoundPage: React.FC = () => {
87
return (
9-
<ErrorPageTemplate title="Not Found">
10-
<Typography variant="h3" component="h1">
11-
404 Not Found Error
12-
</Typography>
8+
<ErrorPageTemplate title="404 Not Found Error">
139
Resource Not Found
1410
</ErrorPageTemplate>
1511
)

frontends/main/src/app/error.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ import * as Sentry from "@sentry/nextjs"
1414
import FallbackErrorPage from "@/app-pages/ErrorPage/FallbackErrorPage"
1515
import { ForbiddenError } from "@/common/permissions"
1616
import ForbiddenPage from "@/app-pages/ErrorPage/ForbiddenPage"
17+
18+
export const metadata = {
19+
title: "Error",
20+
}
21+
1722
const Error = ({ error }: { error: Error }) => {
1823
useEffect(() => {
1924
Sentry.captureException(error)

frontends/main/src/app/not-found.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import React from "react"
22
import NotFoundPage from "@/app-pages/ErrorPage/NotFoundPage"
33

4+
export const metadata = {
5+
title: "Not Found",
6+
}
7+
48
const Page: React.FC = () => {
59
return <NotFoundPage />
610
}

frontends/main/src/page-components/ChannelDetails/ChannelDetails.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo } from "react"
2-
import { styled, Typography, Box } from "ol-components"
2+
import { styled, Typography } from "ol-components"
33
import { capitalize } from "ol-utilities"
44
import { ChannelTypeEnum, Channel } from "api/v0"
55
import { RiExternalLinkLine } from "@remixicon/react"
@@ -142,7 +142,7 @@ const getChannelDetails = (channel: Channel) => {
142142
const InfoLabel = styled(Typography)(({ theme }) => ({
143143
color: theme.custom.colors.mitRed,
144144
}))
145-
const ChannelDetailsCard = styled(Box)(({ theme }) => ({
145+
const ChannelDetailsCard = styled.div(({ theme }) => ({
146146
borderRadius: "12px",
147147
backgroundColor: "white",
148148
padding: "36px",
@@ -186,7 +186,7 @@ const ChannelDetails: React.FC<ChannelDetailsProps> = (props) => {
186186
: detailValue
187187

188188
return (
189-
<Box key={value.title}>
189+
<div key={value.title}>
190190
<InfoLabel
191191
variant="subtitle2"
192192
sx={{ marginBottom: (theme) => theme.typography.pxToRem(4) }}
@@ -196,7 +196,7 @@ const ChannelDetails: React.FC<ChannelDetailsProps> = (props) => {
196196
<Typography variant="body3" color="text.secondary">
197197
{Array.isArray(label) ? label.join(" | ") : label}
198198
</Typography>
199-
</Box>
199+
</div>
200200
)
201201
}
202202
return null

frontends/main/src/page-components/SearchDisplay/SearchDisplay.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import {
33
styled,
44
Pagination,
55
PaginationItem,
6-
MuiCard,
7-
CardContent,
86
PlainList,
97
Container,
108
Typography,
@@ -459,6 +457,14 @@ const AdminTitleContainer = styled.div`
459457
${({ theme }) => css({ ...theme.typography.subtitle3 })}
460458
margin-top: 20px;
461459
`
460+
const NoneFound = styled.div(({ theme }) => ({
461+
backgroundColor: theme.custom.colors.white,
462+
borderRadius: "8px",
463+
padding: "16px",
464+
paddingBottom: "24px",
465+
boxShadow:
466+
"1px 2px 1px -1px rgba(0,0,0,0.2),0px 1px 1px 0px rgba(0,0,0,0.14),0px 1px 3px 0px rgba(0,0,0,0.12)",
467+
}))
462468

463469
const PAGE_SIZE = 20
464470
const MAX_PAGE = 50
@@ -963,9 +969,7 @@ const SearchDisplay: React.FC<SearchDisplayProps> = ({
963969
))}
964970
</PlainList>
965971
) : (
966-
<MuiCard>
967-
<CardContent>No results found for your query.</CardContent>
968-
</MuiCard>
972+
<NoneFound>No results found for your query.</NoneFound>
969973
)}
970974
</StyledResultsContainer>
971975
<PaginationContainer>

frontends/ol-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@emotion/styled": "^11.11.0",
1919
"@mui/base": "5.0.0-beta.61",
2020
"@mui/lab": "6.0.0-beta.15",
21-
"@mui/material": "^6.1.6",
21+
"@mui/material": "^6.1.8",
2222
"@mui/material-nextjs": "^6.1.6",
2323
"@mui/system": "^6.1.6",
2424
"@remixicon/react": "^4.2.0",

0 commit comments

Comments
 (0)