Skip to content

Commit

Permalink
save for now
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Feb 25, 2022
1 parent 6ba541a commit 843f1bc
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 35 deletions.
5 changes: 2 additions & 3 deletions superset-frontend/src/chart/Chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Chart extends React.PureComponent {
// Load saved chart with a GET request
this.props.actions.getSavedChart(
this.props.formData,
this.props.force,
this.props.force || getUrlParam(URL_PARAMS.force), // allow override via url params force=true
this.props.timeout,
this.props.chartId,
this.props.dashboardId,
Expand All @@ -161,10 +161,9 @@ class Chart extends React.PureComponent {
// Create chart with POST request
console.log('starting post call for a given chart');
console.log(getUrlParam(URL_PARAMS.force));
// console.log(force);
this.props.actions.postChartFormData(
this.props.formData,
this.props.force,
this.props.force || getUrlParam(URL_PARAMS.force), // allow override via url params force=true
this.props.timeout,
this.props.chartId,
this.props.dashboardId,
Expand Down
18 changes: 7 additions & 11 deletions superset-frontend/src/chart/chartAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export async function getChartDataRequest({
setDataMask = () => {},
resultFormat = 'json',
resultType = 'full',
force = true,
force = false,
method = 'POST',
requestParams = {},
ownState = {},
Expand All @@ -233,10 +233,7 @@ export async function getChartDataRequest({
querySettings,
);
}
console.log('making v1ChartDataRequest');
console.log('force', force);
return v1ChartDataRequest(
// this makes the call for all charts
formData,
resultFormat,
resultType,
Expand All @@ -247,14 +244,14 @@ export async function getChartDataRequest({
);
}

export function runAnnotationQuery(
export function runAnnotationQuery({
annotation,
timeout = 60,
formData = null,
key,
isDashboardRequest = false,
force = false,
) {
}) {
return function (dispatch, getState) {
const sliceKey = key || Object.keys(getState().charts)[0];
// make a copy of formData, not modifying original formData
Expand Down Expand Up @@ -381,7 +378,6 @@ export function exploreJSON(
const setDataMask = dataMask => {
dispatch(updateDataMask(formData.slice_id, dataMask));
};
console.log('making call for dashboard data');
const chartDataRequest = getChartDataRequest({
setDataMask,
formData,
Expand Down Expand Up @@ -486,16 +482,16 @@ export function exploreJSON(
chartDataRequestCaught,
dispatch(triggerQuery(false, key)),
dispatch(updateQueryFormData(formData, key)),
...annotationLayers.map(x =>
...annotationLayers.map(annotation =>
dispatch(
runAnnotationQuery(
x,
runAnnotationQuery({
annotation,
timeout,
formData,
key,
isDashboardRequest,
force,
),
}),
),
),
]);
Expand Down
1 change: 0 additions & 1 deletion superset-frontend/src/dashboard/actions/hydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ export const hydrateDashboard =

const { roles } = user;
const canEdit = canUserEditDashboard(dashboardData, user);
console.log(chartQueries);

return dispatch({
type: HYDRATE_DASHBOARD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const FilterValue: React.FC<FilterProps> = ({
setIsRefreshing(true);
getChartDataRequest({
formData: newFormData,
force: true,
force: false,
requestParams: { dashboardId: 0 },
ownState: filterOwnState,
})
Expand Down
21 changes: 7 additions & 14 deletions superset-frontend/src/dashboard/containers/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
* under the License.
*/
import React, { FC, useRef, useEffect, useState } from 'react';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { FeatureFlag, isFeatureEnabled, t, useTheme } from '@superset-ui/core';
import { useDispatch, useSelector } from 'react-redux';
import { Global } from '@emotion/react';
import { useParams } from 'react-router-dom';
import { useToasts } from 'src/components/MessageToasts/withToasts';
import Loading from 'src/components/Loading';
Expand Down Expand Up @@ -49,6 +50,7 @@ import { getUrlParam } from 'src/utils/urlUtils';
import { canUserEditDashboard } from 'src/dashboard/util/findPermission';
import { getFilterSets } from '../actions/nativeFilters';
import { getFilterValue } from '../components/nativeFilters/FilterBar/keyValue';
import { filterCardPopoverStyle } from '../styles';

export const MigrationContext = React.createContext(
FILTER_BOX_MIGRATION_STATES.NOOP,
Expand All @@ -68,26 +70,16 @@ const originalDocumentTitle = document.title;

const DashboardPage: FC = () => {
const dispatch = useDispatch();
const theme = useTheme();
const user = useSelector<any, UserWithPermissionsAndRoles>(
state => state.user,
);
const { addDangerToast } = useToasts();
const { idOrSlug } = useParams<{ idOrSlug: string }>();

// 1. Pull url params force from initial request
const params = new URLSearchParams(window.location.search);
console.log('force:', params.get('force'));

// 2. if force=true pass that param into useDashboardCharts
// 3. Read in params from force into dashboard/:id/charts
// 4. Append the force=true to each form_data / url depending on how it needs to be triggered

const { result: dashboard, error: dashboardApiError } =
useDashboard(idOrSlug);
const { result: charts, error: chartsApiError } = useDashboardCharts(
idOrSlug,
true,
);
const { result: charts, error: chartsApiError } =
useDashboardCharts(idOrSlug);
const { result: datasets, error: datasetsApiError } =
useDashboardDatasets(idOrSlug);
const isDashboardHydrated = useRef(false);
Expand Down Expand Up @@ -237,6 +229,7 @@ const DashboardPage: FC = () => {

return (
<>
<Global styles={filterCardPopoverStyle(theme)} />
<FilterBoxMigrationModal
show={filterboxMigrationState === FILTER_BOX_MIGRATION_STATES.UNDECIDED}
hideFooter={!isMigrationEnabled}
Expand Down
6 changes: 2 additions & 4 deletions superset-frontend/src/hooks/apiResources/dashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ export const useDashboard = (idOrSlug: string | number) =>
);

// gets the chart definitions for a dashboard
export const useDashboardCharts = (idOrSlug: string | number, force = false) =>
useApiV1Resource<Chart[]>(
`/api/v1/dashboard/${idOrSlug}/charts?force=${force}`,
);
export const useDashboardCharts = (idOrSlug: string | number) =>
useApiV1Resource<Chart[]>(`/api/v1/dashboard/${idOrSlug}/charts`);

// gets the datasets for a dashboard
// important: this endpoint only returns the fields in the dataset
Expand Down
2 changes: 1 addition & 1 deletion superset/dashboards/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ def import_(self) -> Response:
`{"databases/MyDatabase.yaml": "my_password"}`.
type: string
overwrite:
description: overwrite existing databases?
description: overwrite existing dashboards?
type: boolean
responses:
200:
Expand Down

0 comments on commit 843f1bc

Please sign in to comment.