Skip to content

Commit 7a61899

Browse files
committed
Getting typescript to recognize that we're using our extended CustomTheme type was quite a pain
- I feel pretty confident that we want to use @mui/material/styles since this is how we define our custom theme
1 parent dd85e5a commit 7a61899

File tree

8 files changed

+18
-14
lines changed

8 files changed

+18
-14
lines changed

src/components/DatasetView.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import React, { Dispatch } from 'react';
22
import { connect } from 'react-redux';
33
import { Action } from 'redux';
44
import { Box } from '@mui/material';
5-
import { styled } from '@mui/system';
5+
import { CustomTheme, styled } from '@mui/material/styles';
66
import { getDatasets, addDatasetPolicyMember } from 'actions/index';
77
import { DatasetSummaryModel } from 'generated/tdr';
88
import { TdrState } from 'reducers';
99
import { OrderDirectionOptions } from 'reducers/query';
1010
import DatasetTable from './table/DatasetTable';
1111
import { DatasetRoles } from '../constants';
1212

13-
const Container = styled('div')(({ theme }) => theme.mixins.containerWidth);
13+
const Container = styled('div')(({ theme }: { theme: CustomTheme }) => theme.mixins.containerWidth);
1414

1515
interface IProps {
1616
datasets: Array<DatasetSummaryModel>;

src/components/HomeView.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
33
import { Link } from 'react-router-dom';
44
import { Action } from 'redux';
55
import { Button, Box } from '@mui/material';
6-
import { styled } from '@mui/system';
6+
import { styled } from '@mui/material/styles';
77
import { AddCircle, Refresh } from '@mui/icons-material';
88
import { RouterLocation, RouterRootState } from 'connected-react-router';
99
import {

src/components/JobView.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { getJobs } from 'actions/index';
66
import { JobModel } from 'generated/tdr';
77
import { TdrState } from 'reducers';
88
import { OrderDirectionOptions } from 'reducers/query';
9-
import { styled } from '@mui/system';
9+
import { CustomTheme, styled } from '@mui/material/styles';
1010
import JobTable from './table/JobTable';
1111

12-
const Container = styled('div')(({ theme }) => theme.mixins.containerWidth);
12+
const Container = styled('div')(({ theme }: { theme: CustomTheme }) => theme.mixins.containerWidth);
1313

1414
interface IProps {
1515
jobs: Array<JobModel>;

src/components/SnapshotView.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { SnapshotSummaryModel } from 'generated/tdr';
66
import { Action } from 'redux';
77
import { TdrState } from 'reducers';
88
import { OrderDirectionOptions } from 'reducers/query';
9-
import { styled } from '@mui/system';
9+
import { CustomTheme, styled } from '@mui/material/styles';
1010
import SnapshotTable from './table/SnapshotTable';
1111
import SnapshotPopup from './snapshot/SnapshotPopup';
1212
import { SnapshotRoles } from '../constants';
1313

14-
const Container = styled('div')(({ theme }) => theme.mixins.containerWidth);
14+
const Container = styled('div')(({ theme }: { theme: CustomTheme }) => theme.mixins.containerWidth);
1515

1616
interface IProps {
1717
snapshots: Array<SnapshotSummaryModel>;

src/components/dataset/overview/DatasetOverview.jsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { connect } from 'react-redux';
44
import { Box, Typography } from '@mui/material';
5-
import { styled } from '@mui/system';
5+
import { styled } from '@mui/material/styles';
66
import { getDatasetById, getDatasetPolicy, getUserDatasetRoles } from 'actions';
77
import SnapshotPopup from 'components/snapshot/SnapshotPopup';
88
import DatasetRelationshipsPanel from '../../common/overview/SchemaPanel';
@@ -12,6 +12,10 @@ import LoadingSpinner from '../../common/LoadingSpinner';
1212
import DatasetOverviewPanel from './DatasetOverviewPanel';
1313
import AppBreadcrumbs from '../../AppBreadcrumbs/AppBreadcrumbs';
1414

15+
// When we switch to Typescript, we can use the following type definition to
16+
// fix the unresolved variable warning
17+
// import { CustomTheme, styled } from '@mui/material/styles';
18+
// const Root = styled(Box)(({ theme }: { theme: CustomTheme }) => ({
1519
const Root = styled(Box)(({ theme }) => ({
1620
...theme.mixins.pageRoot,
1721
}));

src/components/dataset/overview/DatasetOverviewPanel.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
Tabs,
1313
Typography,
1414
} from '@mui/material';
15-
import { styled } from '@mui/system';
15+
import { styled } from '@mui/material/styles';
1616
import { ExpandMore, Close } from '@mui/icons-material';
1717
import IconButton from '@mui/material/IconButton';
1818
import { connect } from 'react-redux';

src/components/table/SnapshotAccessRequestTable.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import {
1212
} from 'actions';
1313
import { Action } from 'redux';
1414
import { Link } from 'react-router-dom';
15-
import { styled } from '@mui/system';
15+
import { CustomTheme, styled } from '@mui/material/styles';
1616
import TextWithModalDetails from 'components/common/InfoModal';
1717
import LoadingSpinner from 'components/common/LoadingSpinner';
1818

19-
const OverlaySpinner = styled(Box)(({ theme }) => ({
19+
const OverlaySpinner = styled(Box)(({ theme }: { theme: CustomTheme }) => ({
2020
opacity: 0.9,
2121
position: 'absolute',
2222
right: 0,
@@ -29,7 +29,7 @@ const OverlaySpinner = styled(Box)(({ theme }) => ({
2929
zIndex: 100,
3030
}));
3131

32-
const RequestButton = styled(Button)(({ theme }) => ({
32+
const RequestButton = styled(Button)(({ theme }: { theme: CustomTheme }) => ({
3333
width: '100%',
3434
border: 0,
3535
justifyContent: 'left',

src/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Helmet from 'react-helmet';
66
import { Provider } from 'react-redux';
77
import { Router } from 'react-router-dom';
88
import history from 'modules/hist';
9-
import globalTheme from 'modules/theme';
9+
import theme from 'modules/theme';
1010
import { ThemeProvider } from '@mui/material/styles';
1111
import axios from 'axios';
1212
import { WebStorageStateStore, Log } from 'oidc-client-ts';
@@ -159,7 +159,7 @@ function render(Component) {
159159
<Router history={history}>
160160
{/* CachingProvider is a way to control how css is rendered in the DOM */}
161161
<CacheProvider value={cache}>
162-
<ThemeProvider theme={globalTheme}>
162+
<ThemeProvider theme={theme}>
163163
<AuthProvider {...oidcConfig}>
164164
<Component />
165165
</AuthProvider>

0 commit comments

Comments
 (0)