-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
353 additions
and
33 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
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,90 @@ | ||
import ActionTypes from './action-types'; | ||
import { getProbeService } from '../../lib/getServices'; | ||
|
||
/** | ||
* requestProbeResponse - action creator | ||
* | ||
* @param {String} infoId | ||
* @memberof ActionCreators | ||
*/ | ||
export function requestProbeResponse(probeId, resource, windowId) { | ||
return { | ||
probeId, | ||
resource, | ||
type: ActionTypes.REQUEST_PROBE_RESPONSE, | ||
windowId, | ||
}; | ||
} | ||
|
||
/** | ||
* receiveProbeResponse - action creator | ||
* | ||
* @param {String} infoId | ||
* @param {Object} manifestJson | ||
* @memberof ActionCreators | ||
*/ | ||
export function receiveProbeResponse(probeId, probeJson, ok, tokenServiceId) { | ||
return { | ||
ok, | ||
probeId, | ||
probeJson, | ||
tokenServiceId, | ||
type: ActionTypes.RECEIVE_PROBE_RESPONSE, | ||
}; | ||
} | ||
|
||
/** | ||
* receiveDegradedProbeResponse - action creator | ||
* | ||
* @param {String} infoId | ||
* @param {Object} manifestJson | ||
* @memberof ActionCreators | ||
*/ | ||
export function receiveDegradedProbeResponse(probeId, probeJson, ok, tokenServiceId, windowId) { | ||
return { | ||
ok, | ||
probeId, | ||
probeJson, | ||
tokenServiceId, | ||
type: ActionTypes.RECEIVE_DEGRADED_PROBE_RESPONSE, | ||
windowId, | ||
}; | ||
} | ||
|
||
/** | ||
* receiveProbeResponseFailure - action creator | ||
* | ||
* @param {String} infoId | ||
* @param {String} error | ||
* @memberof ActionCreators | ||
*/ | ||
export function receiveProbeResponseFailure(probeId, error, tokenServiceId) { | ||
return { | ||
error, | ||
probeId, | ||
tokenServiceId, | ||
type: ActionTypes.RECEIVE_PROBE_RESPONSE_FAILURE, | ||
}; | ||
} | ||
|
||
/** | ||
* fetchProbeResponse - action creator | ||
* | ||
* @param {String} infoId | ||
* @memberof ActionCreators | ||
*/ | ||
export function fetchProbeResponse({ resourceId, resource, windowId }) { | ||
const probeService = resource && getProbeService(resource); | ||
const probeId = (resourceId || probeService.id); | ||
return requestProbeResponse(probeId, resource, windowId); | ||
} | ||
|
||
/** | ||
* removeProbeResponse - action creator | ||
* | ||
* @param {String} probeId | ||
* @memberof ActionCreators | ||
*/ | ||
export function removeProbeResponse(probeId) { | ||
return { probeId, type: ActionTypes.REMOVE_PROBE_RESPONSE }; | ||
} |
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,59 @@ | ||
import ActionTypes from '../actions/action-types'; | ||
|
||
/** | ||
* probeResponsesReducer | ||
*/ | ||
export const probeResponsesReducer = (state = {}, action) => { | ||
switch (action.type) { | ||
case ActionTypes.REQUEST_PROBE_RESPONSE: | ||
return { | ||
...state, | ||
[action.probeId]: { | ||
id: action.probeId, | ||
isFetching: true, | ||
}, | ||
}; | ||
case ActionTypes.RECEIVE_PROBE_RESPONSE: | ||
return { | ||
...state, | ||
[action.probeId]: { | ||
degraded: false, | ||
id: action.probeId, | ||
isFetching: false, | ||
json: action.probeJson, | ||
tokenServiceId: action.tokenServiceId, | ||
}, | ||
}; | ||
case ActionTypes.RECEIVE_DEGRADED_PROBE_RESPONSE: | ||
return { | ||
...state, | ||
[action.probeId]: { | ||
degraded: true, | ||
id: action.probeId, | ||
isFetching: false, | ||
json: action.probeJson, | ||
tokenServiceId: action.tokenServiceId, | ||
}, | ||
}; | ||
case ActionTypes.RECEIVE_PROBE_RESPONSE_FAILURE: | ||
return { | ||
...state, | ||
[action.probeId]: { | ||
error: action.error, | ||
id: action.probeId, | ||
isFetching: false, | ||
tokenServiceId: action.tokenServiceId, | ||
}, | ||
}; | ||
case ActionTypes.REMOVE_PROBE_RESPONSE: | ||
return Object.keys(state).reduce((object, key) => { | ||
if (key !== action.probeId) { | ||
object[key] = state[key]; // eslint-disable-line no-param-reassign | ||
} | ||
return object; | ||
}, {}); | ||
case ActionTypes.IMPORT_MIRADOR_STATE: | ||
return {}; | ||
default: return state; | ||
} | ||
}; |
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
Oops, something went wrong.