From 3281c7bf8ff434d1fedc83f26d454d61b33594f6 Mon Sep 17 00:00:00 2001 From: Wojciech Zyla Date: Thu, 15 Sep 2022 12:59:55 +0200 Subject: [PATCH] fix: fixed conditions editing --- .../components/profiles/AddProfileModal.jsx | 6 ++-- .../src/components/profiles/Conditions.jsx | 31 +++++++++---------- .../components/profiles/PatternsCreator.jsx | 1 - 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/frontend/packages/manager/src/components/profiles/AddProfileModal.jsx b/frontend/packages/manager/src/components/profiles/AddProfileModal.jsx index 6694664..036621a 100644 --- a/frontend/packages/manager/src/components/profiles/AddProfileModal.jsx +++ b/frontend/packages/manager/src/components/profiles/AddProfileModal.jsx @@ -22,13 +22,11 @@ function AddProfileModal(props) { }, []); const handleVarBinds = (value) => { - ProfCtx.setVarBinds(value) - console.log('varbindslol: ', value); + ProfCtx.setVarBinds(value); } const handleConditions = (value) => { - ProfCtx.setConditions(value) - console.log('conditionsslol: ', value); + ProfCtx.setConditions(value); } const postProfile = (profileObj) => { diff --git a/frontend/packages/manager/src/components/profiles/Conditions.jsx b/frontend/packages/manager/src/components/profiles/Conditions.jsx index 175f615..15239e0 100644 --- a/frontend/packages/manager/src/components/profiles/Conditions.jsx +++ b/frontend/packages/manager/src/components/profiles/Conditions.jsx @@ -7,38 +7,40 @@ import PatternsCreator from "./PatternsCreator"; class Conditions extends Component { constructor(props) { super(props); - + let stateValue; if(this.props.value){ - this.state = this.props.value; + stateValue = this.props.value; }else{ - this.state = { + stateValue = { condition: 'base', field: '', patterns: null }; } + this.state = stateValue; this.props.onConditionsCreator(this.state); } + handleChange = (e, {value}) => { - this.setState({condition: value}); + if (value != "field"){ + this.setState({condition: value, field: '', patterns :null}, + () => {this.props.onConditionsCreator(this.state);}); + }else{ + this.setState({condition: value}, () => {this.props.onConditionsCreator(this.state);}); + }; }; handleFieldChange = (e, {value}) => { - this.setState({field: value}); + this.setState({field: value}, () => {this.props.onConditionsCreator(this.state);}); }; handlePatterns = (value) => { - this.setState({patterns: value}); - } - - handleConditionChange = (value) => { - var state = this.state; - this.props.onConditionsCreator(state); + this.setState({patterns: value}, () => {this.props.onConditionsCreator(this.state);}); } render() { return ( -
+