mirror of
https://github.com/wassname/talk.git
synced 2026-08-15 12:55:10 +08:00
Merge branch 'admin-asset-list' of github.com:coralproject/talk into admin-asset-list
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import {
|
||||
FETCH_ASSETS,
|
||||
FETCH_ASSETS_REQUEST,
|
||||
FETCH_ASSETS_SUCCESS,
|
||||
FETCH_ASSETS_FAILED,
|
||||
UPDATE_ASSET_STATE,
|
||||
FETCH_ASSETS_FAILURE,
|
||||
UPDATE_ASSET_STATE_REQUEST,
|
||||
UPDATE_ASSET_STATE_SUCCESS,
|
||||
UPDATE_ASSET_STATE_FAILED
|
||||
UPDATE_ASSET_STATE_FAILURE
|
||||
} from '../constants/assets';
|
||||
import coralApi from '../../../coral-framework/helpers/response';
|
||||
|
||||
@@ -14,23 +14,23 @@ import coralApi from '../../../coral-framework/helpers/response';
|
||||
|
||||
// Fetch a page of assets
|
||||
// Get comments to fill each of the three lists on the mod queue
|
||||
export const fetchAssets = (skip, limit, search, sort, filter) => (dispatch) => {
|
||||
dispatch({type: FETCH_ASSETS});
|
||||
return coralApi(`/assets?skip=${skip || ''}&limit=${limit || ''}&sort=${sort || ''}&search=${search || ''}&filter=${filter || ''}`)
|
||||
export const fetchAssets = (skip = '', limit = '', search = '', sort = '', filter = '') => (dispatch) => {
|
||||
dispatch({type: FETCH_ASSETS_REQUEST});
|
||||
return coralApi(`/assets?skip=${skip}&limit=${limit}&sort=${sort}&search=${search}&filter=${filter}`)
|
||||
.then(({result, count}) =>
|
||||
dispatch({type: FETCH_ASSETS_SUCCESS,
|
||||
assets: result,
|
||||
count
|
||||
}))
|
||||
.catch(error => dispatch({type: FETCH_ASSETS_FAILED, error}));
|
||||
.catch(error => dispatch({type: FETCH_ASSETS_FAILURE, error}));
|
||||
};
|
||||
|
||||
// Update an asset state
|
||||
// Get comments to fill each of the three lists on the mod queue
|
||||
export const updateAssetState = (id, closedAt) => (dispatch) => {
|
||||
dispatch({type: UPDATE_ASSET_STATE});
|
||||
dispatch({type: UPDATE_ASSET_STATE_REQUEST});
|
||||
return coralApi(`/assets/${id}/status`, {method: 'PUT', body: {closedAt}})
|
||||
.then(() =>
|
||||
dispatch({type: UPDATE_ASSET_STATE_SUCCESS}))
|
||||
.catch(error => dispatch({type: UPDATE_ASSET_STATE_FAILED, error}));
|
||||
.catch(error => dispatch({type: UPDATE_ASSET_STATE_FAILURE, error}));
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const FETCH_ASSETS = 'FETCH_ASSETS';
|
||||
export const FETCH_ASSETS_REQUEST = 'FETCH_ASSETS_REQUEST';
|
||||
export const FETCH_ASSETS_SUCCESS = 'FETCH_ASSETS_SUCCESS';
|
||||
export const FETCH_ASSETS_FAILED = 'FETCH_ASSETS_FAILED';
|
||||
export const UPDATE_ASSET_STATE = 'UPDATE_ASSET_STATE';
|
||||
export const FETCH_ASSETS_FAILURE = 'FETCH_ASSETS_FAILURE';
|
||||
export const UPDATE_ASSET_STATE_REQUEST = 'UPDATE_ASSET_STATE_REQUEST';
|
||||
export const UPDATE_ASSET_STATE_SUCCESS = 'UPDATE_ASSET_STATE_SUCCESS';
|
||||
export const UPDATE_ASSET_STATE_FAILED = 'UPDATE_ASSET_STATE_FAILED';
|
||||
export const UPDATE_ASSET_STATE_FAILURE = 'UPDATE_ASSET_STATE_FAILURE';
|
||||
|
||||
@@ -60,7 +60,11 @@ class Streams extends Component {
|
||||
prev.statusMenus[id] = false;
|
||||
return prev;
|
||||
});
|
||||
this.props.updateAssetState(id, closeStream ? Date.now() : null);
|
||||
this.props.updateAssetState(id, closeStream ? Date.now() : null)
|
||||
.then(() => {
|
||||
const {search, sort, filter, page} = this.state;
|
||||
this.props.fetchAssets(page, limit, search, sort, filter);
|
||||
});
|
||||
} else {
|
||||
this.setState(prev => {
|
||||
prev.statusMenus[id] = true;
|
||||
@@ -167,9 +171,7 @@ const mapDispatchToProps = (dispatch) => {
|
||||
fetchAssets: (...args) => {
|
||||
dispatch(fetchAssets.apply(this, args));
|
||||
},
|
||||
updateAssetState: (...args) => {
|
||||
dispatch(updateAssetState.apply(this, args));
|
||||
}
|
||||
updateAssetState: (...args) => dispatch(updateAssetState.apply(this, args))
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Map, List, fromJS} from 'immutable';
|
||||
import {FETCH_ASSETS_SUCCESS, UPDATE_ASSET_STATE} from '../constants/assets';
|
||||
import {FETCH_ASSETS_SUCCESS, UPDATE_ASSET_STATE_REQUEST} from '../constants/assets';
|
||||
|
||||
const initialState = Map({
|
||||
byId: Map(),
|
||||
@@ -10,7 +10,7 @@ export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case FETCH_ASSETS_SUCCESS:
|
||||
return replaceAssets(action, state);
|
||||
case UPDATE_ASSET_STATE:
|
||||
case UPDATE_ASSET_STATE_REQUEST:
|
||||
return state.setIn(['byId', action.id, 'closedAt'], action.closedAt);
|
||||
default: return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user