2aa9d73325
集中保留原版权声明,移除文件头检查和全局测试忽略规则。验证:全量单测、受影响用例复测及静态检查通过。
103 lines
2.4 KiB
React
103 lines
2.4 KiB
React
import { Plus as ActionPlus } from '@/components/common/icons/ActionIcons';
|
|
import React from 'react';
|
|
import { Tabs, TabPane, Tag } from '@/components/ui';
|
|
import { Button } from 'antd';
|
|
import { CHANNEL_OPTIONS } from '../../../constants';
|
|
import { getChannelIcon, isRoot } from '../../../helpers';
|
|
import './channels-tabs.css';
|
|
|
|
const ChannelsTabs = ({
|
|
enableTagMode,
|
|
activeTypeKey,
|
|
setActiveTypeKey,
|
|
channelTypeCounts,
|
|
availableTypeKeys,
|
|
loadChannels,
|
|
activePage,
|
|
pageSize,
|
|
idSort,
|
|
setActivePage,
|
|
setEditingChannel,
|
|
setShowEdit,
|
|
t,
|
|
}) => {
|
|
const createButton = isRoot() ? (
|
|
<Button
|
|
className='console-create-action'
|
|
type='primary'
|
|
size='middle'
|
|
icon={<ActionPlus size={16} />}
|
|
onClick={() => {
|
|
setEditingChannel({ id: undefined });
|
|
setShowEdit(true);
|
|
}}
|
|
>
|
|
{t('创建渠道')}
|
|
</Button>
|
|
) : null;
|
|
|
|
if (enableTagMode) {
|
|
return createButton ? (
|
|
<div className='flex justify-end'>{createButton}</div>
|
|
) : null;
|
|
}
|
|
|
|
const handleTabChange = (key) => {
|
|
setActiveTypeKey(key);
|
|
setActivePage(1);
|
|
loadChannels(1, pageSize, idSort, enableTagMode, key);
|
|
};
|
|
|
|
return (
|
|
<Tabs
|
|
activeKey={activeTypeKey}
|
|
type='line'
|
|
onChange={handleTabChange}
|
|
className='channels-tabs mb-2'
|
|
tabBarExtraContent={createButton}
|
|
>
|
|
<TabPane
|
|
itemKey='all'
|
|
tab={
|
|
<span className='flex items-center gap-2'>
|
|
{t('全部')}
|
|
<Tag
|
|
color={activeTypeKey === 'all' ? 'red' : 'grey'}
|
|
shape='circle'
|
|
>
|
|
{channelTypeCounts['all'] || 0}
|
|
</Tag>
|
|
</span>
|
|
}
|
|
/>
|
|
|
|
{CHANNEL_OPTIONS.filter((opt) =>
|
|
availableTypeKeys.includes(String(opt.value)),
|
|
).map((option) => {
|
|
const key = String(option.value);
|
|
const count = channelTypeCounts[option.value] || 0;
|
|
return (
|
|
<TabPane
|
|
key={key}
|
|
itemKey={key}
|
|
tab={
|
|
<span className='flex items-center gap-2'>
|
|
{getChannelIcon(option.value)}
|
|
{option.label}
|
|
<Tag
|
|
color={activeTypeKey === key ? 'red' : 'grey'}
|
|
shape='circle'
|
|
>
|
|
{count}
|
|
</Tag>
|
|
</span>
|
|
}
|
|
/>
|
|
);
|
|
})}
|
|
</Tabs>
|
|
);
|
|
};
|
|
|
|
export default ChannelsTabs;
|