projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
15768: standardized naming Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox@curii...
[arvados.git]
/
src
/
components
/
refresh-button
/
refresh-button.tsx
diff --git
a/src/components/refresh-button/refresh-button.tsx
b/src/components/refresh-button/refresh-button.tsx
index f34a0213259a79f62950b9a5e0b1108b0644252d..e2fe54846820d3efbaf744ce20a1f75d57f0cfec 100644
(file)
--- a/
src/components/refresh-button/refresh-button.tsx
+++ b/
src/components/refresh-button/refresh-button.tsx
@@
-3,11
+3,11
@@
//
// SPDX-License-Identifier: AGPL-3.0
//
// SPDX-License-Identifier: AGPL-3.0
-import
* as
React from 'react';
-import
* as
classNames from 'classnames';
+import React from 'react';
+import classNames from 'classnames';
import { withRouter, RouteComponentProps } from 'react-router';
import { StyleRulesCallback, Button, WithStyles, withStyles } from "@material-ui/core";
import { withRouter, RouteComponentProps } from 'react-router';
import { StyleRulesCallback, Button, WithStyles, withStyles } from "@material-ui/core";
-import { ReRunProcessIcon } from '
~/
components/icon/icon';
+import { ReRunProcessIcon } from 'components/icon/icon';
type CssRules = 'button' | 'buttonRight';
type CssRules = 'button' | 'buttonRight';
@@
-22,13
+22,25
@@
const styles: StyleRulesCallback<CssRules> = theme => ({
},
});
},
});
-export const RefreshButton = ({ history, classes }: RouteComponentProps & WithStyles<CssRules>) =>
+interface RefreshButtonProps {
+ onClick?: () => void;
+}
+
+export const LAST_REFRESH_TIMESTAMP = 'lastRefreshTimestamp';
+
+export const RefreshButton = ({ history, classes, onClick }: RouteComponentProps & WithStyles<CssRules> & RefreshButtonProps) =>
<Button
color="primary"
size="small"
variant="contained"
onClick={() => {
<Button
color="primary"
size="small"
variant="contained"
onClick={() => {
- history.push(window.location.pathname);
+ // Notify interested parties that the refresh button was clicked.
+ const now = (new Date()).getTime();
+ localStorage.setItem(LAST_REFRESH_TIMESTAMP, now.toString());
+ history.replace(window.location.pathname);
+ if (onClick) {
+ onClick();
+ }
}}
className={classNames(classes.buttonRight, classes.button)}>
<ReRunProcessIcon />
}}
className={classNames(classes.buttonRight, classes.button)}>
<ReRunProcessIcon />