Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Fix issues related to zoapp-core by sending empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffladiray authored and arnaud-moncel committed Mar 15, 2019
1 parent a33d23c commit be7018d
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 6 deletions.
12 changes: 8 additions & 4 deletions backend/src/middlewares/openNLX.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,14 @@ class OpenNLXMiddleware {
const bots = this.mainControllers.getBots();
let intents = await bots.getIntents(botId, versionId);
intents = intents.map((int) => {
const intentWithPrevious = int;
intentWithPrevious.previous = int.previousId;
delete intentWithPrevious.previousId;
return intentWithPrevious;
const toOpenNLXIntent = int;
if (int.previousId && int.previousId.length > 0) {
toOpenNLXIntent.previous = int.previousId;
delete toOpenNLXIntent.previousId;
}
toOpenNLXIntent.deactivated =
int.state && int.state === "deactivated";
return toOpenNLXIntent;
});
this.openNLX.deleteAllIntents(botId, version);
this.openNLX.setIntents(botId, version, intents);
Expand Down
3 changes: 2 additions & 1 deletion front/src/shared/components/intentDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ const IntentDetail = ({
Deactivate
<ListItemMeta style={{ minWidth: "320px", display: "flex" }}>
<Switch
id="deactivate"
style={{ margin: "0 auto" }}
checked={isDeactivated}
onChange={(isDisabled) => {
Expand Down Expand Up @@ -233,7 +234,7 @@ export const displayActionEditor = (
label="Select an intent"
style={{ width: "100%" }}
onSelected={(t) => {
setInput({ value: t !== "default" ? t : null });
setInput({ value: t !== "default" ? t : "" });
}}
>
{parameters.options.map((int) => (
Expand Down
2 changes: 1 addition & 1 deletion front/src/shared/containers/builder/intentContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ class IntentContainer extends Component {
if (isDisabled) {
selectedIntent.state = "deactivated";
} else {
selectedIntent.state = null;
selectedIntent.state = "";
}
this.props.appUpdateIntent(
this.props.selectedBotId,
Expand Down
112 changes: 112 additions & 0 deletions front/tests/shared/components/__snapshots__/intentDetail.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,62 @@ exports[`components/intentDetail can render intent with special characters corre
</button>
</span>
</li>
<li
className="mdc-list-item"
onKeyPress={[Function]}
role="menuitem"
>
<i
aria-hidden="true"
className="mdc-list-item__graphic material-icons"
>
link
</i>
Deactivate
<span
className="mdc-list-item__meta"
onClick={null}
onKeyUp={[Function]}
role="button"
style={
Object {
"display": "flex",
"minWidth": "320px",
}
}
tabIndex="0"
>
<div
className="mdc-switch"
onClick={[Function]}
style={
Object {
"margin": "0 auto",
}
}
>
<div
className="mdc-switch__track"
/>
<div
className="mdc-switch__thumb-underlay"
>
<div
className="mdc-switch__thumb"
>
<input
checked={false}
className="mdc-switch__native-control"
disabled={false}
id="deactivate"
role="switch"
type="checkbox"
/>
</div>
</div>
</div>
</span>
</li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -1089,6 +1145,62 @@ exports[`components/intentDetail renders correctly 1`] = `
</button>
</span>
</li>
<li
className="mdc-list-item"
onKeyPress={[Function]}
role="menuitem"
>
<i
aria-hidden="true"
className="mdc-list-item__graphic material-icons"
>
link
</i>
Deactivate
<span
className="mdc-list-item__meta"
onClick={null}
onKeyUp={[Function]}
role="button"
style={
Object {
"display": "flex",
"minWidth": "320px",
}
}
tabIndex="0"
>
<div
className="mdc-switch"
onClick={[Function]}
style={
Object {
"margin": "0 auto",
}
}
>
<div
className="mdc-switch__track"
/>
<div
className="mdc-switch__thumb-underlay"
>
<div
className="mdc-switch__thumb"
>
<input
checked={false}
className="mdc-switch__native-control"
disabled={false}
id="deactivate"
role="switch"
type="checkbox"
/>
</div>
</div>
</div>
</span>
</li>
</ul>
</div>
</div>
Expand Down

0 comments on commit be7018d

Please sign in to comment.