[ARVADOS-WORKBENCH2] created: 1.2.0-430-g5e7c7e2
Git user
git at public.curoverse.com
Fri Sep 21 17:44:29 EDT 2018
at 5e7c7e298eda223e6fcb3876385c59f0552ca642 (commit)
commit 5e7c7e298eda223e6fcb3876385c59f0552ca642
Author: Daniel Kos <daniel.kos at contractors.roche.com>
Date: Fri Sep 21 23:44:20 2018 +0200
Fix snackbar typing, simplify code
Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos at contractors.roche.com>
diff --git a/src/views-components/snackbar/snackbar.tsx b/src/views-components/snackbar/snackbar.tsx
index 7449e1e..c65dc11 100644
--- a/src/views-components/snackbar/snackbar.tsx
+++ b/src/views-components/snackbar/snackbar.tsx
@@ -5,7 +5,7 @@
import * as React from "react";
import { connect } from "react-redux";
import { RootState } from "~/store/store";
-import MaterialSnackbar, { SnackbarProps } from "@material-ui/core/Snackbar";
+import MaterialSnackbar, { SnackbarOrigin } from "@material-ui/core/Snackbar";
import { Dispatch } from "redux";
import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions";
import IconButton from '@material-ui/core/IconButton';
@@ -20,7 +20,20 @@ import { ArvadosTheme } from "~/common/custom-theme";
import { amber, green } from "@material-ui/core/colors";
import * as classNames from 'classnames';
-const mapStateToProps = (state: RootState): SnackbarProps & ArvadosSnackbarProps => {
+interface SnackbarDataProps {
+ anchorOrigin?: SnackbarOrigin;
+ autoHideDuration?: number;
+ open: boolean;
+ message?: React.ReactElement<any>;
+ kind: SnackbarKind;
+}
+
+interface SnackbarEventProps {
+ onClose?: (event: React.SyntheticEvent<any>, reason: string) => void;
+ onExited: () => void;
+}
+
+const mapStateToProps = (state: RootState): SnackbarDataProps => {
const messages = state.snackbar.messages;
return {
anchorOrigin: { vertical: "bottom", horizontal: "right" },
@@ -31,7 +44,7 @@ const mapStateToProps = (state: RootState): SnackbarProps & ArvadosSnackbarProps
};
};
-const mapDispatchToProps = (dispatch: Dispatch) => ({
+const mapDispatchToProps = (dispatch: Dispatch): SnackbarEventProps => ({
onClose: (event: any, reason: string) => {
if (reason !== "clickaway") {
dispatch(snackbarActions.CLOSE_SNACKBAR());
@@ -42,10 +55,6 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
}
});
-const ArvadosSnackbar = (props: any) => <MaterialSnackbar {...props}>
- <ArvadosSnackbarContent {...props}/>
-</MaterialSnackbar>;
-
type CssRules = "success" | "error" | "info" | "warning" | "icon" | "iconVariant" | "message";
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
@@ -74,62 +83,46 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
},
});
-interface ArvadosSnackbarProps {
- kind: SnackbarKind;
-}
-
-const ArvadosSnackbarContent = (props: SnackbarProps & ArvadosSnackbarProps & WithStyles<CssRules>) => {
- const { classes, className, message, onClose, kind } = props;
+const ArvadosSnackbar = (props: SnackbarDataProps & SnackbarEventProps & WithStyles<CssRules>) => {
+ const { classes, message, onClose, kind } = props;
- let Icon = InfoIcon;
- let cssClass = classes.info;
+ const variants = {
+ [SnackbarKind.INFO]: [InfoIcon, classes.info],
+ [SnackbarKind.WARNING]: [WarningIcon, classes.warning],
+ [SnackbarKind.SUCCESS]: [CheckCircleIcon, classes.success],
+ [SnackbarKind.ERROR]: [ErrorIcon, classes.error]
+ };
- switch (kind) {
- case SnackbarKind.INFO:
- Icon = InfoIcon;
- cssClass = classes.info;
- break;
- case SnackbarKind.WARNING:
- Icon = WarningIcon;
- cssClass = classes.warning;
- break;
- case SnackbarKind.SUCCESS:
- Icon = CheckCircleIcon;
- cssClass = classes.success;
- break;
- case SnackbarKind.ERROR:
- Icon = ErrorIcon;
- cssClass = classes.error;
- break;
- }
+ const [Icon, cssClass] = variants[kind];
return (
- <SnackbarContent
- className={classNames(cssClass, className)}
- aria-describedby="client-snackbar"
- message={
- <span id="client-snackbar" className={classes.message}>
- <Icon className={classNames(classes.icon, classes.iconVariant)}/>
- {message}
- </span>
- }
- action={
- <IconButton
- key="close"
- aria-label="Close"
- color="inherit"
- onClick={e => {
- if (onClose) {
- onClose(e, '');
- }
- }}>
- <CloseIcon className={classes.icon}/>
- </IconButton>
- }
- />
+ <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)}/>
+ {message}
+ </span>
+ }
+ action={
+ <IconButton
+ key="close"
+ aria-label="Close"
+ color="inherit"
+ onClick={e => onClose && onClose(e, '')}>
+ <CloseIcon className={classes.icon}/>
+ </IconButton>
+ }
+ />
+ </MaterialSnackbar>
);
};
-export const Snackbar = connect(mapStateToProps, mapDispatchToProps)(
- withStyles(styles)(ArvadosSnackbar)
-);
+export const Snackbar = withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(ArvadosSnackbar));
commit 0d67b1230fcf696598143468c0096558462da9f2
Author: Daniel Kos <daniel.kos at contractors.roche.com>
Date: Thu Sep 20 23:09:34 2018 +0200
Delete useless progress components
Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos at contractors.roche.com>
diff --git a/src/views-components/progress/content-progress.tsx b/src/views-components/progress/content-progress.tsx
deleted file mode 100644
index fa2cad5..0000000
--- a/src/views-components/progress/content-progress.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-// // Copyright (C) The Arvados Authors. All rights reserved.
-// //
-// // SPDX-License-Identifier: AGPL-3.0
-//
-// import * as React from 'react';
-// import { CircularProgress } from '@material-ui/core';
-// import { withProgress } from '~/store/progress-indicator/with-progress';
-// import { WithProgressStateProps } from '~/store/progress-indicator/with-progress';
-// import { ProgressIndicatorData } from '~/store/progress-indicator/progress-indicator-reducer';
-//
-// export const ContentProgress = withProgress(ProgressIndicatorData.CONTENT_PROGRESS)((props: WithProgressStateProps) =>
-// props.started ? <CircularProgress /> : null
-// );
diff --git a/src/views-components/progress/side-panel-progress.tsx b/src/views-components/progress/side-panel-progress.tsx
deleted file mode 100644
index 2d832a5..0000000
--- a/src/views-components/progress/side-panel-progress.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-// // Copyright (C) The Arvados Authors. All rights reserved.
-// //
-// // SPDX-License-Identifier: AGPL-3.0
-//
-// import * as React from 'react';
-// import { CircularProgress } from '@material-ui/core';
-// import { withProgress } from '~/store/progress-indicator/with-progress';
-// import { WithProgressStateProps } from '~/store/progress-indicator/with-progress';
-// import { ProgressIndicatorData } from '~/store/progress-indicator/progress-indicator-reducer';
-//
-// export const SidePanelProgress = withProgress(ProgressIndicatorData.SIDE_PANEL_PROGRESS)((props: WithProgressStateProps) =>
-// props.started ? <span style={{ display: 'flex', justifyContent: 'center', marginTop: "40px" }}><CircularProgress /></span> : null
-// );
diff --git a/src/views-components/progress/workbench-progress.tsx b/src/views-components/progress/workbench-progress.tsx
deleted file mode 100644
index 1fdd57c..0000000
--- a/src/views-components/progress/workbench-progress.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-// import * as React from 'react';
-// import { LinearProgress } from '@material-ui/core';
-// import { withProgress } from '~/store/progress-indicator/with-progress';
-// import { WithProgressStateProps } from '~/store/progress-indicator/with-progress';
-// import { ProgressIndicatorData } from '~/store/progress-indicator/progress-indicator-reducer';
-
-// export const WorkbenchProgress = withProgress(ProgressIndicatorData.WORKBENCH_PROGRESS)(
-// (props: WithProgressStateProps) =>
-// props.started ? <LinearProgress color="secondary" /> : null
-// );
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list