mirror of
https://github.com/apache/superset.git
synced 2026-05-12 11:25:56 +00:00
fix: Redirect on 401 (#17597)
* Redirect on 401 * Bump FAB * Format * Update Cypress save test * Revert Cypress change * Bump FAB 3.4.1rc2 * Update test * Update return statement * Update api test * Update datasets api test * Update datasets api 401s to 403s * Add typeguard * Use Promise.resolve * Update callApiAndParseWithhTimeout test * Disable parseResponse test * Try catch * Handle npm 8 issues
This commit is contained in:
@@ -21,11 +21,8 @@ import React from 'react';
|
||||
import { Slice } from 'src/types/Chart';
|
||||
import { render, screen } from 'spec/helpers/testing-library';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import fetchMock from 'fetch-mock';
|
||||
import ExploreHeader from '.';
|
||||
|
||||
fetchMock.get('http://localhost/api/v1/chart/318', {});
|
||||
|
||||
const createProps = () => ({
|
||||
chart: {
|
||||
latestQueryFormData: {
|
||||
|
||||
@@ -143,26 +143,32 @@ export class ExploreChartHeader extends React.PureComponent {
|
||||
|
||||
async fetchChartDashboardData() {
|
||||
const { dashboardId, slice } = this.props;
|
||||
const response = await SupersetClient.get({
|
||||
await SupersetClient.get({
|
||||
endpoint: `/api/v1/chart/${slice.slice_id}`,
|
||||
});
|
||||
const chart = response.json.result;
|
||||
const dashboards = chart.dashboards || [];
|
||||
const dashboard =
|
||||
dashboardId &&
|
||||
dashboards.length &&
|
||||
dashboards.find(d => d.id === dashboardId);
|
||||
})
|
||||
.then(res => {
|
||||
const response = res?.json?.result;
|
||||
if (response && response.dashboards && response.dashboards.length) {
|
||||
const { dashboards } = response;
|
||||
const dashboard =
|
||||
dashboardId &&
|
||||
dashboards.length &&
|
||||
dashboards.find(d => d.id === dashboardId);
|
||||
|
||||
if (dashboard && dashboard.json_metadata) {
|
||||
// setting the chart to use the dashboard custom label colors if any
|
||||
const labelColors =
|
||||
JSON.parse(dashboard.json_metadata).label_colors || {};
|
||||
const categoricalNamespace = CategoricalColorNamespace.getNamespace();
|
||||
if (dashboard && dashboard.json_metadata) {
|
||||
// setting the chart to use the dashboard custom label colors if any
|
||||
const labelColors =
|
||||
JSON.parse(dashboard.json_metadata).label_colors || {};
|
||||
const categoricalNamespace =
|
||||
CategoricalColorNamespace.getNamespace();
|
||||
|
||||
Object.keys(labelColors).forEach(label => {
|
||||
categoricalNamespace.setColor(label, labelColors[label]);
|
||||
});
|
||||
}
|
||||
Object.keys(labelColors).forEach(label => {
|
||||
categoricalNamespace.setColor(label, labelColors[label]);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
getSliceName() {
|
||||
|
||||
Reference in New Issue
Block a user