Skip to content
Snippets Groups Projects
Commit a5e562cb authored by Atte Keinänen's avatar Atte Keinänen
Browse files

Fix both backend and frontend code style, fix flow type error

parent 4d93eae5
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ type Props = {
activeText?: string,
failedText?: string,
successText?: string,
forceActiveStyle?: boolean
}
type State = {
......@@ -49,7 +50,7 @@ export default class ActionButton extends Component<*, Props, State> {
activeText: "Saving...",
failedText: "Save failed",
successText: "Saved",
overrideStyle: false
forceActiveStyle: false
};
componentWillUnmount() {
......@@ -97,13 +98,13 @@ export default class ActionButton extends Component<*, Props, State> {
render() {
// eslint-disable-next-line no-unused-vars
const { normalText, activeText, failedText, successText, actionFn, className, overrideStyle, children, ...props } = this.props;
const { normalText, activeText, failedText, successText, actionFn, className, forceActiveStyle, children, ...props } = this.props;
const { active, result } = this.state;
return (
<Button
{...props}
className={overrideStyle ? cx('Button', 'Button--waiting') : cx(className, {
className={forceActiveStyle ? cx('Button', 'Button--waiting') : cx(className, {
'Button--waiting pointer-events-none': active,
'Button--success': result === 'success',
'Button--danger': result === 'failed'
......@@ -115,7 +116,7 @@ export default class ActionButton extends Component<*, Props, State> {
activeText
: result === "success" ?
<span>
{overrideStyle ? null : <Icon name='check' size={12} /> }
{forceActiveStyle ? null : <Icon name='check' size={12} /> }
<span className="ml1">{successText}</span>
</span>
: result === "failed" ?
......
......@@ -135,7 +135,7 @@ export default class PulseEditChannels extends Component {
return this.props.testPulse({ ...this.props.pulse, channels: [channel] });
}
willPulseSkip() {
willPulseSkip = () => {
let cards = _.pluck(this.props.pulse.cards, 'id');
let cardPreviews = this.props.cardPreviews;
let previews = _.map(cards, function (id) { return _.find(cardPreviews, function(card){ return (id == card.id);})});
......@@ -204,8 +204,8 @@ export default class PulseEditChannels extends Component {
"Send to " + channelSpec.name + " now"}
activeText="Sending…"
failedText="Sending failed"
successText={ this.willPulseSkip.bind(this)() ? "Didn’t send because the pulse has no results." : "Pulse sent"}
overrideStyle={ this.willPulseSkip.bind(this)() }
successText={ this.willPulseSkip() ? "Didn’t send because the pulse has no results." : "Pulse sent"}
forceActiveStyle={ this.willPulseSkip() }
/>
</div>
</li>
......
databaseChangeLog:
- changeSet:
id: 52
id: 54
author: tlrobinson
changes:
- addColumn:
......
......@@ -64,11 +64,11 @@
skip_if_empty s/Bool}
(write-check Pulse id)
(check-card-read-permissions cards)
(pulse/update-pulse! {:id id
:name name
:cards (map u/get-id cards)
:channels channels
:skip_if_empty? skip_if_empty})
(pulse/update-pulse! {:id id
:name name
:cards (map u/get-id cards)
:channels channels
:skip-if-empty? skip_if_empty})
(pulse/retrieve-pulse id))
......@@ -141,6 +141,6 @@
skip_if_empty s/Bool}
(check-card-read-permissions cards)
(p/send-pulse! body)
{:ok true})
{:ok true})
(define-routes)
......@@ -193,7 +193,7 @@
"Update an existing `Pulse`, including all associated data such as: `PulseCards`, `PulseChannels`, and `PulseChannelRecipients`.
Returns the updated `Pulse` or throws an Exception."
[{:keys [id name cards channels skip_if_empty?] :as pulse}]
[{:keys [id name cards channels skip-if-empty?] :as pulse}]
{:pre [(integer? id)
(string? name)
(sequential? cards)
......@@ -203,7 +203,7 @@
(every? map? channels)]}
(db/transaction
;; update the pulse itself
(db/update! Pulse id, :name name, :skip_if_empty skip_if_empty?)
(db/update! Pulse id, :name name, :skip_if_empty skip-if-empty?)
;; update cards (only if they changed)
(when (not= cards (map :card_id (db/select [PulseCard :card_id], :pulse_id id, {:order-by [[:position :asc]]})))
(update-pulse-cards! pulse cards))
......
......@@ -74,7 +74,7 @@
(= [[nil]]
(-> result :data :rows)))))
(defn are-all-cards-empty?
(defn- are-all-cards-empty?
"Do none of the cards have any results?"
[results]
(every? is-card-empty? results))
......@@ -86,7 +86,7 @@
Example:
(send-pulse! pulse) Send to all Channels
(send-pulse! pulse :channel-ids [312]) Send only to Channel with :id = 312"
[{:keys [cards] :as pulse} & {:keys [channel-ids]}]
[{:keys [cards], :as pulse} & {:keys [channel-ids]}]
{:pre [(map? pulse) (every? map? cards) (every? :id cards)]}
(let [results (for [card cards]
(execute-card (:id card), :pulse-id (:id pulse))) ; Pulse ID may be `nil` if the Pulse isn't saved yet
......
......@@ -172,13 +172,13 @@
(tt/with-temp* [Pulse [{pulse-id :id}]
Card [{card-id-1 :id} {:name "Test Card"}]
Card [{card-id-2 :id} {:name "Bar Card", :display :bar}]]
(update-pulse-then-select! {:id pulse-id
:name "We like to party"
:creator_id (user->id :crowberto)
:cards [card-id-2 card-id-1]
:channels [{:channel_type :email
:schedule_type :daily
:schedule_hour 18
:recipients [{:email "foo@bar.com"}
{:id (user->id :crowberto)}]}]
:skip_if_empty? false})))
(update-pulse-then-select! {:id pulse-id
:name "We like to party"
:creator_id (user->id :crowberto)
:cards [card-id-2 card-id-1]
:channels [{:channel_type :email
:schedule_type :daily
:schedule_hour 18
:recipients [{:email "foo@bar.com"}
{:id (user->id :crowberto)}]}]
:skip-if-empty? false})))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment