diff --git a/src/components/flow/actions/changegroups/addgroups/AddGroupsForm.tsx b/src/components/flow/actions/changegroups/addgroups/AddGroupsForm.tsx index 337f41459..567ee0d66 100644 --- a/src/components/flow/actions/changegroups/addgroups/AddGroupsForm.tsx +++ b/src/components/flow/actions/changegroups/addgroups/AddGroupsForm.tsx @@ -94,7 +94,7 @@ export default class AddGroupsForm extends React.Component diff --git a/src/components/flow/actions/sendbroadcast/SendBroadcast.tsx b/src/components/flow/actions/sendbroadcast/SendBroadcast.tsx index c8dbf95cb..2f52692e8 100644 --- a/src/components/flow/actions/sendbroadcast/SendBroadcast.tsx +++ b/src/components/flow/actions/sendbroadcast/SendBroadcast.tsx @@ -18,37 +18,30 @@ const SendBroadcastComp: React.SFC = ( context: any ): JSX.Element => { const assets = getRecipients(action); - if (action.text) { - return ( -
-
- {renderAssetList(assets, MAX_TO_SHOW, context.config.endpoints)} -
-
- {action.text.split(/\r?\n/).map((line: string, idx: number) => ( + + return ( +
+
+ {renderAssetList(assets, MAX_TO_SHOW, context.config.endpoints)} +
+
+ {action.text && + action.text.split(/\r?\n/).map((line: string, idx: number) => (
{line}
))} -
- {action.attachments && action.attachments.length > 0 ? ( -
- ) : null} - {action.templating && action.templating.template ? ( -
- ) : null} -
+
+ {action.attachments && action.attachments.length > 0 ? ( +
+ ) : null} + {action.templating && action.templating.template ? ( +
+ ) : null}
- ); - } - if (action.attachments && action.attachments.length > 0) { - return
; - } - if (action.templating && action.templating.template) { - return
; - } - return
{PLACEHOLDER}
; +
+ ); }; SendBroadcastComp.contextTypes = { diff --git a/src/components/flow/actions/sendbroadcast/SendBroadcastForm.tsx b/src/components/flow/actions/sendbroadcast/SendBroadcastForm.tsx index 2d0be4bf4..e1f89dd87 100644 --- a/src/components/flow/actions/sendbroadcast/SendBroadcastForm.tsx +++ b/src/components/flow/actions/sendbroadcast/SendBroadcastForm.tsx @@ -138,7 +138,7 @@ export default class SendBroadcastForm extends React.Component< this.setState({ valid }); } } else { - this.setState({ attachmentError: `Not a valid ${type} url` }); + this.setState({ attachmentError: response.data.message }); } }) .catch(error => { @@ -387,7 +387,7 @@ export default class SendBroadcastForm extends React.Component< ) : null}
- {this.state.validAttachment && !this.state.attachmentError ? ( + {this.state.valid && this.state.validAttachment && !this.state.attachmentError ? (
Checking URL validity @@ -427,6 +427,14 @@ export default class SendBroadcastForm extends React.Component< ); } + private checkAttachmentErrors(): boolean { + if (this.state.valid) { + return this.state.validAttachment; + } else { + return false; + } + } + public render(): JSX.Element { const typeConfig = this.props.typeConfig; @@ -441,7 +449,7 @@ export default class SendBroadcastForm extends React.Component< name: 'Attachments', body: this.renderAttachments(), checked: this.state.attachments.length > 0, - hasErrors: this.state.validAttachment + hasErrors: this.checkAttachmentErrors() }; return ( {