Skip to content
Snippets Groups Projects
Unverified Commit 29fef2c4 authored by Tim Macdonald's avatar Tim Macdonald Committed by GitHub
Browse files

Validate dashboard sub to Slack creation (#14531)

[Fixes #14494]
parent 8c41e8c0
Branches
Tags
No related merge requests found
......@@ -46,23 +46,25 @@ export function channelIsValid(channel, channelSpec) {
return true;
}
function pulseChannelsAreValid(pulse, channelSpecs) {
return (
pulse.channels.filter(c =>
channelIsValid(c, channelSpecs && channelSpecs[c.channel_type]),
).length > 0 || false
);
}
export function pulseIsValid(pulse, channelSpecs) {
return (
(pulse.name &&
pulse.cards.length > 0 &&
pulse.channels.filter(c =>
channelIsValid(c, channelSpecs && channelSpecs[c.channel_type]),
).length > 0) ||
pulseChannelsAreValid(pulse, channelSpecs)) ||
false
);
}
export function dashboardPulseIsValid(pulse, channelSpecs) {
return (
pulse.channels.filter(c =>
channelIsValid(c, channelSpecs && channelSpecs[c.channel_type]),
).length > 0 || false
);
return pulseChannelsAreValid(pulse, channelSpecs);
}
export function emailIsEnabled(pulse) {
......
......@@ -28,7 +28,11 @@ import User from "metabase/entities/users";
import { connect } from "react-redux";
import { cleanPulse, createChannel, pulseIsValid } from "metabase/lib/pulse";
import {
cleanPulse,
createChannel,
dashboardPulseIsValid,
} from "metabase/lib/pulse";
import MetabaseSettings from "metabase/lib/settings";
import {
......@@ -604,7 +608,7 @@ class SharingSidebar extends React.Component {
onClose={this.handleSave}
onCancel={this.onCancel}
className="text-dark"
closeIsDisabled={!pulseIsValid(pulse, formInput.channels)}
closeIsDisabled={!dashboardPulseIsValid(pulse, formInput.channels)}
>
<div className="pt4 px4 flex align-center">
<Icon name="mail" className="mr1" size={21} />
......@@ -705,6 +709,7 @@ class SharingSidebar extends React.Component {
onClose={this.handleSave}
onCancel={this.onCancel}
className="text-dark"
closeIsDisabled={!dashboardPulseIsValid(pulse, formInput.channels)}
>
<div className="pt4 flex align-center px4 mb3">
<Icon name="slack" className="mr1" size={21} />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment