diff --git a/packages/desktop-client/src/components/common/Menu.tsx b/packages/desktop-client/src/components/common/Menu.tsx index 9e971fcc9fb..57dd789ab5e 100644 --- a/packages/desktop-client/src/components/common/Menu.tsx +++ b/packages/desktop-client/src/components/common/Menu.tsx @@ -25,7 +25,7 @@ function Keybinding({ keyName }: KeybindingProps) { ); } -export type MenuItem = { +type MenuItem = { type?: string | symbol; name: string; disabled?: boolean; diff --git a/packages/desktop-client/src/components/filters/CondOpMenu.tsx b/packages/desktop-client/src/components/filters/CondOpMenu.tsx index 92bba5a8d46..c2e97ff5db5 100644 --- a/packages/desktop-client/src/components/filters/CondOpMenu.tsx +++ b/packages/desktop-client/src/components/filters/CondOpMenu.tsx @@ -25,7 +25,7 @@ export function CondOpMenu({ ['or', 'any'], ]} value={conditionsOp} - onChange={value => onCondOpChange(value, filters)} + onChange={(value: string) => onCondOpChange(value, filters)} /> of: diff --git a/packages/desktop-client/src/components/filters/FilterMenu.tsx b/packages/desktop-client/src/components/filters/FilterMenu.tsx index 91cab475f22..a392fd1779b 100644 --- a/packages/desktop-client/src/components/filters/FilterMenu.tsx +++ b/packages/desktop-client/src/components/filters/FilterMenu.tsx @@ -3,14 +3,16 @@ import React from 'react'; import { Menu } from '../common/Menu'; import { MenuTooltip } from '../common/MenuTooltip'; +import { type SavedFilter } from './SavedFilterMenuButton'; + export function FilterMenu({ onClose, filterId, onFilterMenuSelect, }: { onClose: () => void; - filterId: any; - onFilterMenuSelect: any; + filterId: SavedFilter; + onFilterMenuSelect: (item: string) => void; }) { return ( @@ -18,36 +20,34 @@ export function FilterMenu({ onMenuSelect={item => { onFilterMenuSelect(item); }} - items={[ - ...(!filterId.id + items={ + !filterId.id ? [ { name: 'save-filter', text: 'Save new filter' }, { name: 'clear-filter', text: 'Clear all conditions' }, ] - : [ - ...(filterId.id !== null && filterId.status === 'saved' - ? [ - { name: 'rename-filter', text: 'Rename' }, - { name: 'delete-filter', text: 'Delete' }, - Menu.line, - { - name: 'save-filter', - text: 'Save new filter', - disabled: true, - }, - { name: 'clear-filter', text: 'Clear all conditions' }, - ] - : [ - { name: 'rename-filter', text: 'Rename' }, - { name: 'update-filter', text: 'Update condtions' }, - { name: 'reload-filter', text: 'Revert changes' }, - { name: 'delete-filter', text: 'Delete' }, - Menu.line, - { name: 'save-filter', text: 'Save new filter' }, - { name: 'clear-filter', text: 'Clear all conditions' }, - ]), - ]), - ]} + : filterId.id !== null && filterId.status === 'saved' + ? [ + { name: 'rename-filter', text: 'Rename' }, + { name: 'delete-filter', text: 'Delete' }, + Menu.line, + { + name: 'save-filter', + text: 'Save new filter', + disabled: true, + }, + { name: 'clear-filter', text: 'Clear all conditions' }, + ] + : [ + { name: 'rename-filter', text: 'Rename' }, + { name: 'update-filter', text: 'Update condtions' }, + { name: 'reload-filter', text: 'Revert changes' }, + { name: 'delete-filter', text: 'Delete' }, + Menu.line, + { name: 'save-filter', text: 'Save new filter' }, + { name: 'clear-filter', text: 'Clear all conditions' }, + ] + } /> ); diff --git a/packages/desktop-client/src/components/filters/NameFilter.tsx b/packages/desktop-client/src/components/filters/NameFilter.tsx index e4fb2bcec78..a7600ab94db 100644 --- a/packages/desktop-client/src/components/filters/NameFilter.tsx +++ b/packages/desktop-client/src/components/filters/NameFilter.tsx @@ -16,6 +16,14 @@ export function NameFilter({ adding, onAddUpdate, err, +}: { + onClose: () => void; + menuItem: string; + name: string; + setName: (item: string) => void; + adding: boolean; + onAddUpdate: () => void; + err: string | null; }) { const inputRef = useRef(); @@ -42,11 +50,10 @@ export function NameFilter({ style={{ userSelect: 'none' }} /> setName(item)} />