Public Dashboards: Extracting config of Public Dashboard (#57788)

Co-authored-by: juanicabanas <juan.cabanas@grafana.com>
This commit is contained in:
lean.dev
2022-11-02 14:32:29 -03:00
committed by GitHub
parent 7954ac3948
commit d5a92e8f42

View File

@@ -4,20 +4,38 @@ import React from 'react';
import { GrafanaTheme2, colorManipulator } from '@grafana/data'; import { GrafanaTheme2, colorManipulator } from '@grafana/data';
import { useStyles2 } from '@grafana/ui'; import { useStyles2 } from '@grafana/ui';
export interface PublicDashboardFooter {
hide: boolean;
text: string;
logo: string;
link: string;
}
export const PubdashFooter = function () { export const PubdashFooter = function () {
const styles = useStyles2(getStyles); const styles = useStyles2(getStyles);
const conf = getPubdashFooterConfig();
return ( return conf.hide ? null : (
<div className={styles.footer}> <div className={styles.footer}>
<span className={styles.logoText}> <span className={styles.logoText}>
<a href="https://grafana.com/" target="_blank" rel="noreferrer noopener"> <a href={conf.link} target="_blank" rel="noreferrer noopener">
powered by Grafana <img className={styles.logoImg} alt="" src="public/img/grafana_icon.svg"></img> {conf.text} <img className={styles.logoImg} alt="" src={conf.logo}></img>
</a> </a>
</span> </span>
</div> </div>
); );
}; };
export function setPubdashFooterConfigFn(fn: typeof getPubdashFooterConfig) {
getPubdashFooterConfig = fn;
}
export let getPubdashFooterConfig = (): PublicDashboardFooter => ({
hide: false,
text: 'powered by Grafana',
logo: 'public/img/grafana_icon.svg',
link: 'https://grafana.com/',
});
const getStyles = (theme: GrafanaTheme2) => ({ const getStyles = (theme: GrafanaTheme2) => ({
footer: css` footer: css`
position: absolute; position: absolute;