Commit 507fb86f authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Pavlov Viacheslav

fixed SSR

removed unnecessary api call from needs
parent 260ebb08
......@@ -66,7 +66,9 @@ export default function admin(state = INITIAL_STATE, action: IReducerAction) {
[receivedIndex]: {$set: execution},
},
},
details: {$set: execution},
details: {
execution: {$set: execution},
},
},
});
} else {
......@@ -75,7 +77,9 @@ export default function admin(state = INITIAL_STATE, action: IReducerAction) {
page: {
content: {$push: [execution]},
},
details: {$set: execution},
details: {
execution: {$set: execution},
},
},
});
}
......
......@@ -41,6 +41,9 @@ interface IDashboardProps extends React.ClassAttributes<any> {
class Dashboard extends React.Component<IDashboardProps, any> {
protected static needs = [
({}) => listExecutions({}),
({}) => listParameters({}),
({}) => listDimensions({}),
];
public componentWillMount() {
......@@ -76,15 +79,15 @@ class Dashboard extends React.Component<IDashboardProps, any> {
{ stillLoading && <Loading /> }
<h5>{ t(`kpi.admin.p.dashboard.KPIExecutions`) }</h5>
{ execs && execs.content.map((exec, i) => (
{ execs && execs.content && execs.content.map((exec, i) => (
<ExecutionCard key={ exec.id } index={ i } execution={ exec } compact style={ {marginBottom: '8px'} }/>
)) }
<h5>{ t(`kpi.admin.p.dashboard.KPIParameters`) }</h5>
{ params && params.content.map((param, i) => (
{ params && params.content && params.content.map((param, i) => (
<ParameterCard key={ param.id } parameter={ param } index={ i } style={ {marginBottom: '8px'} }/>
)) }
<h5>{ t(`kpi.admin.p.dashboard.KPIDimensions`) }</h5>
{ dims && dims.content.map((dim, i) => (
{ dims && dims.content && dims.content.map((dim, i) => (
<DimensionCard key={ dim.id } dimension={ dim } index={ i } style={ {marginBottom: '8px'} }/>
)) }
</Grid>
......
......@@ -54,6 +54,7 @@ class ExecutionDialog extends React.Component<IExecutionDialogProps, any> {
private handleSubmit = (execution: any) => {
const {saveExecution} = this.props;
execution.parameter = typeof execution.parameter === 'string' ? JSON.parse(execution.parameter) : execution.parameter;
saveExecution(execution);
this.setState({open: false});
}
......@@ -64,10 +65,10 @@ class ExecutionDialog extends React.Component<IExecutionDialogProps, any> {
<span>
<Button className={ classes.createButton } onClick={ this.show } variant={ variant }>{ buttonLabel || t(`kpi.admin.p.executionDialog.button`) }</Button>
{ this.state.open &&
<Dialog open={ this.state.open } onClose={ this.hide } maxWidth="md" fullWidth disableEnforceFocus>
<Dialog open={ this.state.open } onClose={ this.hide } maxWidth="md" fullWidth>
<DialogTitle>{ t(`kpi.admin.p.executionDialog.title`) }</DialogTitle>
<DialogContent>
<ExecutionForm nameDisabled={ execution && execution.name } onCancel={ this.hide } onSubmit={ this.handleSubmit } initialValues={ execution }/>
<ExecutionForm t={ t } nameDisabled={ execution && execution.name } onCancel={ this.hide } onSubmit={ this.handleSubmit } initialValues={ execution }/>
</DialogContent>
</Dialog>
}
......@@ -84,4 +85,4 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({
saveExecution,
}, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)<any>(translate()(ExecutionDialog)));
export default translate()(connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(ExecutionDialog)));
......@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { translate } from 'react-i18next';
// Actions
import { deleteExecution, executeExecution, getExecution } from 'kpi/actions/admin';
import { deleteExecution, executeExecution, getExecution, listDimensions, listParameters } from 'kpi/actions/admin';
// Models
import ExecutionDetails from 'model/kpi/ExecutionDetails';
import ExecutionRun from 'model/kpi/ExecutionRun';
......@@ -37,6 +37,8 @@ class ExecutionDisplay extends React.Component<IExecutionProps, any> {
protected static needs = [
({ params: { shortName } }) => getExecution(shortName),
({}) => listParameters({}),
({}) => listDimensions({}),
];
public state = {
......
......@@ -5,7 +5,7 @@ import BooleanDimension from 'model/kpi/BooleanDimension';
import JpaDimension from 'model/kpi/JpaDimension';
import NumericListDimension from 'model/kpi/NumericListDimension';
import StringListDimension from 'model/kpi/StringListDimension';
import Select from '@material-ui/core/es/Select';
import Select from '@material-ui/core/Select';
import MenuItem from '@material-ui/core/MenuItem';
import FormControl from 'ui/common/forms/FormControl';
import {NumericListDimensionFormExtra} from './NumericListDimensionFormExtra';
......
......@@ -6,7 +6,7 @@ import {Field} from 'redux-form';
import { listDimensions } from 'kpi/actions/admin';
import Dimension from 'model/kpi/Dimension';
import Select from '@material-ui/core/es/Select';
import Select from '@material-ui/core/Select';
import MenuItem from '@material-ui/core/MenuItem';
import FormControl from 'ui/common/forms/FormControl';
import Grid from '@material-ui/core/Grid';
......
......@@ -4,7 +4,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import {withStyles} from '@material-ui/core/styles';
import Select from '@material-ui/core/es/Select';
import Select from '@material-ui/core/Select';
import MenuItem from '@material-ui/core/MenuItem';
import FormControl from 'ui/common/forms/FormControl';
import {listParameters} from 'kpi/actions/admin';
......@@ -73,4 +73,4 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({
}, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(translate()(withStyles(styles)(ParameterSelector)));
export default translate()(connect(mapStateToProps, mapDispatchToProps)((withStyles(styles)(ParameterSelector))));
import * as React from 'react';
import {translate} from 'react-i18next';
import {Field, reduxForm} from 'redux-form';
import {TextField} from 'ui/common/text-field';
// constants
......@@ -60,7 +59,7 @@ class ExecutionForm extends React.Component<any, void> {
}
}
export default translate()(reduxForm({
export default reduxForm({
form: EXEC_FORM,
enableReinitialize: true,
})(ExecutionForm));
})(ExecutionForm);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment