import { Button } from "@material-ui/core";
import { shallow, configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
-import { RefreshButton } from './refresh-button';
+import { LAST_REFRESH_TIMESTAMP, RefreshButton } from './refresh-button';
configure({ adapter: new Adapter() });
});
it('should pass window location to router', () => {
+ expect(localStorage.getItem(LAST_REFRESH_TIMESTAMP)).toBeFalsy();
// setup
const wrapper = shallow(<RefreshButton {...props} />);
// then
expect(props.history.replace).toHaveBeenCalledWith('/');
+ expect(localStorage.getItem(LAST_REFRESH_TIMESTAMP)).not.toBeFalsy();
});
});
import { DataColumn } from "components/data-table/data-column";
import { DataColumns } from "components/data-table/data-table";
import { DataTableFilters } from 'components/data-table-filters/data-table-filters-tree';
+import { LAST_REFRESH_TIMESTAMP } from "components/refresh-button/refresh-button";
interface Props {
id: string;
onContextMenu?: (event: React.MouseEvent<HTMLElement>, item: any, isAdmin?: boolean) => void;
onRowDoubleClick: (item: any) => void;
extractKey?: (item: any) => React.Key;
- working?: boolean;
}
let prevRoute = '';
+let prevRefresh = '';
let routeChanged = false;
let isWorking = false;
const progress = state.progressIndicator.find(p => p.id === id);
const dataExplorerState = getDataExplorer(state.dataExplorer, id);
const currentRoute = state.router.location ? state.router.location.pathname : '';
+ const currentRefresh = localStorage.getItem(LAST_REFRESH_TIMESTAMP) || '';
const currentItemUuid = currentRoute === '/workflows' ? state.properties.workflowPanelDetailsUuid : state.detailsPanel.resourceUuid;
- if (currentRoute !== prevRoute) {
+ if (currentRoute !== prevRoute || currentRefresh !== prevRefresh) {
routeChanged = true;
prevRoute = currentRoute;
+ prevRefresh = currentRefresh;
}
if (progress?.working) {
isWorking = true;
import { toggleDetailsPanel } from 'store/details-panel/details-panel-action';
import RefreshButton from "components/refresh-button/refresh-button";
import { loadSidePanelTreeProjects } from "store/side-panel-tree/side-panel-tree-actions";
+import { Dispatch } from "redux";
type CssRules = "infoTooltip";
Routes.matchAllProcessesRoute(pathname) ||
Routes.matchTrashRoute(pathname) ||
Routes.matchFavoritesRoute(pathname);
-
- /* return !Routes.matchWorkflowRoute(pathname) && !Routes.matchUserVirtualMachineRoute(pathname) &&
- * !Routes.matchAdminVirtualMachineRoute(pathname) && !Routes.matchRepositoriesRoute(pathname) &&
- * !Routes.matchSshKeysAdminRoute(pathname) && !Routes.matchSshKeysUserRoute(pathname) &&
- * !Routes.matchSiteManagerRoute(pathname) &&
- * !Routes.matchKeepServicesRoute(pathname) && !Routes.matchComputeNodesRoute(pathname) &&
- * !Routes.matchApiClientAuthorizationsRoute(pathname) && !Routes.matchUsersRoute(pathname) &&
- * !Routes.matchMyAccountRoute(pathname) && !Routes.matchLinksRoute(pathname); */
};
-export const MainContentBar =
- connect((state: RootState) => ({
- buttonVisible: isButtonVisible(state),
- projectUuid: state.detailsPanel.resourceUuid,
- }), (dispatch) => ({
- onDetailsPanelToggle: () => dispatch<any>(toggleDetailsPanel()),
- onRefreshButtonClick: (id) => {
- dispatch<any>(loadSidePanelTreeProjects(id));
- }
- }))(
- withStyles(styles)(
- (props: MainContentBarProps & WithStyles<CssRules> & any) =>
- <Toolbar>
- <Grid container>
- <Grid container item xs alignItems="center">
- <Breadcrumbs />
- </Grid>
- <Grid item>
- <RefreshButton onClick={() => {
- props.onRefreshButtonClick(props.projectUuid);
- }} />
- </Grid>
- <Grid item>
- {props.buttonVisible && <Tooltip title="Additional Info">
- <IconButton data-cy="additional-info-icon" color="inherit" className={props.classes.infoTooltip} onClick={props.onDetailsPanelToggle}>
- <DetailsIcon />
- </IconButton>
- </Tooltip>}
- </Grid>
- </Grid>
- </Toolbar>
- )
- );
+const mapStateToProps = (state: RootState) => ({
+ buttonVisible: isButtonVisible(state),
+ projectUuid: state.detailsPanel.resourceUuid,
+});
+
+const mapDispatchToProps = () => (dispatch: Dispatch) => ({
+ onDetailsPanelToggle: () => dispatch<any>(toggleDetailsPanel()),
+ onRefreshButtonClick: (id) => {
+ dispatch<any>(loadSidePanelTreeProjects(id));
+ }
+});
+
+export const MainContentBar = connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(
+ (props: MainContentBarProps & WithStyles<CssRules> & any) =>
+ <Toolbar><Grid container>
+ <Grid container item xs alignItems="center">
+ <Breadcrumbs />
+ </Grid>
+ <Grid item>
+ <RefreshButton onClick={() => {
+ props.onRefreshButtonClick(props.projectUuid);
+ }} />
+ </Grid>
+ <Grid item>
+ {props.buttonVisible && <Tooltip title="Additional Info">
+ <IconButton data-cy="additional-info-icon"
+ color="inherit"
+ className={props.classes.infoTooltip}
+ onClick={props.onDetailsPanelToggle}>
+ <DetailsIcon />
+ </IconButton>
+ </Tooltip>}
+ </Grid>
+ </Grid></Toolbar>
+));