From be7018da1b3b1826a91f38afe52e88528420db03 Mon Sep 17 00:00:00 2001 From: Jeff LADIRAY Date: Tue, 12 Mar 2019 10:18:16 +0100 Subject: [PATCH] Fix issues related to zoapp-core by sending empty string --- backend/src/middlewares/openNLX.js | 12 +- front/src/shared/components/intentDetail.jsx | 3 +- .../containers/builder/intentContainer.jsx | 2 +- .../__snapshots__/intentDetail.test.js.snap | 112 ++++++++++++++++++ 4 files changed, 123 insertions(+), 6 deletions(-) diff --git a/backend/src/middlewares/openNLX.js b/backend/src/middlewares/openNLX.js index e9f55944..b4282b5c 100644 --- a/backend/src/middlewares/openNLX.js +++ b/backend/src/middlewares/openNLX.js @@ -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); diff --git a/front/src/shared/components/intentDetail.jsx b/front/src/shared/components/intentDetail.jsx index cf3513d0..f0411383 100644 --- a/front/src/shared/components/intentDetail.jsx +++ b/front/src/shared/components/intentDetail.jsx @@ -155,6 +155,7 @@ const IntentDetail = ({ Deactivate { @@ -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) => ( diff --git a/front/src/shared/containers/builder/intentContainer.jsx b/front/src/shared/containers/builder/intentContainer.jsx index dd65a1a2..ab9acae2 100644 --- a/front/src/shared/containers/builder/intentContainer.jsx +++ b/front/src/shared/containers/builder/intentContainer.jsx @@ -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, diff --git a/front/tests/shared/components/__snapshots__/intentDetail.test.js.snap b/front/tests/shared/components/__snapshots__/intentDetail.test.js.snap index a8783afb..cacb4677 100644 --- a/front/tests/shared/components/__snapshots__/intentDetail.test.js.snap +++ b/front/tests/shared/components/__snapshots__/intentDetail.test.js.snap @@ -541,6 +541,62 @@ exports[`components/intentDetail can render intent with special characters corre +
  • + + Deactivate + +
    +
    +
    +
    + +
    +
    +
    + +
  • @@ -1089,6 +1145,62 @@ exports[`components/intentDetail renders correctly 1`] = ` +
  • + + Deactivate + +
    +
    +
    +
    + +
    +
    +
    + +