[ARVADOS-WORKBENCH2] created: 1.4.1-394-gcdd2d022

Git user git at public.arvados.org
Tue Jul 28 21:33:45 UTC 2020


        at  cdd2d0222b4a0d7d2b6e0cf27ca3951d7d89a8c1 (commit)


commit cdd2d0222b4a0d7d2b6e0cf27ca3951d7d89a8c1
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Tue Jul 28 23:32:20 2020 +0200

    16627: Added refresh button to main contet bar
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/src/components/refresh-button/refresh-button.test.tsx b/src/components/refresh-button/refresh-button.test.tsx
new file mode 100644
index 00000000..f6372e5c
--- /dev/null
+++ b/src/components/refresh-button/refresh-button.test.tsx
@@ -0,0 +1,43 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { Button } from "@material-ui/core";
+import { shallow, configure } from "enzyme";
+import * as Adapter from "enzyme-adapter-react-16";
+import { RefreshButton } from './refresh-button';
+
+configure({ adapter: new Adapter() });
+
+describe('<RefreshButton />', () => {
+    let props;
+
+    beforeEach(() => {
+        props = {
+            history: {
+                push: jest.fn(),
+            },
+            classes: {},
+        };
+    });
+
+    it('should render without issues', () => {
+        // when
+        const wrapper = shallow(<RefreshButton {...props} />);
+
+        // then
+        expect(wrapper.html()).toContain('button');
+    });
+
+    it('should pass window location to router', () => {
+        // setup
+        const wrapper = shallow(<RefreshButton {...props} />);
+
+        // when
+        wrapper.find(Button).simulate('click');
+
+        // then
+        expect(props.history.push).toHaveBeenCalledWith('/');
+    });
+});
diff --git a/src/components/refresh-button/refresh-button.tsx b/src/components/refresh-button/refresh-button.tsx
new file mode 100644
index 00000000..f34a0213
--- /dev/null
+++ b/src/components/refresh-button/refresh-button.tsx
@@ -0,0 +1,38 @@
+
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import * as classNames from 'classnames';
+import { withRouter, RouteComponentProps } from 'react-router';
+import { StyleRulesCallback, Button, WithStyles, withStyles } from "@material-ui/core";
+import { ReRunProcessIcon } from '~/components/icon/icon';
+
+type CssRules = 'button' | 'buttonRight';
+
+const styles: StyleRulesCallback<CssRules> = theme => ({
+    button: {
+        boxShadow: 'none',
+        padding: '2px 10px 2px 5px',
+        fontSize: '0.75rem'
+    },
+    buttonRight: {
+        marginLeft: 'auto',
+    },
+});
+
+export const RefreshButton = ({ history, classes }: RouteComponentProps & WithStyles<CssRules>) =>
+    <Button
+        color="primary"
+        size="small"
+        variant="contained"
+        onClick={() => {
+            history.push(window.location.pathname);
+        }}
+        className={classNames(classes.buttonRight, classes.button)}>
+        <ReRunProcessIcon />
+        Refresh
+    </Button>;
+
+export default withStyles(styles)(withRouter(RefreshButton));
\ No newline at end of file
diff --git a/src/views-components/main-content-bar/main-content-bar.tsx b/src/views-components/main-content-bar/main-content-bar.tsx
index c0014d00..c8565d62 100644
--- a/src/views-components/main-content-bar/main-content-bar.tsx
+++ b/src/views-components/main-content-bar/main-content-bar.tsx
@@ -3,15 +3,27 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from "react";
-import { Toolbar, IconButton, Tooltip, Grid } from "@material-ui/core";
+
+import { Toolbar, StyleRulesCallback, IconButton, Tooltip, Grid, WithStyles, withStyles } from "@material-ui/core";
 import { DetailsIcon } from "~/components/icon/icon";
 import { Breadcrumbs } from "~/views-components/breadcrumbs/breadcrumbs";
 import { connect } from 'react-redux';
 import { RootState } from '~/store/store';
 import * as Routes from '~/routes/routes';
 import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
+import RefreshButton from "~/components/refresh-button/refresh-button";
+
+type CssRules = "infoTooltip";
+
+const styles: StyleRulesCallback<CssRules> = theme => ({
+    infoTooltip: {
+        marginTop: '-10px',
+        marginLeft: '10px',
+    }
+});
 
 interface MainContentBarProps {
+    onRefreshPage: () => void;
     onDetailsPanelToggle: () => void;
     buttonVisible: boolean;
 }
@@ -27,22 +39,30 @@ const isButtonVisible = ({ router }: RootState) => {
         !Routes.matchMyAccountRoute(pathname) && !Routes.matchLinksRoute(pathname);
 };
 
-export const MainContentBar = connect((state: RootState) => ({
-    buttonVisible: isButtonVisible(state)
-}), {
-        onDetailsPanelToggle: toggleDetailsPanel
-    })((props: MainContentBarProps) =>
-        <Toolbar>
-            <Grid container>
-                <Grid container item xs alignItems="center">
-                    <Breadcrumbs />
-                </Grid>
-                <Grid item>
-                    {props.buttonVisible && <Tooltip title="Additional Info">
-                        <IconButton color="inherit" onClick={props.onDetailsPanelToggle}>
-                            <DetailsIcon />
-                        </IconButton>
-                    </Tooltip>}
-                </Grid>
-            </Grid>
-        </Toolbar>);
+export const MainContentBar =
+    connect((state: RootState) => ({
+        buttonVisible: isButtonVisible(state)
+    }), {
+        onDetailsPanelToggle: toggleDetailsPanel,
+    })(
+        withStyles(styles)(
+            (props: MainContentBarProps & WithStyles<CssRules> & any) =>
+                <Toolbar>
+                    <Grid container>
+                        <Grid item xs alignItems="center">
+                            <Breadcrumbs />
+                        </Grid>
+                        <Grid item>
+                            <RefreshButton />
+                        </Grid>
+                        <Grid item>
+                            {props.buttonVisible && <Tooltip title="Additional Info">
+                                <IconButton color="inherit" className={props.classes.infoTooltip} onClick={props.onDetailsPanelToggle}>
+                                    <DetailsIcon />
+                                </IconButton>
+                            </Tooltip>}
+                        </Grid>
+                    </Grid>
+                </Toolbar>
+        )
+    );

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list