justinpark commented on code in PR #31421:
URL: https://github.com/apache/superset/pull/31421#discussion_r1926127434
##########
superset-frontend/src/pages/SavedQueryList/index.tsx:
##########
@@ -233,16 +232,31 @@ function SavedQueryList({
};
const copyQueryLink = useCallback(
- (id: number) => {
- copyTextToClipboard(() =>
- Promise.resolve(`${window.location.origin}/sqllab?savedQueryId=${id}`),
- )
- .then(() => {
- addSuccessToast(t('Link Copied!'));
- })
- .catch(() => {
- addDangerToast(t('Sorry, your browser does not support copying.'));
+ async (savedQuery: SavedQueryObject) => {
+ try {
+ const payload = {
+ dbId: savedQuery.db_id,
+ name: savedQuery.label,
+ schema: savedQuery.schema,
+ sql: savedQuery.sql,
+ autorun: false,
+ templateParams: null,
+ };
+
+ const response = await SupersetClient.post({
+ endpoint: '/api/v1/sqllab/permalink',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify(payload),
});
+
+ const { key } = response.json;
+ const permalink = `${window.location.origin}/sqllab/p/${key}`;
Review Comment:
+1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]