[release-12.3.1] Dashboard Controls: Display dashboard links on the right side of the toolbar (#114817)
Dashboard Controls: Display dashboard links on the right side of the toolbar (#114378)
* have dashboard links on the right side
* Lets try a compromise (#114389)
Try to compromise on white space. Having a lot of links will create unessecary empty space under the time controls, but it is necessary if we want to be able to have the links on the right
---------
(cherry picked from commit 8227ecb499)
Co-authored-by: Haris Rozajac <58232930+harisrozajac@users.noreply.github.com>
Co-authored-by: Sergej-Vlasov <sergej.s.vlasov@gmail.com>
This commit is contained in:
co-authored by
Haris Rozajac
Sergej-Vlasov
parent
567f2f79f8
commit
b7cae5fbd0
@@ -170,7 +170,12 @@ function DashboardControlsRenderer({ model }: SceneComponentProps<DashboardContr
|
|||||||
<refreshPicker.Component model={refreshPicker} />
|
<refreshPicker.Component model={refreshPicker} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!hideDashboardControls && model.hasDashboardControls() && <DashboardControlsButton dashboard={dashboard} />}
|
{!hideDashboardControls && model.hasDashboardControls() && (
|
||||||
|
<div className={styles.dashboardControlsButton}>
|
||||||
|
<DashboardControlsButton dashboard={dashboard} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!hideLinksControls && !editPanel && <DashboardLinksControls links={links} dashboard={dashboard} />}
|
||||||
</div>
|
</div>
|
||||||
{!hideVariableControls && (
|
{!hideVariableControls && (
|
||||||
<>
|
<>
|
||||||
@@ -178,7 +183,6 @@ function DashboardControlsRenderer({ model }: SceneComponentProps<DashboardContr
|
|||||||
<DashboardDataLayerControls dashboard={dashboard} />
|
<DashboardDataLayerControls dashboard={dashboard} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{!hideLinksControls && !editPanel && <DashboardLinksControls links={links} dashboard={dashboard} />}
|
|
||||||
{editPanel && <PanelEditControls panelEditor={editPanel} />}
|
{editPanel && <PanelEditControls panelEditor={editPanel} />}
|
||||||
{showDebugger && <SceneDebugger scene={model} key={'scene-debugger'} />}
|
{showDebugger && <SceneDebugger scene={model} key={'scene-debugger'} />}
|
||||||
</div>
|
</div>
|
||||||
@@ -226,17 +230,26 @@ function getStyles(theme: GrafanaTheme2) {
|
|||||||
}),
|
}),
|
||||||
rightControls: css({
|
rightControls: css({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'flex-end',
|
|
||||||
gap: theme.spacing(1),
|
gap: theme.spacing(1),
|
||||||
marginBottom: theme.spacing(1),
|
|
||||||
float: 'right',
|
float: 'right',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
maxWidth: '100%',
|
||||||
|
minWidth: 0,
|
||||||
}),
|
}),
|
||||||
timeControls: css({
|
timeControls: css({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'flex-end',
|
justifyContent: 'flex-end',
|
||||||
gap: theme.spacing(1),
|
gap: theme.spacing(1),
|
||||||
marginBottom: theme.spacing(1),
|
marginBottom: theme.spacing(1),
|
||||||
|
order: 2,
|
||||||
|
marginLeft: 'auto',
|
||||||
|
flexShrink: 0,
|
||||||
|
alignSelf: 'flex-start',
|
||||||
|
}),
|
||||||
|
dashboardControlsButton: css({
|
||||||
|
order: 2,
|
||||||
|
marginLeft: 'auto',
|
||||||
}),
|
}),
|
||||||
rightControlsWrap: css({
|
rightControlsWrap: css({
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
|
import { css } from '@emotion/css';
|
||||||
|
|
||||||
|
import { GrafanaTheme2 } from '@grafana/data';
|
||||||
import { sceneGraph } from '@grafana/scenes';
|
import { sceneGraph } from '@grafana/scenes';
|
||||||
import { DashboardLink } from '@grafana/schema';
|
import { DashboardLink } from '@grafana/schema';
|
||||||
|
import { useStyles2 } from '@grafana/ui';
|
||||||
|
|
||||||
import { DashboardLinkRenderer } from './DashboardLinkRenderer';
|
import { DashboardLinkRenderer } from './DashboardLinkRenderer';
|
||||||
import { DashboardScene } from './DashboardScene';
|
import { DashboardScene } from './DashboardScene';
|
||||||
@@ -12,18 +16,33 @@ export interface Props {
|
|||||||
export function DashboardLinksControls({ links, dashboard }: Props) {
|
export function DashboardLinksControls({ links, dashboard }: Props) {
|
||||||
sceneGraph.getTimeRange(dashboard).useState();
|
sceneGraph.getTimeRange(dashboard).useState();
|
||||||
const uid = dashboard.state.uid;
|
const uid = dashboard.state.uid;
|
||||||
|
const styles = useStyles2(getStyles);
|
||||||
|
|
||||||
if (!links || !uid) {
|
if (!links || !uid) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className={styles.linksContainer}>
|
||||||
{links
|
{links
|
||||||
.filter((link) => link.placement === undefined)
|
.filter((link) => link.placement === undefined)
|
||||||
.map((link: DashboardLink, index: number) => (
|
.map((link: DashboardLink, index: number) => (
|
||||||
<DashboardLinkRenderer link={link} dashboardUID={uid} key={`${link.title}-$${index}`} />
|
<DashboardLinkRenderer link={link} dashboardUID={uid} key={`${link.title}-$${index}`} />
|
||||||
))}
|
))}
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getStyles(theme: GrafanaTheme2) {
|
||||||
|
return {
|
||||||
|
linksContainer: css({
|
||||||
|
display: 'flex',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
gap: theme.spacing(1),
|
||||||
|
maxWidth: '100%',
|
||||||
|
minWidth: 0,
|
||||||
|
order: 1,
|
||||||
|
flex: '1 1 0%',
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user