From b102dedfd441750dcd749359c0bbcbf0494fba9f Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 27 May 2022 08:05:15 -0500 Subject: add fake delay to prevent flashing when navigating --- src/web/src/components/System/Info/index.js | 30 ++++++++++++++------ src/web/src/components/System/Options/index.js | 38 +++++++++++++++++--------- 2 files changed, 47 insertions(+), 21 deletions(-) (limited to 'src/web') diff --git a/src/web/src/components/System/Info/index.js b/src/web/src/components/System/Info/index.js index d1b504e2..063303ac 100644 --- a/src/web/src/components/System/Info/index.js +++ b/src/web/src/components/System/Info/index.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import YAML from 'yaml'; import { restart, shutdown, getVersion } from '../../../lib/application'; @@ -7,11 +7,19 @@ import { Modal, Header, Divider } from 'semantic-ui-react'; import { CodeEditor, + LoaderSegment, ShrinkableButton, + Switch, } from '../../Shared'; const Info = ({ state }) => { - const stateAsYaml = YAML.stringify(state, { simpleKeys: true, sortMapEntries: true }); + const [contents, setContents] = useState(); + + useEffect(() => { + setTimeout(() => { + setContents(YAML.stringify(state, { simpleKeys: true, sortMapEntries: true })); + }, 250); + }, [state]); return ( <> @@ -21,6 +29,7 @@ const Info = ({ state }) => { icon='refresh' mediaQuery='(max-width: 516px)' primary + disabled={!contents} onClick={() => getVersion({ forceCheck: true })} > Check for Updates @@ -32,6 +41,7 @@ const Info = ({ state }) => { icon='shutdown' mediaQuery='(max-width: 516px)' negative + disabled={!contents} > Shut Down @@ -48,6 +58,7 @@ const Info = ({ state }) => { icon='redo' mediaQuery='(max-width: 516px)' negative + disabled={!contents} > Restart @@ -60,12 +71,15 @@ const Info = ({ state }) => { /> - + } + > + + ); }; diff --git a/src/web/src/components/System/Options/index.js b/src/web/src/components/System/Options/index.js index afc1f545..16928a29 100644 --- a/src/web/src/components/System/Options/index.js +++ b/src/web/src/components/System/Options/index.js @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import YAML from 'yaml'; import DebugModal from './DebugModal'; @@ -7,30 +7,38 @@ import EditModal from './EditModal'; import { Divider } from 'semantic-ui-react'; import { CodeEditor, + LoaderSegment, ShrinkableButton, + Switch, } from '../../Shared'; const Index = ({ options }) => { const [debugModal, setDebugModal] = useState(false); const [editModal, setEditModal] = useState(false); + const [contents, setContents] = useState(); + + useEffect(() => { + setTimeout(() => { + setContents(YAML.stringify(options, { simpleKeys: true, sortMapEntries: true })); + }, 250); + }, [options]); const { remoteConfiguration, debug } = options; - const optionsAsYaml = YAML.stringify(options, { simpleKeys: true, sortMapEntries: true }); - - const DebugButton = () => { + const DebugButton = ({ ...props }) => { if (!debug) return <>; return setDebugModal(true)} + {...props} > Debug View ; }; - const EditButton = () => { + const EditButton = ({ ...props }) => { if (!remoteConfiguration) { return { icon='edit' mediaQuery='(max-width: 516px)' onClick={() => setEditModal(true)} + {...props} >Edit; }; return ( <>
- - + +
- + } + > + + setDebugModal(false)} -- cgit v1.2.3