wip
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user