Skip to content

Commit 35bf0e0

Browse files
committed
feat(dashboard): add refresh option to search button
1 parent ed9d320 commit 35bf0e0

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed
Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,41 @@
1-
import { Button } from '@mantine/core';
1+
import { ActionIcon, Button, Menu } from '@mantine/core';
2+
import { IconChevronDown, IconRefresh } from '@tabler/icons-react';
3+
import { useTranslation } from 'react-i18next';
24
import { useDashboardThemeContext } from '~/contexts';
35
import { RenderSearchButtonProps } from '~/index';
46

57
export const SearchButton = ({ disabled, onSubmit }: RenderSearchButtonProps) => {
8+
const { t } = useTranslation();
69
const { renderSearchButton } = useDashboardThemeContext();
710
if (renderSearchButton) {
811
return renderSearchButton({ disabled, onSubmit });
912
}
1013
return (
11-
<Button color="blue" size="sm" onClick={() => onSubmit()} disabled={disabled}>
12-
Search
13-
</Button>
14+
<Button.Group>
15+
<Button color="blue" size="sm" onClick={() => onSubmit()} disabled={disabled}>
16+
{t('common.actions.search')}
17+
</Button>
18+
<Menu trigger="hover" disabled={disabled} position="bottom-end">
19+
<Menu.Target>
20+
<Button
21+
disabled={disabled}
22+
color="blue"
23+
px="xs"
24+
style={{ borderLeft: `1px solid ${disabled ? 'white' : 'var(--mantine-color-gray-4)'}` }}
25+
>
26+
<IconChevronDown size={16} />
27+
</Button>
28+
</Menu.Target>
29+
<Menu.Dropdown>
30+
<Menu.Item
31+
leftSection={<IconRefresh size={14} />}
32+
disabled={disabled}
33+
onClick={() => onSubmit({ force: true })}
34+
>
35+
{t('common.actions.reload')}
36+
</Menu.Item>
37+
</Menu.Dropdown>
38+
</Menu>
39+
</Button.Group>
1440
);
1541
};

dashboard/src/i18n/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ export const en = {
299299
copied: 'Copied to clipboard',
300300
action: 'Action',
301301
actions: {
302+
search: 'Search',
303+
reload: 'Reload',
302304
actions: 'Actions',
303305
open: 'Open',
304306
close: 'Close',

dashboard/src/i18n/zh.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ export const zh = {
299299
copied: '已复制到剪切板',
300300
action: '操作',
301301
actions: {
302+
search: '查询',
303+
reload: '刷新',
302304
actions: '操作',
303305
open: '打开',
304306
close: '关闭',

0 commit comments

Comments
 (0)