Enable workspace renaming

This commit is contained in:
2024-10-27 18:15:11 +01:00
parent c5e0937070
commit b679af08e7
2 changed files with 16 additions and 6 deletions

View File

@@ -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 = () => {
</Badge>
)}
<GeneralSettings />
<GeneralSettings
name={state.localSettings.name}
onInputChange={handleInputChange}
/>
<Divider />
<AppearanceSettings

View File

@@ -1,10 +1,7 @@
import React from 'react';
import { Title, Box, TextInput, Text, Grid } from '@mantine/core';
import { useWorkspace } from '../../contexts/WorkspaceContext';
const GeneralSettings = ({ onInputChange }) => {
const { currentWorkspace } = useWorkspace();
const GeneralSettings = ({ name, onInputChange }) => {
return (
<Box mb="md">
<Title order={3} mb="md">
@@ -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>