You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2025/08/04 14:02:43 UTC
(superset) 03/07: chore: Remove deprecated Menu.Item for DatasourceControl
This is an automated email from the ASF dual-hosted git repository.
diegopucci pushed a commit to branch geido/fix/console-cleanup
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 0dd14831f73d3e074cffb359f754dd9d1d2e5296
Author: Diego Pucci <di...@gmail.com>
AuthorDate: Fri Aug 1 18:18:42 2025 +0300
chore: Remove deprecated Menu.Item for DatasourceControl
---
.../controls/DatasourceControl/index.jsx | 129 ++++++++++++---------
1 file changed, 75 insertions(+), 54 deletions(-)
diff --git a/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx b/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx
index 0a5d5b8488..0675a94870 100644
--- a/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx
+++ b/superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx
@@ -317,47 +317,56 @@ class DatasourceControl extends PureComponent {
sql: datasource.sql,
};
- const defaultDatasourceMenu = (
- <Menu onClick={this.handleMenuItemClick}>
- {this.props.isEditable && !isMissingDatasource && (
- <Menu.Item
- key={EDIT_DATASET}
- data-test="edit-dataset"
- disabled={!allowEdit}
- >
- {!allowEdit ? (
- <Tooltip
- title={t(
- 'You must be a dataset owner in order to edit. Please reach out to a dataset owner to request modifications or edit access.',
- )}
- >
- {editText}
- </Tooltip>
- ) : (
- editText
+ const defaultDatasourceMenuItems = [];
+ if (this.props.isEditable && !isMissingDatasource) {
+ defaultDatasourceMenuItems.push({
+ key: EDIT_DATASET,
+ label: !allowEdit ? (
+ <Tooltip
+ title={t(
+ 'You must be a dataset owner in order to edit. Please reach out to a dataset owner to request modifications or edit access.',
)}
- </Menu.Item>
- )}
- <Menu.Item key={CHANGE_DATASET}>{t('Swap dataset')}</Menu.Item>
- {!isMissingDatasource && canAccessSqlLab && (
- <Menu.Item key={VIEW_IN_SQL_LAB}>
- <Link
- to={{
- pathname: '/sqllab',
- state: { requestedQuery },
- }}
- onClick={preventRouterLinkWhileMetaClicked}
- >
- {t('View in SQL Lab')}
- </Link>
- </Menu.Item>
- )}
- </Menu>
+ >
+ {editText}
+ </Tooltip>
+ ) : (
+ editText
+ ),
+ disabled: !allowEdit,
+ ...{ 'data-test': 'edit-dataset' }, // TypeScript hack for non-standard props
+ });
+ }
+
+ defaultDatasourceMenuItems.push({
+ key: CHANGE_DATASET,
+ label: t('Swap dataset'),
+ });
+
+ if (!isMissingDatasource && canAccessSqlLab) {
+ defaultDatasourceMenuItems.push({
+ key: VIEW_IN_SQL_LAB,
+ label: (
+ <Link
+ to={{
+ pathname: '/sqllab',
+ state: { requestedQuery },
+ }}
+ onClick={preventRouterLinkWhileMetaClicked}
+ >
+ {t('View in SQL Lab')}
+ </Link>
+ ),
+ });
+ }
+
+ const defaultDatasourceMenu = (
+ <Menu onClick={this.handleMenuItemClick} items={defaultDatasourceMenuItems} />
);
- const queryDatasourceMenu = (
- <Menu onClick={this.handleMenuItemClick}>
- <Menu.Item key={QUERY_PREVIEW}>
+ const queryDatasourceMenuItems = [
+ {
+ key: QUERY_PREVIEW,
+ label: (
<ModalTrigger
triggerNode={
<div data-test="view-query-menu-item">{t('Query preview')}</div>
@@ -378,22 +387,34 @@ class DatasourceControl extends PureComponent {
resizable={false}
responsive
/>
- </Menu.Item>
- {canAccessSqlLab && (
- <Menu.Item key={VIEW_IN_SQL_LAB}>
- <Link
- to={{
- pathname: '/sqllab',
- state: { requestedQuery },
- }}
- onClick={preventRouterLinkWhileMetaClicked}
- >
- {t('View in SQL Lab')}
- </Link>
- </Menu.Item>
- )}
- <Menu.Item key={SAVE_AS_DATASET}>{t('Save as dataset')}</Menu.Item>
- </Menu>
+ ),
+ },
+ ];
+
+ if (canAccessSqlLab) {
+ queryDatasourceMenuItems.push({
+ key: VIEW_IN_SQL_LAB,
+ label: (
+ <Link
+ to={{
+ pathname: '/sqllab',
+ state: { requestedQuery },
+ }}
+ onClick={preventRouterLinkWhileMetaClicked}
+ >
+ {t('View in SQL Lab')}
+ </Link>
+ ),
+ });
+ }
+
+ queryDatasourceMenuItems.push({
+ key: SAVE_AS_DATASET,
+ label: t('Save as dataset'),
+ });
+
+ const queryDatasourceMenu = (
+ <Menu onClick={this.handleMenuItemClick} items={queryDatasourceMenuItems} />
);
const { health_check_message: healthCheckMessage } = datasource;