From 2c7b814d376ec9e3c6667e7c9b66f2dc3b71a990 Mon Sep 17 00:00:00 2001 From: Jed Fox <git@jedfox.com> Date: Sun, 4 Jun 2023 14:22:32 -0400 Subject: [PATCH] =?UTF-8?q?Disable=20=E2=80=9CReset=20sync=E2=80=9D=20butt?= =?UTF-8?q?on=20when=20sync=20is=20disabled=20(#1104)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extracted from #984 --- .../src/components/settings/Reset.js | 27 +++++++++++++------ .../src/components/settings/index.js | 2 +- upcoming-release-notes/1104.md | 6 +++++ 3 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 upcoming-release-notes/1104.md diff --git a/packages/desktop-client/src/components/settings/Reset.js b/packages/desktop-client/src/components/settings/Reset.js index f17383cb4..16307b416 100644 --- a/packages/desktop-client/src/components/settings/Reset.js +++ b/packages/desktop-client/src/components/settings/Reset.js @@ -34,7 +34,7 @@ export function ResetCache() { ); } -export function ResetSync({ resetSync }) { +export function ResetSync({ isEnabled, resetSync }) { let [resetting, setResetting] = useState(false); async function onResetSync() { @@ -46,17 +46,28 @@ export function ResetSync({ resetSync }) { return ( <Setting primaryAction={ - <ButtonWithLoading loading={resetting} onClick={onResetSync}> + <ButtonWithLoading + loading={resetting} + disabled={!isEnabled} + onClick={onResetSync} + > Reset sync </ButtonWithLoading> } > - <Text> - <strong>Reset sync</strong> will remove all local data used to track - changes for syncing, and create a fresh sync ID on the server. This file - on other devices will have to be re-downloaded to use the new sync ID. - Use this if there is a problem with syncing and you want to start fresh. - </Text> + {isEnabled ? ( + <Text> + <strong>Reset sync</strong> will remove all local data used to track + changes for syncing, and create a fresh sync ID on the server. This + file on other devices will have to be re-downloaded to use the new + sync ID. Use this if there is a problem with syncing and you want to + start fresh. + </Text> + ) : ( + <Text> + <strong>Reset sync</strong> is only available when syncing is enabled. + </Text> + )} </Setting> ); } diff --git a/packages/desktop-client/src/components/settings/index.js b/packages/desktop-client/src/components/settings/index.js index c56f0775e..85b9fbf8c 100644 --- a/packages/desktop-client/src/components/settings/index.js +++ b/packages/desktop-client/src/components/settings/index.js @@ -176,7 +176,7 @@ function Settings({ <AdvancedToggle> <AdvancedAbout prefs={prefs} /> <ResetCache /> - <ResetSync resetSync={resetSync} /> + <ResetSync isEnabled={!!prefs.groupId} resetSync={resetSync} /> <FixSplitsTool /> <ExperimentalFeatures prefs={prefs} savePrefs={savePrefs} /> </AdvancedToggle> diff --git a/upcoming-release-notes/1104.md b/upcoming-release-notes/1104.md new file mode 100644 index 000000000..5baf9c273 --- /dev/null +++ b/upcoming-release-notes/1104.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [j-f1] +--- + +Disable “Reset sync†button when sync is disabled -- GitLab