fix: [search query view] edit link is broken (#10128)

* fix: [search query view] edit link is broken

* eslint + mypy

* rever app.py changes

* addressing comments

* use api/v1/query

* fix test
This commit is contained in:
Maxime Beauchemin
2020-06-25 12:20:10 -07:00
committed by GitHub
parent 0017b61f51
commit 1781ebbaa4
8 changed files with 43 additions and 20 deletions

View File

@@ -101,6 +101,7 @@ export const CtasEnum = {
TABLE: 'TABLE',
VIEW: 'VIEW',
};
const ERR_MSG_CANT_LOAD_QUERY = t("The query couldn't be loaded");
// a map of SavedQuery field names to the different names used client-side,
// because for now making the names consistent is too complicated
@@ -1182,7 +1183,7 @@ export function popStoredQuery(urlId) {
}),
),
)
.catch(() => dispatch(addDangerToast(t("The query couldn't be loaded"))));
.catch(() => dispatch(addDangerToast(ERR_MSG_CANT_LOAD_QUERY)));
};
}
export function popSavedQuery(saveQueryId) {
@@ -1197,7 +1198,26 @@ export function popSavedQuery(saveQueryId) {
};
return dispatch(addQueryEditor(queryEditorProps));
})
.catch(() => dispatch(addDangerToast(t("The query couldn't be loaded"))));
.catch(() => dispatch(addDangerToast(ERR_MSG_CANT_LOAD_QUERY)));
};
}
export function popQuery(queryId) {
return function (dispatch) {
return SupersetClient.get({
endpoint: `/api/v1/query/${queryId}`,
})
.then(({ json }) => {
const queryData = json.result;
const queryEditorProps = {
dbId: queryData.database.id,
schema: queryData.schema,
sql: queryData.sql,
title: `Copy of ${queryData.tab_name}`,
autorun: false,
};
return dispatch(addQueryEditor(queryEditorProps));
})
.catch(() => dispatch(addDangerToast(ERR_MSG_CANT_LOAD_QUERY)));
};
}
export function popDatasourceQuery(datasourceKey, sql) {