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

Replace CRA with Vite; COUNTRY=cambodia #1210

Merged
merged 74 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
00ac909
Add Vite
echaidemenos Apr 29, 2024
7928ab3
Fix eslint
echaidemenos Apr 30, 2024
6e75058
Configure jest
echaidemenos May 1, 2024
c8f2c1b
Bump react to 17
echaidemenos May 1, 2024
e85f277
Merge branch 'master' into vite-migration
echaidemenos May 1, 2024
c47aa6b
merge main
ericboucher Jul 3, 2024
e7d37d1
Remove unused React imports
ericboucher Jul 3, 2024
c8b743d
Update node version
ericboucher Jul 3, 2024
6672efe
Update Dockerfile
ericboucher Jul 3, 2024
5f48abe
Fix a few linting errors
ericboucher Jul 3, 2024
5dbd10d
Fix typos
ericboucher Jul 3, 2024
1a9751d
Fix typos
ericboucher Jul 3, 2024
fe2c866
Fix a few linting errors
ericboucher Jul 3, 2024
3c4e975
Load environment variables
ericboucher Jul 4, 2024
4f99ca1
Fix add layer (to QA)
ericboucher Jul 4, 2024
95fe7d2
Fix menu item console error
ericboucher Jul 4, 2024
808ee29
WIP: Fix build
echaidemenos Jul 4, 2024
a4566c6
Update setupTests.ts
echaidemenos Jul 4, 2024
e514b5d
Merge branch 'master' into vite-migration
ericboucher Jul 4, 2024
7a26116
Fix a few build errors
ericboucher Jul 4, 2024
194bf64
Fix a few more build errors
ericboucher Jul 4, 2024
e3ac705
Fix a few more build errors
ericboucher Jul 4, 2024
7ccad47
Fix a few more build errors
ericboucher Jul 4, 2024
7cacf75
Remove test files from build
ericboucher Jul 4, 2024
0801307
Fix a few more build errors
ericboucher Jul 4, 2024
4fa4bfb
Fix build and lint errors
echaidemenos Jul 5, 2024
4c3b8ec
Re-add missing package commands
ericboucher Jul 5, 2024
1007317
Upgrade react-pdf
ericboucher Jul 5, 2024
6ec6e3c
Update index.tsx
ericboucher Jul 5, 2024
9104439
Update package.json
ericboucher Jul 5, 2024
4bb2e68
Update preprocess-layers.ts
ericboucher Jul 5, 2024
5ef1a4e
Remove files for other countries
ericboucher Jul 5, 2024
f03c895
Update tests
echaidemenos Jul 5, 2024
7ef5839
Merge branch 'vite-migration' of github.com:WFP-VAM/prism-app into vi…
echaidemenos Jul 5, 2024
b58cbaa
Update tests
echaidemenos Jul 5, 2024
1f17a14
Update test
echaidemenos Jul 5, 2024
b7d06b6
Update package.json
ericboucher Jul 5, 2024
1c6dde9
Fix Box style issue
echaidemenos Jul 5, 2024
0783b86
Fix tests
echaidemenos Jul 5, 2024
9f38b95
Update node and host setups for docker
ericboucher Jul 7, 2024
8a8523e
Apply react-refresh/only-export-components
echaidemenos Jul 8, 2024
34969e6
Update .eslintrc.cjs
echaidemenos Jul 8, 2024
464c09b
Update tests
echaidemenos Jul 8, 2024
7bf66d9
Merge branch 'master' into vite-migration
echaidemenos Jul 8, 2024
69f75f4
Fix tests
echaidemenos Jul 8, 2024
adc85b4
Use useMediaQuery
echaidemenos Jul 8, 2024
6d4fe00
Update report
echaidemenos Jul 8, 2024
64374b5
Update package.json
ericboucher Jul 8, 2024
829960d
Fix api report
ericboucher Jul 9, 2024
ca16657
Fix hidden button
ericboucher Jul 9, 2024
b02ae2f
Update server-utils.ts
ericboucher Jul 9, 2024
bc67b5b
Fix tooltip
echaidemenos Jul 9, 2024
98ee745
Update report doc
echaidemenos Jul 9, 2024
92fd8fd
update react-pdf
ericboucher Jul 9, 2024
8a0a4a6
Address comments
ericboucher Jul 10, 2024
f1482e2
Test reinstall canvas
ericboucher Jul 10, 2024
0206c6d
Update no-unused-vars rule
echaidemenos Jul 10, 2024
63d5750
Update package.json
ericboucher Jul 10, 2024
9f6fe25
default-param-last
ericboucher Jul 10, 2024
6bafc2f
Use lint:ci
ericboucher Jul 10, 2024
6cdb26c
Update package.json
ericboucher Jul 10, 2024
b6f75b8
Update frontend.yml
ericboucher Jul 10, 2024
d2971f1
Update frontend.yml
ericboucher Jul 10, 2024
677a685
Update action cache
ericboucher Jul 10, 2024
6b137a2
Update i18n.ts
ericboucher Jul 10, 2024
1d29b00
Update i18n.ts
ericboucher Jul 10, 2024
2b2efed
Merge branch 'master' into vite-migration
ericboucher Jul 11, 2024
eef9d0f
Update frontend.yml
ericboucher Jul 11, 2024
4820bfa
Merge branch 'master' into vite-migration
wadhwamatic Jul 11, 2024
e34274b
Overriding install of optional dependency canvas https://github.com/w…
gislawill Jul 11, 2024
5992c22
Completing removal of canvas
gislawill Jul 11, 2024
90e5963
Update index.tsx
ericboucher Jul 12, 2024
7c11bfc
Update index.tsx
ericboucher Jul 12, 2024
54a6b63
Update index.tsx
ericboucher Jul 12, 2024
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 frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ module.exports = {
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'warn',
'react/prop-types': 'off',
'default-param-last': 'off',
ericboucher marked this conversation as resolved.
Show resolved Hide resolved
},
settings: {
'import/resolver': {
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"react": "^18",
"react-chartjs-2": "^2.9.0",
"react-datepicker": "^2.14.1",
"react-dom": "^17",
"react-dom": "^18",
ericboucher marked this conversation as resolved.
Show resolved Hide resolved
"react-draggable": "^4.4.3",
"react-i18next": "^14.1.2",
"react-map-gl": "^7.1.0",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Common/BoundaryDropdown/goto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function GoToBoundaryDropdown() {
</Button>
{/* </Hidden> */}
{/* <Hidden mdUp> */}
{0 && (
{false && (
<IconButton style={{ color: 'white' }} onClick={handleClick}>
<RoomOutlinedIcon />
</IconButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,30 @@ const TimelineItems = memo(
.flat();

// Hard coded styling for date items (first, second, and third layers)
const DATE_ITEM_STYLING: DateItemStyle[] = [
{
class: classes.layerOneDate,
color: LIGHT_BLUE_HEX,
layerDirectionClass: classes.layerOneDirection,
emphasis: classes.layerOneEmphasis,
},
{
class: classes.layerTwoDate,
color: LIGHT_GREEN_HEX,
layerDirectionClass: classes.layerTwoDirection,
emphasis: classes.layerTwoEmphasis,
},
{
class: classes.layerThreeDate,
color: LIGHT_ORANGE_HEX,
layerDirectionClass: classes.layerThreeDirection,
emphasis: classes.layerThreeEmphasis,
},
{ class: classes.availabilityDate, color: LIGHT_ORANGE_HEX },
];
const DATE_ITEM_STYLING: DateItemStyle[] = React.useMemo(
() => [
{
class: classes.layerOneDate,
color: LIGHT_BLUE_HEX,
layerDirectionClass: classes.layerOneDirection,
emphasis: classes.layerOneEmphasis,
},
{
class: classes.layerTwoDate,
color: LIGHT_GREEN_HEX,
layerDirectionClass: classes.layerTwoDirection,
emphasis: classes.layerTwoEmphasis,
},
{
class: classes.layerThreeDate,
color: LIGHT_ORANGE_HEX,
layerDirectionClass: classes.layerThreeDirection,
emphasis: classes.layerThreeEmphasis,
},
{ class: classes.availabilityDate, color: LIGHT_ORANGE_HEX },
],
[classes],
);

const getTooltipTitle = useCallback(
(date: DateRangeType): React.JSX.Element[] => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/MapView/DateSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ const DateSelector = memo(({ classes }: DateSelectorProps) => {
<Grid item xs={12} sm={1} className={classes.datePickerGrid}>
{/* TODO: useMediaQuery */}
{/* <Hidden smUp> */}
{0 && (
{false && (
<Button onClick={decrementDate}>
<ChevronLeft style={{ color: '#101010' }} />
</Button>
Expand All @@ -426,7 +426,7 @@ const DateSelector = memo(({ classes }: DateSelectorProps) => {
/>

{/* <Hidden smUp> */}
{0 && (
{false && (
<Button onClick={incrementDate}>
<ChevronRight style={{ color: '#101010' }} />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const ExposureAnalysisTable = memo(
);

const handleClickTableBodyRow = useCallback(
row => async () => {
(row: any) => async () => {
if (!row.coordinates || !map) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const AnalysisTable = memo(
);

const handleClickTableBodyRow = useCallback(
row => async () => {
(row: any) => async () => {
if (!row.coordinates || !map) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
getCurrentDefinition,
TableRow as AnalysisTableRow,
} from 'context/analysisResultStateSlice';
import ReportDialog from 'components/Common/ReportDialog';
// import ReportDialog from 'components/Common/ReportDialog';
import { Column } from 'utils/analysis-utils';
import { ReportsDefinitions } from 'config/utils';
import { getExposureAnalysisCsvData } from 'utils/csv-utils';
Expand All @@ -39,7 +39,7 @@ function ExposureAnalysisActions({
const analysisDefinition = useSelector(getCurrentDefinition);
const exposureLayerId = useSelector(exposureLayerIdSelector);

const [openReport, setOpenReport] = useState(false);
const [_openReport, setOpenReport] = useState(false);
const [downloadReportIsLoading, setDownloadReportIsLoading] = useState(false);

const API_URL = 'https://prism-api.ovio.org/report';
Expand Down Expand Up @@ -160,13 +160,14 @@ function ExposureAnalysisActions({
<Typography variant="body2">{t('Download Report')}</Typography>
{downloadReportIsLoading && <LoadingBlinkingDots dotColor="white" />}
</Button>
<ReportDialog
{/* TODO: */}
{/* <ReportDialog
ericboucher marked this conversation as resolved.
Show resolved Hide resolved
open={openReport}
handleClose={handleToggleReport(false)}
reportConfig={reportConfig}
tableData={tableData}
columns={columns}
/>
/> */}
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,9 +720,9 @@ const ChartsPanel = memo(() => {
}, [compareLocations, comparePeriods, selectedLayerTitles]);

const chartsSelectRenderValue = useCallback(
selected =>
(selected: any) =>
selected
.map((selectedValue: string | TFunctionKeys) => t(selectedValue))
.map((selectedValue: string | any) => t(selectedValue))
.join(', '),
[t],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const AnalysisLayerMenuItem = memo(
<AnalysisLayerSwitchItem
initialOpacity={initialOpacity}
analysisData={analysisData}
title={analysisData?.getTitle(t) ?? ''}
title={(analysisData as any)?.getTitle(t) ?? ''}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid the as any, we should be able to fix these properly no?

analysisResultSortByKey={analysisResultSortByKey}
analysisResultSortOrder={analysisResultSortOrder}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const AnalysisLayerSwitchItemDownloadOptions = memo(
!analysisData ||
analysisData instanceof ExposedPopulationResult
) {
return analysisData?.getTitle(t);
return (analysisData as any)?.getTitle(t);
}
return generateAnalysisFilename(analysisData, analysisDate ?? null);
}, [analysisData, analysisDate, t]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function ExposureAnalysisOption({
dispatch(
setCurrentDataDefinition({
id: generateUniqueTableKey('exposure_analysis') as TableKey,
title: analysisResult?.getTitle(t) || '',
title: (analysisResult as any)?.getTitle(t) || '',
table: '',
legendText: t(analysisResult?.legendText || ''),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const MenuSwitch = memo(({ title, layers, extent }: MenuSwitchProps) => {
const [isExpanded, setIsExpanded] = useState(false);

const handleAccordionExpand = useCallback(
(event: ChangeEvent<{}>, expanded: boolean) => {
(_event: ChangeEvent<{}>, expanded: boolean) => {
setIsExpanded(expanded);
},
[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const useLayerMenuItemStyles = makeStyles(() =>

interface MenuItemProps {
title: string;
icon: string;
layersCategories: LayersCategoryType[];
extent?: Extent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function AnalysisDownloadButton() {
!analysisResult ||
analysisResult instanceof ExposedPopulationResult
) {
return analysisResult?.getTitle(t);
return (analysisResult as any)?.getTitle(t);
}
return generateAnalysisFilename(analysisResult, analysisDate ?? null);
}, [analysisDate, analysisResult, t]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const LegendItem = memo(
if (legendUrl) {
return <img src={legendUrl} alt={title} />;
}
return <>{renderedLegendDefinitionItems}</>;
return renderedLegendDefinitionItems;
}, [legendUrl, renderedLegendDefinitionItems, title]);

const renderedLegend = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function LegendItemsList({
? invertLegendColors(analysisResult?.legend || [])
: analysisResult?.legend
}
title={analysisResult?.getTitle(t)}
title={(analysisResult as any)?.getTitle(t)}
opacity={analysisLayerOpacity}
forPrinting={forPrinting}
showDescription={showDescription}
Expand Down
17 changes: 12 additions & 5 deletions frontend/src/components/MapView/Legends/LegendMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,30 @@ import {
createStyles,
withStyles,
} from '@material-ui/core';
import { ClassNameMap } from '@material-ui/styles';
import React from 'react';
import Markdown from 'react-markdown';

interface LegendMarkdownProps extends WithStyles<typeof styles> {
children: string;
}

// TODO: ?
ericboucher marked this conversation as resolved.
Show resolved Hide resolved
const p = (classes: ClassNameMap<'legendTextMarkdown'>) =>
function _p({ children: pChildren }: { children: React.ReactNode }) {
return (
<Typography variant="h5" className={classes.legendTextMarkdown}>
{pChildren}
</Typography>
);
};

function LegendMarkdown({ children, classes }: LegendMarkdownProps) {
return (
<Markdown
linkTarget="_blank"
components={{
p: ({ children: pChildren }: { children: React.ReactNode }) => (
<Typography variant="h5" className={classes.legendTextMarkdown}>
{pChildren}
</Typography>
),
p: p(classes),
}}
allowedElements={['p', 'h5', 'strong', 'em', 'a']}
>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/MapView/Legends/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Legends = memo(({ classes }: LegendsProps) => {
{/* </Hidden> */}

{/* <Hidden mdUp> */}
{0 && (
{false && (
<IconButton
style={{ backgroundColor: open ? cyanBlue : undefined }}
onClick={toggleLegendVisibility}
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/components/MapView/Map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ const MapComponent = memo(({ setIsAlertFormOpen }: MapComponentProps) => {

const firstBoundaryId = boundaryId && getLayerMapId(boundaryId);

const mapOnClick = useCallback(
() => useMapOnClick(setIsAlertFormOpen, boundaryLayerId, mapRef.current),
[boundaryLayerId, setIsAlertFormOpen],
const mapOnClick = useMapOnClick(
setIsAlertFormOpen,
boundaryLayerId,
mapRef.current,
);

const getBeforeId = useCallback(
Expand Down Expand Up @@ -232,7 +233,7 @@ const MapComponent = memo(({ setIsAlertFormOpen }: MapComponentProps) => {
}}
mapStyle={mapStyle.toString()}
onLoad={onMapLoad}
onClick={mapOnClick()}
onClick={mapOnClick}
maxBounds={maxBounds}
>
{selectedLayers.map((layer, index) => {
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/NavBar/About/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useState, MouseEvent, memo, useMemo } from 'react';
import InfoOutlinedIcon from '@material-ui/icons/InfoOutlined';
import { Button, Hidden, Typography } from '@material-ui/core';
import { Button, Typography } from '@material-ui/core';
import { useDispatch } from 'react-redux';
import { appConfig } from 'config';
import ContentDialog from 'components/NavBar/ContentDialog';
Expand Down Expand Up @@ -48,11 +48,11 @@ const About = memo(() => {
onClick={handler}
startIcon={<InfoOutlinedIcon style={{ fontSize: '1.5rem' }} />}
>
<Hidden smDown>
<Typography color="secondary" style={{ textTransform: 'none' }}>
{t('About')}
</Typography>
</Hidden>
{/* <Hidden smDown> */}
<Typography color="secondary" style={{ textTransform: 'none' }}>
{t('About')}
</Typography>
{/* </Hidden> */}
{renderedContentDialog}
</Button>
);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/NavBar/PrintImage/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ function DownloadImage({ classes, open, handleClose }: DownloadImageProps) {
handleDownloadMenuClose();
};

// eslint-disable-next-line react/jsx-no-constructed-context-values
const printContext = {
printConfig: {
open,
Expand Down
Loading
Loading