feat: display server version on settings page

Shows the version returned form the server /info endpoint as static text
on the Settings component.
This commit is contained in:
Arthur E. Jones 2022-07-01 22:12:04 -05:00 committed by James Long
parent 6c8cb65ac2
commit 7d31c51790

View file

@ -474,6 +474,23 @@ function SettingsLink({ to, name, style, first, last }) {
}
function Version() {
let [version, setVersion] = useState('');
useEffect(async () => {
const url = await send('get-server-url');
if (!url || url.indexOf('not-configured') !== -1) return;
try {
const res = await fetch(url + '/info');
if (!res.ok) return;
const info = await res.json();
setVersion((info && info.build.version) || '');
} catch (e) {
setVersion('');
}
}, []);
return (
<Text
style={[
@ -487,7 +504,7 @@ function Version() {
styles.smallText
]}
>
v{window.Actual.ACTUAL_VERSION}
v{window.Actual.ACTUAL_VERSION} | {version ? `v${version}` : 'N/A'}
</Text>
);
}