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(style): hide dashboard header by url parameter #12918

Merged
merged 22 commits into from
Feb 11, 2021

Conversation

simcha90
Copy link
Contributor

@simcha90 simcha90 commented Feb 3, 2021

SUMMARY

  • Hide dashboard header with name and edit button dependent on url parameter standalone
    e.g. http://localhost:8088/superset/dashboard/11/?standalone=true
    Here supported options (according proposal of @ktmud ):
    a. standalone=true (for backward compatibility) or standalone=1 hide only navbar
    b. standalone=2 hide navbar and title
    c. standalone=false (for backward compatibility) or no param show all
  • Add global constants for url params

Reason for PR: When dashboard is embedded as standalone there is also a use-case to hide the dashboard header

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen.Recording.2021-02-07.at.10.31.56.mov

TEST PLAN

  • Test according 1. flows
  • Test filter bar of native filters working as expected

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@simcha90 simcha90 changed the title feat(native-filters): hide dashboard header bu url parameter feat(style): hide dashboard header bu url parameter Feb 3, 2021
@simcha90 simcha90 changed the title feat(style): hide dashboard header bu url parameter feat(style): hide dashboard header by url parameter Feb 3, 2021
@codecov-io
Copy link

codecov-io commented Feb 3, 2021

Codecov Report

Merging #12918 (7c2bf4d) into master (2ce7982) will increase coverage by 8.83%.
The diff coverage is 65.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12918      +/-   ##
==========================================
+ Coverage   53.06%   61.89%   +8.83%     
==========================================
  Files         489      547      +58     
  Lines       17314    20173    +2859     
  Branches     4482     5282     +800     
==========================================
+ Hits         9187    12486    +3299     
+ Misses       8127     7475     -652     
- Partials        0      212     +212     
Flag Coverage Δ
cypress ?
javascript 61.89% <65.38%> (?)

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

Impacted Files Coverage Δ
...ontend/src/components/ListViewCard/ImageLoader.tsx 86.36% <0.00%> (+11.36%) ⬆️
...set-frontend/src/components/URLShortLinkButton.jsx 100.00% <ø> (ø)
...src/dashboard/components/HeaderActionsDropdown.jsx 54.79% <ø> (-12.78%) ⬇️
...end/src/dashboard/components/StickyVerticalBar.tsx 50.00% <ø> (-50.00%) ⬇️
...rontend/src/explore/components/EmbedCodeButton.jsx 80.76% <ø> (ø)
...ntend/src/explore/components/ExploreChartPanel.jsx 16.17% <ø> (-67.41%) ⬇️
...nd/src/explore/components/ExploreViewContainer.jsx 2.43% <0.00%> (-77.07%) ⬇️
superset-frontend/src/utils/common.js 87.27% <ø> (+68.43%) ⬆️
...perset-frontend/src/views/CRUD/chart/ChartList.tsx 71.65% <ø> (-2.66%) ⬇️
...rontend/src/views/CRUD/dashboard/DashboardCard.tsx 75.67% <ø> (-0.33%) ⬇️
... and 477 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e0681b...7c2bf4d. Read the comment docs.

@junlincc junlincc added viz:dashboard:customize hold:testing! On hold for testing need:design-review Requires input/approval from a Designer labels Feb 3, 2021
@junlincc
Copy link
Member

junlincc commented Feb 3, 2021

thanks for the PR @simcha90 ! User will still be able to add filters after hiding header and edit button since the actions take place in the view mode. is this intentional?
@mihir174 I think this is a valid user need - sharing a dashboard to those who should not be editing it. this solution to me is a bit "hacky" though. any idea?
from Product standpoint, this is a good start, if the code looks good, let's let it in and iterate on the the UX ✅
feature works as expected! ✅
Screen Shot 2021-02-03 at 3 15 48 PM

@junlincc junlincc requested a review from suddjian February 3, 2021 23:13
@junlincc junlincc removed the hold:testing! On hold for testing label Feb 3, 2021
@mihir174
Copy link
Contributor

mihir174 commented Feb 4, 2021

Agreed that this is a bit hacky but it's a good first step. We need to think about security/view permission configurations on embed links.
I like the way Google, for example, deals with link sharing:
Screen Shot 2021-02-03 at 4 31 16 PM

@ktmud
Copy link
Member

ktmud commented Feb 4, 2021

Why not call the parameter standalone, too, just to be consistent with charts?

@simcha90
Copy link
Contributor Author

simcha90 commented Feb 4, 2021

Why not call the parameter standalone, too, just to be consistent with charts?

standalone - hides only top menu bar
hide_dashboard_hide - hides only header with edit button

@ktmud I think it dependent on user needs we need give both options to manage dashboard view

@ktmud
Copy link
Member

ktmud commented Feb 4, 2021

Why would you want to keep Superset navs while hiding dashboard title? Wouldn't users be able to navigate to other Superset pages in the embedded dashboard? I'm finding it hard to imagine a scenario where this would be desired.

@amitmiran137
Copy link
Member

@ktmud I agree that the use-case of standalone=false and hide_dashboard_hide=true does not exist
but there are 2 cases that do exist

  1. standalone=true & hide_dashboard_hide=false
  2. standalone =true & hide_dashboard_hide=true

I can agree that by just setting hide_dashboard_hide=true we can enable standalone but not sure we must enforce it
WDYT?

