Skip to content
Snippets Groups Projects
Unverified Commit 9c3b6b9b authored by metamben's avatar metamben Committed by GitHub
Browse files

Return is_app_page for dashboard bookmarks (#25244)

parent f88c818c
Branches
Tags
No related merge requests found
......@@ -32,18 +32,19 @@
(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)
(s/optional-key :app_id) (s/maybe su/IntGreaterThanOrEqualToZero)})
(s/optional-key :app_id) (s/maybe su/IntGreaterThanOrEqualToZero)
(s/optional-key :is_app_page) (s/maybe s/Bool)})
(s/defn ^:private normalize-bookmark-result :- BookmarkResult
"Normalizes bookmark results. Bookmarks are left joined against the card, collection, and dashboard tables, but only
points to one of them. Normalizes it so it has an id (concatenation of model and model-id), type, item_id, name, and
description."
points to one of them. Normalizes it so it has just the desired fields."
[result]
(let [result (into {} (remove (comp nil? second) result))
normalized-result (zipmap (map unqualify-key (keys result)) (vals result))
id-str (str (:type normalized-result) "-" (:item_id normalized-result))]
(-> normalized-result
(select-keys [:item_id :type :name :dataset :description :display :authority_level :app_id])
(select-keys [:item_id :type :name :dataset :description :display
:authority_level :app_id :is_app_page])
(assoc :id id-str))))
(defn- bookmarks-union-query
......@@ -90,6 +91,7 @@
[:dashboard.name (db/qualify 'Dashboard :name)]
[:dashboard.description (db/qualify 'Dashboard :description)]
[:dashboard.archived (db/qualify 'Dashboard :archived)]
[:dashboard.is_app_page (db/qualify 'Dashboard :is_app_page)]
[:collection.name (db/qualify 'Collection :name)]
[:collection.authority_level (db/qualify 'Collection :authority_level)]
[:collection.description (db/qualify 'Collection :description)]
......
......@@ -17,7 +17,7 @@
(testing "POST /api/bookmark/:model/:model-id"
(mt/with-temp* [Collection [collection {:name "Test Collection"}]
Card [card {:name "Test Card" :display "area"}]
Dashboard [dashboard {:name "Test Dashboard"}]
Dashboard [dashboard {:name "Test Dashboard" :is_app_page true}]
App [app {:collection_id (:id collection), :dashboard_id (:id dashboard)}]]
(testing "check that we can bookmark a Collection"
(is (= (u/the-id collection)
......@@ -43,8 +43,11 @@
(is (= #{"card" "collection" "dashboard"}
(into #{} (map :type) result)))
(testing "that app_id is hydrated on app collections"
(is (partial= [{:app_id (:id app)}]
(filter #(= (:type %) "collection") result))))))
(is (partial= [{:item_id (:id collection), :app_id (:id app)}]
(filter #(= (:type %) "collection") result))))
(testing "that is_app_page is returned for dashboards"
(is (partial= [{:item_id (:id dashboard), :is_app_page true}]
(filter #(= (:type %) "dashboard") result))))))
(testing "check that we can delete bookmarks"
(mt/user-http-request :rasta :delete 204 (str "bookmark/card/" (u/the-id card)))
(is (= #{"collection" "dashboard"}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment