mirror of
https://github.com/apache/superset.git
synced 2026-04-29 13:04:22 +00:00
Compare commits
2 Commits
upgrade-sq
...
v2021.36.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d35a91642 | ||
|
|
cc821bb747 |
@@ -613,7 +613,7 @@ describe('async actions', () => {
|
||||
|
||||
describe('queryEditorSetSql', () => {
|
||||
describe('with backend persistence flag on', () => {
|
||||
it('does not update the tab state in the backend', () => {
|
||||
it('updates the tab state in the backend', () => {
|
||||
expect.assertions(2);
|
||||
|
||||
const sql = 'SELECT * ';
|
||||
@@ -629,7 +629,7 @@ describe('async actions', () => {
|
||||
});
|
||||
});
|
||||
describe('with backend persistence flag off', () => {
|
||||
it('updates the tab state in the backend', () => {
|
||||
it('does not update the tab state in the backend', () => {
|
||||
const backendPersistenceOffMock = jest
|
||||
.spyOn(featureFlags, 'isFeatureEnabled')
|
||||
.mockImplementation(
|
||||
|
||||
@@ -949,6 +949,11 @@ export function queryEditorSetQueryLimit(queryEditor, queryLimit) {
|
||||
|
||||
export function queryEditorSetTemplateParams(queryEditor, templateParams) {
|
||||
return function (dispatch) {
|
||||
dispatch({
|
||||
type: QUERY_EDITOR_SET_TEMPLATE_PARAMS,
|
||||
queryEditor,
|
||||
templateParams,
|
||||
});
|
||||
const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE)
|
||||
? SupersetClient.put({
|
||||
endpoint: encodeURI(`/tabstateview/${queryEditor.id}`),
|
||||
@@ -956,24 +961,16 @@ export function queryEditorSetTemplateParams(queryEditor, templateParams) {
|
||||
})
|
||||
: Promise.resolve();
|
||||
|
||||
return sync
|
||||
.then(() =>
|
||||
dispatch({
|
||||
type: QUERY_EDITOR_SET_TEMPLATE_PARAMS,
|
||||
queryEditor,
|
||||
templateParams,
|
||||
}),
|
||||
)
|
||||
.catch(() =>
|
||||
dispatch(
|
||||
addDangerToast(
|
||||
t(
|
||||
'An error occurred while setting the tab template parameters. ' +
|
||||
'Please contact your administrator.',
|
||||
),
|
||||
return sync.catch(() =>
|
||||
dispatch(
|
||||
addDangerToast(
|
||||
t(
|
||||
'An error occurred while setting the tab template parameters. ' +
|
||||
'Please contact your administrator.',
|
||||
),
|
||||
),
|
||||
);
|
||||
),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -25,3 +25,9 @@ export interface DatasourcePanelDndItem {
|
||||
value: DndItemValue;
|
||||
type: DndItemType;
|
||||
}
|
||||
|
||||
export function isDatasourcePanelDndItem(
|
||||
item: any,
|
||||
): item is DatasourcePanelDndItem {
|
||||
return item?.value && item?.type;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,10 @@ import { usePrevious } from 'src/common/hooks/usePrevious';
|
||||
import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetric';
|
||||
import AdhocMetricPopoverTrigger from 'src/explore/components/controls/MetricControl/AdhocMetricPopoverTrigger';
|
||||
import MetricDefinitionValue from 'src/explore/components/controls/MetricControl/MetricDefinitionValue';
|
||||
import { DatasourcePanelDndItem } from 'src/explore/components/DatasourcePanel/types';
|
||||
import {
|
||||
DatasourcePanelDndItem,
|
||||
isDatasourcePanelDndItem,
|
||||
} from 'src/explore/components/DatasourcePanel/types';
|
||||
import { DndItemType } from 'src/explore/components/DndItemType';
|
||||
import DndSelectLabel from 'src/explore/components/controls/DndColumnSelectControl/DndSelectLabel';
|
||||
import { savedMetricType } from 'src/explore/components/controls/MetricControl/types';
|
||||
@@ -143,9 +146,9 @@ export const DndMetricSelect = (props: any) => {
|
||||
const [value, setValue] = useState<ValueType[]>(
|
||||
coerceAdhocMetrics(props.value),
|
||||
);
|
||||
const [droppedItem, setDroppedItem] = useState<DatasourcePanelDndItem | null>(
|
||||
null,
|
||||
);
|
||||
const [droppedItem, setDroppedItem] = useState<
|
||||
DatasourcePanelDndItem | typeof EMPTY_OBJECT
|
||||
>({});
|
||||
const [newMetricPopoverVisible, setNewMetricPopoverVisible] = useState(false);
|
||||
const prevColumns = usePrevious(columns);
|
||||
const prevSavedMetrics = usePrevious(savedMetrics);
|
||||
@@ -323,13 +326,16 @@ export const DndMetricSelect = (props: any) => {
|
||||
);
|
||||
|
||||
const handleClickGhostButton = useCallback(() => {
|
||||
setDroppedItem(null);
|
||||
setDroppedItem({});
|
||||
togglePopover(true);
|
||||
}, [togglePopover]);
|
||||
|
||||
const adhocMetric = useMemo(() => {
|
||||
if (droppedItem?.type === DndItemType.Column) {
|
||||
const itemValue = droppedItem?.value as ColumnMeta;
|
||||
if (
|
||||
isDatasourcePanelDndItem(droppedItem) &&
|
||||
droppedItem.type === DndItemType.Column
|
||||
) {
|
||||
const itemValue = droppedItem.value as ColumnMeta;
|
||||
const config: Partial<AdhocMetric> = {
|
||||
column: { column_name: itemValue?.column_name },
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user