From eca17f2b2c9cadf79ee5186c112fcf3d41bf2fd2 Mon Sep 17 00:00:00 2001 From: proddy Date: Tue, 4 Mar 2025 20:57:24 +0100 Subject: [PATCH] move Version back to Status page --- interface/src/AuthenticatedRouting.tsx | 4 ++-- interface/src/app/settings/Settings.tsx | 16 +------------ interface/src/app/status/Status.tsx | 9 ++++++++ .../src/app/{settings => status}/Version.tsx | 23 ++++++++++++++----- src/version.h | 2 +- 5 files changed, 30 insertions(+), 24 deletions(-) rename interface/src/app/{settings => status}/Version.tsx (96%) diff --git a/interface/src/AuthenticatedRouting.tsx b/interface/src/AuthenticatedRouting.tsx index 7fd3701b1..9777ed50a 100644 --- a/interface/src/AuthenticatedRouting.tsx +++ b/interface/src/AuthenticatedRouting.tsx @@ -15,7 +15,6 @@ import DownloadUpload from 'app/settings/DownloadUpload'; import MqttSettings from 'app/settings/MqttSettings'; import NTPSettings from 'app/settings/NTPSettings'; import Settings from 'app/settings/Settings'; -import Version from 'app/settings/Version'; import Network from 'app/settings/network/Network'; import Security from 'app/settings/security/Security'; import APStatus from 'app/status/APStatus'; @@ -26,6 +25,7 @@ import NTPStatus from 'app/status/NTPStatus'; import NetworkStatus from 'app/status/NetworkStatus'; import Status from 'app/status/Status'; import SystemLog from 'app/status/SystemLog'; +import Version from 'app/status/Version'; import { Layout } from 'components'; import { AuthenticatedContext } from 'contexts/authentication'; @@ -48,11 +48,11 @@ const AuthenticatedRouting = () => { } /> } /> } /> + } /> {me.admin && ( <> } /> - } /> } /> } /> } /> diff --git a/interface/src/app/settings/Settings.tsx b/interface/src/app/settings/Settings.tsx index 96d25853b..34abc2554 100644 --- a/interface/src/app/settings/Settings.tsx +++ b/interface/src/app/settings/Settings.tsx @@ -1,7 +1,6 @@ import { useState } from 'react'; import AccessTimeIcon from '@mui/icons-material/AccessTime'; -import BuildIcon from '@mui/icons-material/Build'; import CancelIcon from '@mui/icons-material/Cancel'; import DeviceHubIcon from '@mui/icons-material/DeviceHub'; import ImportExportIcon from '@mui/icons-material/ImportExport'; @@ -21,7 +20,7 @@ import { List } from '@mui/material'; -import { API, callAction } from 'api/app'; +import { API } from 'api/app'; import { dialogStyle } from 'CustomTheme'; import { useRequest } from 'alova/client'; @@ -40,11 +39,6 @@ const Settings = () => { immediate: false }); - // call checkUpgrade with no param to fetch EMS-ESP version - const { data } = useRequest(() => callAction({ action: 'checkUpgrade' }), { - initialData: { emsesp_version: '...' } - }); - const doFormat = async () => { await sendAPI({ device: 'system', cmd: 'format', id: 0 }).then(() => { setConfirmFactoryReset(false); @@ -83,14 +77,6 @@ const Settings = () => { const content = () => ( <> - - { return ( <> + + diff --git a/interface/src/app/settings/Version.tsx b/interface/src/app/status/Version.tsx similarity index 96% rename from interface/src/app/settings/Version.tsx rename to interface/src/app/status/Version.tsx index 7fbfbf2d0..0f75bdd58 100644 --- a/interface/src/app/settings/Version.tsx +++ b/interface/src/app/status/Version.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react'; +import { useContext, useEffect, useState } from 'react'; import { toast } from 'react-toastify'; import CancelIcon from '@mui/icons-material/Cancel'; @@ -34,10 +34,13 @@ import { SingleUpload, useLayoutTitle } from 'components'; +import { AuthenticatedContext } from 'contexts/authentication'; import { useI18nContext } from 'i18n/i18n-react'; const Version = () => { const { LL, locale } = useI18nContext(); + const { me } = useContext(AuthenticatedContext); + const [restarting, setRestarting] = useState(false); const [openInstallDialog, setOpenInstallDialog] = useState(false); const [usingDevVersion, setUsingDevVersion] = useState(false); @@ -230,6 +233,10 @@ const Version = () => { }; const showButtons = (showDev?: boolean) => { + if (!me.admin) { + return; + } + if (downloadOnly) { return (