Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const mapStateToProps = (state, ownProps) => {
const path = compose(ownProps.path, toDataPathSegments(ownProps.uischema.scope.$ref).join('.'));
const visible = _.has(ownProps, 'visible') ? ownProps.visible : isVisible(ownProps, state);
const enabled = _.has(ownProps, 'enabled') ? ownProps.enabled : isEnabled(ownProps, state);
return {
rootData: getData(state),
data: resolveData(getData(state), path),
uischema: ownProps.uischema,
schema: ownProps.schema,
resolvedSchema: resolveSchema(ownProps.schema, ownProps.uischema.scope.$ref),
path,
visible,
enabled
};
};
componentWillMount() {
const { uischema, data, resolvedSchema } = this.props;
const controlElement = uischema as MasterDetailLayout;
this.setState({
dialog: {
open: false,
schema: undefined,
path: undefined
}
});
if (_.isArray(data)) {
const dataPathSegments = toDataPathSegments(controlElement.scope.$ref);
const path = _.isEmpty(dataPathSegments) ? '' : dataPathSegments.join('.');
this.setState({
selected: {
schema: resolvedSchema.items,
data: data[0],
path: compose(path, '0')
}
});
} else {
this.setState({
selected: {
schema: resolvedSchema,
data,
path: ''
}
});