Inline ArvadosSnackbar into Snackbar
authorDaniel Kos <daniel.kos@contractors.roche.com>
Sat, 22 Sep 2018 07:03:37 +0000 (09:03 +0200)
committerDaniel Kos <daniel.kos@contractors.roche.com>
Sat, 22 Sep 2018 07:03:37 +0000 (09:03 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos@contractors.roche.com>

src/views-components/snackbar/snackbar.tsx

index 59dddcafcd8a403740807c4d07529201fa48da36..388a2e0081a05674de6254aa147bb24d02bec662 100644 (file)
@@ -83,46 +83,47 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     },
 });
 
-const ArvadosSnackbar = (props: SnackbarDataProps & SnackbarEventProps & WithStyles<CssRules>) => {
-    const { classes } = props;
+// const ArvadosSnackbar =
+export const Snackbar = withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(
+    (props: SnackbarDataProps & SnackbarEventProps & WithStyles<CssRules>) => {
+        const { classes } = props;
 
-    const variants = {
-        [SnackbarKind.INFO]: [InfoIcon, classes.info],
-        [SnackbarKind.WARNING]: [WarningIcon, classes.warning],
-        [SnackbarKind.SUCCESS]: [CheckCircleIcon, classes.success],
-        [SnackbarKind.ERROR]: [ErrorIcon, classes.error]
-    };
-
-    const [Icon, cssClass] = variants[props.kind];
+        const variants = {
+            [SnackbarKind.INFO]: [InfoIcon, classes.info],
+            [SnackbarKind.WARNING]: [WarningIcon, classes.warning],
+            [SnackbarKind.SUCCESS]: [CheckCircleIcon, classes.success],
+            [SnackbarKind.ERROR]: [ErrorIcon, classes.error]
+        };
 
-    return (
-        <MaterialSnackbar
-            open={props.open}
-            message={props.message}
-            onClose={props.onClose}
-            anchorOrigin={props.anchorOrigin}
-            autoHideDuration={props.autoHideDuration}>
-            <SnackbarContent
-                className={classNames(cssClass)}
-                aria-describedby="client-snackbar"
-                message={
-                    <span id="client-snackbar" className={classes.message}>
-                        <Icon className={classNames(classes.icon, classes.iconVariant)}/>
-                        {props.message}
-                    </span>
-                }
-                action={
-                    <IconButton
-                        key="close"
-                        aria-label="Close"
-                        color="inherit"
-                        onClick={e => props.onClose && props.onClose(e, '')}>
-                        <CloseIcon className={classes.icon}/>
-                    </IconButton>
-                }
-            />
-        </MaterialSnackbar>
-    );
-};
+        const [Icon, cssClass] = variants[props.kind];
 
-export const Snackbar = withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(ArvadosSnackbar));
+        return (
+            <MaterialSnackbar
+                open={props.open}
+                message={props.message}
+                onClose={props.onClose}
+                anchorOrigin={props.anchorOrigin}
+                autoHideDuration={props.autoHideDuration}>
+                <SnackbarContent
+                    className={classNames(cssClass)}
+                    aria-describedby="client-snackbar"
+                    message={
+                        <span id="client-snackbar" className={classes.message}>
+                            <Icon className={classNames(classes.icon, classes.iconVariant)}/>
+                            {props.message}
+                        </span>
+                    }
+                    action={
+                        <IconButton
+                            key="close"
+                            aria-label="Close"
+                            color="inherit"
+                            onClick={e => props.onClose && props.onClose(e, '')}>
+                            <CloseIcon className={classes.icon}/>
+                        </IconButton>
+                    }
+                />
+            </MaterialSnackbar>
+        );
+    }
+));