mirror of
https://github.com/apache/superset.git
synced 2026-04-21 00:54:44 +00:00
feat: Added configuration to SQL Lab results "Explore" button (#10164)
* added configuration to virtual table explore button * added description to mixin * fixed unit tests Co-authored-by: Jason Davis <@dropbox.com>
This commit is contained in:
@@ -37,6 +37,7 @@ describe('ResultSet', () => {
|
|||||||
cache: true,
|
cache: true,
|
||||||
query: queries[0],
|
query: queries[0],
|
||||||
height: 0,
|
height: 0,
|
||||||
|
database: { allows_virtual_table_explore: true },
|
||||||
};
|
};
|
||||||
const stoppedQueryProps = { ...mockedProps, query: stoppedQuery };
|
const stoppedQueryProps = { ...mockedProps, query: stoppedQuery };
|
||||||
const runningQueryProps = { ...mockedProps, query: runningQuery };
|
const runningQueryProps = { ...mockedProps, query: runningQuery };
|
||||||
|
|||||||
@@ -145,13 +145,15 @@ export default class ResultSet extends React.PureComponent {
|
|||||||
return (
|
return (
|
||||||
<div className="ResultSetControls">
|
<div className="ResultSetControls">
|
||||||
<div className="ResultSetButtons">
|
<div className="ResultSetButtons">
|
||||||
{this.props.visualize && (
|
{this.props.visualize &&
|
||||||
<ExploreResultsButton
|
this.props.database &&
|
||||||
query={this.props.query}
|
this.props.database.allows_virtual_table_explore && (
|
||||||
database={this.props.database}
|
<ExploreResultsButton
|
||||||
actions={this.props.actions}
|
query={this.props.query}
|
||||||
/>
|
database={this.props.database}
|
||||||
)}
|
actions={this.props.actions}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{this.props.csv && (
|
{this.props.csv && (
|
||||||
<Button
|
<Button
|
||||||
bsSize="small"
|
bsSize="small"
|
||||||
|
|||||||
@@ -189,6 +189,12 @@ class Database(
|
|||||||
and cost_estimate_enabled
|
and cost_estimate_enabled
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def allows_virtual_table_explore(self) -> bool:
|
||||||
|
extra = self.get_extra()
|
||||||
|
|
||||||
|
return bool(extra.get("allows_virtual_table_explore", True))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self) -> Dict[str, Any]:
|
def data(self) -> Dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
@@ -198,6 +204,7 @@ class Database(
|
|||||||
"allow_multi_schema_metadata_fetch": self.allow_multi_schema_metadata_fetch,
|
"allow_multi_schema_metadata_fetch": self.allow_multi_schema_metadata_fetch,
|
||||||
"allows_subquery": self.allows_subquery,
|
"allows_subquery": self.allows_subquery,
|
||||||
"allows_cost_estimate": self.allows_cost_estimate,
|
"allows_cost_estimate": self.allows_cost_estimate,
|
||||||
|
"allows_virtual_table_explore": self.allows_virtual_table_explore,
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ class DatabaseRestApi(DatabaseMixin, BaseSupersetModelRestApi):
|
|||||||
"allow_csv_upload",
|
"allow_csv_upload",
|
||||||
"allows_subquery",
|
"allows_subquery",
|
||||||
"allows_cost_estimate",
|
"allows_cost_estimate",
|
||||||
|
"allows_virtual_table_explore",
|
||||||
"backend",
|
"backend",
|
||||||
"function_names",
|
"function_names",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -144,7 +144,9 @@ class DatabaseMixin:
|
|||||||
"If database flavor does not support schema or any schema is allowed "
|
"If database flavor does not support schema or any schema is allowed "
|
||||||
"to be accessed, just leave the list empty<br/>"
|
"to be accessed, just leave the list empty<br/>"
|
||||||
"4. the ``version`` field is a string specifying the this db's version. "
|
"4. the ``version`` field is a string specifying the this db's version. "
|
||||||
"This should be used with Presto DBs so that the syntax is correct",
|
"This should be used with Presto DBs so that the syntax is correct<br/>"
|
||||||
|
"5. The ``allows_virtual_table_explore`` field is a boolean specifying "
|
||||||
|
"whether or not the Explore button in SQL Lab results is shown.",
|
||||||
True,
|
True,
|
||||||
),
|
),
|
||||||
"encrypted_extra": utils.markdown(
|
"encrypted_extra": utils.markdown(
|
||||||
|
|||||||
@@ -1284,6 +1284,29 @@ class CoreTests(SupersetTestCase):
|
|||||||
payload = views.Superset._get_sqllab_tabs(user_id=user_id)
|
payload = views.Superset._get_sqllab_tabs(user_id=user_id)
|
||||||
self.assertEqual(len(payload["queries"]), 1)
|
self.assertEqual(len(payload["queries"]), 1)
|
||||||
|
|
||||||
|
def test_virtual_table_explore_visibility(self):
|
||||||
|
# test that default visibility it set to True
|
||||||
|
database = utils.get_example_database()
|
||||||
|
self.assertEqual(database.allows_virtual_table_explore, True)
|
||||||
|
|
||||||
|
# test that visibility is disabled when extra is set to False
|
||||||
|
extra = database.get_extra()
|
||||||
|
extra["allows_virtual_table_explore"] = False
|
||||||
|
database.extra = json.dumps(extra)
|
||||||
|
self.assertEqual(database.allows_virtual_table_explore, False)
|
||||||
|
|
||||||
|
# test that visibility is enabled when extra is set to True
|
||||||
|
extra = database.get_extra()
|
||||||
|
extra["allows_virtual_table_explore"] = True
|
||||||
|
database.extra = json.dumps(extra)
|
||||||
|
self.assertEqual(database.allows_virtual_table_explore, True)
|
||||||
|
|
||||||
|
# test that visibility is not broken with bad values
|
||||||
|
extra = database.get_extra()
|
||||||
|
extra["allows_virtual_table_explore"] = "trash value"
|
||||||
|
database.extra = json.dumps(extra)
|
||||||
|
self.assertEqual(database.allows_virtual_table_explore, True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class DatabaseApiTests(SupersetTestCase):
|
|||||||
"allow_run_async",
|
"allow_run_async",
|
||||||
"allows_cost_estimate",
|
"allows_cost_estimate",
|
||||||
"allows_subquery",
|
"allows_subquery",
|
||||||
|
"allows_virtual_table_explore",
|
||||||
"backend",
|
"backend",
|
||||||
"database_name",
|
"database_name",
|
||||||
"expose_in_sqllab",
|
"expose_in_sqllab",
|
||||||
|
|||||||
Reference in New Issue
Block a user