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

DT-6589 & DT-6587: Navigator shows notifications for expired legs and we should disallow close for canceled routes #5189

Merged
merged 2 commits into from
Dec 9, 2024
Merged
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
6 changes: 3 additions & 3 deletions app/component/itinerary/navigator/NaviCardContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ function NaviCardContainer(
}
}
if (incomingMessages.size || legChanged) {
// Handle messages when new messages arrives or leg is changed.
// Handle messages when new messages arrives.

// Current active messages. Filter away legChange messages when leg changes.
// Current active messages. Filter away expired messages.
const previousValidMessages = legChanged
? activeMessages.filter(m => m.expiresOn !== 'legChange')
? activeMessages.filter(m => m.expiresOn < time)
: activeMessages;

// handle messages that are updated.
Expand Down
34 changes: 22 additions & 12 deletions app/component/itinerary/navigator/NaviMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { configShape } from '../../../util/shapes';

import Icon from '../../Icon';

function NaviMessage({ severity, children, index, handleRemove }, { config }) {
function NaviMessage(
{ severity, children, index, handleRemove, hideClose },
{ config },
) {
const [removingIndex, setRemovingIndex] = useState(null);

const handleRemoveClick = () => {
Expand Down Expand Up @@ -45,17 +48,19 @@ function NaviMessage({ severity, children, index, handleRemove }, { config }) {
>
<Icon img={iconId} height={1.4} width={1.4} color={color} />
{children}
<button
type="button"
className="info-close"
onClick={() => handleRemoveClick()}
>
<Icon
img="notification-close"
className="notification-close"
color={config.colors.primary}
/>
</button>
{!hideClose && (
<button
type="button"
className="info-close"
onClick={() => handleRemoveClick()}
>
<Icon
img="notification-close"
className="notification-close"
color={config.colors.primary}
/>
</button>
)}
</div>
);
}
Expand All @@ -65,6 +70,11 @@ NaviMessage.propTypes = {
children: PropTypes.node.isRequired,
index: PropTypes.number.isRequired,
handleRemove: PropTypes.func.isRequired,
hideClose: PropTypes.bool,
};

NaviMessage.defaultProps = {
hideClose: false,
};

NaviMessage.contextTypes = {
Expand Down
1 change: 1 addition & 0 deletions app/component/itinerary/navigator/NaviStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const NaviStack = ({ messages, handleRemove, topPosition }) => {
severity={notification.severity}
index={index}
handleRemove={handleRemove}
hideClose={notification.hideClose}
>
{notification.content}
</NaviMessage>
Expand Down
6 changes: 4 additions & 2 deletions app/component/itinerary/navigator/NaviUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const getAdditionalMessages = (leg, time, intl, config, messages) => {
};

export const getTransitLegState = (leg, intl, messages, time) => {
const { start, realtimeState, from, mode, legId, route } = leg;
const { start, realtimeState, from, mode, legId, route, end } = leg;
const { scheduledTime, estimated } = start;
if (mode === 'WALK') {
return null;
Expand Down Expand Up @@ -139,7 +139,7 @@ export const getTransitLegState = (leg, intl, messages, time) => {
severity = 'INFO';
}
const state = severity
? [{ severity, content, id: legId, expiresOn: 'legChange' }]
? [{ severity, content, id: legId, expiresOn: legTime(end) }]
: [];
return state;
};
Expand Down Expand Up @@ -222,6 +222,7 @@ export const getItineraryAlerts = (legs, intl, messages, location, router) => {
severity: 'ALERT',
content,
id: `canceled-${legId}`,
hideClose: true,
});
}
});
Expand All @@ -246,6 +247,7 @@ export const getItineraryAlerts = (legs, intl, messages, location, router) => {
severity: 'ALERT',
content,
id: transferId,
hideClose: true,
});
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/component/itinerary/navigator/navigator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@
margin-bottom: var(--space-s);

.extension-divider {
border: 1px solid #ddd;
height: 1px;
background: #ddd;
width: 85%;
margin-left: 35px;
margin-top: var(--space-s);
Expand Down
Loading