From 5eaffbd991ef75a69cb8b28e353548aa21cd9087 Mon Sep 17 00:00:00 2001 From: Aniko Litvanyi Date: Mon, 4 Dec 2017 14:17:34 +0100 Subject: [PATCH] Release/3.4.1 (#57) * Merge release/3.0.1 branch (#35) (#36) * fix(Epics): Fix checkoutLoginState at failure checkoutLoginState epic is now return null instead of error message when user is not authenticated * chore: Update version number * [KFI]chore: Update version number * sn-client-js update (#49) * chore(package): update @types/redux-mock-store to version 0.0.11 (#37) * chore(package): update semantic-release to version 8.0.0 (#38) * Greenkeeper/sn client js 2.4.0 (#40) * chore(package): update sn-client-js to version 2.4.0 * [KFI]chore(launch.json): fixed mocha debug profile for vs code * [KFI]test(EpicsTest): Flatterned Select assertions, added RELOAD_CONTENTFIELDS_REQUEST field list (r * Release/3.2.0 (#41) * [KFI]fix(Epics): Remove requestContent call from the initSensenetStoreEpic * [KFI]fix(Reducers): Fix userAvatarPath For now userAvatarPath contains the Avatar field's value so it doesn't matter if the avatar is a binary or a reference * [KFI]test(ReducerTests): Fix userAvatarPath test * [KFI]fix(Reducers): Fix fetch getError and order reducers * [KFI]feat(Actions): Add two new Actions for selection and deselecting a Content * [KFI]feat(Reducers): Change selected reducer to handle select and deselect actions * [KFI]test(Actions): Add tests for select and deselect actions * [KFI]test(Reducers): Add test for testing the selected Reducer handling select and deselect Actions * [KFI]feat(Actions): Add actions for getting sn Actions of a content * [KFI]test(Actions): Add tests for testing the new sn action getter Actions * [KFI]feat(Reducers): Complete the Reducer of the content items * [KFI]test(Reducers): Add test for testing the childrenactions reducer * [KFI]feat(Reducers): Add a isOpened reducer This reducer holds the id of the content where the actionmenu was opened last * [KFI]fix(Reducers): Change action in isOpened reducer to REQUEST_CONTENT_ACTION * [KFI]test(Reducers): Add test for testing isOpened reducer * [KFI]feat(Reducers): Add a function to return the currently opened items id * [KFI]refactor(Reducer): Rename getOpenedContentId to getOpenedContent * [KFI]test(Reducers): Add a test for testing getOpenedContent function * [KFI]feat(Actions): Add id as input attr to RequestContentActions Action * [KFI]feat(Reducers): Add getChildrenActions function to return actions from the state tree * [KFI]feat(Actions): Change RequestContentActions first input param to content * [KFI]feat(Epics): Add getContentActions Epic * [KFI]fix(GetActions): Fix GetActions action * [KFI]feat(Reducers): Add getCurrentContent to get the path of the current content * [KFI]fix(Epics): Fix loadContentActions epic * [KFI]test: Improve epic tests * [KFI]chore: Update version number * [KFI]fix(Login): Fix action order and subscribing in the login process * [KFI]test(Login): Add tests for testing the new login buffer action and epic * [KFI]chore: Update version number * chore(package): update mocha to version 4.0.0 (#42) * chore(package): update typedoc to version 0.9.0 (#43) * Merge release/3.2.2 (#44) * [KFI]fix(Reducers): Fix entity list after update success action * [KFI]test(Reducers): Add test for checking the entity list after update success * [KFI]chore: Update version number * [KFI]chore: Update version number * [KFI]feat(Actions): Add an action to clear the selected reducer * [KFI]test(Actions): Add test for testing the new clear selection action * [KFI]chore: Update version number to 3.2.2 * Fileupload (#45) * [KFI]feat(Actions): Add upload request, success and failure actions * [KFI]test(Actions): Add tests for testing the new upload related actions * [KFI]feat(Epics): Add new epic for upload a file * [KFI]test(Epics): Add test for testing the upload epic * [KFI]feat(Reducers): Change ids and entities reducer to handle UPLOAD_CONTENT_SUCCESS * [KFI]test(Reducers): Add upload related reducer tests * [KFI]chore: Update sn-client-js to 2.5.0 * [KFI]test(Epics): Fix epic tests related to sn-client-js upgrade * [KFI]chore: Update version number to 3.3.0 * [KFI]fix(Epics): Add rxjs mergeMap import * merge fix * [KFI]refactor(project): replaced '@reactivex/rxjs' package with 'rxjs', updated imports * [KFI]test(Epics): Fix Epic tests (#51) * Feat/batchactions (#52) * [KFI]feat(BatchActions): Add new reducer to handle batch action responses * [KFI]feat(BatchActions): Add copy and move batch actions * [KFI]feat(BatchActions): Modify batchActions reducers to handle general errors also * [KFI]docs(BatchActions): Add some docs to the new reducers * [KFI]test(BatchActions): Fix deleteBatch action tests to handle the new arguments * [KFI]test(DeleteBatch): Fix tests * [KFI]test(Reducers): Add tests to test batch response related reducers * [KFI]fix(BatchActions): Add a path param to copybatch and movebatch to hold the target path * [KFI]test(BatchActions): Add tests for testing the new batch actions * [KFI]fix(BatchActions): Improve deleteBatch Epic * [KFI]feat(Selection): Change select and deselect actions to handle a content except an id * [KFI]test(Selection): Fix selection related tests * [KFI]test(Selection): Fix selected reducer tests * [KFI]feat(Selection): Add a new reducer to hold and handle selected content items for batch actions * [KFI]fix(Selection): Fix selectedContentItems reducer and its tests * [KFI]feat(Selection): Add new functions to return to value of selectedIds and selectedContentItems r * [KFI]test(Selection): Add test for testing new selection reducers * [KFI]feat(DeleteBatch): Change id param to contentItems * [KFI]test(DeleteBatch): Fix deleteBatch related tests to handle content items as a param * [KFI]feat(DeleteBatch): Complete deleteBatch functionality * [KFI]test(DeleteBatch): Fix batch delete related tests * [KFI]fix(BatchActions): Change copy and move batch actions first param to a contenlist object * [KFI]test(BatchActions): Fix tests that are related to the changed param * [KFI]feat(MoveBatch): Add move batch action to the ids and entities reducers * [KFI]test(MoveBatch): Add moveBatch action related tests * [KFI]feat(BatchActionEpics): Add move- and copyBatch epics * [KFI]test(BatchEpics): Add copy- and movebatch epic tests * Feat/addnew upload (#53) * [KFI]feat(Actions): Add a new param to requestContentActions to make it possible to add custom actio * [KFI]test(Actions): Fix RequestContentActions tests * [KFI]feat(Epics): Change getContentActions epic to handle custom listitems * [KFI]fix: Remove unused variables and add the check into the tsconfig.json to detect them in the fut * [KFI]feat(Reducers): Add new reducer to retrieving children entities object * [KFI]test(Reducers): Add test for testing getChildren reducer * [KFI]feat(Authentication): Add stuff for google oauth (#54) * [KFI]feat(Authentication): Add initial stuff for google oauth * [KFI]test(Actions): Add google auth login test * [KFI]chore: Update dependencies * [KFI]fix(Epics): Move content conversion from application level to Epic level * [KFI]fix(Epics): Fix update epic to handle content changes * [KFI]chore: Update version number to 3.4.1 --- package.json | 2 +- src/Epics.ts | 72 +++++++++++++++++++++++++++++++++------------------- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index 5f95746..f8d50c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sn-redux", - "version": "3.4.0", + "version": "3.4.1", "description": "A set of redux actions, reducers and redux-ovbservable epics for Sense/Net ECM", "main": "dist/src/sn-redux.js", "scripts": { diff --git a/src/Epics.ts b/src/Epics.ts index 1599d2a..3b09591 100644 --- a/src/Epics.ts +++ b/src/Epics.ts @@ -121,10 +121,12 @@ export module Epics { * Epic for reloading content from the Content Repository. It is related to three redux actions, returns the ```ReloadContent``` action and sends the JSON response to the * ```ReceiveReloadedContent``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```ReceiveReloadedContentFailure``` action. */ - export const reloadContentEpic = (action$, store) => { + export const reloadContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('RELOAD_CONTENT_REQUEST') + .mergeMap(action => { - return action.content.Reload(action.actionname) + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.Reload(action.actionname) .map((response) => Actions.ReceiveReloadedContent(response)) .catch(error => { return Observable.of(Actions.ReceiveReloadedContentFailure(error)) @@ -136,10 +138,11 @@ export module Epics { * Epic for reloading fields of a content from the Content Repository. It is related to three redux actions, returns the ```ReloadContentFields``` action and sends the JSON response to the * ```ReceiveReloadedContentFields``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```ReceiveReloadedContentFieldsFailure``` action. */ - export const reloadContentFieldsEpic = (action$, store) => { + export const reloadContentFieldsEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('RELOAD_CONTENTFIELDS_REQUEST') .mergeMap(action => { - return action.content.ReloadFields(action.fields) + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.ReloadFields(action.fields) .map((response) => Actions.ReceiveReloadedContentFields(response)) .catch(error => { return Observable.of(Actions.ReceiveReloadedContentFieldsFailure(error)) @@ -151,10 +154,11 @@ export module Epics { * Epic for creating a Content in the Content Repository. It is related to three redux actions, returns ```CreateContent``` action and sends the JSON response to the * ```CreateContentSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```CreateContentFailure``` action. */ - export const createContentEpic = (action$, store) => { + export const createContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('CREATE_CONTENT_REQUEST') .mergeMap(action => { - return action.content.Save() + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.Save() .map(Actions.CreateContentSuccess) .catch(error => Observable.of(Actions.CreateContentFailure(error))) }) @@ -163,10 +167,17 @@ export module Epics { * Epic for updating metadata of a Content in the Content Repository. It is related to three redux actions, returns ```UpdateContent``` action and sends the JSON response to the * ```UpdateContentSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```UpdateContentFailure``` action. */ - export const updateContentEpic = (action$, store) => { + export const updateContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('UPDATE_CONTENT_REQUEST') .mergeMap(action => { - return action.content.Save() + let c = dependencies.repository.HandleLoadedContent({Id: action.content.Id, Name: action.content.Name, Path: action.content.Path}); + let fields = c.GetFields() + for (let field in fields) { + if (fields[field] !== action.content[field]) { + c[field] = action.content[field]; + } + } + return c.Save().share() .map(Actions.UpdateContentSuccess) .catch(error => Observable.of(Actions.UpdateContentFailure(error))) }) @@ -175,10 +186,11 @@ export module Epics { * Epic to delete a Content from the Content Repository. It is related to three redux actions, returns ```Delete``` action and sends the response to the * ```DeleteSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```DeleteFailure``` action. */ - export const deleteContentEpic = (action$, store) => { + export const deleteContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('DELETE_CONTENT_REQUEST') .mergeMap(action => { - return action.content.Delete(action.content, action.permanently) + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.Delete(action.permanently) .map((response) => { const state = store.getState(); const ids = Reducers.getIds(state.sensenet.children); @@ -242,10 +254,11 @@ export module Epics { * Epic to checkout a Content in the Content Repository. It is related to three redux actions, returns ```CheckOut``` action and sends the response to the * ```CheckOutSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```CheckOutFailure``` action. */ - export const checkoutContentEpic = (action$, store) => { + export const checkoutContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('CHECKOUT_CONTENT_REQUEST') .mergeMap(action => { - return action.content.Checkout() + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.Checkout() .map(Actions.CheckOutSuccess) .catch(error => Observable.of(Actions.CheckOutFailure(error))) }) @@ -255,10 +268,11 @@ export module Epics { * Epic to checkin a Content in the Content Repository. It is related to three redux actions, returns ```CheckIn``` action and sends the response to the * ```CheckInSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```CheckInFailure``` action. */ - export const checkinContentEpic = (action$, store) => { + export const checkinContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('CHECKIN_CONTENT_REQUEST') .mergeMap(action => { - return action.content.CheckIn(action.checkinComment) + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.CheckIn(action.checkinComment) .map(Actions.CheckInSuccess) .catch(error => Observable.of(Actions.CheckInFailure(error))) }) @@ -267,10 +281,11 @@ export module Epics { * Epic to publish a Content in the Content Repository. It is related to three redux actions, returns ```Publish``` action and sends the response to the * ```PublishSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```PublishFailure``` action. */ - export const publishContentEpic = (action$, store) => { + export const publishContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('PUBLISH_CONTENT_REQUEST') .mergeMap(action => { - return action.content.Publish() + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.Publish() .map(Actions.PublishSuccess) .catch(error => Observable.of(Actions.PublishFailure(error))) }) @@ -279,10 +294,11 @@ export module Epics { * Epic to approve a Content in the Content Repository. It is related to three redux actions, returns ```Approve``` action and sends the response to the * ```ApproveSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```ApproveFailure``` action. */ - export const approveContentEpic = (action$, store) => { + export const approveContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('APPROVE_CONTENT_REQUEST') .mergeMap(action => { - return action.content.Approve() + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.Approve() .map(Actions.ApproveSuccess) .catch(error => Observable.of(Actions.ApproveFailure(error))) }) @@ -291,10 +307,11 @@ export module Epics { * Epic to reject a Content in the Content Repository. It is related to three redux actions, returns ```Reject``` action and sends the response to the * ```RejectSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```RejectFailure``` action. */ - export const rejectContentEpic = (action$, store) => { + export const rejectContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('REJECT_CONTENT_REQUEST') .mergeMap(action => { - return action.content.Reject(action.rejectReason) + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.Reject(action.rejectReason) .map(Actions.RejectSuccess) .catch(error => Observable.of(Actions.RejectFailure(error))) }) @@ -303,10 +320,11 @@ export module Epics { * Epic to undo checkout a Content in the Content Repository. It is related to three redux actions, returns ```UndoCheckout``` action and sends the response to the * ```UndoCheckoutSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```UndoCheckoutFailure``` action. */ - export const undocheckoutContentEpic = (action$, store) => { + export const undocheckoutContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('UNDOCHECKOUT_CONTENT_REQUEST') .mergeMap(action => { - return action.content.UndoCheckout() + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.UndoCheckout() .map(Actions.UndoCheckoutSuccess) .catch(error => Observable.of(Actions.UndoCheckoutFailure(error))) }) @@ -315,10 +333,11 @@ export module Epics { * Epic to force undo checkout a Content in the Content Repository. It is related to three redux actions, returns ```ForceUndoCheckout``` action and sends the response to the * ```ForceUndoCheckoutSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```ForceUndoCheckoutFailure``` action. */ - export const forceundocheckoutContentEpic = (action$, store) => { + export const forceundocheckoutContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('FORCEUNDOCHECKOUT_CONTENT_REQUEST') .mergeMap(action => { - return action.content.ForceUndoCheckout() + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.ForceUndoCheckout() .map(Actions.ForceUndoCheckoutSuccess) .catch(error => Observable.of(Actions.ForceUndoCheckoutFailure(error))) }) @@ -327,10 +346,11 @@ export module Epics { * Epic to restore a version of a Content in the Content Repository. It is related to three redux actions, returns ```RestoreVersion``` action and sends the response to the * ```RestoreVersionSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```RestoreVersionFailure``` action. */ - export const restoreversionContentEpic = (action$, store) => { + export const restoreversionContentEpic = (action$, store, dependencies?: { repository: Repository.BaseRepository }) => { return action$.ofType('RESTOREVERSION_CONTENT_REQUEST') .mergeMap(action => { - return action.content.RestoreVersion(action.version) + let c = dependencies.repository.HandleLoadedContent(action.content, ContentTypes.GenericContent); + return c.RestoreVersion(action.version) .map(Actions.RestoreVersionSuccess) .catch(error => Observable.of(Actions.RestoreVersionFailure(error))) })