mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-11 22:44:45 +00:00
Convert processes
This commit is contained in:
parent
5731f7e1df
commit
89b64adc4a
@ -56,10 +56,13 @@ export const transaction = {
|
|||||||
failure: (error) => action(TRANSACTION[FAILURE], {error})
|
failure: (error) => action(TRANSACTION[FAILURE], {error})
|
||||||
};
|
};
|
||||||
|
|
||||||
// Processes
|
export const PROCESSES = createRequestTypes('PROCESSES');
|
||||||
export const FETCH_PROCESSES = 'FETCH_PROCESSES';
|
export const processes = {
|
||||||
export const RECEIVE_PROCESSES = 'RECEIVE_PROCESSES';
|
request: () => action(PROCESSES[REQUEST]),
|
||||||
export const RECEIVE_PROCESSES_ERROR = 'RECEIVE_PROCESSES_ERROR';
|
success: (processes) => action(PROCESSES[SUCCESS], {processes}),
|
||||||
|
failure: (error) => action(PROCESSES[FAILURE], {error})
|
||||||
|
};
|
||||||
|
|
||||||
// Process logs
|
// Process logs
|
||||||
export const FETCH_PROCESS_LOGS = 'FETCH_PROCESS_LOGS';
|
export const FETCH_PROCESS_LOGS = 'FETCH_PROCESS_LOGS';
|
||||||
export const RECEIVE_PROCESS_LOGS = 'RECEIVE_PROCESS_LOGS';
|
export const RECEIVE_PROCESS_LOGS = 'RECEIVE_PROCESS_LOGS';
|
||||||
@ -69,26 +72,6 @@ export const RECEIVE_PROCESS_LOGS_ERROR = 'RECEIVE_PROCESS_LOGS_ERROR';
|
|||||||
// BlockHeader
|
// BlockHeader
|
||||||
export const INIT_BLOCK_HEADER = 'INIT_BLOCK_HEADER';
|
export const INIT_BLOCK_HEADER = 'INIT_BLOCK_HEADER';
|
||||||
|
|
||||||
export function fetchProcesses() {
|
|
||||||
return {
|
|
||||||
type: FETCH_PROCESSES
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function receiveProcesses(processes) {
|
|
||||||
return {
|
|
||||||
type: RECEIVE_PROCESSES,
|
|
||||||
processes
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function receiveProcessesError(error) {
|
|
||||||
return {
|
|
||||||
type: RECEIVE_PROCESSES_ERROR,
|
|
||||||
error
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchProcessLogs(processName) {
|
export function fetchProcessLogs(processName) {
|
||||||
return {
|
return {
|
||||||
type: FETCH_PROCESS_LOGS,
|
type: FETCH_PROCESS_LOGS,
|
||||||
|
@ -36,7 +36,7 @@ export function fetchTransaction(payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function fetchProcesses() {
|
export function fetchProcesses() {
|
||||||
return axios.get(`${constants.httpEndpoint}/processes`);
|
return get('/processes');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchProcessLogs(processName) {
|
export function fetchProcessLogs(processName) {
|
||||||
|
@ -6,7 +6,7 @@ import React, {Component} from 'react';
|
|||||||
import history from '../history';
|
import history from '../history';
|
||||||
import Layout from '../components/Layout';
|
import Layout from '../components/Layout';
|
||||||
import routes from '../routes';
|
import routes from '../routes';
|
||||||
import {initBlockHeader, fetchProcesses} from '../actions';
|
import {initBlockHeader, processes as processesAction} from '../actions';
|
||||||
|
|
||||||
class AppContainer extends Component {
|
class AppContainer extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -34,6 +34,6 @@ export default connect(
|
|||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
initBlockHeader,
|
initBlockHeader,
|
||||||
fetchProcesses
|
fetchProcesses: processesAction.request
|
||||||
},
|
},
|
||||||
)(AppContainer);
|
)(AppContainer);
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
import {
|
import * as actions from "../actions";
|
||||||
RECEIVE_PROCESSES,
|
|
||||||
RECEIVE_PROCESSES_ERROR,
|
|
||||||
RECEIVE_PROCESS_LOGS,
|
|
||||||
RECEIVE_PROCESS_LOGS_ERROR,
|
|
||||||
RECEIVE_NEW_PROCESS_LOG,
|
|
||||||
WATCH_NEW_PROCESS_LOGS
|
|
||||||
} from "../actions";
|
|
||||||
|
|
||||||
export default function processes(state = {}, action) {
|
export default function processes(state = {}, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case RECEIVE_PROCESSES:
|
case actions.PROCESSES[actions.SUCCESS]:
|
||||||
return Object.assign({}, state, {data: action.processes.data});
|
return Object.assign({}, state, {data: action.processes.data});
|
||||||
case RECEIVE_PROCESSES_ERROR:
|
case actions.PROCESSES[actions.FAILURE]:
|
||||||
return Object.assign({}, state, {error: action.error});
|
return Object.assign({}, state, {error: action.error});
|
||||||
case RECEIVE_PROCESS_LOGS:
|
case actions.RECEIVE_PROCESS_LOGS:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
data: {
|
data: {
|
||||||
@ -24,7 +17,7 @@ export default function processes(state = {}, action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
case RECEIVE_NEW_PROCESS_LOG: {
|
case actions.RECEIVE_NEW_PROCESS_LOG: {
|
||||||
const logs = state.data[action.processName].logs || [];
|
const logs = state.data[action.processName].logs || [];
|
||||||
logs.push(action.log);
|
logs.push(action.log);
|
||||||
return {
|
return {
|
||||||
@ -38,7 +31,7 @@ export default function processes(state = {}, action) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case WATCH_NEW_PROCESS_LOGS: {
|
case actions.WATCH_NEW_PROCESS_LOGS: {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
data: {
|
data: {
|
||||||
@ -50,7 +43,7 @@ export default function processes(state = {}, action) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case RECEIVE_PROCESS_LOGS_ERROR:
|
case actions.RECEIVE_PROCESS_LOGS_ERROR:
|
||||||
return Object.assign({}, state, {error: action.error});
|
return Object.assign({}, state, {error: action.error});
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
@ -3,7 +3,7 @@ import * as api from '../api';
|
|||||||
import {eventChannel} from 'redux-saga';
|
import {eventChannel} from 'redux-saga';
|
||||||
import {all, call, fork, put, takeEvery, take} from 'redux-saga/effects';
|
import {all, call, fork, put, takeEvery, take} from 'redux-saga/effects';
|
||||||
|
|
||||||
const {account, accounts, block, blocks, transaction, transactions} = actions;
|
const {account, accounts, block, blocks, transaction, transactions, processes} = actions;
|
||||||
|
|
||||||
function *fetchEntity(entity, apiFn, id) {
|
function *fetchEntity(entity, apiFn, id) {
|
||||||
const {response, error} = yield call(apiFn, id);
|
const {response, error} = yield call(apiFn, id);
|
||||||
@ -20,6 +20,7 @@ export const fetchTransaction = fetchEntity.bind(null, transaction, api.fetchTra
|
|||||||
export const fetchAccounts = fetchEntity.bind(null, accounts, api.fetchAccounts);
|
export const fetchAccounts = fetchEntity.bind(null, accounts, api.fetchAccounts);
|
||||||
export const fetchBlocks = fetchEntity.bind(null, blocks, api.fetchBlocks);
|
export const fetchBlocks = fetchEntity.bind(null, blocks, api.fetchBlocks);
|
||||||
export const fetchTransactions = fetchEntity.bind(null, transactions, api.fetchTransactions);
|
export const fetchTransactions = fetchEntity.bind(null, transactions, api.fetchTransactions);
|
||||||
|
export const fetchProcesses = fetchEntity.bind(null, processes, api.fetchProcesses);
|
||||||
|
|
||||||
export function *watchFetchTransaction() {
|
export function *watchFetchTransaction() {
|
||||||
yield takeEvery(actions.TRANSACTION[actions.REQUEST], fetchTransaction);
|
yield takeEvery(actions.TRANSACTION[actions.REQUEST], fetchTransaction);
|
||||||
@ -45,17 +46,8 @@ export function *watchFetchAccounts() {
|
|||||||
yield takeEvery(actions.ACCOUNTS[actions.REQUEST], fetchAccounts);
|
yield takeEvery(actions.ACCOUNTS[actions.REQUEST], fetchAccounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function *fetchProcesses() {
|
|
||||||
try {
|
|
||||||
const processes = yield call(api.fetchProcesses);
|
|
||||||
yield put(actions.receiveProcesses(processes));
|
|
||||||
} catch (e) {
|
|
||||||
yield put(actions.receiveProcessesError(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function *watchFetchProcesses() {
|
export function *watchFetchProcesses() {
|
||||||
yield takeEvery(actions.FETCH_PROCESSES, fetchProcesses);
|
yield takeEvery(actions.PROCESSES[actions.REQUEST], fetchProcesses);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function *fetchProcessLogs(action) {
|
export function *fetchProcessLogs(action) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user