-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix can't clear the notifications (#518)
* fix: fix can't clear the notifications * test: update tests * test: ignore render tests
- Loading branch information
1 parent
76f2be1
commit 2503f4a
Showing
8 changed files
with
120 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 40 additions & 3 deletions
43
src/workbench/notification/__tests__/__snapshots__/statusBarView.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,44 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Test Notification StatusBar View Component Match The NotificationStatusBarView snapshot 1`] = ` | ||
<span | ||
className="codicon codicon-bell-dot" | ||
/> | ||
Array [ | ||
<span | ||
className="codicon codicon-bell-dot" | ||
/>, | ||
<div | ||
className="mo-notification mo-context-view--shadow" | ||
style={ | ||
Object { | ||
"display": "none", | ||
} | ||
} | ||
> | ||
<header | ||
className="mo-notification__header" | ||
> | ||
<span> | ||
Notifications | ||
</span> | ||
<div | ||
className="mo-action-bar" | ||
> | ||
<ul | ||
className="mo-action-bar__container" | ||
/> | ||
</div> | ||
</header> | ||
<div | ||
className="mo-notification__body" | ||
> | ||
<div> | ||
<span | ||
className="mo-notification--close codicon codicon-close" | ||
onClick={[Function]} | ||
title="Clear Notification" | ||
/> | ||
</div> | ||
</div> | ||
</div>, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,35 @@ | ||
import React, { memo } from 'react'; | ||
import { Icon } from 'mo/components/icon'; | ||
import { IStatusBarItem } from 'mo/model/workbench/statusBar'; | ||
import type { INotification } from 'mo/model'; | ||
import { NotificationPane } from '../notificationPane'; | ||
import type { INotificationController } from 'mo/controller'; | ||
|
||
export function NotificationStatusBarView(props: IStatusBarItem) { | ||
const { data = [], onClick } = props; | ||
export function NotificationStatusBarView( | ||
props: INotification & Partial<INotificationController> | ||
) { | ||
const { | ||
data = [], | ||
onClick, | ||
showNotifications, | ||
id, | ||
actionBar, | ||
onActionBarClick, | ||
onCloseNotification, | ||
} = props; | ||
const hasNotifications = data.length > 0; | ||
const renderIcon = hasNotifications ? 'bell-dot' : 'bell'; | ||
return <Icon onClick={onClick} type={renderIcon} />; | ||
return ( | ||
<> | ||
<Icon onClick={onClick} type={renderIcon} /> | ||
<NotificationPane | ||
id={id} | ||
data={data} | ||
actionBar={actionBar} | ||
showNotifications={showNotifications} | ||
onActionBarClick={onActionBarClick} | ||
onCloseNotification={onCloseNotification} | ||
/> | ||
</> | ||
); | ||
} | ||
export default memo(NotificationStatusBarView); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters