From 47804c52d2cde8d40b0b72cb8467ed1f09e20931 Mon Sep 17 00:00:00 2001 From: Alexander Polyankin <alexander.polyankin@metabase.com> Date: Mon, 17 Oct 2022 20:11:27 +0300 Subject: [PATCH] Remove metabase/writeback dependency in metabase-lib (#25959) --- .../lib/parameters/utils/click-behavior.js | 21 +++++++++++++++++- frontend/src/metabase/writeback/utils.ts | 22 ------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/frontend/src/metabase-lib/lib/parameters/utils/click-behavior.js b/frontend/src/metabase-lib/lib/parameters/utils/click-behavior.js index 0a1a815ea83..596131d2f7b 100644 --- a/frontend/src/metabase-lib/lib/parameters/utils/click-behavior.js +++ b/frontend/src/metabase-lib/lib/parameters/utils/click-behavior.js @@ -3,7 +3,6 @@ import { getIn } from "icepick"; import { parseTimestamp } from "metabase/lib/time"; import { formatDateTimeForParameter } from "metabase/lib/formatting/date"; -import { isValidImplicitActionClickBehavior } from "metabase/writeback/utils"; import { dimensionFilterForParameter, variableFilterForParameter, @@ -231,6 +230,26 @@ export function clickBehaviorIsValid(clickBehavior) { return false; } +function isValidImplicitActionClickBehavior(clickBehavior) { + if ( + !clickBehavior || + clickBehavior.type !== "action" || + !("actionType" in clickBehavior) + ) { + return false; + } + if (clickBehavior.actionType === "insert") { + return clickBehavior.tableId != null; + } + if ( + clickBehavior.actionType === "update" || + clickBehavior.actionType === "delete" + ) { + return typeof clickBehavior.objectDetailDashCardId === "number"; + } + return false; +} + export function formatSourceForTarget( source, target, diff --git a/frontend/src/metabase/writeback/utils.ts b/frontend/src/metabase/writeback/utils.ts index 6a067db4e01..b8daf5b8051 100644 --- a/frontend/src/metabase/writeback/utils.ts +++ b/frontend/src/metabase/writeback/utils.ts @@ -87,28 +87,6 @@ export function isMappedExplicitActionButton( ); } -export function isValidImplicitActionClickBehavior( - clickBehavior?: ClickBehavior, -) { - if ( - !clickBehavior || - clickBehavior.type !== "action" || - !("actionType" in clickBehavior) - ) { - return false; - } - if (clickBehavior.actionType === "insert") { - return clickBehavior.tableId != null; - } - if ( - clickBehavior.actionType === "update" || - clickBehavior.actionType === "delete" - ) { - return typeof clickBehavior.objectDetailDashCardId === "number"; - } - return false; -} - export function getActionButtonLabel(dashCard: ActionDashboardCard) { const label = dashCard.visualization_settings?.["button.label"]; return label || ""; -- GitLab