From 075fcedc8155bdb5c5450c6a500b9a58257f8666 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 30 Jul 2023 11:24:49 +0200 Subject: [PATCH 1/2] wip: client: Relegate source filter to advanced settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most people will not use filter for most sources so let’s only show it when filled in or when advanced settings are enabled. With advanced settings we will be able to implement less common features like archival, reduced update frequency or icon overriding. WIP because I do not like the the toggle button placement. --- client/js/templates/Source.jsx | 56 ++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/client/js/templates/Source.jsx b/client/js/templates/Source.jsx index c91275d12e..62940c5918 100644 --- a/client/js/templates/Source.jsx +++ b/client/js/templates/Source.jsx @@ -370,6 +370,18 @@ function SourceEditForm({ const _ = useContext(LocalizationContext); + const [showAdvanced, setShowAdvanced] = useState(false); + const [filterUsed, setFilterUsed] = useState(source.filter !== ''); + + const toggleShowAdvanced = useCallback( + () => { + setShowAdvanced((advanced) => !advanced); + console.log(source.filter); + setFilterUsed(source.filter !== ''); + }, + [source.filter] + ); + const sourceParamsContent = ( sourceParamsLoading ? ( @@ -451,22 +463,24 @@ function SourceEditForm({ {/* filter */} -
  • - - - {sourceErrors['filter'] ? ( - {sourceErrors['filter']} - ) : null} -
  • + {showAdvanced || filterUsed ? ( +
  • + + + {sourceErrors['filter'] ? ( + {sourceErrors['filter']} + ) : null} +
  • + ) : null} {/* type */}
  • @@ -513,6 +527,16 @@ function SourceEditForm({ {/* save/delete */}
  • + + {' • '}
  • + {showAdvanced || iconUsed ? ( +
  • + + + {sourceErrors['icon'] ? ( + {sourceErrors['icon']} + ) : null} +
  • + ) : null} + {/* settings */} {sourceParamsContent ? (