feat: make unsaved settings obvious

This commit is contained in:
鲁树人
2024-09-26 21:02:42 +01:00
parent b26e62e8d9
commit 00813957d6
2 changed files with 28 additions and 4 deletions

View File

@@ -1,12 +1,36 @@
import { Box, VStack } from '@chakra-ui/react';
import { Alert, AlertIcon, Box, Button, Flex, Text, VStack } from '@chakra-ui/react';
import { SelectFile } from '../components/SelectFile';
import { FileListing } from '~/features/file-listing/FileListing';
import { useAppDispatch, useAppSelector } from '~/hooks.ts';
import { selectIsSettingsNotSaved } from '~/features/settings/settingsSelector.ts';
import { commitStagingChange } from '~/features/settings/settingsSlice.ts';
export function MainTab() {
const dispatch = useAppDispatch();
const isSettingsNotSaved = useAppSelector(selectIsSettingsNotSaved);
const onClickSaveSettings = () => {
dispatch(commitStagingChange());
};
return (
<Box h="full" w="full" pt="4">
<VStack gap="3">
{isSettingsNotSaved && (
<Alert borderRadius={7} maxW={400} status="warning">
<AlertIcon />
<Flex flexDir="row" alignItems="center" flexGrow={1} justifyContent="space-between">
<Text m={0}>
<br />
</Text>
<Button type="button" ml={3} size="md" onClick={onClickSaveSettings}>
</Button>
</Flex>
</Alert>
)}
<SelectFile />
<Box w="full">