mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
fix(permalink): exclude edit mode from dashboard permalink (#35889)
This commit is contained in:
committed by
GitHub
parent
21d585d586
commit
e2e831e322
@@ -103,6 +103,10 @@ export const URL_PARAMS = {
|
||||
name: 'focused_chart',
|
||||
type: 'number',
|
||||
},
|
||||
editMode: {
|
||||
name: 'edit',
|
||||
type: 'boolean',
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const RESERVED_CHART_URL_PARAMS: string[] = [
|
||||
@@ -117,6 +121,7 @@ export const RESERVED_DASHBOARD_URL_PARAMS: string[] = [
|
||||
URL_PARAMS.nativeFiltersKey.name,
|
||||
URL_PARAMS.permalinkKey.name,
|
||||
URL_PARAMS.preselectFilters.name,
|
||||
URL_PARAMS.editMode.name,
|
||||
];
|
||||
|
||||
export const DEFAULT_COMMON_BOOTSTRAP_DATA: CommonBootstrapData = {
|
||||
|
||||
@@ -153,7 +153,7 @@ export const useDownloadScreenshot = (
|
||||
anchor,
|
||||
activeTabs,
|
||||
dataMask,
|
||||
urlParams: getDashboardUrlParams(['edit']),
|
||||
urlParams: getDashboardUrlParams(),
|
||||
},
|
||||
})
|
||||
.then(({ json }) => {
|
||||
|
||||
@@ -17,7 +17,12 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { isUrlExternal, parseUrl, toQueryString } from './urlUtils';
|
||||
import {
|
||||
isUrlExternal,
|
||||
parseUrl,
|
||||
toQueryString,
|
||||
getDashboardUrlParams,
|
||||
} from './urlUtils';
|
||||
|
||||
test('isUrlExternal', () => {
|
||||
expect(isUrlExternal('http://google.com')).toBeTruthy();
|
||||
@@ -95,3 +100,48 @@ test('toQueryString should handle special characters in keys and values', () =>
|
||||
'?user%40domain=me%26you',
|
||||
);
|
||||
});
|
||||
|
||||
test('getDashboardUrlParams should exclude edit parameter by default', () => {
|
||||
// Mock window.location.search to include edit parameter
|
||||
const originalLocation = window.location;
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: {
|
||||
...originalLocation,
|
||||
search: '?edit=true&standalone=false&expand_filters=1',
|
||||
},
|
||||
writable: true,
|
||||
});
|
||||
|
||||
const urlParams = getDashboardUrlParams(['edit']);
|
||||
const paramNames = urlParams.map(([key]) => key);
|
||||
|
||||
expect(paramNames).not.toContain('edit');
|
||||
expect(paramNames).toContain('standalone');
|
||||
expect(paramNames).toContain('expand_filters');
|
||||
|
||||
// Restore original location
|
||||
window.location = originalLocation;
|
||||
});
|
||||
|
||||
test('getDashboardUrlParams should exclude multiple parameters when provided', () => {
|
||||
// Mock window.location.search with multiple parameters
|
||||
const originalLocation = window.location;
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: {
|
||||
...originalLocation,
|
||||
search: '?edit=true&standalone=false&debug=true&test=value',
|
||||
},
|
||||
writable: true,
|
||||
});
|
||||
|
||||
const urlParams = getDashboardUrlParams(['edit', 'debug']);
|
||||
const paramNames = urlParams.map(([key]) => key);
|
||||
|
||||
expect(paramNames).not.toContain('edit');
|
||||
expect(paramNames).not.toContain('debug');
|
||||
expect(paramNames).toContain('standalone');
|
||||
expect(paramNames).toContain('test');
|
||||
|
||||
// Restore original location
|
||||
window.location = originalLocation;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user