@ktmud
Copy link
Member

ktmud commented Feb 4, 2021

How about we introduce two "standalone modes"?

  • standelone=true or standlone=1: hide navs only
  • standalone=2: hide navs and title

Let's not give users the choice to hide just the dashboard title. If the request comes back up with a reasonable business need to support it, then we can add it as standlone=3.

@simcha90
Copy link
Contributor Author

simcha90 commented Feb 7, 2021

How about we introduce two "standalone modes"?

  • standelone=true or standlone=1: hide navs only
  • standalone=2: hide navs and title

Let's not give users the choice to hide just the dashboard title. If the request comes back up with a reasonable business need to support it, then we can add it as standlone=3.

done

Copy link
Member

@ktmud ktmud left a comment

Choose a reason for hiding this comment

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

Some code style suggestions, most are non-blocking.

export function getUrlParam(paramName: string, type: 'string'): string;
export function getUrlParam(paramName: string, type: 'number'): number;
export function getUrlParam(paramName: string, type: 'boolean'): boolean;
export function getUrlParam(paramName: string, type: UrlParamType): unknown {
Copy link
Member

Choose a reason for hiding this comment

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

This feel like a useful general util. Maybe move to src/commons/utils/getUrlPram.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved it here: superset-frontend/src/utils/common.ts

superset-frontend/src/dashboard/util/getDashboardUrl.ts Outdated Show resolved Hide resolved
superset-frontend/src/dashboard/util/getDashboardUrl.ts Outdated Show resolved Hide resolved
superset-frontend/src/dashboard/util/getDashboardUrl.ts Outdated Show resolved Hide resolved
superset/utils/core.py Outdated Show resolved Hide resolved
superset/views/core.py Outdated Show resolved Hide resolved
superset/utils/core.py Outdated Show resolved Hide resolved
Copy link
Member

@ktmud ktmud left a comment

Choose a reason for hiding this comment

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

Code LGTM, just one comment about typing.

I'm also seeing this gap for native filters. Is this expected?

image

schema: any;
autorun: any;
sql: any;
}) {
Copy link
Member

Choose a reason for hiding this comment

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

queryEditor: PropTypes.shape({
dbId: PropTypes.number,
title: PropTypes.string,
schema: PropTypes.string,
autorun: PropTypes.bool,
sql: PropTypes.string,
remoteId: PropTypes.number,
}).isRequired,

Maybe make the typing consistent with here?

To avoid having to update typing for all other util functions, you may also create getParamFromQuery as its own file. I think in general we should welcome smaller util files so it's easier to maintain and search (to find a specific util function you can just search by file name instead of search file content).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 did as second proposal, created file for urlUtils

@simcha90
Copy link
Contributor Author

@ktmud 👍 good catch about UI bug, fixed

Copy link
Member

@ktmud ktmud 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 last suggestion.

Thanks for all the iterations!

superset-frontend/src/explore/exploreUtils.js Outdated Show resolved Hide resolved
@ktmud
Copy link
Member

ktmud commented Feb 10, 2021

cc @junlincc if you want to do a final round of QA & product sign-off.

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.

A few non blocking nits

@villebro villebro merged commit c5781cd into apache:master Feb 11, 2021
amitmiran137 pushed a commit to nielsen-oss/superset that referenced this pull request Feb 14, 2021
* feat(native-filters): hide dashboard header bu url parameter

* lint: fix lint

* test: add tests

* test: fix test

* refactor: upgrade standalone param

* fix: pre-commit and extract to method is_standalone_mode

* test: fix tests

* test: fix tests

* fix: fix standalone statement

* refactor: fix CR notes

* chore: pre-commit

* fix: fix sticky tabs + update CR notes

* lint: fix lint

* lint: fix lint

* fix: fix CR notes

* fix: fix CR notes

* lint: fix lint

* refactor: fix cr notes

Co-authored-by: amitmiran137 <[email protected]>
amitmiran137 pushed a commit to nielsen-oss/superset that referenced this pull request Feb 14, 2021
* master: (30 commits)
  refactor(native-filters): decouple params from filter config modal (first phase) (apache#13021)
  fix(native-filters): set currentValue null when empty (apache#13000)
  Custom superset_config.py + secret envs (apache#13096)
  Update http error code from 400 to 403 (apache#13061)
  feat(native-filters): add storybook entry for select filter (apache#13005)
  feat(native-filters): Time native filter (apache#12992)
  Force pod restart on config changes (apache#13056)
  feat(cross-filters): add cross filters (apache#12662)
  fix(explore): Enable selecting an option not included in suggestions (apache#13029)
  Improves RTL configuration (apache#13079)
  Added a note about the ! prefix for breaking changes to CONTRIBUTING.md (apache#13083)
  chore: lock down npm to v6 (apache#13069)
  fix: API tests, make them possible to run independently again (apache#13076)
  fix: add config to disable dataset ownership on the old api (apache#13051)
  add required * indicator to message content/notif method (apache#12931)
  fix: Retroactively add granularity param to charts (apache#12960)
  fix(ci): multiline regex in change detection (apache#13075)
  feat(style): hide dashboard header by url parameter (apache#12918)
  fix(explore): pie chart label bugs (apache#13052)
  fix: Disabled state button transition time (apache#13008)
  ...
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 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 need:design-review Requires input/approval from a Designer size/L 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants