mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 18:33:33 +00:00
allow hiding context menu items
This commit is contained in:
parent
f746114041
commit
004c9a8d06
6 changed files with 100 additions and 1 deletions
|
|
@ -0,0 +1,58 @@
|
|||
import { useTranslation } from 'react-i18next';
|
||||
import { SettingsOptions } from '/@/renderer/features/settings/components/settings-option';
|
||||
import { useState } from 'react';
|
||||
import { Button, Checkbox } from '/@/renderer/components';
|
||||
import { Divider, Stack } from '@mantine/core';
|
||||
import {
|
||||
CONFIGURABLE_CONTEXT_MENU_ITEMS,
|
||||
CONTEXT_MENU_ITEM_MAPPING,
|
||||
} from '/@/renderer/features/context-menu';
|
||||
import { useSettingsStore, useSettingsStoreActions } from '/@/renderer/store';
|
||||
|
||||
export const ContextMenuSettings = () => {
|
||||
const disabledItems = useSettingsStore((state) => state.general.disabledContextMenu);
|
||||
const { toggleContextMenuItem } = useSettingsStoreActions();
|
||||
const [open, setOpen] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<SettingsOptions
|
||||
control={
|
||||
<Button
|
||||
compact
|
||||
variant="filled"
|
||||
onClick={() => setOpen(!open)}
|
||||
>
|
||||
{t(open ? 'common.close' : 'common.edit', { postProcess: 'titleCase' })}
|
||||
</Button>
|
||||
}
|
||||
description={t('setting.contextMenu', {
|
||||
context: 'description',
|
||||
postProcess: 'sentenceCase',
|
||||
})}
|
||||
title={t('setting.contextMenu', {
|
||||
postProcess: 'sentenceCase',
|
||||
})}
|
||||
/>
|
||||
{open && (
|
||||
<Stack>
|
||||
{CONFIGURABLE_CONTEXT_MENU_ITEMS.map((item) => (
|
||||
<Checkbox
|
||||
key={item}
|
||||
checked={!disabledItems[item]}
|
||||
label={t(
|
||||
`page.contextMenu.${CONTEXT_MENU_ITEM_MAPPING[item] || item}`,
|
||||
{
|
||||
postProcess: 'sentenceCase',
|
||||
},
|
||||
)}
|
||||
onChange={() => toggleContextMenuItem(item)}
|
||||
/>
|
||||
))}
|
||||
</Stack>
|
||||
)}
|
||||
<Divider />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
@ -8,6 +8,7 @@ import { CacheSettings } from '/@/renderer/features/settings/components/window/c
|
|||
import isElectron from 'is-electron';
|
||||
import { HomeSettings } from '/@/renderer/features/settings/components/general/home-settings';
|
||||
import { SidebarReorder } from '/@/renderer/features/settings/components/general/sidebar-reorder';
|
||||
import { ContextMenuSettings } from '/@/renderer/features/settings/components/general/context-menu-settings';
|
||||
|
||||
export const GeneralTab = () => {
|
||||
return (
|
||||
|
|
@ -18,6 +19,7 @@ export const GeneralTab = () => {
|
|||
<HomeSettings />
|
||||
<SidebarReorder />
|
||||
<SidebarSettings />
|
||||
<ContextMenuSettings />
|
||||
{isElectron() && <RemoteSettings />}
|
||||
<CacheSettings />
|
||||
</Stack>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue