-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
fix(dashboard): copy permalink to dashboard chart #19772
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,14 +18,10 @@ | |||||||||||||
*/ | ||||||||||||||
import React from 'react'; | ||||||||||||||
import copyTextToClipboard from 'src/utils/copy'; | ||||||||||||||
import { t, logging, QueryFormData } from '@superset-ui/core'; | ||||||||||||||
import { t, logging } from '@superset-ui/core'; | ||||||||||||||
import { Menu } from 'src/components/Menu'; | ||||||||||||||
import { | ||||||||||||||
getChartPermalink, | ||||||||||||||
getDashboardPermalink, | ||||||||||||||
getUrlParam, | ||||||||||||||
} from 'src/utils/urlUtils'; | ||||||||||||||
import { RESERVED_DASHBOARD_URL_PARAMS, URL_PARAMS } from 'src/constants'; | ||||||||||||||
import { getDashboardPermalink, getUrlParam } from 'src/utils/urlUtils'; | ||||||||||||||
import { URL_PARAMS } from 'src/constants'; | ||||||||||||||
import { getFilterValue } from 'src/dashboard/components/nativeFilters/FilterBar/keyValue'; | ||||||||||||||
|
||||||||||||||
interface ShareMenuItemProps { | ||||||||||||||
|
@@ -36,8 +32,8 @@ interface ShareMenuItemProps { | |||||||||||||
emailBody: string; | ||||||||||||||
addDangerToast: Function; | ||||||||||||||
addSuccessToast: Function; | ||||||||||||||
dashboardId?: string; | ||||||||||||||
formData?: Pick<QueryFormData, 'slice_id' | 'datasource'>; | ||||||||||||||
dashboardId: string | number; | ||||||||||||||
hash?: string; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
const ShareMenuItems = (props: ShareMenuItemProps) => { | ||||||||||||||
|
@@ -49,23 +45,17 @@ const ShareMenuItems = (props: ShareMenuItemProps) => { | |||||||||||||
addDangerToast, | ||||||||||||||
addSuccessToast, | ||||||||||||||
dashboardId, | ||||||||||||||
formData, | ||||||||||||||
hash, | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to understand what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would have personally gone with
So I went with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's okay to keep it as long as it is pushed downward to when the URL is actually used. Or we can add some comments. |
||||||||||||||
...rest | ||||||||||||||
} = props; | ||||||||||||||
|
||||||||||||||
async function generateUrl() { | ||||||||||||||
// chart | ||||||||||||||
if (formData) { | ||||||||||||||
// we need to remove reserved dashboard url params | ||||||||||||||
return getChartPermalink(formData, RESERVED_DASHBOARD_URL_PARAMS); | ||||||||||||||
} | ||||||||||||||
// dashboard | ||||||||||||||
const nativeFiltersKey = getUrlParam(URL_PARAMS.nativeFiltersKey); | ||||||||||||||
let filterState = {}; | ||||||||||||||
if (nativeFiltersKey && dashboardId) { | ||||||||||||||
filterState = await getFilterValue(dashboardId, nativeFiltersKey); | ||||||||||||||
} | ||||||||||||||
return getDashboardPermalink(String(dashboardId), filterState); | ||||||||||||||
return getDashboardPermalink(String(dashboardId), filterState, hash); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice if we make this more explicit:
Suggested change
|
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
async function onCopyLink() { | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we push down the concept of
hash
to only when we interact with the URL? It took me a while to realize what it really means.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea, I like it 👍