Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions superset-frontend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand All @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const useDownloadScreenshot = (
anchor,
activeTabs,
dataMask,
urlParams: getDashboardUrlParams(['edit']),
urlParams: getDashboardUrlParams(),
},
})
.then(({ json }) => {
Expand Down
52 changes: 51 additions & 1 deletion superset-frontend/src/utils/urlUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
});
Loading