Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
7720c2ab
Unverified
Commit
7720c2ab
authored
3 years ago
by
Anton Kulyk
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove not used `isCardDirty` helper (#20367)
parent
08e60aa0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/lib/card.js
+0
-34
0 additions, 34 deletions
frontend/src/metabase/lib/card.js
frontend/test/metabase/lib/card.unit.spec.js
+0
-35
0 additions, 35 deletions
frontend/test/metabase/lib/card.unit.spec.js
with
0 additions
and
69 deletions
frontend/src/metabase/lib/card.js
+
0
−
34
View file @
7720c2ab
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
frontend/test/metabase/lib/card.unit.spec.js
+
0
−
35
View file @
7720c2ab
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
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment