From 0f12f0e21bd5d2870457c27cbac5f668655b4840 Mon Sep 17 00:00:00 2001 From: Aniko Litvanyi Date: Thu, 28 Sep 2017 13:25:38 +0200 Subject: [PATCH 1/7] [KFI]fix(Reducers): Fix entity list after update success action --- src/Reducers.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Reducers.ts b/src/Reducers.ts index daea077..771c288 100644 --- a/src/Reducers.ts +++ b/src/Reducers.ts @@ -195,10 +195,11 @@ export module Reducers { */ export const entities = (state = {}, action) => { if (action.response && ( - action.type !== 'USER_LOGIN_SUCCESS' && - action.type !== 'USER_LOGIN_BUFFER' && + action.type !== 'USER_LOGIN_SUCCESS' && + action.type !== 'USER_LOGIN_BUFFER' && action.type !== 'LOAD_CONTENT_SUCCESS' && - action.type !== 'REQUEST_CONTENT_ACTIONS_SUCCESS')) { + action.type !== 'REQUEST_CONTENT_ACTIONS_SUCCESS' && + action.type !== 'UPDATE_CONTENT_SUCCESS')) { return (Object).assign({}, state, action.response.entities.entities); } switch (action.type) { @@ -206,6 +207,9 @@ export module Reducers { let res = Object.assign({}, state); delete res[action.id]; return res; + case 'UPDATE_CONTENT_SUCCESS': + state[action.response.Id] = action.response + return state default: return state; } @@ -646,7 +650,7 @@ export module Reducers { export const getChildrenActions = (state) => { return state.actions } - + export const getCurrentContent = (state) => { return state.currentcontent.content } From 7110dfb1abfd3e7db402f58c21ca0b9b19e8bc0f Mon Sep 17 00:00:00 2001 From: Aniko Litvanyi Date: Thu, 28 Sep 2017 13:26:12 +0200 Subject: [PATCH 2/7] [KFI]test(Reducers): Add test for checking the entity list after update success --- test/ReducersTests.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/ReducersTests.ts b/test/ReducersTests.ts index bd8582a..5b899ed 100644 --- a/test/ReducersTests.ts +++ b/test/ReducersTests.ts @@ -171,6 +171,34 @@ describe('Reducers', () => { expect(Reducers.entities({}, { response: { entities: { entities: { a: 0, b: 2 } } } })) .to.be.deep.eq({ a: 0, b: 2 }); }); + it('should handle UPDATE_CONTENT_SUCCESS', () => { + const entities = { + 5145: { + Id: 5145, + DisplayName: 'Some Article', + Status: ['Active'] + }, + 5146: { + Id: 5146, + Displayname: 'Other Article', + Status: ['Completed'] + } + }; + expect(Reducers.entities(entities, { type: 'UPDATE_CONTENT_SUCCESS', response: { Id: 5145, DisplayName: 'aaa', Status: ['Active'] } })).to.be.deep.equal( + { + 5145: { + Id: 5145, + DisplayName: 'aaa', + Status: ['Active'] + }, + 5146: { + Id: 5146, + Displayname: 'Other Article', + Status: ['Completed'] + } + } + ); + }); }); describe('isFetching reducer', () => { From 2e696bc5212e999266aa73d762a415a5e944ccd6 Mon Sep 17 00:00:00 2001 From: Aniko Litvanyi Date: Thu, 28 Sep 2017 15:04:58 +0200 Subject: [PATCH 3/7] [KFI]chore: Update version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ce49f1..a70660c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sn-redux", - "version": "3.2.1", + "version": "3.2.1-beta.1", "description": "A set of redux actions, reducers and redux-ovbservable epics for Sense/Net ECM", "main": "dist/src/sn-redux.js", "scripts": { From 2be01064e31d11b48c1ec57cd6735fc14b91f7a8 Mon Sep 17 00:00:00 2001 From: Aniko Litvanyi Date: Wed, 4 Oct 2017 09:34:58 +0200 Subject: [PATCH 4/7] [KFI]chore: Update version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 01c9872..6d34fba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sn-redux", - "version": "3.2.1-beta.1", + "version": "3.2.2-beta.1", "description": "A set of redux actions, reducers and redux-ovbservable epics for Sense/Net ECM", "main": "dist/src/sn-redux.js", "scripts": { From 1ba5afd56ff2eaa56fb7f2d8dfc33843209df45d Mon Sep 17 00:00:00 2001 From: Aniko Litvanyi Date: Mon, 9 Oct 2017 14:36:07 +0200 Subject: [PATCH 5/7] [KFI]feat(Actions): Add an action to clear the selected reducer --- src/Actions.ts | 8 +++++++- src/Reducers.ts | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Actions.ts b/src/Actions.ts index 83d3014..e6bbca8 100644 --- a/src/Actions.ts +++ b/src/Actions.ts @@ -719,7 +719,13 @@ export module Actions { export const DeSelectContent = (id) => ({ type: 'DESELECT_CONTENT', id - }) + })/** + * Action creator for clearing the array of selected content + * @returns {Object} Returns a redux action. + */ + export const ClearSelection = () => ({ + type: 'CLEAR_SELECTION' + }) /** * Action creator for a request for get actions of a content by a given scenario. * @param content {Content} The name of the scenario diff --git a/src/Reducers.ts b/src/Reducers.ts index 771c288..45dca6a 100644 --- a/src/Reducers.ts +++ b/src/Reducers.ts @@ -585,6 +585,8 @@ export module Reducers { case 'DESELECT_CONTENT': const index = state.indexOf(action.id) return [...state.slice(0, index), ...state.slice(index + 1)] + case 'CLEAR_SELECTION': + return [] default: return state } From 0b5ded4e1624e569cb3d2e0435cce3bf1cfc8841 Mon Sep 17 00:00:00 2001 From: Aniko Litvanyi Date: Mon, 9 Oct 2017 14:36:35 +0200 Subject: [PATCH 6/7] [KFI]test(Actions): Add test for testing the new clear selection action --- test/ActionsTests.ts | 8 ++++++++ test/ReducersTests.ts | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/test/ActionsTests.ts b/test/ActionsTests.ts index 8cdd533..2bbc372 100644 --- a/test/ActionsTests.ts +++ b/test/ActionsTests.ts @@ -572,6 +572,14 @@ describe('Actions', () => { expect(Actions.DeSelectContent(1)).to.deep.equal(expectedAction) }) }) + describe('ClearSelection', () => { + it('should return the clear selection action', () => { + const expectedAction = { + type: 'CLEAR_SELECTION' + } + expect(Actions.ClearSelection()).to.deep.equal(expectedAction) + }) + }) describe('RequestContentActions', () => { const content = Content.Create({ DisplayName: 'My content', Id: 123 }, ContentTypes.Task, repo) diff --git a/test/ReducersTests.ts b/test/ReducersTests.ts index 5b899ed..ee4aac3 100644 --- a/test/ReducersTests.ts +++ b/test/ReducersTests.ts @@ -693,6 +693,12 @@ describe('Reducers', () => { } expect(Reducers.selected([1], action)).to.deep.equal([]); }) + it('should return an empty array', () => { + const action = { + type: 'CLEAR_SELECTION' + } + expect(Reducers.selected([1], action)).to.deep.equal([]); + }) }) describe('getContent', () => { const state = { From a395638246d86dc1baf63e93fa903f9caf16f500 Mon Sep 17 00:00:00 2001 From: Aniko Litvanyi Date: Mon, 9 Oct 2017 15:03:39 +0200 Subject: [PATCH 7/7] [KFI]chore: Update version number to 3.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6d34fba..5f662c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sn-redux", - "version": "3.2.2-beta.1", + "version": "3.2.2", "description": "A set of redux actions, reducers and redux-ovbservable epics for Sense/Net ECM", "main": "dist/src/sn-redux.js", "scripts": {