mirror of
https://github.com/apache/superset.git
synced 2026-04-26 03:24:53 +00:00
chore: deprecate /superset/slice_json/<int:slice_id> and /superset/annotation_json/<int:layer_id> (#22496)
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { getAnnotationJsonUrl } from '.';
|
||||
|
||||
let windowLocation: any;
|
||||
|
||||
beforeAll(() => {
|
||||
windowLocation = window.location;
|
||||
// @ts-expect-error
|
||||
delete window.location;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
window.location = {
|
||||
search: '?testA=0&testB=1',
|
||||
} as any;
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
window.location = windowLocation;
|
||||
});
|
||||
|
||||
test('get correct annotation when isNative:true', () => {
|
||||
const response = getAnnotationJsonUrl('slice_id', 'form_data', true);
|
||||
expect(response).toBe(
|
||||
'/superset/annotation_json/slice_id?form_data=%22form_data%22',
|
||||
);
|
||||
});
|
||||
|
||||
test('get correct annotation when isNative:false', () => {
|
||||
const response = getAnnotationJsonUrl('slice_id', { json: 'my-data' }, false);
|
||||
expect(response).toBe(
|
||||
'/superset/slice_json/slice_id?form_data=%7B%22json%22%3A%22my-data%22%7D',
|
||||
);
|
||||
});
|
||||
@@ -61,18 +61,16 @@ export function getHostName(allowDomainSharding = false) {
|
||||
return availableDomains[currentIndex];
|
||||
}
|
||||
|
||||
export function getAnnotationJsonUrl(slice_id, form_data, isNative, force) {
|
||||
export function getAnnotationJsonUrl(slice_id, force) {
|
||||
if (slice_id === null || slice_id === undefined) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const uri = URI(window.location.search);
|
||||
const endpoint = isNative ? 'annotation_json' : 'slice_json';
|
||||
return uri
|
||||
.pathname(`/superset/${endpoint}/${slice_id}`)
|
||||
.pathname('/api/v1/chart/data')
|
||||
.search({
|
||||
form_data: safeStringify(form_data, (key, value) =>
|
||||
value === null ? undefined : value,
|
||||
),
|
||||
form_data: safeStringify({ slice_id }),
|
||||
force,
|
||||
})
|
||||
.toString();
|
||||
|
||||
Reference in New Issue
Block a user