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

feat(embedded-dashboard): Share Switchboard State for Sending Events from Plugins #21319

Merged
merged 10 commits into from
Oct 10, 2022

Conversation

sinhashubham95
Copy link
Contributor

@sinhashubham95 sinhashubham95 commented Sep 3, 2022

SUMMARY

This is a new feature where we can have a shared switchboard singleton instance available. The idea is to be able to send the interactions happening from the embedded dashboard back to the parent loading the iframe. Another thing is to be able to send any details or data like what filters are selected by the user back to the parent loading the iframe. Now for that we need to have a shared state maintained which can be accessed from the plugins which are actually rendered into the dashboards. For this, a singleton instance of Switchboard which can be lazily initialised has been added. Now the embedded dashboard will use this singleton instance instead of initialising its own.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Embedded dashboards should render without any issue like before.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Sep 3, 2022

Codecov Report

Merging #21319 (08d611b) into master (61bd696) will decrease coverage by 0.01%.
The diff coverage is 75.00%.

@@            Coverage Diff             @@
##           master   #21319      +/-   ##
==========================================
- Coverage   66.85%   66.83%   -0.02%     
==========================================
  Files        1798     1798              
  Lines       68827    68844      +17     
  Branches     7333     7339       +6     
==========================================
+ Hits        46011    46014       +3     
- Misses      20931    20951      +20     
+ Partials     1885     1879       -6     
Flag Coverage Δ
javascript 53.18% <75.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/embedded/index.tsx 0.00% <0.00%> (ø)
...ackages/superset-ui-switchboard/src/switchboard.ts 100.00% <100.00%> (ø)
...rd/components/nativeFilters/FilterBar/keyValue.tsx 18.51% <0.00%> (-22.23%) ⬇️
...board/components/nativeFilters/FilterBar/index.tsx 60.43% <0.00%> (-5.76%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@sinhashubham95
Copy link
Contributor Author

@villebro can you please check this feature request?

@sinhashubham95
Copy link
Contributor Author

@stephenLYZ @villebro can you please check?

@sinhashubham95
Copy link
Contributor Author

@stephenLYZ @villebro can you guys please check?

@stephenLYZ
Copy link
Member

@sinhashubham95 Hi. I think it's a nice feature but I don't have enough context for this. So It would be great if @suddjian can help with this.
Besides, if you want to use the singleton pattern, superset-ui-core provides a makeSingleton method to use.

@sinhashubham95
Copy link
Contributor Author

Thanks for your comment @stephenLYZ. I am aware of the makeSingleton function in the superset-ui-core package, but it still does not provide a way to share the instance across packages. That's why I took this route.

@sinhashubham95
Copy link
Contributor Author

@suddjian @villebro can you please check this pr?

@sinhashubham95
Copy link
Contributor Author

@stephenLYZ @villebro @suddjian @rusackas can you guys please help review this pr?

@sinhashubham95
Copy link
Contributor Author

@stephenLYZ @villebro @suddjian @rusackas can you please check this? It has been open since long.

@jayakrishnankk
Copy link
Contributor

@lilykuang

@sinhashubham95
Copy link
Contributor Author

@suddjian @villebro @stephenLYZ @rusackas @lilykuang anyone can help with this pr? This has been open for around a month now.

@villebro
Copy link
Member

villebro commented Oct 1, 2022

@sinhashubham95 sorry for the delayed review. I'm not super familiar with this area, but I will review this in the coming days.

@villebro villebro self-requested a review October 1, 2022 07:40
@sinhashubham95
Copy link
Contributor Author

Thanks @villebro

@sinhashubham95
Copy link
Contributor Author

@villebro any update?

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

LGTM with one nit. I much prefer switching to a singleton, but I would be curious to hear if there were motivations for keeping it multiton. I'll leave this open for a few days and ping some other people, and if there are no objections I'll go ahead with merging.

name: string;
name = '';
Copy link
Member

Choose a reason for hiding this comment

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

Is this change needed? I feel like the previous one was cleaner.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to Ville's comment, I'd prefer string as well ... and rest of the file does it that way too!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is added because there can be instances of logging the error even when Switchboard is not initialised, which will lead to logging undefined if this change is not made. It's just like providing a default initial value.

Copy link
Contributor

Choose a reason for hiding this comment

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

So, it should be name: string = ''; then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's automatically detected in typescript based on the value assigned.

Copy link
Member

Choose a reason for hiding this comment

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

@sinhashubham95 makes sense, I hadn't thought of that 👍

@villebro villebro requested a review from srinify October 7, 2022 13:27
@sinhashubham95
Copy link
Contributor Author

@villebro can we merge this?

@villebro villebro merged commit 20b9dc8 into apache:master Oct 10, 2022
@sinhashubham95 sinhashubham95 deleted the switchboard-singleton branch October 10, 2022 13:28
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants