Dashboard: extend dashnav to add custom content (#23433)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// Libaries
|
// Libaries
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent, FC } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { css } from 'emotion';
|
import { css } from 'emotion';
|
||||||
import { e2e } from '@grafana/e2e';
|
import { e2e } from '@grafana/e2e';
|
||||||
@@ -29,6 +29,12 @@ export interface OwnProps {
|
|||||||
onAddPanel: () => void;
|
onAddPanel: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const customNavbarContent: Array<FC<Partial<OwnProps>>> = [];
|
||||||
|
|
||||||
|
export function addNavbarContent(content: FC<Partial<OwnProps>>) {
|
||||||
|
customNavbarContent.push(content);
|
||||||
|
}
|
||||||
|
|
||||||
export interface StateProps {
|
export interface StateProps {
|
||||||
location: any;
|
location: any;
|
||||||
}
|
}
|
||||||
@@ -173,6 +179,10 @@ class DashNav extends PureComponent<Props> {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{customNavbarContent.map((Component, index) => (
|
||||||
|
<Component {...this.props} key={`navbar-custom-content-${index}`} />
|
||||||
|
))}
|
||||||
|
|
||||||
<div className="navbar-buttons navbar-buttons--actions">
|
<div className="navbar-buttons navbar-buttons--actions">
|
||||||
{canSave && (
|
{canSave && (
|
||||||
<DashNavButton
|
<DashNavButton
|
||||||
|
|||||||
Reference in New Issue
Block a user