18972: Records the last refresh click on localStorage for others to act on.
[arvados-workbench2.git] / src / components / refresh-button / refresh-button.tsx
index f2c41d28f63769a74f45bfa38f2867d93a2dfefa..e2fe54846820d3efbaf744ce20a1f75d57f0cfec 100644 (file)
@@ -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={() => {
+            // 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 />