[enhancement]: support serach on settings page

This commit is contained in:
Kendall Garner 2024-05-05 13:25:05 -07:00
parent 683bb0222c
commit 645697367d
No known key found for this signature in database
GPG key ID: 18D2767419676C87
21 changed files with 439 additions and 385 deletions

View file

@ -3,8 +3,11 @@ import { useQueryClient } from '@tanstack/react-query';
import isElectron from 'is-electron';
import { useTranslation } from 'react-i18next';
import { Button, ConfirmModal, toast } from '/@/renderer/components';
import { SettingsOptions } from '/@/renderer/features/settings/components/settings-option';
import { useCallback, useState } from 'react';
import {
SettingOption,
SettingsSection,
} from '/@/renderer/features/settings/components/settings-section';
const browser = isElectron() ? window.electron.browser : null;
@ -50,42 +53,46 @@ export const CacheSettings = () => {
});
};
const options: SettingOption[] = [
{
control: (
<Button
compact
disabled={isClearing}
variant="filled"
onClick={() => openResetConfirmModal(false)}
>
{t('common.clear', { postProcess: 'sentenceCase' })}
</Button>
),
description: t('setting.clearQueryCache', {
context: 'description',
}),
title: t('setting.clearQueryCache'),
},
{
control: (
<Button
compact
disabled={isClearing}
variant="filled"
onClick={() => openResetConfirmModal(true)}
>
{t('common.clear', { postProcess: 'sentenceCase' })}
</Button>
),
description: t('setting.clearCache', {
context: 'description',
}),
isHidden: !browser,
title: t('setting.clearCache'),
},
];
return (
<>
<SettingsOptions
control={
<Button
compact
disabled={isClearing}
variant="filled"
onClick={() => openResetConfirmModal(false)}
>
{t('common.clear', { postProcess: 'sentenceCase' })}
</Button>
}
description={t('setting.clearQueryCache', {
context: 'description',
})}
title={t('setting.clearQueryCache')}
/>
{browser && (
<SettingsOptions
control={
<Button
compact
disabled={isClearing}
variant="filled"
onClick={() => openResetConfirmModal(true)}
>
{t('common.clear', { postProcess: 'sentenceCase' })}
</Button>
}
description={t('setting.clearCache', {
context: 'description',
})}
title={t('setting.clearCache')}
/>
)}
</>
<SettingsSection
divider={false}
options={options}
/>
);
};

View file

@ -52,5 +52,10 @@ export const PasswordSettings = () => {
},
];
return <SettingsSection options={updateOptions} />;
return (
<SettingsSection
divider={false}
options={updateOptions}
/>
);
};

View file

@ -8,6 +8,7 @@ import {
import { Switch } from '/@/renderer/components';
const localSettings = isElectron() ? window.electron.localSettings : null;
const utils = isElectron() ? window.electron.utils : null;
export const UpdateSettings = () => {
const { t } = useTranslation();
@ -42,5 +43,10 @@ export const UpdateSettings = () => {
},
];
return <SettingsSection options={updateOptions} />;
return (
<SettingsSection
divider={utils?.isLinux()}
options={updateOptions}
/>
);
};

View file

@ -1,4 +1,4 @@
import { Divider, Stack } from '@mantine/core';
import { Stack } from '@mantine/core';
import { UpdateSettings } from '/@/renderer/features/settings/components/window/update-settings';
import { WindowSettings } from '/@/renderer/features/settings/components/window/window-settings';
import { DiscordSettings } from '/@/renderer/features/settings/components/window/discord-settings';
@ -11,13 +11,10 @@ export const WindowTab = () => {
return (
<Stack spacing="md">
<WindowSettings />
<Divider />
<DiscordSettings />
<Divider />
<UpdateSettings />
{utils?.isLinux() && (
<>
<Divider />
<PasswordSettings />
</>
)}