Skip to content

Commit cec4055

Browse files
authored
fix: only add visualization for active query (#5116)
1 parent adbaffe commit cec4055

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/dataExplorer/components/SaveAsNotebookForm.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ interface Props {
4141
const SaveAsNotebookForm: FC<Props> = ({dismiss}) => {
4242
const [notebookName, setNotebookName] = useState('')
4343
const orgID = useSelector(getOrg).id
44-
const {draftQueries, autoRefresh, timeRange} = useSelector(
44+
const {draftQueries, autoRefresh, timeRange, activeQueryIndex} = useSelector(
4545
getActiveTimeMachine
4646
)
4747
const {properties} = useSelector(getSaveableView)
@@ -73,7 +73,7 @@ const SaveAsNotebookForm: FC<Props> = ({dismiss}) => {
7373
const pipes: any = []
7474

7575
for (let i = 0; i < draftQueries.length; i++) {
76-
const draftQuery = draftQueries[i]
76+
const draftQuery = JSON.parse(JSON.stringify(draftQueries[i]))
7777
let pipe: any = {
7878
id: `local_${nanoid()}`,
7979
visible: !draftQuery.hidden,
@@ -99,16 +99,19 @@ const SaveAsNotebookForm: FC<Props> = ({dismiss}) => {
9999
}
100100

101101
pipes.push(pipe)
102-
pipes.push({
103-
id: `local_${nanoid()}`,
104-
properties: {
105-
...properties,
106-
builderConfig: draftQuery.builderConfig,
107-
},
108-
title: `Visualize the Result ${i + 1}`,
109-
type: 'visualization',
110-
visible: true,
111-
})
102+
103+
if (i === activeQueryIndex) {
104+
pipes.push({
105+
id: `local_${nanoid()}`,
106+
properties: {
107+
...properties,
108+
builderConfig: draftQuery.builderConfig,
109+
},
110+
title: `Visualize the Result ${i + 1}`,
111+
type: 'visualization',
112+
visible: true,
113+
})
114+
}
112115
}
113116

114117
const flow = hydrate({

0 commit comments

Comments
 (0)