From 7720c2ab1faf2d3c1db86102b432a77cd0f928e4 Mon Sep 17 00:00:00 2001
From: Anton Kulyk <kuliks.anton@gmail.com>
Date: Wed, 9 Feb 2022 14:24:31 +0200
Subject: [PATCH] Remove not used `isCardDirty` helper (#20367)

---
 frontend/src/metabase/lib/card.js            | 34 -------------------
 frontend/test/metabase/lib/card.unit.spec.js | 35 --------------------
 2 files changed, 69 deletions(-)

diff --git a/frontend/src/metabase/lib/card.js b/frontend/src/metabase/lib/card.js
index f524023e5f4..cf6be0d4417 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 f7974ef8c7b..51849a94060 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(
-- 
GitLab