Commit 28d6240c authored by kennylbj's avatar kennylbj Committed by 陈帅

Add name prop for NoticeIconTab (#2436)

* Add name prop for NoticeIconTab in order to support clear-by-type when using i18n.

* Fix typo
parent 23f6dcd9
...@@ -117,18 +117,21 @@ export default class GlobalHeaderRight extends PureComponent { ...@@ -117,18 +117,21 @@ export default class GlobalHeaderRight extends PureComponent {
<NoticeIcon.Tab <NoticeIcon.Tab
list={noticeData.notification} list={noticeData.notification}
title={formatMessage({ id: 'component.globalHeader.notification' })} title={formatMessage({ id: 'component.globalHeader.notification' })}
name="notification"
emptyText={formatMessage({ id: 'component.globalHeader.notification.empty' })} emptyText={formatMessage({ id: 'component.globalHeader.notification.empty' })}
emptyImage="https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg" emptyImage="https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg"
/> />
<NoticeIcon.Tab <NoticeIcon.Tab
list={noticeData.message} list={noticeData.message}
title={formatMessage({ id: 'component.globalHeader.message' })} title={formatMessage({ id: 'component.globalHeader.message' })}
name="message"
emptyText={formatMessage({ id: 'component.globalHeader.message.empty' })} emptyText={formatMessage({ id: 'component.globalHeader.message.empty' })}
emptyImage="https://gw.alipayobjects.com/zos/rmsportal/sAuJeJzSKbUmHfBQRzmZ.svg" emptyImage="https://gw.alipayobjects.com/zos/rmsportal/sAuJeJzSKbUmHfBQRzmZ.svg"
/> />
<NoticeIcon.Tab <NoticeIcon.Tab
list={noticeData.event} list={noticeData.event}
title={formatMessage({ id: 'component.globalHeader.event' })} title={formatMessage({ id: 'component.globalHeader.event' })}
name="event"
emptyText={formatMessage({ id: 'component.globalHeader.event.empty' })} emptyText={formatMessage({ id: 'component.globalHeader.event.empty' })}
emptyImage="https://gw.alipayobjects.com/zos/rmsportal/HsIsxMZiWKrNUavQUXqx.svg" emptyImage="https://gw.alipayobjects.com/zos/rmsportal/HsIsxMZiWKrNUavQUXqx.svg"
/> />
......
...@@ -11,6 +11,7 @@ export interface INoticeIconData { ...@@ -11,6 +11,7 @@ export interface INoticeIconData {
export interface INoticeIconTabProps { export interface INoticeIconTabProps {
list?: INoticeIconData[]; list?: INoticeIconData[];
title?: string; title?: string;
name?: string;
emptyText?: React.ReactNode; emptyText?: React.ReactNode;
emptyImage?: string; emptyImage?: string;
style?: React.CSSProperties; style?: React.CSSProperties;
......
...@@ -6,9 +6,9 @@ export interface INoticeIconProps { ...@@ -6,9 +6,9 @@ export interface INoticeIconProps {
bell?: React.ReactNode; bell?: React.ReactNode;
className?: string; className?: string;
loading?: boolean; loading?: boolean;
onClear?: (tableTile: string) => void; onClear?: (tabName: string) => void;
onItemClick?: (item: INoticeIconData, tabProps: INoticeIconProps) => void; onItemClick?: (item: INoticeIconData, tabProps: INoticeIconProps) => void;
onTabChange?: (tableTile: string) => void; onTabChange?: (tabTile: string) => void;
popupAlign?: { popupAlign?: {
points?: [string, string]; points?: [string, string];
offset?: [number, number]; offset?: [number, number];
......
...@@ -14,7 +14,7 @@ Property | Description | Type | Default ...@@ -14,7 +14,7 @@ Property | Description | Type | Default
count | Total number of messages | number | - count | Total number of messages | number | -
bell | Change the bell Icon | ReactNode | `<Icon type='bell' />` bell | Change the bell Icon | ReactNode | `<Icon type='bell' />`
loading | Popup card loading status | boolean | false loading | Popup card loading status | boolean | false
onClear | Click to clear button the callback | function(tabTitle) | - onClear | Click to clear button the callback | function(tabName) | -
onItemClick | Click on the list item's callback | function(item, tabProps) | - onItemClick | Click on the list item's callback | function(item, tabProps) | -
onTabChange | Switching callbacks for tabs | function(tabTitle) | - onTabChange | Switching callbacks for tabs | function(tabTitle) | -
popupAlign | Popup card location configuration | Object [alignConfig](https://github.com/yiminghe/dom-align#alignconfig-object-details) | - popupAlign | Popup card location configuration | Object [alignConfig](https://github.com/yiminghe/dom-align#alignconfig-object-details) | -
...@@ -27,6 +27,7 @@ locale | Default message text | Object | `{ emptyText: '暂无数据', clear: ' ...@@ -27,6 +27,7 @@ locale | Default message text | Object | `{ emptyText: '暂无数据', clear: '
Property | Description | Type | Default Property | Description | Type | Default
----|------|-----|------ ----|------|-----|------
title | header for message Tab | string | - title | header for message Tab | string | -
name | identifier for message Tab | string | -
list | List data, format refer to the following table | Array | `[]` list | List data, format refer to the following table | Array | `[]`
showClear | Clear button display status | boolean | true showClear | Clear button display status | boolean | true
emptyText | message text when list is empty | ReactNode | - emptyText | message text when list is empty | ReactNode | -
......
...@@ -44,12 +44,12 @@ export default class NoticeIcon extends PureComponent { ...@@ -44,12 +44,12 @@ export default class NoticeIcon extends PureComponent {
? `${child.props.title} (${child.props.list.length})` ? `${child.props.title} (${child.props.list.length})`
: child.props.title; : child.props.title;
return ( return (
<TabPane tab={title} key={child.props.title}> <TabPane tab={title} key={child.props.name}>
<List <List
{...child.props} {...child.props}
data={child.props.list} data={child.props.list}
onClick={item => this.onItemClick(item, child.props)} onClick={item => this.onItemClick(item, child.props)}
onClear={() => onClear(child.props.title)} onClear={() => onClear(child.props.name)}
title={child.props.title} title={child.props.title}
locale={locale} locale={locale}
/> />
......
...@@ -14,7 +14,7 @@ order: 9 ...@@ -14,7 +14,7 @@ order: 9
count | 图标上的消息总数 | number | - count | 图标上的消息总数 | number | -
bell | translate this please -> Change the bell Icon | ReactNode | `<Icon type='bell' />` bell | translate this please -> Change the bell Icon | ReactNode | `<Icon type='bell' />`
loading | 弹出卡片加载状态 | boolean | false loading | 弹出卡片加载状态 | boolean | false
onClear | 点击清空按钮的回调 | function(tabTitle) | - onClear | 点击清空按钮的回调 | function(tabName) | -
onItemClick | 点击列表项的回调 | function(item, tabProps) | - onItemClick | 点击列表项的回调 | function(item, tabProps) | -
onTabChange | 切换页签的回调 | function(tabTitle) | - onTabChange | 切换页签的回调 | function(tabTitle) | -
popupAlign | 弹出卡片的位置配置 | Object [alignConfig](https://github.com/yiminghe/dom-align#alignconfig-object-details) | - popupAlign | 弹出卡片的位置配置 | Object [alignConfig](https://github.com/yiminghe/dom-align#alignconfig-object-details) | -
...@@ -27,6 +27,7 @@ locale | 默认文案 | Object | `{ emptyText: '暂无数据', clear: '清空' } ...@@ -27,6 +27,7 @@ locale | 默认文案 | Object | `{ emptyText: '暂无数据', clear: '清空' }
参数 | 说明 | 类型 | 默认值 参数 | 说明 | 类型 | 默认值
----|------|-----|------ ----|------|-----|------
title | 消息分类的页签标题 | string | - title | 消息分类的页签标题 | string | -
name | 消息分类的标识符 | string | -
list | 列表数据,格式参照下表 | Array | `[]` list | 列表数据,格式参照下表 | Array | `[]`
showClear | 是否显示清空按钮 | boolean | true showClear | 是否显示清空按钮 | boolean | true
emptyText | 针对每个 Tab 定制空数据文案 | ReactNode | - emptyText | 针对每个 Tab 定制空数据文案 | ReactNode | -
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment