mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
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:
committed by
David Lechner
parent
ec05ad38aa
commit
c373b3abc5
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user