Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Replace question" action to dashboard cards #36744

Merged
merged 26 commits into from Dec 14, 2023

Conversation

kulyk
Copy link
Member

@kulyk kulyk commented Dec 13, 2023

Closes #36497, closes #36586

Adds a "Replace" button to dashboard cards with questions or models. It makes it possible to swap the dashboard card's query while keeping the dashboard layout intact. It's important to call out that we would reset properties of a dash card that no longer makes sense with a new query: parameter mappings, click behavior, visualization settings, and added series.

How to verify

  1. Open any dashboard that has a few cards
  2. Enter the editing mode
  3. Hover a dashboard card using a question or a model
  4. Find and click the "Replace" action in the top-right floating panel
  5. Select a new question or a model from the modal picker
  6. Ensure the dashboard card's content is replaced, and the query is rerun
  7. Ensure parameters auto-wiring worked (your dashboard should have another card using the same table and mapped to some parameters)
  8. Ensure you can undo the revert
  9. Ensure changes are persisted after clicking "Save"

Demo

Basic
CleanShot.2023-12-13.at.11.25.41.mp4
Filters auto-wiring
CleanShot.2023-12-13.at.11.29.29.mp4

Checklist

  • Tests have been added/updated to cover changes in this PR

@kulyk kulyk added no-backport Do not backport this PR to any branch .Team/DashViz Dashboard and Viz team labels Dec 13, 2023
@kulyk kulyk requested review from kdoh, cdeweyx and a team December 13, 2023 11:30
@kulyk kulyk self-assigned this Dec 13, 2023
Copy link

deploysentinel bot commented Dec 13, 2023

No failed tests 🎉

@kulyk kulyk force-pushed the 36497-replace-dashcard-card branch from e364299 to 94dd166 Compare December 13, 2023 13:28
@kulyk kulyk changed the base branch from master to handle-mantine-modals-in-e2e December 13, 2023 13:29
Base automatically changed from handle-mantine-modals-in-e2e to master December 13, 2023 14:34
@markbastian markbastian self-assigned this Dec 13, 2023
markbastian and others added 4 commits December 13, 2023 09:45
Under the old behavior, only action dashcards allowed changing their card ids. Now card ids can be changed for any dashcard type. This test captured the old behavior and has been updated to capture the new behavior.
Copy link
Contributor

@snoe snoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BE LGTM

@calherries
Copy link
Contributor

If Case is cool with updating card IDs, you should change the logic in models.dashboard-card.update-dashboard-card! which prevents it

;; Allow changing card_id for action dashcards, but not for card dashcards.
;; This is to preserve the existing behavior of questions and card_id
;; I don't know why card_id couldn't be changed for cards though.

@markbastian
Copy link
Contributor

If Case is cool with updating card IDs, you should change the logic in models.dashboard-card.update-dashboard-card! which prevents it

;; Allow changing card_id for action dashcards, but not for card dashcards.
;; This is to preserve the existing behavior of questions and card_id
;; I don't know why card_id couldn't be changed for cards though.

Isn't this addressed here? https://github.com/metabase/metabase/pull/36744/files#diff-b6abb82aa02f4647f6ac74d17bfa75dda523bf75c2eed11954c56127a6d7446dR180-R189

@calherries
Copy link
Contributor

calherries commented Dec 13, 2023

Ah, so sorry, I didn't see that was part of the PR. I just read the test. All clear then!

@alxnddr
Copy link
Member

alxnddr commented Dec 13, 2023

It would be great if users could replace errored cards, I think it can be a valid use case for the functionality
Screenshot 2023-12-13 at 6 43 34 PM

@@ -5,6 +5,10 @@ export function getDashboardId(state: State) {
return state.dashboard.dashboardId;
}

export function getDashboardBeforeEditing(state: State) {
return state.dashboard.isEditing;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, isEditing is a dashboard instead of a boolean 🤯

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid you're right 😢

Copy link
Member

@alxnddr alxnddr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and clean! Please have a look at the suggestion about errored cards

@kulyk
Copy link
Member Author

kulyk commented Dec 14, 2023

It would be great if users could replace errored cards, I think it can be a valid use case for the functionality

@alxnddr, love the idea, added in 92bc305. Thanks!

Demo
CleanShot.2023-12-14.at.12.10.19.mp4

Copy link

cypress bot commented Dec 14, 2023

Passing run #200 ↗︎

0 139 9 0 Flakiness 0

Details:

Add "Replace question" action to dashboard cards
Project: Metabase e2e Commit: 5762787c85
Status: Passed Duration: 09:00 💡
Started: Dec 14, 2023 12:59 PM Ended: Dec 14, 2023 1:08 PM

Review all test suite changes for PR #36744 ↗︎

@perivamsi
Copy link
Contributor

It would be great if users could replace errored cards, I think it can be a valid use case for the functionality

@alxnddr, love the idea, added in 92bc305. Thanks!

Demo

If it is possible to show the "replace card" prompt directly on the error card, that will be helpful.

So change "There was a problem displaying this card." by adding a "replace it" link or button at the end? This is more discoverable.

@kulyk
Copy link
Member Author

kulyk commented Dec 14, 2023

It would be great if users could replace errored cards, I think it can be a valid use case for the functionality

@alxnddr, love the idea, added in 92bc305. Thanks!

Demo

If it is possible to show the "replace card" prompt directly on the error card, that will be helpful.

So change "There was a problem displaying this card." by adding a "replace it" link or button at the end? This is more discoverable.

For context, we figured we'd prefer to keep the action as is. People might prefer to fix the issue instead of replacing the card

@kulyk kulyk merged commit d478a78 into master Dec 14, 2023
106 checks passed
@kulyk kulyk deleted the 36497-replace-dashcard-card branch December 14, 2023 14:34
Copy link

@kulyk Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone?

@kulyk kulyk added this to the 0.49 milestone Dec 14, 2023
EmmadUsmani added a commit that referenced this pull request Feb 2, 2024
Part of #36497

### Description

In #36744 we tracked dashcard replacement with a new event name, but did not add this event name to the dashboard snowplow schema.

In this PR we add the name to the schema, and update an e2e test to ensure the event is being tracked.

### How to verify

Follow this [guide](https://www.notion.so/metabase/Snowplow-integration-5da1f874beda4153b4fccfa6c1e77caa) to run snowplow, then try replacing a dashcard locally, you should see the log in the console.

### Demo

https://github.com/metabase/metabase/assets/37751258/e8566f09-b9b8-47de-b215-fe0e25c7d920

### Checklist

- [x] Tests have been added/updated to cover changes in this PR
npfitz pushed a commit that referenced this pull request Feb 5, 2024
Part of #36497

### Description

In #36744 we tracked dashcard replacement with a new event name, but did not add this event name to the dashboard snowplow schema.

In this PR we add the name to the schema, and update an e2e test to ensure the event is being tracked.

### How to verify

Follow this [guide](https://www.notion.so/metabase/Snowplow-integration-5da1f874beda4153b4fccfa6c1e77caa) to run snowplow, then try replacing a dashcard locally, you should see the log in the console.

### Demo

https://github.com/metabase/metabase/assets/37751258/e8566f09-b9b8-47de-b215-fe0e25c7d920

### Checklist

- [x] Tests have been added/updated to cover changes in this PR
@kulyk kulyk mentioned this pull request Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport Do not backport this PR to any branch .Team/DashViz Dashboard and Viz team
Projects
None yet
8 participants