Skip to content

feat(dashboards): Add to dashboard option on dashboard widget dropdown #93922

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

Merged

Conversation

nikkikapadia
Copy link
Member

@nikkikapadia nikkikapadia commented Jun 19, 2025

Closes DAIN-385

Added the add to dashboard option to dashboard widgets to allow for users to add other widgets to their dashboards. Also had to make a small styling change to the big number widget so that the number shows up in the modal widget.

Screen.Recording.2025-06-20.at.11.05.04.AM.mov

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 19, 2025
Copy link

codecov bot commented Jun 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #93922   +/-   ##
=======================================
  Coverage   88.02%   88.02%           
=======================================
  Files       10331    10331           
  Lines      596378   596374    -4     
  Branches    23160    23159    -1     
=======================================
- Hits       524976   524973    -3     
+ Misses      70946    70945    -1     
  Partials      456      456           

@nikkikapadia nikkikapadia marked this pull request as ready for review June 20, 2025 15:19
@nikkikapadia nikkikapadia requested a review from a team as a code owner June 20, 2025 15:19
return (
<GrowingWrapper>
<GrowingWrapper style={{minHeight}}>
Copy link
Member Author

Choose a reason for hiding this comment

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

when this doesn't have a min height, the number from the big number widget is reduced to a height of 0px. Let me know if there's a cleaner way to do this

Copy link
Contributor

Choose a reason for hiding this comment

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

Haven't tested this (and maybe you have), but what about adding the style to GrowingWrapper directly? ex. min-height: fit-content; or something

Copy link
Member Author

Choose a reason for hiding this comment

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

ya that's what I was thinking initially too but that unfortunately doesn't work like we think it would 😭

image

Copy link
Contributor

Choose a reason for hiding this comment

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

NOOOO 😭

Copy link
Member

Choose a reason for hiding this comment

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

👀 HMM. BigNumberWidgetVisualization by design obeys the height of the parent element, is it possible to set the height there, rather than adding this min-height prop? It's good to keep the prop list as small as possible!

Copy link
Member

@gggritso gggritso left a comment

Choose a reason for hiding this comment

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

Makes sense, just a few questions about the implementation!

query:
source && source === DashboardWidgetSource.DASHBOARDS
? {
...convertWidgetToBuilderStateParams(widget),
Copy link
Member

Choose a reason for hiding this comment

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

🤔 is it possible to lift this logic up into the dashboard widget so the modal is opened with the params all ready to go? This source prop is a bit of an anti-pattern IMO, since now the modal would have to know about every possible source, rather than the sources knowing how to make queries for the modal (which would be better)

return (
<GrowingWrapper>
<GrowingWrapper style={{minHeight}}>
Copy link
Member

Choose a reason for hiding this comment

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

👀 HMM. BigNumberWidgetVisualization by design obeys the height of the parent element, is it possible to set the height there, rather than adding this min-height prop? It's good to keep the prop list as small as possible!

Copy link
Member

@gggritso gggritso left a comment

Choose a reason for hiding this comment

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

You can disregard my complaint about widgetAsQueryParams if you want (although it is confusing IMO) but the thing about widget previous height is worth it!

@@ -78,7 +79,7 @@ export type AddToDashboardModalProps = {
router: InjectedRouter;
selection: PageFilters;
widget: Widget;
widgetAsQueryParams: WidgetAsQueryParams;
widgetAsQueryParams: WidgetAsQueryParams | WidgetBuilderStateQueryParams;
Copy link
Member

Choose a reason for hiding this comment

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

😭 the more I read about this the more confused I get! If widgetAsQueryParams is made from a widget, can't the modal just run convertWidgetToBuilderStateParams inside itself? Why pass both? This union of two objects that have nothing in common is haunted!

Copy link
Member Author

Choose a reason for hiding this comment

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

ah i see what you mean, I assume we probably don't need both. I know the WidgetAsQueryParams type carries over some page level context so I can account for that when I change this. Sorry for the confusion 😭 lolll

Comment on lines 331 to 333
<WidgetCardWrapper
needsDefaultHeight={widget.displayType === 'big_number'}
>
Copy link
Member

Choose a reason for hiding this comment

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

Okay, I accidentally sent you on a wild goose chase. My suggestion:

  1. Remove this conditional, always apply the manual height
  2. Rename BIG_NUMBER_WIDGET_HEIGHT to WIDGET_PREVIEW_HEIGHT
  3. Set shouldResize={true} on the widget
  4. Set WIDGET_PREVIEW_HEIGHT to "200px"

Less code, less confusing, and the previews are nice and consistent, IMO!

Copy link
Member

@gggritso gggritso left a comment

Choose a reason for hiding this comment

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

🧹

@nikkikapadia nikkikapadia merged commit 57f0354 into master Jun 24, 2025
46 checks passed
@nikkikapadia nikkikapadia deleted the nikki/feat/add-to-dashboard-from-dashboard-widget branch June 24, 2025 15:40
@github-actions github-actions bot locked and limited conversation to collaborators Jul 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants