Skip to content
Snippets Groups Projects
Unverified Commit 37642aaa authored by adam-james's avatar adam-james Committed by GitHub
Browse files

Add :dataset key to card bookmarks (#21261)

* Add :dataset key to card bookmarks

The :dataset key is boolean and indicates when a card (question) has been turned into a model.
The frontend will use this key to determine which icon is used to display the bookmark in the sidebar.

* Reduce some duplication in this test
parent 376f6a31
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@
:type (s/enum :card :collection :dashboard)
:item_id su/IntGreaterThanZero
:name su/NonBlankString
(s/optional-key :dataset) (s/maybe s/Bool)
(s/optional-key :display) (s/maybe s/Str)
(s/optional-key :authority_level) (s/maybe s/Str)
(s/optional-key :description) (s/maybe s/Str)})
......@@ -49,7 +50,7 @@
(merge
{:id (str (name ttype) "-" item-id-str)
:type ttype}
(select-keys normalized-result [:item_id :name :description :display :authority_level]))))
(select-keys normalized-result [:item_id :name :dataset :description :display :authority_level]))))
(defn- bookmarks-union-query
[id]
......@@ -84,6 +85,7 @@
{:select [[:bookmark.created_at :created_at]
[:card.id (db/qualify 'Card :item_id)]
[:card.name (db/qualify 'Card :name)]
[:card.dataset (db/qualify 'Card :dataset)]
[:card.display (db/qualify 'Card :display)]
[:card.description (db/qualify 'Card :description)]
[:card.archived (db/qualify 'Card :archived)]
......
......@@ -21,12 +21,13 @@
(is (= (u/the-id card)
(->> (mt/user-http-request :rasta :post 200 (str "bookmark/card/" (u/the-id card)))
:card_id))))
(testing "check a card bookmark has `:display` key"
(is (= "area"
(->> (mt/user-http-request :rasta :get 200 "bookmark")
(filter #(= (:type % ) "card"))
first
:display))))
(let [card-result (->> (mt/user-http-request :rasta :get 200 "bookmark")
(filter #(= (:type % ) "card"))
first)]
(testing "check a card bookmark has `:display` key"
(is (contains? card-result :display)))
(testing "check a card bookmark has `:dataset` key"
(is (contains? card-result :dataset))))
(testing "check that we can bookmark a Dashboard"
(is (= (u/the-id dashboard)
(->> (mt/user-http-request :rasta :post 200 (str "bookmark/dashboard/" (u/the-id dashboard)))
......
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