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

[Hotfix 2] - Fix issues on dref import and imminent risk map #1467

Closed
wants to merge 3 commits into from
Closed
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
8 changes: 8 additions & 0 deletions .changeset/cool-eggs-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"go-web-app": patch
---

Update labels for severity control in Imminent Risk Map.
Update navigation for the events in Imminent Risk Map.
Fix issue displayed when opening a DREF import template.
Fix submission issue when importing a DREF import file.
1 change: 0 additions & 1 deletion app/scripts/translatte/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ yargs(hideBin(process.argv))
});
},
async (argv) => {
console.warn(argv);
await applyMigrations(
currentDir,
argv.SOURCE_FILE as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,22 @@ function LayerOptions(props: Props) {
const setFieldValue = useSetFieldValue(onChange);

// FIXME: use strings
// FIXME: These are hard-coded for Gdacs source.
// Currently we are only showing severity control for Gdacs
const severityLegendItems = useMemo<SeverityLegendItem[]>(() => ([
{
severity: 'green',
label: 'Green',
label: '60 km/h',
color: COLOR_GREEN,
},
{
severity: 'orange',
label: 'Orange',
label: '90 km/h',
color: COLOR_ORANGE,
},
{
severity: 'red',
label: 'Red',
label: '120 km/h',
color: COLOR_RED,
},
{
Expand Down
1 change: 0 additions & 1 deletion app/src/components/domain/RiskImminentEventMap/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"namespace": "common",
"strings": {
"riskImminentEventsMap": "Risk Imminent Events Map",
"backToEventsLabel": "Back to events",
"emptyImminentEventMessage": "No imminent event forecasted"
}
}
100 changes: 51 additions & 49 deletions app/src/components/domain/RiskImminentEventMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import {
useMemo,
useState,
} from 'react';
import { ChevronLeftLineIcon } from '@ifrc-go/icons';
import {
Button,
Container,
List,
} from '@ifrc-go/ui';
Expand Down Expand Up @@ -86,8 +84,10 @@ export type EventPointFeature = GeoJSON.Feature<GeoJSON.Point, EventPointPropert

export interface RiskEventListItemProps<EVENT> {
data: EVENT;
expanded: boolean;
onExpandClick: (eventId: number | string) => void;
className?: string;
children?: React.ReactNode;
}

export interface RiskEventDetailProps<EVENT, EXPOSURE> {
Expand Down Expand Up @@ -243,10 +243,15 @@ function RiskImminentEventMap<
(eventId: string | number | undefined) => {
const eventIdSafe = eventId as KEY | undefined;

setActiveEventId(eventIdSafe);
onActiveEventChange(eventIdSafe);
if (activeEventId === eventIdSafe) {
setActiveEventId(undefined);
onActiveEventChange(undefined);
} else {
setActiveEventId(eventIdSafe);
onActiveEventChange(eventIdSafe);
}
},
[onActiveEventChange],
[onActiveEventChange, activeEventId],
);

const handlePointClick = useCallback(
Expand All @@ -258,17 +263,44 @@ function RiskImminentEventMap<
[setActiveEventIdSafe],
);

const DetailComponent = detailRenderer;

const eventListRendererParams = useCallback(
(_: string | number, event: EVENT): RiskEventListItemProps<EVENT> => ({
data: event,
onExpandClick: setActiveEventIdSafe,
expanded: activeEventId === keySelector(event),
className: styles.riskEventListItem,
children: activeEventId === keySelector(event) && (
<DetailComponent
data={event}
exposure={activeEventExposure}
pending={activeEventExposurePending}
>
{hazardTypeSelector(event) === 'TC' && (
<LayerOptions
value={layerOptions}
// NOTE: Currently the information is only visible in gdacas
exposureAreaControlHidden={source !== 'gdacs'}
onChange={setLayerOptions}
/>
)}
</DetailComponent>
),
}),
[setActiveEventIdSafe],
[
setActiveEventIdSafe,
activeEventExposure,
activeEventExposurePending,
layerOptions,
hazardTypeSelector,
DetailComponent,
activeEventId,
keySelector,
source,
],
);

const DetailComponent = detailRenderer;

const [loadedIcons, setLoadedIcons] = useState<Record<string, boolean>>({});

const handleIconLoad = useCallback(
Expand Down Expand Up @@ -443,48 +475,18 @@ function RiskImminentEventMap<
withInternalPadding
childrenContainerClassName={styles.content}
spacing="cozy"
actions={isDefined(activeEventId) && (
<Button
name={undefined}
onClick={setActiveEventIdSafe}
variant="tertiary"
icons={(
<ChevronLeftLineIcon className={styles.icon} />
)}
>
{strings.backToEventsLabel}
</Button>
)}
>
{isNotDefined(activeEventId) && (
<List
className={styles.eventList}
filtered={false}
pending={pending}
errored={false}
data={events}
keySelector={keySelector}
renderer={listItemRenderer}
rendererParams={eventListRendererParams}
emptyMessage={strings.emptyImminentEventMessage}
/>
)}
{isDefined(activeEvent) && (
<DetailComponent
data={activeEvent}
exposure={activeEventExposure}
pending={activeEventExposurePending}
>
{hazardTypeSelector(activeEvent) === 'TC' && (
<LayerOptions
value={layerOptions}
// NOTE: Currently the information is only visible in gdacas
exposureAreaControlHidden={source !== 'gdacs'}
onChange={setLayerOptions}
/>
)}
</DetailComponent>
)}
<List
className={styles.eventList}
filtered={false}
pending={pending}
errored={false}
data={events}
keySelector={keySelector}
renderer={listItemRenderer}
rendererParams={eventListRendererParams}
emptyMessage={strings.emptyImminentEventMessage}
/>
</Container>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"namespace": "common",
"strings": {
"eventStartOnLabel": "Started on",
"eventMoreDetailsLink": "More Details",
"eventSourceLabel": "Forecast provider",
"eventDeathLabel": "Estimated deaths",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ type Props = RiskEventDetailProps<GdacsItem, GdacsExposure | undefined>;
function EventDetails(props: Props) {
const {
data: {
hazard_name,
start_date,
event_details,
},
exposure,
Expand All @@ -87,16 +85,7 @@ function EventDetails(props: Props) {
return (
<Container
contentViewType="vertical"
heading={hazard_name}
headingLevel={5}
spacing="cozy"
headerDescription={(
<TextOutput
label={strings.eventStartOnLabel}
value={start_date}
valueType="date"
/>
)}
withBorderAndHeaderBackground
pending={pending}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"namespace": "common",
"strings": {
"gdacsEventViewDetails": "View Details",
"gdacsEventViewDetails": "View / Hide Details",
"gdacsEventStartedOn": "Started On"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { ChevronRightLineIcon } from '@ifrc-go/icons';
import {
useEffect,
useRef,
} from 'react';
import {
ChevronDownLineIcon,
ChevronUpLineIcon,
} from '@ifrc-go/icons';
import {
Button,
Header,
Expand All @@ -25,35 +32,62 @@ function EventListItem(props: Props) {
hazard_name,
start_date,
},
expanded,
onExpandClick,
className,
children,
} = props;

const strings = useTranslation(i18n);

const elementRef = useRef<HTMLDivElement>(null);

useEffect(
() => {
if (expanded && elementRef.current) {
const y = window.scrollY;
const x = window.scrollX;
elementRef.current.scrollIntoView({
behavior: 'instant',
block: 'start',
});
// NOTE: We need to scroll back because scrollIntoView also
// scrolls the parent container
window.scroll(x, y);
}
},
[expanded],
);

return (
<Header
className={_cs(styles.eventListItem, className)}
heading={hazard_name ?? '--'}
headingLevel={5}
actions={(
<Button
name={id}
onClick={onExpandClick}
variant="tertiary"
title={strings.gdacsEventViewDetails}
>
<ChevronRightLineIcon className={styles.icon} />
</Button>
)}
spacing="cozy"
>
<TextOutput
label={strings.gdacsEventStartedOn}
value={start_date}
valueType="date"
/>
</Header>
<>
<Header
elementRef={elementRef}
className={_cs(styles.eventListItem, className)}
heading={hazard_name ?? '--'}
headingLevel={5}
actions={(
<Button
name={id}
onClick={onExpandClick}
variant="tertiary"
title={strings.gdacsEventViewDetails}
>
{expanded
? <ChevronUpLineIcon className={styles.icon} />
: <ChevronDownLineIcon className={styles.icon} />}
</Button>
)}
spacing="cozy"
>
<TextOutput
label={strings.gdacsEventStartedOn}
value={start_date}
valueType="date"
/>
</Header>
{children}
</>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"meteoSwissAuthoritativeMessage": "Please also consider {link} and classification of {classificationLink}.",
"meteoSwissAuthoritativeLinkLabel": "authoritative information about the hazard",
"meteoSwissTropicalStorm": "tropical storm",
"meteoSwissEventDetailsStartedOnLabel": "Started on",
"meteoSwissEventDetailsUpdatedAtLabel": "Updated at",
"meteoSwissHazardName": "{hazardType} - {hazardName}",
"meteoSwissImpactValue": "{value} ({fivePercent} - {ninetyFivePercent}) {unit}",
"beta": "beta",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ interface Props {
function EventDetails(props: Props) {
const {
data: {
// id,
hazard_type_display,
country_details,
start_date,
updated_at,
Expand All @@ -55,14 +53,6 @@ function EventDetails(props: Props) {

const strings = useTranslation(i18n);

const hazardName = resolveToString(
strings.meteoSwissHazardName,
{
hazardType: hazard_type_display,
hazardName: country_details?.name ?? hazard_name,
},
);

const getSaffirSimpsonScaleDescription = useCallback((windspeed: number) => {
if (windspeed < 33) {
return strings.tropicalStormDescription;
Expand Down Expand Up @@ -179,25 +169,6 @@ function EventDetails(props: Props) {
<Container
className={styles.eventDetails}
childrenContainerClassName={styles.content}
heading={hazardName}
headingLevel={4}
headerDescription={(
<>
<TextOutput
label={strings.meteoSwissEventDetailsStartedOnLabel}
value={start_date}
valueType="date"
strongValue
/>
<TextOutput
label={strings.meteoSwissEventDetailsUpdatedAtLabel}
value={updated_at}
valueType="date"
format={UPDATED_AT_FORMAT}
strongValue
/>
</>
)}
contentViewType="vertical"
>
{pending && <BlockLoading />}
Expand Down
Loading