forked from City-of-Helsinki/varaamo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a timeslot notification for maintenance mode (#267)
Changes: - added custom error notification for timeslot selecting when maintenance mode is on - added redux state handling for maintenance mode reading and writing
- Loading branch information
Showing
18 changed files
with
149 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { createAction } from 'redux-actions'; | ||
|
||
import types from 'constants/ActionTypes'; | ||
|
||
export const setMaintenanceMode = createAction(types.UI.SET_MAINTENANCE_MODE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Immutable from 'seamless-immutable'; | ||
|
||
import types from 'constants/ActionTypes'; | ||
|
||
const initialState = Immutable({ | ||
isMaintenanceModeOn: false, | ||
}); | ||
|
||
function maintenanceReducer(state = initialState, action) { | ||
switch (action.type) { | ||
case types.UI.SET_MAINTENANCE_MODE: { | ||
return state.merge({ | ||
isMaintenanceModeOn: action.payload | ||
}); | ||
} | ||
|
||
default: { | ||
return state; | ||
} | ||
} | ||
} | ||
|
||
export default maintenanceReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
import Immutable from 'seamless-immutable'; | ||
|
||
import types from 'constants/ActionTypes'; | ||
import reducer from './maintenanceReducer'; | ||
|
||
describe('/state/reducers/ui/maintenanceReducer', () => { | ||
const initialState = Immutable({ | ||
isMaintenanceModeOn: false | ||
}); | ||
|
||
const action = { | ||
type: types.UI.SET_MAINTENANCE_MODE, | ||
payload: true | ||
}; | ||
|
||
const expectedState = { isMaintenanceModeOn: true }; | ||
|
||
test('initialState is correct', () => { | ||
const actual = reducer(undefined, { type: 'nothing' }); | ||
expect(actual).toEqual(initialState); | ||
}); | ||
|
||
test('returns correct state on SET_MAINTENANCE_MODE', () => { | ||
const actual = reducer(undefined, action); | ||
expect(actual).toEqual(expectedState); | ||
}); | ||
|
||
test('returns correct state if no matching action type is given', () => { | ||
const actual = reducer(undefined, { type: types.API.RESOURCES_GET_SUCCESS }); | ||
expect(actual).toEqual(initialState); | ||
}); | ||
}); |