From 408dbd43e3e2ba88cb915f3d810f0c6f3b062cba Mon Sep 17 00:00:00 2001 From: Jake Low Date: Tue, 17 Dec 2024 19:10:13 -0800 Subject: [PATCH] Improve footer version info --- src/components/Footer/Footer.jsx | 58 ++++++++++++++------------------ vite.config.js | 6 ++++ vitest.config.js | 22 +++++++----- 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/components/Footer/Footer.jsx b/src/components/Footer/Footer.jsx index 7d7f309dc..f953e18b2 100644 --- a/src/components/Footer/Footer.jsx +++ b/src/components/Footer/Footer.jsx @@ -3,26 +3,16 @@ import { FormattedMessage, injectIntl } from 'react-intl' import SvgSymbol from '../SvgSymbol/SvgSymbol' import messages from './Messages' -import { version } from '../../../package.json' - class Footer extends Component { - constructor(props) { - super(props); - - this.state = { - data : null - }; - } + state = { + serviceInfo: null + }; componentDidMount() { - this.renderMyData(); - } - - renderMyData(){ fetch(`${window.env.REACT_APP_MAP_ROULETTE_SERVER_URL}/api/v2/service/info`) - .then((response) => response.json()) - .then((responseJson) => { - this.setState({ data : responseJson }) + .then((res) => res.json()) + .then((serviceInfo) => { + this.setState({ serviceInfo }); }) .catch((error) => { console.error(error); @@ -30,36 +20,38 @@ class Footer extends Component { } render() { + let frontendVersion = __GIT_TAG__ !== '' ? __GIT_TAG__ : __GIT_SHA__.slice(0, 7); + let frontendVersionUrl = __GIT_TAG__ !== '' + ? `https://github.com/maproulette/maproulette3/releases/tag/${__GIT_TAG__}` + : `https://github.com/maproulette/maproulette3/commit/${__GIT_SHA__}`; + + let info = this.state.serviceInfo?.compiletime; + let backendVersion = info?.version === info?.gitHeadCommit + ? info?.gitHeadCommit.slice(0, 7) + : info?.version; + let backendVersionUrl = info?.version === info?.gitHeadCommit + ? `https://github.com/maproulette/maproulette-backend/commit/${info?.gitHeadCommit}` + : `https://github.com/maproulette/maproulette-backend/releases/tag/v${info?.version}`; + return ( -