Skip to content
Snippets Groups Projects
Unverified Commit 878290b4 authored by Cal Herries's avatar Cal Herries Committed by GitHub
Browse files

Deprecate PUT /api/dashboard/:id/cards endpoint (#35499)

parent d756bd36
No related branches found
No related tags found
No related merge requests found
......@@ -557,7 +557,8 @@
[id {:keys [dashcards tabs] :as dash-updates}]
(let [current-dash (api/write-check Dashboard id)
changes-stats (atom nil)
;; tabs are sent in production as well, but there are lots of tests that exclude it. so this only checks for dashcards
;; tabs are always sent in production as well when dashcards are updated, but there are lots of
;; tests that exclude it. so this only checks for dashcards
update-dashcards-and-tabs? (contains? dash-updates :dashcards)]
(collection/check-allowed-to-change-collection current-dash dash-updates)
(check-allowed-to-change-embedding current-dash dash-updates)
......@@ -607,9 +608,7 @@
true))
(let [dashboard (t2/select-one :model/Dashboard id)]
(events/publish-event! :event/dashboard-update {:object dashboard :user-id api/*current-user-id*})
(when update-dashcards-and-tabs?
;; execute these events for old PUT /api/dashboard/:id/cards calls and new PUT /api/dashboard/:id calls, and not for old PUT /api/dashboard/:id calls
(track-dashcard-and-tab-events! dashboard @changes-stats))
(track-dashcard-and-tab-events! dashboard @changes-stats)
(-> (t2/hydrate dashboard [:collection :is_personal] [:dashcards :series] :tabs)
(assoc :last-edit-info (last-edit/edit-information-for-user @api/*current-user*))))))
......@@ -638,7 +637,8 @@
(update-dashboard id dash-updates))
(api/defendpoint PUT "/:id/cards"
"Update `Cards` and `Tabs` on a Dashboard. Request body should have the form:
"(DEPRECATED -- Use the `PUT /api/dashboard/:id` endpoint instead.)
Update `Cards` and `Tabs` on a Dashboard. Request body should have the form:
{:cards [{:id ... ; DashboardCard ID
:size_x ...
......@@ -657,6 +657,8 @@
;; tabs should be required in production, making it optional because lots of
;; e2e tests curerntly doesn't include it
tabs [:maybe (ms/maps-with-unique-key [:sequential UpdatedDashboardTab] :id)]}
(log/warn
"DELETE /api/dashboard/:id/cards is deprecated. Use PUT /api/dashboard/:id instead.")
(let [dashboard (update-dashboard id {:dashcards cards :tabs tabs})]
{:cards (:dashcards dashboard)
:tabs (:tabs 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