From b679af08e7911017ea991316e9d4e449d33d4d35 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Sun, 27 Oct 2024 18:15:11 +0100 Subject: [PATCH] Enable workspace renaming --- frontend/src/components/Settings.js | 14 +++++++++++++- .../src/components/settings/GeneralSettings.js | 8 +++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Settings.js b/frontend/src/components/Settings.js index 18cba57..b64f51c 100644 --- a/frontend/src/components/Settings.js +++ b/frontend/src/components/Settings.js @@ -63,6 +63,7 @@ const Settings = () => { if (isInitialMount.current) { isInitialMount.current = false; const settings = { + name: currentWorkspace.name, theme: currentWorkspace.theme, autoSave: currentWorkspace.autoSave, gitEnabled: currentWorkspace.gitEnabled, @@ -82,6 +83,14 @@ const Settings = () => { const handleSubmit = async () => { try { + if (!state.localSettings.name?.trim()) { + notifications.show({ + message: 'Workspace name cannot be empty', + color: 'red', + }); + return; + } + await updateSettings(state.localSettings); dispatch({ type: 'MARK_SAVED' }); notifications.show({ @@ -117,7 +126,10 @@ const Settings = () => { )} - + { - const { currentWorkspace } = useWorkspace(); +const GeneralSettings = ({ name, onInputChange }) => { return ( @@ -17,11 +14,12 @@ const GeneralSettings = ({ onInputChange }) => { </Grid.Col> <Grid.Col span={6}> <TextInput - value={currentWorkspace?.name || ''} + value={name || ''} onChange={(event) => onInputChange('name', event.currentTarget.value) } placeholder="Enter workspace name" + required /> </Grid.Col> </Grid>