-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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: add permalink to dashboard and explore #19078
Changes from all commits
2693cf4
a6cda78
3223490
f191337
dd81dca
14f7bb0
4e39cc2
e4c808f
6ca1862
3adc45a
ca939cf
1de6b51
f4fbad8
b32a473
d8a4056
6f31dd7
c174e1b
5efd9de
226e5c0
3f5a444
da58de0
85aaa39
32cd5dd
fe2fba0
90381e6
13c6fe5
a317ad0
cc99cba
6ea5462
0373492
5708dba
065c6f4
6b6d0c4
1c20627
392ea9c
9dc2405
50e7d04
89cee4b
6417634
4e9b423
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 |
---|---|---|
|
@@ -21,14 +21,17 @@ import PropTypes from 'prop-types'; | |
import { t } from '@superset-ui/core'; | ||
import Popover from 'src/components/Popover'; | ||
import CopyToClipboard from 'src/components/CopyToClipboard'; | ||
import { getShortUrl } from 'src/utils/urlUtils'; | ||
import { getDashboardPermalink, getUrlParam } from 'src/utils/urlUtils'; | ||
import withToasts from 'src/components/MessageToasts/withToasts'; | ||
import { URL_PARAMS } from 'src/constants'; | ||
import { getFilterValue } from 'src/dashboard/components/nativeFilters/FilterBar/keyValue'; | ||
|
||
const propTypes = { | ||
url: PropTypes.string, | ||
addDangerToast: PropTypes.func.isRequired, | ||
anchorLinkId: PropTypes.string, | ||
dashboardId: PropTypes.number, | ||
emailSubject: PropTypes.string, | ||
emailContent: PropTypes.string, | ||
addDangerToast: PropTypes.func.isRequired, | ||
placement: PropTypes.oneOf(['right', 'left', 'top', 'bottom']), | ||
}; | ||
|
||
|
@@ -50,9 +53,20 @@ class URLShortLinkButton extends React.Component { | |
|
||
getCopyUrl(e) { | ||
e.stopPropagation(); | ||
getShortUrl(this.props.url) | ||
.then(this.onShortUrlSuccess) | ||
.catch(this.props.addDangerToast); | ||
const nativeFiltersKey = getUrlParam(URL_PARAMS.nativeFiltersKey); | ||
if (this.props.dashboardId) { | ||
getFilterValue(this.props.dashboardId, nativeFiltersKey) | ||
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. Maybe We should probably also just pass the full state to By passing full states (an arbitrary JSON object + a base URL template), it also decouples |
||
.then(filterState => | ||
getDashboardPermalink( | ||
String(this.props.dashboardId), | ||
filterState, | ||
this.props.anchorLinkId, | ||
) | ||
.then(this.onShortUrlSuccess) | ||
.catch(this.props.addDangerToast), | ||
) | ||
.catch(this.props.addDangerToast); | ||
} | ||
} | ||
|
||
renderPopover() { | ||
|
@@ -96,7 +110,6 @@ class URLShortLinkButton extends React.Component { | |
} | ||
|
||
URLShortLinkButton.defaultProps = { | ||
url: window.location.href.substring(window.location.origin.length), | ||
placement: 'left', | ||
emailSubject: '', | ||
emailContent: '', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import moment from 'moment'; | |
import { | ||
Behavior, | ||
getChartMetadataRegistry, | ||
QueryFormData, | ||
styled, | ||
t, | ||
} from '@superset-ui/core'; | ||
|
@@ -98,7 +99,7 @@ export interface SliceHeaderControlsProps { | |
isExpanded?: boolean; | ||
updatedDttm: number | null; | ||
isFullSize?: boolean; | ||
formData: { slice_id: number; datasource: string }; | ||
formData: Pick<QueryFormData, 'slice_id' | 'datasource'>; | ||
onExploreChart: () => void; | ||
|
||
forceRefresh: (sliceId: number, dashboardId: number) => void; | ||
|
@@ -309,8 +310,8 @@ class SliceHeaderControls extends React.PureComponent< | |
|
||
{supersetCanShare && ( | ||
<ShareMenuItems | ||
copyMenuItemTitle={t('Copy chart URL')} | ||
emailMenuItemTitle={t('Share chart by email')} | ||
copyMenuItemTitle={t('Copy permalink to clipboard')} | ||
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 not sure if using a word "permalink" brings value to the end user. I feel like it might be confusing, and simply saying "link" or "URL" makes the intention clearer. I'd suggest asking a product manager for an opinion on that. 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. 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. Agreed - I know @michael-s-molina did some investigative work and found many products use the term. Here's GitHub: One other thing we may want to consider is removing "to clipboard", as it's pretty much self evident. |
||
emailMenuItemTitle={t('Share permalink by email')} | ||
emailSubject={t('Superset chart')} | ||
emailBody={t('Check out this chart: ')} | ||
addSuccessToast={addSuccessToast} | ||
|
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.
Since this is just a 100L component, it may be worth just converting this to TypeScript instead of adding new proptypes