This is an automated email from the ASF dual-hosted git repository. amaranhao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git
The following commit(s) were added to refs/heads/master by this push: new ef0c189 Configure the notification's visible time (#1047) ef0c189 is described below commit ef0c1894eeea95cdff61b5b68108ef6f9f6986e5 Author: Antonio Maranhao <30349380+antonio-maran...@users.noreply.github.com> AuthorDate: Wed Jan 24 20:43:29 2018 -0500 Configure the notification's visible time (#1047) * Allows setting the notification's visible time * Added Jest test * Set pouchdb-core version to fix runtime failure --- .../notifications/__tests__/components.test.js | 75 +++++++++++++++------- app/addons/fauxton/notifications/notifications.js | 2 + package.json | 4 +- 3 files changed, 55 insertions(+), 26 deletions(-) diff --git a/app/addons/fauxton/notifications/__tests__/components.test.js b/app/addons/fauxton/notifications/__tests__/components.test.js index 829f920..9c3bb31 100644 --- a/app/addons/fauxton/notifications/__tests__/components.test.js +++ b/app/addons/fauxton/notifications/__tests__/components.test.js @@ -16,8 +16,8 @@ import utils from "../../../../../test/mocha/testUtils"; import React from "react"; import ReactDOM from "react-dom"; import moment from "moment"; -import {mount} from 'enzyme'; -import "sinon"; +import { mount } from 'enzyme'; +import sinon from 'sinon'; const assert = utils.assert; var store = Stores.notificationStore; @@ -50,6 +50,33 @@ describe('NotificationController', () => { }); }); +describe('Notification', () => { + it('startHide is only called after visible time is out', (done) => { + store._notificationCenterVisible = true; + const spy = sinon.spy(); + const component = mount(<Views.Notification + notificationId={'some id'} + isHiding={false} + key={11} + msg={'a msg'} + type={'error'} + escape={true} + style={{opacity:1}} + visibleTime={1000} + onStartHide={spy} + onHideComplete={() => {}} + />); + + assert.notOk(spy.called); + + setTimeout(() => { + component.update(); + assert.ok(spy.called); + done(); + }, 3000); + }); +}); + describe('NotificationPanelRow', () => { const notifications = { success: { @@ -103,7 +130,7 @@ describe('NotificationPanelRow', () => { style={style} isVisible={true} filter="all" - item={notifications.info}/> + item={notifications.info} /> ); assert.notOk(row3.find('li').prop('aria-hidden')); }); @@ -138,16 +165,16 @@ describe('NotificationCenterPanel', () => { }); it('shows all notifications by default', (done) => { - store.addNotification({type: 'success', msg: 'Success are okay'}); - store.addNotification({type: 'success', msg: 'another success.'}); - store.addNotification({type: 'info', msg: 'A single info message'}); - store.addNotification({type: 'error', msg: 'Error #1'}); - store.addNotification({type: 'error', msg: 'Error #2'}); - store.addNotification({type: 'error', msg: 'Error #3'}); + store.addNotification({ type: 'success', msg: 'Success are okay' }); + store.addNotification({ type: 'success', msg: 'another success.' }); + store.addNotification({ type: 'info', msg: 'A single info message' }); + store.addNotification({ type: 'error', msg: 'Error #1' }); + store.addNotification({ type: 'error', msg: 'Error #2' }); + store.addNotification({ type: 'error', msg: 'Error #3' }); var panelEl = mount( <Views.NotificationCenterPanel - style={{x: 1}} + style={{ x: 1 }} visible={true} filter="all" notifications={store.getNotifications()} @@ -160,16 +187,16 @@ describe('NotificationCenterPanel', () => { }); it('appropriate filters are applied - 1', (done) => { - store.addNotification({type: 'success', msg: 'Success are okay'}); - store.addNotification({type: 'success', msg: 'another success.'}); - store.addNotification({type: 'info', msg: 'A single info message'}); - store.addNotification({type: 'error', msg: 'Error #1'}); - store.addNotification({type: 'error', msg: 'Error #2'}); - store.addNotification({type: 'error', msg: 'Error #3'}); + store.addNotification({ type: 'success', msg: 'Success are okay' }); + store.addNotification({ type: 'success', msg: 'another success.' }); + store.addNotification({ type: 'info', msg: 'A single info message' }); + store.addNotification({ type: 'error', msg: 'Error #1' }); + store.addNotification({ type: 'error', msg: 'Error #2' }); + store.addNotification({ type: 'error', msg: 'Error #3' }); var panelEl = mount( <Views.NotificationCenterPanel - style={{x: 1}} + style={{ x: 1 }} visible={true} filter="success" notifications={store.getNotifications()} @@ -183,16 +210,16 @@ describe('NotificationCenterPanel', () => { }); it('appropriate filters are applied - 2', (done) => { - store.addNotification({type: 'success', msg: 'Success are okay'}); - store.addNotification({type: 'success', msg: 'another success.'}); - store.addNotification({type: 'info', msg: 'A single info message'}); - store.addNotification({type: 'error', msg: 'Error #1'}); - store.addNotification({type: 'error', msg: 'Error #2'}); - store.addNotification({type: 'error', msg: 'Error #3'}); + store.addNotification({ type: 'success', msg: 'Success are okay' }); + store.addNotification({ type: 'success', msg: 'another success.' }); + store.addNotification({ type: 'info', msg: 'A single info message' }); + store.addNotification({ type: 'error', msg: 'Error #1' }); + store.addNotification({ type: 'error', msg: 'Error #2' }); + store.addNotification({ type: 'error', msg: 'Error #3' }); var panelEl = mount( <Views.NotificationCenterPanel - style={{x: 1}} + style={{ x: 1 }} visible={true} filter="error" notifications={store.getNotifications()} diff --git a/app/addons/fauxton/notifications/notifications.js b/app/addons/fauxton/notifications/notifications.js index 7473d0a..3897811 100644 --- a/app/addons/fauxton/notifications/notifications.js +++ b/app/addons/fauxton/notifications/notifications.js @@ -142,6 +142,7 @@ class GlobalNotifications extends React.Component { msg={notification.msg} type={notification.type} escape={notification.escape} + visibleTime={notification.visibleTime} onStartHide={Actions.startHidingNotification} onHideComplete={Actions.hideNotification} /> ); @@ -160,6 +161,7 @@ class GlobalNotifications extends React.Component { msg={notification.msg} type={notification.type} escape={notification.escape} + visibleTime={notification.visibleTime} onStartHide={Actions.startHidingNotification} onHideComplete={Actions.hideNotification} /> ); diff --git a/package.json b/package.json index 13da0e8..cdd5fdb 100644 --- a/package.json +++ b/package.json @@ -86,8 +86,8 @@ "moment": "^2.17.1", "nano": "~5.12.0", "optimist": "^0.6.1", - "pouchdb-adapter-http": "^6.1.2", - "pouchdb-core": "^6.1.2", + "pouchdb-adapter-http": "6.4.1", + "pouchdb-core": "6.4.1", "prop-types": "^15.6.0", "react": "~16.2.0", "react-bootstrap": "^0.31.3", -- To stop receiving notification emails like this one, please contact amaran...@apache.org.