TopNav: Make dashboard toolbar actions work in new top nav (#51950)

* Initial work on new toolbar button

* Minor step

* Small progress

* Minor progress

* Minor fix

* removed console.log

* Removing stuff we don't need yet
This commit is contained in:
Torkel Ödegaard
2022-07-14 20:34:00 +02:00
committed by GitHub
parent ecdd4a184f
commit 7947629f82
13 changed files with 106 additions and 44 deletions

View File

@@ -6,6 +6,7 @@ import { locationUtil, textUtil } from '@grafana/data';
import { locationService } from '@grafana/runtime';
import { ButtonGroup, ModalsController, ToolbarButton, PageToolbar, useForceUpdate } from '@grafana/ui';
import { AppChromeUpdate } from 'app/core/components/AppChrome/AppChromeUpdate';
import { NavToolbarSeparator } from 'app/core/components/AppChrome/NavToolbarSeparator';
import config from 'app/core/config';
import { toggleKioskMode } from 'app/core/navigation/kiosk';
import { DashboardCommentsModal } from 'app/features/dashboard/components/DashboardComments/DashboardCommentsModal';
@@ -109,7 +110,7 @@ export const DashNav = React.memo<Props>((props) => {
return playlistSrv.isPlaying;
};
const renderLeftActionsButton = () => {
const renderLeftActions = () => {
const { dashboard, kioskMode } = props;
const { canStar, canShare, isStarred } = dashboard.meta;
const buttons: ReactNode[] = [];
@@ -199,7 +200,7 @@ export const DashNav = React.memo<Props>((props) => {
);
};
const renderRightActionsButton = () => {
const renderRightActions = () => {
const { dashboard, onAddPanel, isFullscreen, kioskMode } = props;
const { canSave, canEdit, showSettings } = dashboard.meta;
const { snapshot } = dashboard;
@@ -279,7 +280,13 @@ export const DashNav = React.memo<Props>((props) => {
return (
<AppChromeUpdate
pageNav={{ text: title }}
actions={<ToolbarButton onClick={onOpenSettings} icon="cog"></ToolbarButton>}
actions={
<>
{renderLeftActions()}
<NavToolbarSeparator leftActionsSeparator />
{renderRightActions()}
</>
}
/>
);
}
@@ -292,9 +299,9 @@ export const DashNav = React.memo<Props>((props) => {
titleHref={titleHref}
parentHref={parentHref}
onGoBack={onGoBack}
leftItems={renderLeftActionsButton()}
leftItems={renderLeftActions()}
>
{renderRightActionsButton()}
{renderRightActions()}
</PageToolbar>
);
});