This commit is contained in:
Marcus Andersson
2025-12-19 16:21:17 +01:00
parent 5e3baf593d
commit 8e0bd2527c
@@ -17,22 +17,29 @@ export function DashboardLinksControls({ links, dashboard }: Props) {
sceneGraph.getTimeRange(dashboard).useState();
const uid = dashboard.state.uid;
const styles = useStyles2(getStyles);
const linksToDisplay = excludeControlMenuLinks(links);
if (!links || !uid || links.length === 0) {
if (!uid || linksToDisplay.length === 0) {
return null;
}
return (
<div className={styles.linksContainer}>
{links
.filter((link) => link.placement === undefined)
.map((link: DashboardLink, index: number) => (
<DashboardLinkRenderer link={link} dashboardUID={uid} key={`${link.title}-$${index}`} />
))}
{linksToDisplay.map((link: DashboardLink, index: number) => (
<DashboardLinkRenderer link={link} dashboardUID={uid} key={`${link.title}-$${index}`} />
))}
</div>
);
}
function excludeControlMenuLinks(links: DashboardLink[]): DashboardLink[] {
if (!links || links.length === 0) {
return [];
}
return links.filter((link) => link.placement === undefined);
}
function getStyles(theme: GrafanaTheme2) {
return {
linksContainer: css({