|
1 | 1 | import { IconLock, IconUnlock } from '@douyinfe/semi-icons'; |
2 | 2 | import { Button, ButtonGroup, Tooltip } from '@douyinfe/semi-ui'; |
3 | 3 | import { flatten } from 'lodash-es'; |
| 4 | +import { Fragment } from 'react'; |
4 | 5 | import { isValidArray, t } from '@/share/core/utils'; |
5 | 6 | import useMarkCommon from '@/share/hooks/use-mark-common'; |
6 | 7 | import Api from '@/share/pages/api'; |
7 | 8 | import { Toast } from '@/share/pages/toast'; |
| 9 | +import GroupItem from './group-item'; |
8 | 10 |
|
9 | 11 | const toggleGroup = async (name: string, target: boolean) => { |
10 | 12 | const rules = flatten(Object.values(await Api.getAllRules())); |
@@ -33,29 +35,32 @@ const Group = () => { |
33 | 35 | return ( |
34 | 36 | <div className="item-block"> |
35 | 37 | {keys.map(key => ( |
36 | | - <div className="item" key={key}> |
37 | | - <div className="name">{key}</div> |
38 | | - <ButtonGroup> |
39 | | - <Tooltip content={t('enable')}> |
40 | | - <Button |
41 | | - theme="borderless" |
42 | | - type="tertiary" |
43 | | - onClick={() => toggleGroup(key, true)} |
44 | | - size="small" |
45 | | - icon={<IconUnlock />} |
46 | | - /> |
47 | | - </Tooltip> |
48 | | - <Tooltip content={t('disable')}> |
49 | | - <Button |
50 | | - theme="borderless" |
51 | | - type="tertiary" |
52 | | - onClick={() => toggleGroup(key, false)} |
53 | | - size="small" |
54 | | - icon={<IconLock />} |
55 | | - /> |
56 | | - </Tooltip> |
57 | | - </ButtonGroup> |
58 | | - </div> |
| 38 | + <Fragment key={key}> |
| 39 | + <div className="title group"> |
| 40 | + <div className="name">{key}</div> |
| 41 | + <ButtonGroup> |
| 42 | + <Tooltip content={t('enable')}> |
| 43 | + <Button |
| 44 | + theme="borderless" |
| 45 | + type="tertiary" |
| 46 | + onClick={() => toggleGroup(key, true)} |
| 47 | + size="small" |
| 48 | + icon={<IconUnlock />} |
| 49 | + /> |
| 50 | + </Tooltip> |
| 51 | + <Tooltip content={t('disable')}> |
| 52 | + <Button |
| 53 | + theme="borderless" |
| 54 | + type="tertiary" |
| 55 | + onClick={() => toggleGroup(key, false)} |
| 56 | + size="small" |
| 57 | + icon={<IconLock />} |
| 58 | + /> |
| 59 | + </Tooltip> |
| 60 | + </ButtonGroup> |
| 61 | + </div> |
| 62 | + <GroupItem group={key} /> |
| 63 | + </Fragment> |
59 | 64 | ))} |
60 | 65 | </div> |
61 | 66 | ); |
|
0 commit comments