mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
feat: save active tabs in dashboard permalink (#19983)
This commit is contained in:
@@ -50,10 +50,15 @@ export function parseErrorJson(responseObject: JsonObject): ClientErrorObject {
|
||||
}
|
||||
// Marshmallow field validation returns the error mssage in the format
|
||||
// of { message: { field1: [msg1, msg2], field2: [msg], } }
|
||||
if (error.message && typeof error.message === 'object' && !error.error) {
|
||||
error.error =
|
||||
Object.values(error.message as Record<string, string[]>)[0]?.[0] ||
|
||||
t('Invalid input');
|
||||
if (!error.error && error.message) {
|
||||
if (typeof error.message === 'object') {
|
||||
error.error =
|
||||
Object.values(error.message as Record<string, string[]>)[0]?.[0] ||
|
||||
t('Invalid input');
|
||||
}
|
||||
if (typeof error.message === 'string') {
|
||||
error.error = error.message;
|
||||
}
|
||||
}
|
||||
if (error.stack) {
|
||||
error = {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
import { JsonObject, QueryFormData, SupersetClient } from '@superset-ui/core';
|
||||
import rison from 'rison';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { getClientErrorObject } from './getClientErrorObject';
|
||||
import {
|
||||
RESERVED_CHART_URL_PARAMS,
|
||||
RESERVED_DASHBOARD_URL_PARAMS,
|
||||
@@ -96,7 +95,7 @@ function getUrlParams(excludedParams: string[]): URLSearchParams {
|
||||
return urlParams;
|
||||
}
|
||||
|
||||
type UrlParamEntries = [string, string][];
|
||||
export type UrlParamEntries = [string, string][];
|
||||
|
||||
function getUrlParamEntries(urlParams: URLSearchParams): UrlParamEntries {
|
||||
const urlEntries: [string, string][] = [];
|
||||
@@ -134,14 +133,7 @@ function getPermalink(endpoint: string, jsonPayload: JsonObject) {
|
||||
return SupersetClient.post({
|
||||
endpoint,
|
||||
jsonPayload,
|
||||
})
|
||||
.then(result => result.json.url as string)
|
||||
.catch(response =>
|
||||
// @ts-ignore
|
||||
getClientErrorObject(response).then(({ error, statusText }) =>
|
||||
Promise.reject(error || statusText),
|
||||
),
|
||||
);
|
||||
}).then(result => result.json.url as string);
|
||||
}
|
||||
|
||||
export function getChartPermalink(
|
||||
@@ -156,17 +148,30 @@ export function getChartPermalink(
|
||||
|
||||
export function getDashboardPermalink({
|
||||
dashboardId,
|
||||
filterState,
|
||||
hash, // the anchor part of the link which corresponds to the tab/chart id
|
||||
dataMask,
|
||||
activeTabs,
|
||||
anchor, // the anchor part of the link which corresponds to the tab/chart id
|
||||
}: {
|
||||
dashboardId: string | number;
|
||||
filterState: JsonObject;
|
||||
hash?: string;
|
||||
/**
|
||||
* Current applied data masks (for native filters).
|
||||
*/
|
||||
dataMask: JsonObject;
|
||||
/**
|
||||
* Current active tabs in the dashboard.
|
||||
*/
|
||||
activeTabs: string[];
|
||||
/**
|
||||
* The "anchor" component for the permalink. It will be scrolled into view
|
||||
* and highlighted upon page load.
|
||||
*/
|
||||
anchor?: string;
|
||||
}) {
|
||||
// only encode filter box state if non-empty
|
||||
return getPermalink(`/api/v1/dashboard/${dashboardId}/permalink`, {
|
||||
filterState,
|
||||
urlParams: getDashboardUrlParams(),
|
||||
hash,
|
||||
dataMask,
|
||||
activeTabs,
|
||||
anchor,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user