mirror of
https://github.com/apache/superset.git
synced 2026-07-26 00:22:31 +00:00
Compare commits
2 Commits
fix/docker
...
sl-hide-si
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7716466704 | ||
|
|
13d94b2d23 |
@@ -128,6 +128,44 @@ test('open with Saved tab selected when there is a saved column selected', () =>
|
|||||||
expect(getByText('Custom SQL')).toHaveAttribute('aria-selected', 'false');
|
expect(getByText('Custom SQL')).toHaveAttribute('aria-selected', 'false');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('disables Custom SQL for semantic views but keeps Simple enabled', () => {
|
||||||
|
// Semantic-view contexts disable the Custom SQL tab (ad-hoc SQL doesn't
|
||||||
|
// apply to pre-defined semantic-model items). Simple stays enabled — SV
|
||||||
|
// dimensions carry ``expression=`` empty, which routes them into the
|
||||||
|
// Simple tab's list, and disabling that tab would leave the dimensions
|
||||||
|
// unreachable in the popover.
|
||||||
|
const store = mockStore({
|
||||||
|
explore: { datasource: { type: 'semantic_view' } },
|
||||||
|
});
|
||||||
|
const { getByText } = render(
|
||||||
|
<ColumnSelectPopover
|
||||||
|
columns={[{ column_name: 'year' }]}
|
||||||
|
editedColumn={undefined}
|
||||||
|
getCurrentTab={jest.fn()}
|
||||||
|
onChange={jest.fn()}
|
||||||
|
hasCustomLabel
|
||||||
|
isTemporal={false}
|
||||||
|
label="Custom Label"
|
||||||
|
onClose={jest.fn()}
|
||||||
|
setDatasetModal={jest.fn()}
|
||||||
|
setLabel={jest.fn()}
|
||||||
|
disabledTabs={new Set(['sqlExpression'])}
|
||||||
|
/>,
|
||||||
|
{ store },
|
||||||
|
);
|
||||||
|
|
||||||
|
// Simple is enabled and selected by default (no adhoc/saved column
|
||||||
|
// to steer initial selection elsewhere).
|
||||||
|
expect(getByText('Simple')).not.toHaveAttribute('aria-disabled', 'true');
|
||||||
|
expect(getByText('Simple')).toHaveAttribute('aria-selected', 'true');
|
||||||
|
// Saved remains enabled but is not the initial tab.
|
||||||
|
expect(getByText('Saved')).not.toHaveAttribute('aria-disabled', 'true');
|
||||||
|
expect(getByText('Saved')).toHaveAttribute('aria-selected', 'false');
|
||||||
|
// Custom SQL is greyed out and unselected.
|
||||||
|
expect(getByText('Custom SQL')).toHaveAttribute('aria-disabled', 'true');
|
||||||
|
expect(getByText('Custom SQL')).toHaveAttribute('aria-selected', 'false');
|
||||||
|
});
|
||||||
|
|
||||||
test('open with Custom SQL tab selected when there is a custom SQL selected', () => {
|
test('open with Custom SQL tab selected when there is a custom SQL selected', () => {
|
||||||
const { getByText } = renderPopover({
|
const { getByText } = renderPopover({
|
||||||
columns: [{ column_name: 'year' }],
|
columns: [{ column_name: 'year' }],
|
||||||
|
|||||||
@@ -281,11 +281,20 @@ const ColumnSelectPopover = ({
|
|||||||
[columnMap, metricMap, onSimpleColumnChange, onSimpleMetricChange],
|
[columnMap, metricMap, onSimpleColumnChange, onSimpleMetricChange],
|
||||||
);
|
);
|
||||||
|
|
||||||
const defaultActiveTabKey = initialAdhocColumn
|
// Pick the most natural starting tab, but never one that's disabled —
|
||||||
? 'sqlExpression'
|
// semantic-view contexts disable Simple and Custom SQL, leaving Saved.
|
||||||
: selectedCalculatedColumn
|
let defaultActiveTabKey: string;
|
||||||
? 'saved'
|
if (initialAdhocColumn && !disabledTabs.has('sqlExpression')) {
|
||||||
: 'simple';
|
defaultActiveTabKey = 'sqlExpression';
|
||||||
|
} else if (selectedCalculatedColumn && !disabledTabs.has('saved')) {
|
||||||
|
defaultActiveTabKey = 'saved';
|
||||||
|
} else if (!disabledTabs.has('simple')) {
|
||||||
|
defaultActiveTabKey = 'simple';
|
||||||
|
} else if (!disabledTabs.has('saved')) {
|
||||||
|
defaultActiveTabKey = 'saved';
|
||||||
|
} else {
|
||||||
|
defaultActiveTabKey = 'sqlExpression';
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getCurrentTab(defaultActiveTabKey);
|
getCurrentTab(defaultActiveTabKey);
|
||||||
@@ -501,8 +510,15 @@ const ColumnSelectPopover = ({
|
|||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
|
// The Simple tab is rendered even when disabled (mirroring how
|
||||||
|
// Custom SQL behaves below) so users see all the options that
|
||||||
|
// could exist in another context and understand why they're
|
||||||
|
// unavailable here. Semantic-view contexts disable it because
|
||||||
|
// dimensions there are pre-defined items in the semantic model,
|
||||||
|
// not physical columns to wrap.
|
||||||
key: TABS_KEYS.SIMPLE,
|
key: TABS_KEYS.SIMPLE,
|
||||||
label: t('Simple'),
|
label: t('Simple'),
|
||||||
|
disabled: disabledTabs.has('simple'),
|
||||||
children: (
|
children: (
|
||||||
<>
|
<>
|
||||||
{isTemporal && simpleColumns.length === 0 ? (
|
{isTemporal && simpleColumns.length === 0 ? (
|
||||||
|
|||||||
@@ -130,8 +130,12 @@ function DndColumnMetricSelect(props: DndColumnMetricSelectProps) {
|
|||||||
formData,
|
formData,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
// Semantic views do not support arbitrary SQL expressions as dimensions.
|
// Semantic-view dimensions and metrics are pre-defined items in the
|
||||||
// Merge 'sqlExpression' into disabledTabs so the Custom SQL tab is hidden.
|
// semantic model, so the Custom SQL tab (ad-hoc SQL expressions) doesn't
|
||||||
|
// apply and is disabled. The Simple tab stays enabled: dimensions land
|
||||||
|
// there because ``expression`` is left unset (a truthy ``expression``
|
||||||
|
// triggers fx-icon treatment in the popover and hides the time-grain
|
||||||
|
// selector, which we need to keep reachable).
|
||||||
const effectiveDisabledTabs = useMemo(
|
const effectiveDisabledTabs = useMemo(
|
||||||
() =>
|
() =>
|
||||||
String(datasource?.type) === 'semantic_view'
|
String(datasource?.type) === 'semantic_view'
|
||||||
|
|||||||
@@ -53,7 +53,12 @@ function DndColumnSelect(props: DndColumnSelectProps) {
|
|||||||
disabledTabs,
|
disabledTabs,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
// Semantic views do not support arbitrary SQL expressions as dimensions.
|
// Semantic-view dimensions are pre-defined items in the semantic model,
|
||||||
|
// so the Custom SQL tab (ad-hoc SQL expressions) doesn't apply and is
|
||||||
|
// disabled. The Simple tab stays enabled: dimensions land there because
|
||||||
|
// ``expression`` is left unset (a truthy ``expression`` triggers fx-icon
|
||||||
|
// treatment in the popover and hides the time-grain selector, which we
|
||||||
|
// need to keep reachable).
|
||||||
const datasourceType = useSelector<ExplorePageState, string | undefined>(
|
const datasourceType = useSelector<ExplorePageState, string | undefined>(
|
||||||
state => state.explore.datasource?.type,
|
state => state.explore.datasource?.type,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user