Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Apr 19, 2022
1 parent 783d590 commit c4862e2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
8 changes: 4 additions & 4 deletions superset-frontend/src/components/URLShortLinkButton/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ class URLShortLinkButton extends React.Component {
if (this.props.dashboardId) {
getFilterValue(this.props.dashboardId, nativeFiltersKey)
.then(filterState =>
getDashboardPermalink(
String(this.props.dashboardId),
getDashboardPermalink({
dashboardId: this.props.dashboardId,
filterState,
this.props.anchorLinkId,
)
hash: this.props.anchorLinkId,
})
.then(this.onShortUrlSuccess)
.catch(this.props.addDangerToast),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class SliceHeaderControls extends React.PureComponent<
{supersetCanShare && (
<ShareMenuItems
dashboardId={dashboardId}
hash={componentId}
dashboardComponentId={componentId}
copyMenuItemTitle={t('Copy permalink to clipboard')}
emailMenuItemTitle={t('Share permalink by email')}
emailSubject={t('Superset chart')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface ShareMenuItemProps {
addDangerToast: Function;
addSuccessToast: Function;
dashboardId: string | number;
hash?: string;
dashboardComponentId?: string;
}

const ShareMenuItems = (props: ShareMenuItemProps) => {
Expand All @@ -45,7 +45,7 @@ const ShareMenuItems = (props: ShareMenuItemProps) => {
addDangerToast,
addSuccessToast,
dashboardId,
hash,
dashboardComponentId,
...rest
} = props;

Expand All @@ -55,7 +55,11 @@ const ShareMenuItems = (props: ShareMenuItemProps) => {
if (nativeFiltersKey && dashboardId) {
filterState = await getFilterValue(dashboardId, nativeFiltersKey);
}
return getDashboardPermalink(String(dashboardId), filterState, hash);
return getDashboardPermalink({
dashboardId,
filterState,
hash: dashboardComponentId,
});
}

async function onCopyLink() {
Expand Down
14 changes: 9 additions & 5 deletions superset-frontend/src/utils/urlUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,15 @@ export function getChartPermalink(
});
}

export function getDashboardPermalink(
dashboardId: string,
filterState: JsonObject,
hash?: string,
) {
export function getDashboardPermalink({
dashboardId,
filterState,
hash, // the anchor part of the link which corresponds to the tab/chart id
}: {
dashboardId: string | number;
filterState: JsonObject;
hash?: string;
}) {
// only encode filter box state if non-empty
return getPermalink(`/api/v1/dashboard/${dashboardId}/permalink`, {
filterState,
Expand Down

0 comments on commit c4862e2

Please sign in to comment.