Skip to content

Commit

Permalink
fix: fixed conditions editing
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekzyla committed Sep 15, 2022
1 parent 1214370 commit 3281c7b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
31 changes: 14 additions & 17 deletions frontend/packages/manager/src/components/profiles/Conditions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div onChange={this.handleConditionChange}>
<div>
<ControlGroup label="Condition"
labelFor="customized-select-after">
<Select value={this.state.condition} onChange={this.handleChange} filter>
Expand All @@ -61,9 +63,4 @@ class Conditions extends Component {
}
}

Conditions.prototype.toString = function conditionToString () {
let result = `\n condition: ${this.state.condition}`;

};

export default Conditions;
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class PatternsCreator extends Component {
}

handleItemValue = (index, e) => {
console.log(`old patter: ${this.patterns[index].pattern}, new pattern: ${e.target.value}, index: ${index}`)
this.patterns[index].pattern = e.target.value
}

Expand Down

0 comments on commit 3281c7b

Please sign in to comment.