mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 07:54:22 +00:00
Add rename and delete workspace ui elements
This commit is contained in:
@@ -1,11 +1,21 @@
|
|||||||
import React, { useReducer, useEffect, useCallback, useRef } from 'react';
|
import React, { useReducer, useEffect, useCallback, useRef } from 'react';
|
||||||
import { Modal, Badge, Button, Group, Title } from '@mantine/core';
|
import {
|
||||||
|
Modal,
|
||||||
|
Badge,
|
||||||
|
Button,
|
||||||
|
Group,
|
||||||
|
Title,
|
||||||
|
Stack,
|
||||||
|
Divider,
|
||||||
|
} from '@mantine/core';
|
||||||
import { notifications } from '@mantine/notifications';
|
import { notifications } from '@mantine/notifications';
|
||||||
import { useWorkspace } from '../contexts/WorkspaceContext';
|
import { useWorkspace } from '../contexts/WorkspaceContext';
|
||||||
import AppearanceSettings from './settings/AppearanceSettings';
|
import AppearanceSettings from './settings/AppearanceSettings';
|
||||||
import EditorSettings from './settings/EditorSettings';
|
import EditorSettings from './settings/EditorSettings';
|
||||||
import GitSettings from './settings/GitSettings';
|
import GitSettings from './settings/GitSettings';
|
||||||
|
import GeneralSettings from './settings/GeneralSettings';
|
||||||
import { useModalContext } from '../contexts/ModalContext';
|
import { useModalContext } from '../contexts/ModalContext';
|
||||||
|
import DangerZoneSettings from './settings/DangerZoneSettings';
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
localSettings: {},
|
localSettings: {},
|
||||||
@@ -100,34 +110,47 @@ const Settings = () => {
|
|||||||
centered
|
centered
|
||||||
size="lg"
|
size="lg"
|
||||||
>
|
>
|
||||||
{state.hasUnsavedChanges && (
|
<Stack spacing="xl">
|
||||||
<Badge color="yellow" variant="light" mb="md">
|
{state.hasUnsavedChanges && (
|
||||||
Unsaved Changes
|
<Badge color="yellow" variant="light">
|
||||||
</Badge>
|
Unsaved Changes
|
||||||
)}
|
</Badge>
|
||||||
<AppearanceSettings
|
)}
|
||||||
themeSettings={state.localSettings.theme}
|
|
||||||
onThemeChange={(newTheme) => handleInputChange('theme', newTheme)}
|
<GeneralSettings />
|
||||||
/>
|
<Divider />
|
||||||
<EditorSettings
|
|
||||||
autoSave={state.localSettings.autoSave}
|
<AppearanceSettings
|
||||||
onAutoSaveChange={(value) => handleInputChange('autoSave', value)}
|
themeSettings={state.localSettings.theme}
|
||||||
/>
|
onThemeChange={(newTheme) => handleInputChange('theme', newTheme)}
|
||||||
<GitSettings
|
/>
|
||||||
gitEnabled={state.localSettings.gitEnabled}
|
<Divider />
|
||||||
gitUrl={state.localSettings.gitUrl}
|
|
||||||
gitUser={state.localSettings.gitUser}
|
<EditorSettings
|
||||||
gitToken={state.localSettings.gitToken}
|
autoSave={state.localSettings.autoSave}
|
||||||
gitAutoCommit={state.localSettings.gitAutoCommit}
|
onAutoSaveChange={(value) => handleInputChange('autoSave', value)}
|
||||||
gitCommitMsgTemplate={state.localSettings.gitCommitMsgTemplate}
|
/>
|
||||||
onInputChange={handleInputChange}
|
<Divider />
|
||||||
/>
|
|
||||||
<Group justify="flex-end" mt="xl">
|
<GitSettings
|
||||||
<Button variant="default" onClick={handleClose}>
|
gitEnabled={state.localSettings.gitEnabled}
|
||||||
Cancel
|
gitUrl={state.localSettings.gitUrl}
|
||||||
</Button>
|
gitUser={state.localSettings.gitUser}
|
||||||
<Button onClick={handleSubmit}>Save Changes</Button>
|
gitToken={state.localSettings.gitToken}
|
||||||
</Group>
|
gitAutoCommit={state.localSettings.gitAutoCommit}
|
||||||
|
gitCommitMsgTemplate={state.localSettings.gitCommitMsgTemplate}
|
||||||
|
onInputChange={handleInputChange}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<DangerZoneSettings />
|
||||||
|
|
||||||
|
<Group justify="flex-end">
|
||||||
|
<Button variant="default" onClick={handleClose}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleSubmit}>Save Changes</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
35
frontend/src/components/modals/DeleteWorkspaceModal.js
Normal file
35
frontend/src/components/modals/DeleteWorkspaceModal.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Modal, Text, Button, Group, Stack } from '@mantine/core';
|
||||||
|
|
||||||
|
const DeleteWorkspaceModal = ({
|
||||||
|
opened,
|
||||||
|
onClose,
|
||||||
|
onConfirm,
|
||||||
|
workspaceName,
|
||||||
|
}) => (
|
||||||
|
<Modal
|
||||||
|
opened={opened}
|
||||||
|
onClose={onClose}
|
||||||
|
title="Delete Workspace"
|
||||||
|
centered
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
<Stack>
|
||||||
|
<Text>
|
||||||
|
Are you sure you want to delete workspace "{workspaceName}"? This action
|
||||||
|
cannot be undone and all files in this workspace will be permanently
|
||||||
|
deleted.
|
||||||
|
</Text>
|
||||||
|
<Group justify="flex-end" mt="xl">
|
||||||
|
<Button variant="default" onClick={onClose}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button color="red" onClick={onConfirm}>
|
||||||
|
Delete Workspace
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default DeleteWorkspaceModal;
|
||||||
40
frontend/src/components/settings/DangerZoneSettings.js
Normal file
40
frontend/src/components/settings/DangerZoneSettings.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { Box, Button, Title } from '@mantine/core';
|
||||||
|
import DeleteWorkspaceModal from '../modals/DeleteWorkspaceModal';
|
||||||
|
import { useWorkspace } from '../../contexts/WorkspaceContext';
|
||||||
|
|
||||||
|
const DangerZoneSettings = () => {
|
||||||
|
const { currentWorkspace } = useWorkspace();
|
||||||
|
const [deleteModalOpened, setDeleteModalOpened] = useState(false);
|
||||||
|
|
||||||
|
const handleDelete = () => {
|
||||||
|
// TODO: Implement delete functionality
|
||||||
|
setDeleteModalOpened(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box mb="md">
|
||||||
|
<Title order={3} mb="md">
|
||||||
|
Danger Zone
|
||||||
|
</Title>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
color="red"
|
||||||
|
variant="light"
|
||||||
|
onClick={() => setDeleteModalOpened(true)}
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
Delete Workspace
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<DeleteWorkspaceModal
|
||||||
|
opened={deleteModalOpened}
|
||||||
|
onClose={() => setDeleteModalOpened(false)}
|
||||||
|
onConfirm={handleDelete}
|
||||||
|
workspaceName={currentWorkspace?.name}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DangerZoneSettings;
|
||||||
32
frontend/src/components/settings/GeneralSettings.js
Normal file
32
frontend/src/components/settings/GeneralSettings.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Title, Box, TextInput, Text, Grid } from '@mantine/core';
|
||||||
|
import { useWorkspace } from '../../contexts/WorkspaceContext';
|
||||||
|
|
||||||
|
const GeneralSettings = ({ onInputChange }) => {
|
||||||
|
const { currentWorkspace } = useWorkspace();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box mb="md">
|
||||||
|
<Title order={3} mb="md">
|
||||||
|
General
|
||||||
|
</Title>
|
||||||
|
|
||||||
|
<Grid gutter="md" align="center">
|
||||||
|
<Grid.Col span={6}>
|
||||||
|
<Text size="sm">Workspace Name</Text>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={6}>
|
||||||
|
<TextInput
|
||||||
|
value={currentWorkspace?.name || ''}
|
||||||
|
onChange={(event) =>
|
||||||
|
onInputChange('name', event.currentTarget.value)
|
||||||
|
}
|
||||||
|
placeholder="Enter workspace name"
|
||||||
|
/>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GeneralSettings;
|
||||||
@@ -61,11 +61,6 @@ export const WorkspaceProvider = ({ children }) => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
await updateLastWorkspace(workspaceId);
|
await updateLastWorkspace(workspaceId);
|
||||||
await loadWorkspaceData(workspaceId);
|
await loadWorkspaceData(workspaceId);
|
||||||
notifications.show({
|
|
||||||
title: 'Success',
|
|
||||||
message: 'Workspace switched successfully',
|
|
||||||
color: 'green',
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to switch workspace:', error);
|
console.error('Failed to switch workspace:', error);
|
||||||
notifications.show({
|
notifications.show({
|
||||||
|
|||||||
Reference in New Issue
Block a user