|
|
|
@ -1,47 +1,50 @@ |
|
|
|
|
import { DateTimeInput, GrafanaTheme } from '@grafana/data'; |
|
|
|
|
import { stylesFactory, useStyles } from '@grafana/ui'; |
|
|
|
|
import { OptionsPaneCategory } from 'app/features/dashboard/components/PanelEditor/OptionsPaneCategory'; |
|
|
|
|
import { PanelModel } from 'app/features/dashboard/state'; |
|
|
|
|
import { useStyles } from '@grafana/ui'; |
|
|
|
|
import { css } from '@emotion/css'; |
|
|
|
|
import React from 'react'; |
|
|
|
|
import { PanelModelWithLibraryPanel } from '../../types'; |
|
|
|
|
import { isPanelModelLibraryPanel } from '../../guard'; |
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
|
panel: PanelModel & Required<Pick<PanelModel, 'libraryPanel'>>; |
|
|
|
|
panel: PanelModelWithLibraryPanel; |
|
|
|
|
formatDate?: (dateString: DateTimeInput, format?: string) => string; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const LibraryPanelInformation: React.FC<Props> = ({ panel, formatDate }) => { |
|
|
|
|
const styles = useStyles(getStyles); |
|
|
|
|
|
|
|
|
|
if (!isPanelModelLibraryPanel(panel)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<OptionsPaneCategory title="Reusable panel information" id="Shared Panel Info" key="Shared Panel Info"> |
|
|
|
|
{panel.libraryPanel.uid && ( |
|
|
|
|
<p className={styles.libraryPanelInfo}> |
|
|
|
|
{`Used on ${panel.libraryPanel.meta.connectedDashboards} `} |
|
|
|
|
{panel.libraryPanel.meta.connectedDashboards === 1 ? 'dashboard' : 'dashboards'} |
|
|
|
|
<br /> |
|
|
|
|
Last edited on {formatDate?.(panel.libraryPanel.meta.updated, 'L') ?? panel.libraryPanel.meta.updated} by |
|
|
|
|
{panel.libraryPanel.meta.updatedBy.avatarUrl && ( |
|
|
|
|
<img |
|
|
|
|
width="22" |
|
|
|
|
height="22" |
|
|
|
|
className={styles.userAvatar} |
|
|
|
|
src={panel.libraryPanel.meta.updatedBy.avatarUrl} |
|
|
|
|
alt={`Avatar for ${panel.libraryPanel.meta.updatedBy.name}`} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
{panel.libraryPanel.meta.updatedBy.name} |
|
|
|
|
</p> |
|
|
|
|
)} |
|
|
|
|
</OptionsPaneCategory> |
|
|
|
|
<> |
|
|
|
|
<p className={styles.libraryPanelInfo}> |
|
|
|
|
{`Used on ${panel.libraryPanel.meta.connectedDashboards} `} |
|
|
|
|
{panel.libraryPanel.meta.connectedDashboards === 1 ? 'dashboard' : 'dashboards'} |
|
|
|
|
<br /> |
|
|
|
|
Last edited on {formatDate?.(panel.libraryPanel.meta.updated, 'L') ?? panel.libraryPanel.meta.updated} by |
|
|
|
|
{panel.libraryPanel.meta.updatedBy.avatarUrl && ( |
|
|
|
|
<img |
|
|
|
|
width="22" |
|
|
|
|
height="22" |
|
|
|
|
className={styles.userAvatar} |
|
|
|
|
src={panel.libraryPanel.meta.updatedBy.avatarUrl} |
|
|
|
|
alt={`Avatar for ${panel.libraryPanel.meta.updatedBy.name}`} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
{panel.libraryPanel.meta.updatedBy.name} |
|
|
|
|
</p> |
|
|
|
|
</> |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const getStyles = stylesFactory((theme: GrafanaTheme) => { |
|
|
|
|
const getStyles = (theme: GrafanaTheme) => { |
|
|
|
|
return { |
|
|
|
|
libraryPanelInfo: css` |
|
|
|
|
color: ${theme.colors.textSemiWeak}; |
|
|
|
|
font-size: ${theme.typography.size.sm}; |
|
|
|
|
margin-left: ${theme.spacing.xxs}; |
|
|
|
|
`,
|
|
|
|
|
userAvatar: css` |
|
|
|
|
border-radius: 50%; |
|
|
|
@ -52,4 +55,4 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => { |
|
|
|
|
padding-right: ${theme.spacing.sm}; |
|
|
|
|
`,
|
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|