Skip to content

Commit 959563a

Browse files
committed
fix: added "Out of Tab" option for parents that have GRID_ID
1 parent c361fb3 commit 959563a

2 files changed

Lines changed: 47 additions & 12 deletions

File tree

superset-frontend/src/explore/components/SaveModal.tsx

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ class SaveModal extends Component<SaveModalProps, SaveModalState> {
253253
? sliceDashboards
254254
: [...sliceDashboards, dashboard.id];
255255
formData.dashboards = sliceDashboards;
256-
if (this.state.action === 'saveas') {
256+
if (
257+
this.state.action === 'saveas' &&
258+
this.state.selectedTab?.value !== 'OUT_OF_TAB'
259+
) {
257260
selectedTabId = this.state.selectedTab?.value as string;
258261
}
259262
}
@@ -497,20 +500,51 @@ class SaveModal extends Component<SaveModalProps, SaveModalState> {
497500
return [];
498501
}
499502
const tabTree = result.tab_tree;
500-
503+
const gridTabIds = new Set<string>();
501504
const convertToTreeData = (nodes: TabNode[]): TabTreeNode[] =>
502-
nodes.map(node => ({
503-
value: node.value,
504-
title: node.title,
505-
key: node.value,
506-
children:
507-
node.children && node.children.length > 0
508-
? convertToTreeData(node.children)
509-
: undefined,
510-
}));
505+
nodes.map(node => {
506+
const isGridTab =
507+
Array.isArray(node.parents) && node.parents.includes('GRID_ID');
508+
if (isGridTab) {
509+
gridTabIds.add(node.value);
510+
}
511+
return {
512+
value: node.value,
513+
title: node.title,
514+
key: node.value,
515+
children:
516+
node.children && node.children.length > 0
517+
? convertToTreeData(node.children)
518+
: undefined,
519+
};
520+
});
511521

512522
const treeData = convertToTreeData(tabTree);
513-
this.setState({ tabsData: treeData });
523+
524+
// Add "Out of tab" option at the beginning
525+
if (gridTabIds.size > 0) {
526+
const tabsDataWithOutOfTab = [
527+
{
528+
value: 'OUT_OF_TAB',
529+
title: 'Out of tab',
530+
key: 'OUT_OF_TAB',
531+
children: undefined,
532+
},
533+
...treeData,
534+
];
535+
536+
this.setState({
537+
tabsData: tabsDataWithOutOfTab,
538+
selectedTab: { value: 'OUT_OF_TAB', label: 'Out of tab' },
539+
});
540+
} else {
541+
const firstTab = treeData[0];
542+
this.setState({
543+
tabsData: treeData,
544+
selectedTab: { value: firstTab.value, label: firstTab.title },
545+
});
546+
}
547+
514548
return treeData;
515549
} catch (error) {
516550
logging.error('Error loading tabs:', error);

superset-frontend/src/explore/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export interface ExplorePageState {
127127
export interface TabNode {
128128
value: string;
129129
title: string;
130+
parents: string[];
130131
children?: TabNode[];
131132
}
132133

0 commit comments

Comments
 (0)