From 1e80bac2d226e8d62c53aa45c1209067a13711fb Mon Sep 17 00:00:00 2001 From: Johannes Schill Date: Mon, 14 Jan 2019 22:15:21 +0100 Subject: [PATCH] chore: Reactify footer --- public/app/core/components/Footer/Footer.tsx | 50 ++++++++++++++++++++ public/app/core/components/Page/Page.tsx | 21 ++++---- public/app/core/config.ts | 2 + 3 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 public/app/core/components/Footer/Footer.tsx diff --git a/public/app/core/components/Footer/Footer.tsx b/public/app/core/components/Footer/Footer.tsx new file mode 100644 index 00000000000..01da74036b6 --- /dev/null +++ b/public/app/core/components/Footer/Footer.tsx @@ -0,0 +1,50 @@ +import React, { SFC } from 'react'; +import { Tooltip } from '@grafana/ui'; + +interface Props { + appName: string; + buildVersion: string; + buildCommit: string; + newGrafanaVersionExists: boolean; + newGrafanaVersion: string; +} + +export const Footer: SFC = ({appName, buildVersion, buildCommit, newGrafanaVersionExists, newGrafanaVersion}) => { + return ( + + ); +}; + +export default Footer; diff --git a/public/app/core/components/Page/Page.tsx b/public/app/core/components/Page/Page.tsx index eeba4b3037b..95345f250ed 100644 --- a/public/app/core/components/Page/Page.tsx +++ b/public/app/core/components/Page/Page.tsx @@ -1,11 +1,14 @@ // Libraries import React, { Component } from 'react'; +import config from 'app/core/config'; // Components import PageHeader from '../PageHeader/PageHeader'; +import Footer from '../Footer/Footer'; import PageContents from './PageContents'; import { CustomScrollbar } from '@grafana/ui'; + interface Props { title?: string; children: JSX.Element[] | JSX.Element; @@ -14,15 +17,11 @@ interface Props { class Page extends Component { private bodyClass = 'is-react'; private body = document.getElementsByTagName('body')[0]; - private footer = document.getElementsByClassName('footer')[0].cloneNode(true); - private scrollbarElementRef = React.createRef(); static Header = PageHeader; static Contents = PageContents; - componentDidMount() { this.body.classList.add(this.bodyClass); - this.copyFooter(); this.updateTitle(); } @@ -41,17 +40,19 @@ class Page extends Component { document.title = title ? title + ' - Grafana' : 'Grafana'; } - copyFooter = () => { - const c = this.scrollbarElementRef.current; - c.append(this.footer); - } - render() { + const { buildInfo } = config; return (
-
+
{this.props.children} +
diff --git a/public/app/core/config.ts b/public/app/core/config.ts index 13d84772ecf..0aa159af84d 100644 --- a/public/app/core/config.ts +++ b/public/app/core/config.ts @@ -6,6 +6,8 @@ export interface BuildInfo { commit: string; isEnterprise: boolean; env: string; + latestVersion: string; + hasUpdate: boolean; } export class Settings {