refactor(sqllab): migrate share queries via kv by permalink (#29163)

This commit is contained in:
JUST.in DO IT
2025-01-17 16:16:02 -08:00
committed by GitHub
parent b86572b084
commit 2874096e27
27 changed files with 682 additions and 229 deletions

View File

@@ -1167,9 +1167,31 @@ export function persistEditorHeight(queryEditor, northPercent, southPercent) {
};
}
export function popPermalink(key) {
return function (dispatch) {
return SupersetClient.get({ endpoint: `/api/v1/sqllab/permalink/${key}` })
.then(({ json }) =>
dispatch(
addQueryEditor({
name: json.name ? json.name : t('Shared query'),
dbId: json.dbId ? parseInt(json.dbId, 10) : null,
catalog: json.catalog ? json.catalog : null,
schema: json.schema ? json.schema : null,
autorun: json.autorun ? json.autorun : false,
sql: json.sql ? json.sql : 'SELECT ...',
templateParams: json.templateParams,
}),
),
)
.catch(() => dispatch(addDangerToast(ERR_MSG_CANT_LOAD_QUERY)));
};
}
export function popStoredQuery(urlId) {
return function (dispatch) {
return SupersetClient.get({ endpoint: `/kv/${urlId}` })
return SupersetClient.get({
endpoint: `/api/v1/sqllab/permalink/kv:${urlId}`,
})
.then(({ json }) =>
dispatch(
addQueryEditor({