Skip to content
Snippets Groups Projects
Unverified Commit 485b83ec authored by Ngoc Khuat's avatar Ngoc Khuat Committed by GitHub
Browse files

Fallback to Card's description when sending Pulse (#21910)


* Fall back to Card's description if it's not exists when send subscription email

* fix ns

* use card from arg instead of fetching from DB

* Update src/metabase/pulse/render.clj

Co-authored-by: default avatarNoah Moss <32746338+noahmoss@users.noreply.github.com>

Co-authored-by: default avatarNoah Moss <32746338+noahmoss@users.noreply.github.com>
parent 357efa59
Branches
Tags
No related merge requests found
......@@ -48,9 +48,10 @@
:src (:image-src image-bundle)}])]]]]})))
(s/defn ^:private make-description-if-needed :- (s/maybe common/RenderedPulseCard)
[dashcard]
[dashcard card]
(when *include-description*
(when-let [description (-> dashcard :visualization_settings :card.description)]
(when-let [description (or (get-in dashcard [:visualization_settings :card.description])
(:description card))]
{:attachments {}
:content [:div {:style (style/style {:color style/color-text-medium
:font-size :12px
......@@ -162,7 +163,7 @@
scalar results where text is preferable to an image of a div of a single result."
[render-type timezone-id :- (s/maybe s/Str) card dashcard results]
(let [{title :content, title-attachments :attachments} (make-title-if-needed render-type card dashcard)
{description :content} (make-description-if-needed dashcard)
{description :content} (make-description-if-needed dashcard card)
{pulse-body :content
body-attachments :attachments
text :render/text} (render-pulse-card-body render-type timezone-id card dashcard results)]
......
......@@ -113,3 +113,19 @@
{:base_type :type/Number}]
:rows [["apple" 3]
["banana" 4]]}))))
(deftest make-description-if-needed-test
(testing "Use Visualization Settings's description if it exists"
(mt/with-temp* [Card [card {:description "Card description"}]
Dashboard [dashboard]
DashboardCard [dc1 {:dashboard_id (:id dashboard) :card_id (:id card)
:visualization_settings {:card.description "Visualization description"}}]]
(binding [render/*include-description* true]
(is (= "Visualization description" (last (:content (#'render/make-description-if-needed dc1 card))))))))
(testing "Fallback to Card's description if Visualization Settings's description not exists"
(mt/with-temp* [Card [card {:description "Card description"}]
Dashboard [dashboard]
DashboardCard [dc1 {:dashboard_id (:id dashboard) :card_id (:id card)}]]
(binding [render/*include-description* true]
(is (= "Card description" (last (:content (#'render/make-description-if-needed dc1 card)))))))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment