Skip to content

Commit

Permalink
Scene: UX improvement on new trigger/action (#2086)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles authored May 20, 2024
1 parent 6054152 commit 24f98ca
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 55 deletions.
18 changes: 0 additions & 18 deletions front/cypress/e2e/routes/scene/Scene.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ describe('Scene view', () => {
.click(0, 0, { force: true });
});

// I don't know why, but I'm unable to get this button with
// the text. Using the class but it's not recommended otherwise!!
cy.get('.btn-success').then(buttons => {
cy.wrap(buttons[1]).click();
});

cy.get('div[class*="-control"]').then(inputs => {
cy.wrap(inputs[1])
.click(0, 0, { force: true })
Expand Down Expand Up @@ -138,12 +132,6 @@ describe('Scene view', () => {
.click(0, 0, { force: true });
});

// I don't know why, but I'm unable to get this button with
// the text. Using the class but it's not recommended otherwise!!
cy.get('.btn-success').then(buttons => {
cy.wrap(buttons[1]).click();
});

cy.wait('@loadDevices');
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(100);
Expand Down Expand Up @@ -176,12 +164,6 @@ describe('Scene view', () => {
.click(0, 0, { force: true });
});

// I don't know why, but I'm unable to get this button with
// the text. Using the class but it's not recommended otherwise!!
cy.get('.btn-success').then(buttons => {
cy.wrap(buttons[1]).click();
});

cy.get('select').then(selects => {
cy.wrap(selects[0]).select('contains');
cy.wrap(selects[1]).select('start');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ class ChooseActionType extends Component {
this.setState({
currentAction: selectedOption
});
};
changeBoxType = () => {
if (this.state.currentAction) {
this.props.updateActionProperty(this.props.columnIndex, this.props.index, 'type', this.state.currentAction.value);
if (selectedOption) {
this.props.updateActionProperty(this.props.columnIndex, this.props.index, 'type', selectedOption.value);
}
};
render(props, { currentAction }) {
Expand All @@ -74,11 +72,6 @@ class ChooseActionType extends Component {
options={options}
/>
</div>
<div class="form-group">
<button onClick={this.changeBoxType} class="btn btn-success">
<Text id="editScene.addActionButton" />
</button>
</div>
</div>
);
}
Expand Down
36 changes: 22 additions & 14 deletions front/src/routes/scene/edit-scene/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,25 @@ class EditScene extends Component {
}
this.setState({ saving: false });
};
addAction = columnIndex => {
this.setState(prevState => {
addEmptyActionGroupIfNeeded = async () => {
const { actions } = this.state.scene;
const lastActionGroup = actions[actions.length - 1];
if (lastActionGroup.length > 0) {
const newState = update(this.state, {
scene: {
actions: {
$push: [[]]
}
},
variables: {
$push: [[]]
}
});
await this.setState(newState);
}
};
addAction = async columnIndex => {
await this.setState(prevState => {
let newState = update(prevState, {
scene: {
actions: {
Expand All @@ -118,20 +135,9 @@ class EditScene extends Component {
}
}
});
if (columnIndex + 1 === newState.scene.actions.length && newState.scene.actions[columnIndex].length === 1) {
newState = update(newState, {
scene: {
actions: {
$push: [[]]
}
},
variables: {
$push: [[]]
}
});
}
return newState;
});
await this.addEmptyActionGroupIfNeeded();
};
deleteActionGroup = columnIndex => {
let newState = update(this.state, {
Expand Down Expand Up @@ -392,6 +398,7 @@ class EditScene extends Component {
}
});
await this.setState(newState);
await this.addEmptyActionGroupIfNeeded();
};

moveCardGroup = async (index, destIndex) => {
Expand Down Expand Up @@ -428,6 +435,7 @@ class EditScene extends Component {
}
});
await this.setState(newState);
await this.addEmptyActionGroupIfNeeded();
};

setTags = tags => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,7 @@ class ChooseTriggerType extends Component {
this.setState({
currentTrigger: selectedOption
});
} else {
this.setState({
currentTrigger: null
});
}
};
changeBoxType = () => {
if (this.state.currentTrigger) {
this.props.updateTriggerProperty(this.props.index, 'type', this.state.currentTrigger.value);
this.props.updateTriggerProperty(this.props.index, 'type', selectedOption.value);
}
};

Expand Down Expand Up @@ -77,11 +69,6 @@ class ChooseTriggerType extends Component {
onChange={this.handleChange}
/>
</div>
<div class="form-group">
<button onClick={this.changeBoxType} class="btn btn-success">
<Text id="editScene.addTriggerButton" />
</button>
</div>
</div>
);
}
Expand Down

0 comments on commit 24f98ca

Please sign in to comment.