mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Chore: Fix typescript strict null errors * Added new limit * Fixed ts issue * fixed tests * trying to fix type inference * Fixing more ts errors * Revert tsconfig option * Fix * Fixed code * More fixes * fix tests * Updated snapshot * Chore: More ts strict null fixes * More fixes in some really messed up azure config components * More fixes, current count: 441 * 419 * More fixes * Fixed invalid initial state in explore * Fixing tests * Fixed tests * Explore fix * More fixes * Progress * Sub 300 * Now at 218 * Progress * Update * Progress * Updated tests * at 159 * fixed tests * Fixed test
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import React, { FC } from 'react';
|
|
import { Icon, IconName, Tooltip } from '@grafana/ui';
|
|
import { sanitize, sanitizeUrl } from '@grafana/data/src/text/sanitize';
|
|
import { DashboardLinksDashboard } from './DashboardLinksDashboard';
|
|
import { getLinkSrv } from '../../../panel/panellinks/link_srv';
|
|
|
|
import { DashboardModel } from '../../state';
|
|
import { DashboardLink } from '../../state/DashboardModel';
|
|
import { iconMap } from '../DashLinks/DashLinksEditorCtrl';
|
|
|
|
export interface Props {
|
|
dashboard: DashboardModel;
|
|
}
|
|
|
|
export const DashboardLinks: FC<Props> = ({ dashboard }) => {
|
|
if (!dashboard.links.length) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{dashboard.links.map((link: DashboardLink, index: number) => {
|
|
const linkInfo = getLinkSrv().getAnchorInfo(link);
|
|
const key = `${link.title}-$${index}`;
|
|
|
|
if (link.type === 'dashboards') {
|
|
return <DashboardLinksDashboard key={key} link={link} linkInfo={linkInfo} dashboardId={dashboard.id} />;
|
|
}
|
|
|
|
const linkElement = (
|
|
<a className="gf-form-label" href={sanitizeUrl(linkInfo.href)} target={link.targetBlank ? '_blank' : '_self'}>
|
|
<Icon name={iconMap[link.icon] as IconName} style={{ marginRight: '4px' }} />
|
|
<span>{sanitize(linkInfo.title)}</span>
|
|
</a>
|
|
);
|
|
|
|
return (
|
|
<div key={key} className="gf-form">
|
|
{link.tooltip ? <Tooltip content={link.tooltip}>{linkElement}</Tooltip> : linkElement}
|
|
</div>
|
|
);
|
|
})}
|
|
</>
|
|
);
|
|
};
|