Skip to content

Commit f5b13c5

Browse files
Sidebar refresh button (#788)
* added refresh button to refresh dashboard, it will also refresh the current dashboard if it's not in draft mode * added edge case when trying to reload the selected dashboard by clicking it and it's in draft mode, the discard modal will be shown to prevent wrong loading * Fixed styling on sidebar refresh button --------- Co-authored-by: Alfred Rubin <[email protected]> Co-authored-by: Niels de Jong <[email protected]>
1 parent 0d4535a commit f5b13c5

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

src/dashboard/sidebar/DashboardSidebar.tsx

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import { getDashboardIsEditable, getPageNumber } from '../../settings/SettingsSe
44
import { getDashboardSettings, getDashboardTitle } from '../DashboardSelectors';
55
import { Button, SideNavigation, SideNavigationGroupHeader, SideNavigationList, TextInput } from '@neo4j-ndl/react';
66
import { removeReportThunk } from '../../page/PageThunks';
7-
import { PlusIconOutline, MagnifyingGlassIconOutline, CircleStackIconOutline } from '@neo4j-ndl/react/icons';
7+
import {
8+
PlusIconOutline,
9+
MagnifyingGlassIconOutline,
10+
CircleStackIconOutline,
11+
ArrowPathIconOutline,
12+
} from '@neo4j-ndl/react/icons';
13+
814
import Tooltip from '@mui/material/Tooltip';
915
import { DashboardSidebarListItem } from './DashboardSidebarListItem';
1016
import {
@@ -367,6 +373,33 @@ export const NeoDashboardSidebar = ({
367373
<span className='n-text-palette-neutral-text-weak' style={{ lineHeight: '28px' }}>
368374
Dashboards
369375
</span>
376+
<Tooltip title='Refresh' aria-label='refresh' disableInteractive>
377+
<Button
378+
aria-label={'refresh'}
379+
fill='text'
380+
size='small'
381+
color='neutral'
382+
style={{
383+
float: 'right',
384+
marginLeft: '3px',
385+
marginRight: '12px',
386+
paddingLeft: 0,
387+
paddingRight: '3px',
388+
}}
389+
onClick={() => {
390+
getDashboardListFromNeo4j();
391+
// When reloading, if the dashboard is not in DRAFT mode, we can directly refresh it.
392+
if (!draft) {
393+
const d = dashboards[selectedDashboardIndex];
394+
loadDashboardFromNeo4j(driver, dashboardDatabase, d.uuid, (file) => {
395+
loadDashboard(d.uuid, file);
396+
});
397+
}
398+
}}
399+
>
400+
<ArrowPathIconOutline className='btn-icon-base-r-m' />
401+
</Button>
402+
</Tooltip>
370403
{/* Only let users create dashboards and change database when running in editor mode. */}
371404
{!readonly || (readonly && standaloneSettings.standaloneLoadFromOtherDatabases) ? (
372405
<>
@@ -379,7 +412,7 @@ export const NeoDashboardSidebar = ({
379412
style={{
380413
float: 'right',
381414
marginLeft: '0px',
382-
marginRight: '12px',
415+
marginRight: '3px',
383416
paddingLeft: 0,
384417
paddingRight: '3px',
385418
}}
@@ -479,7 +512,7 @@ export const NeoDashboardSidebar = ({
479512
saved={!(draft && selectedDashboardIndex == d.index)}
480513
readonly={readonly}
481514
onSelect={() => {
482-
if (draft && d.index !== selectedDashboardIndex) {
515+
if (draft) {
483516
setInspectedIndex(d.index);
484517
setModalOpen(Modal.LOAD);
485518
} else {

src/index.pcss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
@apply n-mr-token-2 n-w-4 n-h-4;
3838
}
3939

40+
.btn-icon-base-r-m {
41+
@apply n-ml-token-3 n-w-5 n-h-5;
42+
}
43+
4044
.btn-icon-base-r {
4145
@apply n-ml-token-3 n-w-6 n-h-6;
4246
}

0 commit comments

Comments
 (0)