diff --git a/frontend/src/metabase/lib/card.js b/frontend/src/metabase/lib/card.js index f524023e5f42e1c0f392812cf385d649104017bf..cf6be0d44170806d13f61da6e6ecbd339e3f9cd8 100644 --- a/frontend/src/metabase/lib/card.js +++ b/frontend/src/metabase/lib/card.js @@ -35,40 +35,6 @@ export async function loadCard(cardId) { } } -// TODO Atte Keinänen 5/31/17 Deprecated, we should migrate existing references to this method to `question.isCardDirty` -// predicate function that dermines if a given card is "dirty" compared to the last known version of the card -export function isCardDirty(card, originalCard) { - // The rules: - // - if it's new, then it's dirty when - // 1) there is a database/table chosen or - // 2) when there is any content on the native query - // - if it's saved, then it's dirty when - // 1) the current card doesn't match the last saved version - - if (!card) { - return false; - } else if (!card.id) { - if (card.dataset_query.query && card.dataset_query.query["source-table"]) { - return true; - } else if ( - card.dataset_query.native && - !_.isEmpty(card.dataset_query.native.query) - ) { - return true; - } else { - return false; - } - } else { - const origCardSerialized = originalCard - ? serializeCardForUrl(originalCard) - : null; - const newCardSerialized = card - ? serializeCardForUrl(_.omit(card, "original_card_id")) - : null; - return newCardSerialized !== origCardSerialized; - } -} - // TODO Atte Keinänen 5/31/17 Deprecated, we should move tests to Questions.spec.js export function serializeCardForUrl(card) { const dataset_query = Utils.copy(card.dataset_query); diff --git a/frontend/test/metabase/lib/card.unit.spec.js b/frontend/test/metabase/lib/card.unit.spec.js index f7974ef8c7b50a9ade7b80428316f18a006012eb..51849a94060400514daf70bfe36a338bfb3e0a06 100644 --- a/frontend/test/metabase/lib/card.unit.spec.js +++ b/frontend/test/metabase/lib/card.unit.spec.js @@ -1,6 +1,5 @@ import { createCard, - isCardDirty, serializeCardForUrl, deserializeCardFromUrl, } from "metabase/lib/card"; @@ -103,40 +102,6 @@ describe("lib/card", () => { }); }); - describe("isCardDirty", () => { - it("should consider a new card clean if no db table or native query is defined", () => { - expect(isCardDirty(getCard({ newCard: true }), null)).toBe(false); - }); - it("should consider a new card dirty if a db table is chosen", () => { - expect(isCardDirty(getCard({ newCard: true, table: 5 }), null)).toBe( - true, - ); - }); - it("should consider a new card dirty if there is any content on the native query", () => { - expect(isCardDirty(getCard({ newCard: true, table: 5 }), null)).toBe( - true, - ); - }); - it("should consider a saved card and a matching original card identical", () => { - expect( - isCardDirty( - getCard({ hasOriginalCard: true }), - getCard({ hasOriginalCard: false }), - ), - ).toBe(false); - }); - it("should consider a saved card dirty if the current card doesn't match the last saved version", () => { - expect( - isCardDirty( - getCard({ - hasOriginalCard: true, - queryFields: [["field", 21, null]], - }), - getCard({ hasOriginalCard: false }), - ), - ).toBe(true); - }); - }); describe("serializeCardForUrl", () => { it("should include `original_card_id` property to the serialized URL", () => { const cardAfterSerialization = deserializeCardFromUrl(