mirror of
https://github.com/apache/superset.git
synced 2026-04-23 18:14:56 +00:00
Add feature flags to control query sharing, KV exposure (#9120)
* Add feature flags to control query sharing, KV exposure * Add tests, fix bug * Skip test for kv endpoints when they are disabled * ESLint fixes * Remove unnecessary binds * Fix eslint errors * Add note to UPDATING.md RE: new feature flag options * Use expanded version of RBAC * Enable KV_STORE and SHARE_QUERIES_VIA_KV_STORE feature flags in the test environment * Fix black
This commit is contained in:
@@ -20,6 +20,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Popover, OverlayTrigger } from 'react-bootstrap';
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
|
||||
|
||||
import Button from '../../components/Button';
|
||||
import CopyToClipboard from '../../components/CopyToClipboard';
|
||||
@@ -34,6 +35,7 @@ const propTypes = {
|
||||
schema: PropTypes.string,
|
||||
autorun: PropTypes.bool,
|
||||
sql: PropTypes.string,
|
||||
remoteId: PropTypes.number,
|
||||
}).isRequired,
|
||||
addDangerToast: PropTypes.func.isRequired,
|
||||
};
|
||||
@@ -48,6 +50,14 @@ class ShareSqlLabQuery extends React.Component {
|
||||
}
|
||||
|
||||
getCopyUrl() {
|
||||
if (isFeatureEnabled(FeatureFlag.SHARE_QUERIES_VIA_KV_STORE)) {
|
||||
return this.getCopyUrlForKvStore();
|
||||
}
|
||||
|
||||
return this.getCopyUrlForSavedQuery();
|
||||
}
|
||||
|
||||
getCopyUrlForKvStore() {
|
||||
const { dbId, title, schema, autorun, sql } = this.props.queryEditor;
|
||||
const sharedQuery = { dbId, title, schema, autorun, sql };
|
||||
|
||||
@@ -63,6 +73,21 @@ class ShareSqlLabQuery extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
getCopyUrlForSavedQuery() {
|
||||
let savedQueryToastContent;
|
||||
|
||||
if (this.props.queryEditor.remoteId) {
|
||||
savedQueryToastContent =
|
||||
window.location.origin +
|
||||
window.location.pathname +
|
||||
`?savedQueryId=${this.props.queryEditor.remoteId}`;
|
||||
this.setState({ shortUrl: savedQueryToastContent });
|
||||
} else {
|
||||
savedQueryToastContent = t('Please save the query to enable sharing');
|
||||
this.setState({ shortUrl: savedQueryToastContent });
|
||||
}
|
||||
}
|
||||
|
||||
renderPopover() {
|
||||
return (
|
||||
<Popover id="sqllab-shareurl-popover">
|
||||
|
||||
Reference in New Issue
Block a user