From 510e9f458d0873871e2175307860980b861d0f2b Mon Sep 17 00:00:00 2001 From: Andres Orozco Date: Mon, 29 Apr 2019 20:03:57 -0400 Subject: [PATCH 1/7] MM-15128 - add support for interactive dialogs with no elements --- components/interactive_dialog/interactive_dialog.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/interactive_dialog/interactive_dialog.jsx b/components/interactive_dialog/interactive_dialog.jsx index 94a1750f0718..87a119f3d00c 100644 --- a/components/interactive_dialog/interactive_dialog.jsx +++ b/components/interactive_dialog/interactive_dialog.jsx @@ -17,7 +17,7 @@ export default class InteractiveDialog extends React.Component { static propTypes = { url: PropTypes.string.isRequired, callbackId: PropTypes.string, - elements: PropTypes.arrayOf(PropTypes.object).isRequired, + elements: PropTypes.arrayOf(PropTypes.object), title: PropTypes.string.isRequired, iconUrl: PropTypes.string, submitLabel: PropTypes.string, From ac768aa8b962fd1d3e58009c230dccabc14828bd Mon Sep 17 00:00:00 2001 From: Andres Orozco Date: Wed, 1 May 2019 09:26:57 -0400 Subject: [PATCH 2/7] MM-15128 - add check for null elements --- components/interactive_dialog/interactive_dialog.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/interactive_dialog/interactive_dialog.jsx b/components/interactive_dialog/interactive_dialog.jsx index 87a119f3d00c..2a3ac7892320 100644 --- a/components/interactive_dialog/interactive_dialog.jsx +++ b/components/interactive_dialog/interactive_dialog.jsx @@ -33,9 +33,11 @@ export default class InteractiveDialog extends React.Component { super(props); const values = {}; - props.elements.forEach((e) => { - values[e.name] = e.default || null; - }); + if (props.elements != null) { + props.elements.forEach((e) => { + values[e.name] = e.default || null; + }); + } this.state = { show: true, @@ -163,7 +165,7 @@ export default class InteractiveDialog extends React.Component { - {elements.map((e) => { + {elements && elements.map((e) => { return ( Date: Wed, 1 May 2019 11:17:29 -0400 Subject: [PATCH 3/7] MM-15128 fix TypeError for null elements, add conditonal modal --- .../interactive_dialog/interactive_dialog.jsx | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/components/interactive_dialog/interactive_dialog.jsx b/components/interactive_dialog/interactive_dialog.jsx index 2a3ac7892320..019b63ae8b49 100644 --- a/components/interactive_dialog/interactive_dialog.jsx +++ b/components/interactive_dialog/interactive_dialog.jsx @@ -53,19 +53,21 @@ export default class InteractiveDialog extends React.Component { const {elements} = this.props; const values = this.state.values; const errors = {}; - elements.forEach((elem) => { - const error = checkDialogElementForError(elem, values[elem.name]); - if (error) { - errors[elem.name] = ( - - ); - } - }); - + if (elements != null) { + elements.forEach((elem) => { + const error = checkDialogElementForError(elem, values[elem.name]); + if (error) { + errors[elem.name] = ( + + ); + } + }); + } + this.setState({errors}); if (Object.keys(errors).length !== 0) { @@ -164,8 +166,8 @@ export default class InteractiveDialog extends React.Component { {icon}{title} - - {elements && elements.map((e) => { + {elements && + {elements.map((e) => { return ( ); })} - + } +