Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/5.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
gallayl committed Aug 3, 2018
2 parents edb9d3a + 995d232 commit 2a05be8
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 31 deletions.
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sensenet/redux",
"version": "5.0.1",
"version": "5.1.0",
"description": "A set of redux actions, reducers and redux-ovbservable epics for sensenet",
"main": "dist/index.js",
"scripts": {
Expand Down Expand Up @@ -61,16 +61,16 @@
"dependencies": {
"@sensenet/authentication-google": "^2.0.0",
"@sensenet/authentication-jwt": "^1.0.4",
"@sensenet/client-core": "^1.2.4",
"@sensenet/client-core": "^1.2.5",
"@sensenet/default-content-types": "^1.1.0",
"@sensenet/redux-promise-middleware": "^2.0.0",
"@sensenet/redux-promise-middleware": "^2.1.0",
"redux": "^4.0.0",
"redux-logger": "^3.0.6"
},
"devDependencies": {
"@types/chai": "^4.1.4",
"@types/mocha": "^5.2.5",
"@types/node": "^10.5.4",
"@types/node": "^10.5.5",
"@types/redux-logger": "^3.0.5",
"chai": "^4.1.1",
"codecov": "^3.0.4",
Expand Down
1 change: 1 addition & 0 deletions src/Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export const forceUndoCheckout = <T extends IContent = IContent>(idOrPath: numbe
*/
export const restoreVersion = <T extends IContent = IContent>(idOrPath: number | string, version: string, options?: IODataParams<T>) => ({
type: 'RESTOREVERSION_CONTENT',
version,
payload: (repository: Repository) => repository.versioning.restoreVersion(idOrPath, version, options),
})
/**
Expand Down
4 changes: 2 additions & 2 deletions src/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
import { Repository } from '@sensenet/client-core'
import { promiseMiddleware } from '@sensenet/redux-promise-middleware'
import { applyMiddleware, compose, createStore, Middleware, Reducer, Store, StoreEnhancer } from 'redux'
import { applyMiddleware, compose, createStore, DeepPartial, Middleware, Reducer, Store, StoreEnhancer } from 'redux'
import { createLogger } from 'redux-logger'
import * as Actions from './Actions'

Expand Down Expand Up @@ -86,7 +86,7 @@ export interface CreateStoreOptions<T> {
/**
* Initial state of the store
*/
persistedState?: T,
persistedState?: DeepPartial<T>,
/**
* Array of additional enhancers
*/
Expand Down
5 changes: 4 additions & 1 deletion src/reducers/batchresponses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export const batchResponseError: Reducer<string> = (state = '', action) => {
/**
* Reducer combining response and error into a single object, ```batchResponses```.
*/
export const batchResponses = combineReducers({
export const batchResponses = combineReducers<{
response: ReturnType<typeof odataBatchResponse>,
error: ReturnType<typeof batchResponseError>,
}>({
response: odataBatchResponse,
error: batchResponseError,
})
7 changes: 6 additions & 1 deletion src/reducers/contentstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ export const isOperationInProgress: Reducer<boolean> = (state = false, action) =
/**
* Reducer combining isSaved, isValid, isDirty and isOperationInProgress into a single object, ```contentState```.
*/
export const contentState = combineReducers({
export const contentState = combineReducers<{
isSaved: ReturnType<typeof isSaved>,
isValid: ReturnType<typeof isValid>,
isDirty: ReturnType<typeof isDirty>,
isOperationInProgress: ReturnType<typeof isOperationInProgress>,
}>({
isSaved,
isValid,
isDirty,
Expand Down
9 changes: 8 additions & 1 deletion src/reducers/currentcontent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@ export const schema: Reducer<Schema | null, Action & { result: Schema }> = (stat
/**
* Reducer combining contentState, error, actions, fields and content into a single object, ```currentcontent```.
*/
export const currentcontent = combineReducers({
export const currentcontent = combineReducers<{
contentState: ReturnType<typeof contentState>,
error: ReturnType<typeof contenterror>,
actions: ReturnType<typeof contentactions>,
fields: ReturnType<typeof fields>,
content: ReturnType<typeof content>,
schema: ReturnType<typeof schema>,
}>({
contentState,
error: contenterror,
actions: contentactions,
Expand Down
10 changes: 9 additions & 1 deletion src/reducers/currentitems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,15 @@ export const options: Reducer<IODataParams<GenericContent> | null> = (state = nu
/**
* Reducer combining ids, entities, isFetching, actions, error, top, skip, query, order, filter, select and isOpened into a single object, ```currentitems```.
*/
export const currentitems = combineReducers({
export const currentitems = combineReducers<{
ids: ReturnType<typeof ids>,
entities: ReturnType<typeof entities>,
isFetching: ReturnType<typeof isFetching>,
actions: ReturnType<typeof childrenactions>,
error: ReturnType<typeof childrenerror>,
isOpened: ReturnType<typeof isOpened>,
options: ReturnType<typeof options>,
}>({
ids,
entities,
isFetching,
Expand Down
5 changes: 4 additions & 1 deletion src/reducers/selected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export const selectedContentItems: Reducer<any, ReturnType<typeof selectContent
/**
* Reducer combining ids and entities into a single object, ```selected```.
*/
export const selected = combineReducers({
export const selected = combineReducers<{
ids: ReturnType<typeof selectedIds>
entities: ReturnType<typeof selectedContentItems>,
}>({
ids: selectedIds,
entities: selectedContentItems,
})
10 changes: 9 additions & 1 deletion src/reducers/sensenet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { LoginState } from '@sensenet/client-core'
import { Workspace } from '@sensenet/default-content-types'
import { combineReducers, Reducer } from 'redux'
import { loadContent, PromiseReturns } from '../Actions'
Expand Down Expand Up @@ -28,7 +29,14 @@ export const currentworkspace: Reducer<Workspace | null> = (state = null, action
/**
* Reducer combining session, currentitems, currentcontent and selected into a single object, ```sensenet``` which will be the top-level one.
*/
export const sensenet = combineReducers({
export const sensenet = combineReducers<{
session: ReturnType<typeof session> & { loginState: LoginState },
currentworkspace: ReturnType<typeof currentworkspace>,
currentcontent: ReturnType<typeof currentcontent>,
currentitems: ReturnType<typeof currentitems>,
selected: ReturnType<typeof selected>,
batchResponses: ReturnType<typeof batchResponses>,
}>({
session,
currentworkspace,
currentcontent,
Expand Down
49 changes: 40 additions & 9 deletions src/reducers/session.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ConstantContent, LoginState } from '@sensenet/client-core'
import { RepositoryConfiguration } from '@sensenet/client-core/dist/Repository/RepositoryConfiguration'
import { User } from '@sensenet/default-content-types'
import { combineReducers, Reducer } from 'redux'
import { loadRepository, userChanged } from '../Actions'

Expand Down Expand Up @@ -126,14 +127,36 @@ export const userAvatarPath: Reducer<string, ReturnType<typeof userChanged>> = (
return state
}
}

/**
* Reducer to handle Actions on the id property in the user object.
* @param state Represents the current state.
* @param action Represents an action that is called.
* @returns state. Returns the next state based on the action.
*/
export const userContent: Reducer<User, ReturnType<typeof userChanged>> = (state = ConstantContent.VISITOR_USER, action) => {
switch (action.type) {
case 'USER_CHANGED':
return action.user
default:
return state
}
}
/**
* Reducer combining userName, fullName, userLanguage, userAvatarPath into a single object, ```user```.
*/
const user = combineReducers({
const user = combineReducers<{
userName: ReturnType<typeof userName>,
fullName: ReturnType<typeof fullName>,
userLanguage: ReturnType<typeof userLanguage>,
userAvatarPath: ReturnType<typeof userAvatarPath>,
content: ReturnType<typeof userContent>,
}>({
userName,
fullName,
userLanguage,
userAvatarPath,
content: userContent,
})
/**
* Reducer to handle Actions on the repostory property in the user object.
Expand All @@ -152,11 +175,19 @@ export const repository: Reducer<RepositoryConfiguration | null, ReturnType<type
/**
* Reducer combining country, language, loginState, error, user and repository into a single object, ```session```.
*/
export const session = combineReducers({
country,
language,
loginState,
error: loginError,
user,
repository,
})
export const session = combineReducers<{
country: ReturnType<typeof country>,
language: ReturnType<typeof language>,
loginState: ReturnType<typeof loginState>,
error: ReturnType<typeof loginError>,
user: ReturnType<typeof user>,
repository: ReturnType<typeof repository>,
}>
({
country,
language,
loginState,
error: loginError,
user,
repository,
})

0 comments on commit 2a05be8

Please sign in to comment.