mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
improving dash nav react comp
This commit is contained in:
@@ -5,6 +5,9 @@ import { connect } from 'react-redux';
|
|||||||
// Utils & Services
|
// Utils & Services
|
||||||
import { appEvents } from 'app/core/app_events';
|
import { appEvents } from 'app/core/app_events';
|
||||||
|
|
||||||
|
// Components
|
||||||
|
import { DashNavButton } from './DashNavButton';
|
||||||
|
|
||||||
// State
|
// State
|
||||||
import { updateLocation } from 'app/core/actions';
|
import { updateLocation } from 'app/core/actions';
|
||||||
|
|
||||||
@@ -41,10 +44,17 @@ export class DashNav extends PureComponent<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onClose = () => {
|
onClose = () => {
|
||||||
|
if (this.props.editview) {
|
||||||
this.props.updateLocation({
|
this.props.updateLocation({
|
||||||
query: { editview: null, panelId: null, edit: null, fullscreen: null },
|
query: { editview: null },
|
||||||
partial: true,
|
partial: true,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.props.updateLocation({
|
||||||
|
query: { panelId: null, edit: null, fullscreen: null },
|
||||||
|
partial: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onToggleTVMode = () => {
|
onToggleTVMode = () => {
|
||||||
@@ -116,19 +126,12 @@ export class DashNav extends PureComponent<Props> {
|
|||||||
|
|
||||||
<div className="navbar-buttons navbar-buttons--actions">
|
<div className="navbar-buttons navbar-buttons--actions">
|
||||||
{canEdit && (
|
{canEdit && (
|
||||||
<button className="btn navbar-button navbar-button--add-panel" title="Add panel" onClick={this.onAddPanel}>
|
<DashNavButton
|
||||||
<i className="gicon gicon-add-panel" />
|
tooltip="Add panel"
|
||||||
</button>
|
classSuffix="add-panel"
|
||||||
)}
|
icon="gicon gicon-add-panel"
|
||||||
|
onClick={this.onAddPanel}
|
||||||
{showSettings && (
|
/>
|
||||||
<button
|
|
||||||
className="btn navbar-button navbar-button--settings"
|
|
||||||
onClick={this.onOpenSettings}
|
|
||||||
title="Dashboard Settings"
|
|
||||||
>
|
|
||||||
<i className="fa fa-cog" />
|
|
||||||
</button>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{canStar && (
|
{canStar && (
|
||||||
@@ -171,6 +174,16 @@ export class DashNav extends PureComponent<Props> {
|
|||||||
<i className="fa fa-link" />
|
<i className="fa fa-link" />
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{showSettings && (
|
||||||
|
<button
|
||||||
|
className="btn navbar-button navbar-button--settings"
|
||||||
|
onClick={this.onOpenSettings}
|
||||||
|
title="Dashboard Settings"
|
||||||
|
>
|
||||||
|
<i className="fa fa-cog" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="navbar-buttons navbar-buttons--tv">
|
<div className="navbar-buttons navbar-buttons--tv">
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// Libraries
|
||||||
|
import React, { FunctionComponent } from 'react';
|
||||||
|
|
||||||
|
// Components
|
||||||
|
import { Tooltip } from '@grafana/ui';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
icon: string;
|
||||||
|
tooltip: string;
|
||||||
|
classSuffix: string;
|
||||||
|
onClick: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DashNavButton: FunctionComponent<Props> = ({ icon, tooltip, classSuffix, onClick }) => {
|
||||||
|
return (
|
||||||
|
<Tooltip content={tooltip} placement="bottom">
|
||||||
|
<button className={`btn navbar-button navbar-button--${classSuffix}`} onClick={onClick}>
|
||||||
|
<i className={icon} />
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -33,7 +33,7 @@ async function redirectToNewUrl(slug: string, dispatch: any) {
|
|||||||
export function initDashboard({ $injector, $scope, urlUid, urlSlug, urlType }: InitDashboardArgs): ThunkResult<void> {
|
export function initDashboard({ $injector, $scope, urlUid, urlSlug, urlType }: InitDashboardArgs): ThunkResult<void> {
|
||||||
return async dispatch => {
|
return async dispatch => {
|
||||||
// handle old urls with no uid
|
// handle old urls with no uid
|
||||||
if (!urlUid && urlSlug) {
|
if (!urlUid && urlSlug && !urlType) {
|
||||||
redirectToNewUrl(urlSlug, dispatch);
|
redirectToNewUrl(urlSlug, dispatch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user