begin rework of notifications

The notification reducer should decide when to display notifications rather than having notifications scattered throughout the code.

Also start using translations so that user-visible strings are not scattered in code.
This commit is contained in:
David Lechner
2020-05-26 21:20:08 -05:00
committed by David Lechner
parent ec05ad38aa
commit c373b3abc5
19 changed files with 575 additions and 128 deletions
+14 -2
View File
@@ -6,7 +6,7 @@ import { Collapse } from 'react-bootstrap';
import { connect } from 'react-redux';
import { TransitionGroup } from 'react-transition-group';
import { RootState } from '../reducers';
import { NotificationList } from '../reducers/notification';
import { Level, NotificationList } from '../reducers/notification';
import Notification from './Notification';
interface StateProps {
@@ -15,6 +15,17 @@ interface StateProps {
type NotificationStackProps = StateProps;
function mapLevelToStyle(level: Level): string {
switch (level) {
case Level.Error:
return 'danger';
case Level.Warning:
return 'warning';
case Level.Info:
return 'info';
}
}
class NotificationStack extends React.Component<NotificationStackProps> {
render(): JSX.Element {
return (
@@ -33,8 +44,9 @@ class NotificationStack extends React.Component<NotificationStackProps> {
<Collapse key={n.id} in={true}>
<Notification
id={n.id}
style={n.style}
style={mapLevelToStyle(n.level)}
message={n.message}
messageId={n.messageId}
helpUrl={n.helpUrl}
/>
</Collapse>