renamed actions
This commit is contained in:
parent
4672a72d02
commit
295cbb6486
12 changed files with 114 additions and 175 deletions
|
@ -3,7 +3,7 @@ import * as actions from 'constants/show_action_types';
|
|||
// basic request parsing
|
||||
export function updateRequestError (error) {
|
||||
return {
|
||||
type: actions.REQUEST_ERROR_UPDATE,
|
||||
type: actions.REQUEST_ERROR,
|
||||
data: error,
|
||||
};
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ export function updateRequestError (error) {
|
|||
export function updateRequestWithChannelRequest (name, id) {
|
||||
const requestId = `cr#${name}#${id}`;
|
||||
return {
|
||||
type: actions.REQUEST_CHANNEL_UPDATE,
|
||||
type: actions.REQUEST_UPDATE_CHANNEL,
|
||||
data: { requestId, name, id },
|
||||
};
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ export function updateRequestWithChannelRequest (name, id) {
|
|||
export function updateRequestWithAssetRequest (name, id, channelName, channelId, extension) {
|
||||
const requestId = `ar#${name}#${id}#${channelName}#${channelId}`;
|
||||
return {
|
||||
type: actions.REQUEST_CLAIM_UPDATE,
|
||||
type: actions.REQUEST_UPDATE_CLAIM,
|
||||
data: {
|
||||
requestId,
|
||||
name,
|
||||
|
@ -39,14 +39,14 @@ export function updateRequestWithAssetRequest (name, id, channelName, channelId,
|
|||
|
||||
export function newAssetRequest (id, name, modifier) {
|
||||
return {
|
||||
type: actions.ASSET_REQUEST_NEW,
|
||||
type: actions.ASSET_REQUEST_ASYNC,
|
||||
data: { id, name, modifier },
|
||||
};
|
||||
};
|
||||
|
||||
export function addAssetRequest (id, error, name, claimId) {
|
||||
return {
|
||||
type: actions.ASSET_REQUEST_ADD,
|
||||
type: actions.ASSET_REQUEST_SUCCESS,
|
||||
data: { id, error, name, claimId },
|
||||
};
|
||||
};
|
||||
|
@ -56,7 +56,7 @@ export function addAssetRequest (id, error, name, claimId) {
|
|||
export function showNewAsset (name, claimId) {
|
||||
const id = `a#${name}#${claimId}`;
|
||||
return {
|
||||
type: actions.SHOW_ASSET_NEW,
|
||||
type: actions.ASSET_NEW_ASYNC,
|
||||
data: { id, name, claimId },
|
||||
};
|
||||
};
|
||||
|
@ -65,7 +65,7 @@ export function showNewAsset (name, claimId) {
|
|||
|
||||
export function addAssetToAssetList (id, error, name, claimId, shortId, claimData) {
|
||||
return {
|
||||
type: actions.ASSET_LIST_ADD,
|
||||
type: actions.ASSET_NEW_SUCCESS,
|
||||
data: { id, error, name, claimId, shortId, claimData },
|
||||
};
|
||||
}
|
||||
|
@ -74,14 +74,14 @@ export function addAssetToAssetList (id, error, name, claimId, shortId, claimDat
|
|||
|
||||
export function newChannelRequest (id, name, channelId) {
|
||||
return {
|
||||
type: actions.CHANNEL_REQUEST_NEW,
|
||||
type: actions.CHANNEL_REQUEST_ASYNC,
|
||||
data: {id, name, channelId},
|
||||
};
|
||||
};
|
||||
|
||||
export function addChannelRequest (id, error, name, longId, shortId) {
|
||||
return {
|
||||
type: actions.CHANNEL_REQUEST_ADD,
|
||||
type: actions.CHANNEL_REQUEST_SUCCESS,
|
||||
data: { id, error, name, longId, shortId },
|
||||
};
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ export function addChannelRequest (id, error, name, longId, shortId) {
|
|||
export function showNewChannel (name, shortId, longId) {
|
||||
const id = `c#${name}#${longId}`; // move to the action
|
||||
return {
|
||||
type: actions.SHOW_CHANNEL_NEW,
|
||||
type: actions.CHANNEL_NEW_ASYNC,
|
||||
data: { id, name, shortId, longId },
|
||||
};
|
||||
};
|
||||
|
@ -100,7 +100,7 @@ export function showNewChannel (name, shortId, longId) {
|
|||
|
||||
export function addNewChannelToChannelList (id, name, shortId, longId, claimsData) {
|
||||
return {
|
||||
type: actions.CHANNEL_LIST_ADD,
|
||||
type: actions.CHANNEL_NEW_SUCCESS,
|
||||
data: { id, name, shortId, longId, claimsData },
|
||||
};
|
||||
};
|
||||
|
@ -109,14 +109,14 @@ export function addNewChannelToChannelList (id, name, shortId, longId, claimsDat
|
|||
|
||||
export function updateChannelClaimsAsync (channelKey, name, longId, page) {
|
||||
return {
|
||||
type: actions.CHANNEL_LIST_CLAIMS_UPDATE_ASYNC,
|
||||
type: actions.CHANNEL_CLAIMS_UPDATE_ASYNC,
|
||||
data: {channelKey, name, longId, page},
|
||||
};
|
||||
};
|
||||
|
||||
export function updateChannelClaims (channelListId, claimsData) {
|
||||
return {
|
||||
type: actions.CHANNEL_LIST_CLAIMS_UPDATE,
|
||||
type: actions.CHANNEL_CLAIMS_UPDATE_SUCCESS,
|
||||
data: {channelListId, claimsData},
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,18 +3,19 @@ import View from './view';
|
|||
import { fileRequested } from 'actions/show';
|
||||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
let props = {
|
||||
error : show.displayAsset.error,
|
||||
status: show.displayAsset.status,
|
||||
};
|
||||
// select asset info
|
||||
const previousRequest = show.assetRequests[show.request.id];
|
||||
const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`;
|
||||
// select error and status
|
||||
const error = show.displayAsset.error;
|
||||
const status = show.displayAsset.status;
|
||||
// select asset
|
||||
const request = show.assetRequests[show.request.id];
|
||||
const assetKey = `a#${request.name}#${request.claimId}`;
|
||||
const asset = show.assetList[assetKey];
|
||||
if (asset) {
|
||||
props['asset'] = asset;
|
||||
// return props
|
||||
return {
|
||||
error,
|
||||
status,
|
||||
asset,
|
||||
};
|
||||
return props;
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
|
|
|
@ -2,15 +2,14 @@ import { connect } from 'react-redux';
|
|||
import View from './view';
|
||||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
let props = {};
|
||||
// select asset info
|
||||
// select asset
|
||||
const request = show.assetRequests[show.request.id];
|
||||
const assetKey = `a#${request.name}#${request.claimId}`;
|
||||
const asset = show.assetList[assetKey];
|
||||
if (asset) {
|
||||
props['asset'] = asset;
|
||||
// return props
|
||||
return {
|
||||
asset,
|
||||
};
|
||||
return props;
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, null)(View);
|
||||
|
|
|
@ -2,15 +2,18 @@ import { connect } from 'react-redux';
|
|||
import View from './view';
|
||||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
let props = {};
|
||||
// select title
|
||||
const previousRequest = show.assetRequests[show.request.id];
|
||||
const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`;
|
||||
const request = show.assetRequests[show.request.id];
|
||||
const assetKey = `a#${request.name}#${request.claimId}`;
|
||||
const asset = show.assetList[assetKey];
|
||||
let title;
|
||||
if (asset) {
|
||||
props['title'] = asset.claimData.title;
|
||||
title = asset.claimData.title;
|
||||
};
|
||||
// return props
|
||||
return {
|
||||
title,
|
||||
};
|
||||
return props;
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, null)(View);
|
||||
|
|
|
@ -1,4 +1,32 @@
|
|||
import { connect } from 'react-redux';
|
||||
import View from './view';
|
||||
import React from 'react';
|
||||
import NavBar from 'containers/NavBar';
|
||||
import AssetTitle from 'components/AssetTitle';
|
||||
import AssetDisplay from 'components/AssetDisplay';
|
||||
import AssetInfo from 'components/AssetInfo';
|
||||
|
||||
export default connect(null, null)(View);
|
||||
class ShowAssetDetails extends React.Component {
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<NavBar/>
|
||||
<div className="row row--tall row--padded">
|
||||
<div className="column column--10">
|
||||
<AssetTitle />
|
||||
</div>
|
||||
<div className="column column--5 column--sml-10 align-content-top">
|
||||
<div className="row row--padded">
|
||||
<AssetDisplay />
|
||||
</div>
|
||||
</div><div className="column column--5 column--sml-10 align-content-top">
|
||||
<div className="row row--padded">
|
||||
<AssetInfo />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default ShowAssetDetails;
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
import React from 'react';
|
||||
import NavBar from 'containers/NavBar';
|
||||
import AssetTitle from 'components/AssetTitle';
|
||||
import AssetDisplay from 'components/AssetDisplay';
|
||||
import AssetInfo from 'components/AssetInfo';
|
||||
|
||||
class ShowAssetDetails extends React.Component {
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<NavBar/>
|
||||
<div className="row row--tall row--padded">
|
||||
<div className="column column--10">
|
||||
<AssetTitle />
|
||||
</div>
|
||||
<div className="column column--5 column--sml-10 align-content-top">
|
||||
<div className="row row--padded">
|
||||
<AssetDisplay />
|
||||
</div>
|
||||
</div><div className="column column--5 column--sml-10 align-content-top">
|
||||
<div className="row row--padded">
|
||||
<AssetInfo />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default ShowAssetDetails;
|
|
@ -2,16 +2,20 @@ import { connect } from 'react-redux';
|
|||
import View from './view';
|
||||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
let props = {};
|
||||
// select name and claim id
|
||||
let name, claimId;
|
||||
const previousRequest = show.assetRequests[show.request.id];
|
||||
const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`;
|
||||
const asset = show.assetList[assetKey];
|
||||
if (asset) {
|
||||
props['name'] = asset.name;
|
||||
props['claimId'] = asset.claimId;
|
||||
name = asset.name;
|
||||
claimId = asset.claimId;
|
||||
};
|
||||
// return props
|
||||
return {
|
||||
name,
|
||||
claimId,
|
||||
};
|
||||
return props;
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, null)(View);
|
||||
|
|
|
@ -1,26 +1,24 @@
|
|||
// request actions
|
||||
export const REQUEST_CHANNEL_UPDATE = 'REQUEST_CHANNEL_UPDATE';
|
||||
export const REQUEST_CLAIM_UPDATE = 'REQUEST_CLAIM_UPDATE';
|
||||
export const REQUEST_ERROR_UPDATE = 'REQUEST_ERROR_UPDATE';
|
||||
export const REQUEST_UPDATE_CHANNEL = 'REQUEST_UPDATE_CHANNEL';
|
||||
export const REQUEST_UPDATE_CLAIM = 'REQUEST_UPDATE_CLAIM';
|
||||
export const REQUEST_ERROR = 'REQUEST_ERROR';
|
||||
|
||||
// asset request actions
|
||||
export const ASSET_REQUEST_NEW = 'ASSET_REQUEST_NEW';
|
||||
export const ASSET_REQUEST_ADD = 'ASSET_REQUEST_ADD';
|
||||
// asset actions
|
||||
export const ASSET_REQUEST_ASYNC = 'ASSET_REQUEST_ASYNC';
|
||||
export const ASSET_REQUEST_SUCCESS = 'ASSET_REQUEST_SUCCESS';
|
||||
|
||||
export const SHOW_ASSET_NEW = 'SHOW_ASSET_NEW';
|
||||
export const ASSET_LIST_ADD = `ASSET_LIST_ADD`;
|
||||
export const ASSET_NEW_ASYNC = 'ASSET_NEW_ASYNC';
|
||||
export const ASSET_NEW_SUCCESS = `ASSET_NEW_SUCCESS`;
|
||||
|
||||
// channel request actions
|
||||
export const CHANNEL_REQUEST_NEW = 'CHANNEL_REQUEST_NEW';
|
||||
export const CHANNEL_REQUEST_ADD = 'CHANNEL_REQUEST_ADD';
|
||||
// channel actions
|
||||
export const CHANNEL_REQUEST_ASYNC = 'CHANNEL_REQUEST_ASYNC';
|
||||
export const CHANNEL_REQUEST_SUCCESS = 'CHANNEL_REQUEST_SUCCESS';
|
||||
|
||||
export const SHOW_CHANNEL_NEW = 'SHOW_CHANNEL_NEW';
|
||||
export const SHOW_CHANNEL_UPDATE = 'SHOW_CHANNEL_UPDATE';
|
||||
export const SHOW_CHANNEL_CLEAR = 'SHOW_CHANNEL_CLEAR';
|
||||
export const CHANNEL_NEW_ASYNC = 'CHANNEL_NEW_ASYNC';
|
||||
export const CHANNEL_NEW_SUCCESS = 'CHANNEL_NEW_SUCCESS';
|
||||
|
||||
export const CHANNEL_LIST_ADD = 'CHANNEL_LIST_ADD';
|
||||
export const CHANNEL_LIST_CLAIMS_UPDATE_ASYNC = 'CHANNEL_LIST_CLAIMS_UPDATE_ASYNC';
|
||||
export const CHANNEL_LIST_CLAIMS_UPDATE = 'CHANNEL_LIST_CLAIMS_UPDATE';
|
||||
export const CHANNEL_CLAIMS_UPDATE_ASYNC = 'CHANNEL_CLAIMS_UPDATE_ASYNC';
|
||||
export const CHANNEL_CLAIMS_UPDATE_SUCCESS = 'CHANNEL_CLAIMS_UPDATE_SUCCESS';
|
||||
|
||||
// asset/file display actions
|
||||
export const FILE_REQUESTED = 'FILE_REQUESTED';
|
||||
|
|
|
@ -22,13 +22,13 @@ const initialState = {
|
|||
export default function (state = initialState, action) {
|
||||
switch (action.type) {
|
||||
// handle request
|
||||
case actions.REQUEST_ERROR_UPDATE:
|
||||
case actions.REQUEST_ERROR:
|
||||
return Object.assign({}, state, {
|
||||
request: Object.assign({}, state.request, {
|
||||
error: action.data,
|
||||
}),
|
||||
});
|
||||
case actions.REQUEST_CHANNEL_UPDATE:
|
||||
case actions.REQUEST_UPDATE_CHANNEL:
|
||||
return Object.assign({}, state, {
|
||||
request: {
|
||||
type : CHANNEL,
|
||||
|
@ -40,7 +40,7 @@ export default function (state = initialState, action) {
|
|||
},
|
||||
},
|
||||
});
|
||||
case actions.REQUEST_CLAIM_UPDATE:
|
||||
case actions.REQUEST_UPDATE_CLAIM:
|
||||
return Object.assign({}, state, {
|
||||
request: {
|
||||
type : ASSET,
|
||||
|
@ -53,8 +53,8 @@ export default function (state = initialState, action) {
|
|||
},
|
||||
},
|
||||
});
|
||||
// request for an asset
|
||||
case actions.ASSET_REQUEST_ADD:
|
||||
// successful requests
|
||||
case actions.ASSET_REQUEST_SUCCESS:
|
||||
return Object.assign({}, state, {
|
||||
assetRequests: Object.assign({}, state.assetRequests, {
|
||||
[action.data.id]: {
|
||||
|
@ -64,8 +64,19 @@ export default function (state = initialState, action) {
|
|||
},
|
||||
}),
|
||||
});
|
||||
// add asset to asset list
|
||||
case actions.ASSET_LIST_ADD:
|
||||
case actions.CHANNEL_REQUEST_SUCCESS:
|
||||
return Object.assign({}, state, {
|
||||
channelRequests: Object.assign({}, state.channelRequests, {
|
||||
[action.data.id]: {
|
||||
error : action.data.error,
|
||||
name : action.data.name,
|
||||
longId : action.data.longId,
|
||||
shortId: action.data.shortId,
|
||||
},
|
||||
}),
|
||||
});
|
||||
// updates to asset list
|
||||
case actions.ASSET_NEW_SUCCESS:
|
||||
return Object.assign({}, state, {
|
||||
assetList: Object.assign({}, state.assetList, {
|
||||
[action.data.id]: {
|
||||
|
@ -77,35 +88,8 @@ export default function (state = initialState, action) {
|
|||
},
|
||||
}),
|
||||
});
|
||||
// request a channel
|
||||
case actions.CHANNEL_REQUEST_ADD:
|
||||
return Object.assign({}, state, {
|
||||
channelRequests: Object.assign({}, state.channelRequests, {
|
||||
[action.data.id]: {
|
||||
error : action.data.error,
|
||||
name : action.data.name,
|
||||
longId : action.data.longId,
|
||||
shortId: action.data.shortId,
|
||||
},
|
||||
}),
|
||||
});
|
||||
// show a channel
|
||||
case actions.SHOW_CHANNEL_UPDATE:
|
||||
return Object.assign({}, state, {
|
||||
showChannel: {
|
||||
error: action.data.error,
|
||||
id : action.data.id,
|
||||
},
|
||||
});
|
||||
case actions.SHOW_CHANNEL_CLEAR:
|
||||
return Object.assign({}, state, {
|
||||
showChannel: {
|
||||
error: null,
|
||||
id : null,
|
||||
},
|
||||
});
|
||||
// add channel to channel list
|
||||
case actions.CHANNEL_LIST_ADD:
|
||||
// updates to channel list
|
||||
case actions.CHANNEL_NEW_SUCCESS:
|
||||
return Object.assign({}, state, {
|
||||
channelList: Object.assign({}, state.channelList, {
|
||||
[action.data.id]: {
|
||||
|
@ -116,7 +100,7 @@ export default function (state = initialState, action) {
|
|||
},
|
||||
}),
|
||||
});
|
||||
case actions.CHANNEL_LIST_CLAIMS_UPDATE:
|
||||
case actions.CHANNEL_CLAIMS_UPDATE_SUCCESS:
|
||||
return Object.assign({}, state, {
|
||||
channelList: Object.assign({}, state.channelList, {
|
||||
[action.data.channelListId]: Object.assign({}, state.channelList[action.data.channelListId], {
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
import { call, put, takeLatest } from 'redux-saga/effects';
|
||||
import * as actions from 'constants/show_action_types';
|
||||
import { addAssetRequest, updateRequestError, showNewAsset, addChannelRequest, showNewChannel } from 'actions/show';
|
||||
import { getLongClaimId } from 'api/assetApi';
|
||||
import { getChannelData } from 'api/channelApi';
|
||||
|
||||
function* newAssetRequest (action) {
|
||||
const { id, name, modifier } = action.data;
|
||||
let success, message, longId;
|
||||
try {
|
||||
({success, message, data: longId} = yield call(getLongClaimId, name, modifier));
|
||||
} catch (error) {
|
||||
return yield put(updateRequestError(error.message));
|
||||
}
|
||||
if (!success) {
|
||||
return yield put(updateRequestError(message));
|
||||
}
|
||||
yield put(addAssetRequest(id, null, name, longId));
|
||||
yield put(showNewAsset(name, longId));
|
||||
};
|
||||
|
||||
function* newChannelRequest (action) {
|
||||
const { id, name, channelId } = action.data;
|
||||
let success, message, data;
|
||||
try {
|
||||
({success, message, data} = yield call(getChannelData, name, channelId));
|
||||
} catch (error) {
|
||||
// return yield put(addChannelRequest(id, error.message, null, null, null));
|
||||
return yield put(updateRequestError(error.message));
|
||||
}
|
||||
if (!success) {
|
||||
// return yield put(addChannelRequest(id, message, null, null, null));
|
||||
return yield put(updateRequestError(message));
|
||||
}
|
||||
const { longChannelClaimId: longId, shortChannelClaimId: shortId } = data;
|
||||
yield put(addChannelRequest(id, null, name, longId, shortId));
|
||||
yield put(showNewChannel(name, shortId, longId));
|
||||
}
|
||||
|
||||
export function* watchNewAssetRequest () {
|
||||
yield takeLatest(actions.ASSET_REQUEST_NEW, newAssetRequest);
|
||||
};
|
||||
|
||||
export function* watchNewChannelRequest () {
|
||||
yield takeLatest(actions.CHANNEL_REQUEST_NEW, newChannelRequest);
|
||||
};
|
|
@ -33,5 +33,5 @@ function* getAssetDataAndShowAsset (action) {
|
|||
}
|
||||
|
||||
export function* watchShowNewAsset () {
|
||||
yield takeLatest(actions.SHOW_ASSET_NEW, getAssetDataAndShowAsset);
|
||||
yield takeLatest(actions.ASSET_NEW_ASYNC, getAssetDataAndShowAsset);
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ function* getChannelClaimsAndShowChannel (action) {
|
|||
}
|
||||
|
||||
export function* watchShowNewChannel () {
|
||||
yield takeLatest(actions.SHOW_CHANNEL_NEW, getChannelClaimsAndShowChannel);
|
||||
yield takeLatest(actions.CHANNEL_NEW_ASYNC, getChannelClaimsAndShowChannel);
|
||||
};
|
||||
|
||||
function* getNewClaimsAndUpdateClaimsList (action) {
|
||||
|
@ -37,5 +37,5 @@ function* getNewClaimsAndUpdateClaimsList (action) {
|
|||
}
|
||||
|
||||
export function* watchShowNewChannelClaimsRequest () {
|
||||
yield takeLatest(actions.CHANNEL_LIST_CLAIMS_UPDATE_ASYNC, getNewClaimsAndUpdateClaimsList);
|
||||
yield takeLatest(actions.CHANNEL_CLAIMS_UPDATE_ASYNC, getNewClaimsAndUpdateClaimsList);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue