Antonio-Maranhao closed pull request #1047: Configure the notification's
visible time
URL: https://github.com/apache/couchdb-fauxton/pull/1047
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/app/addons/fauxton/notifications/__tests__/components.test.js
b/app/addons/fauxton/notifications/__tests__/components.test.js
index 829f9201c..9c3bb3168 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 7473d0a28..3897811e1 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 13da0e8b5..cdd5fdb09 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",
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services