Skip to content

Commit 093ba50

Browse files
authored
fix: broken export from DE (#5042)
1 parent 65e690a commit 093ba50

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/dataExplorer/components/SaveAsNotebookForm.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@ const SaveAsNotebookForm: FC<Props> = ({dismiss}) => {
8989
buckets: bucket,
9090
}
9191
} else {
92-
pipe.title = 'Query to Run'
93-
pipe.queries = draftQuery.builderConfig
94-
pipe.activeQuery = 0
95-
pipe.type = 'rawFluxEditor'
92+
pipe = {
93+
...pipe,
94+
title: 'Query to Run',
95+
queries: [draftQuery],
96+
activeQuery: 0,
97+
type: 'rawFluxEditor',
98+
}
9699
}
97100

98101
pipes.push(pipe)

src/flows/pipes/RawFluxEditor/view.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import 'src/flows/pipes/RawFluxEditor/style.scss'
3838
import {event} from 'src/cloud/utils/reporting'
3939
import {CLOUD} from 'src/shared/constants'
4040
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
41+
import {buildQuery} from 'src/timeMachine/utils/queryBuilder'
4142

4243
const FluxMonacoEditor = lazy(() =>
4344
import('src/shared/components/FluxMonacoEditor')
@@ -51,9 +52,28 @@ const Query: FC<PipeProp> = ({Context}) => {
5152
const editorContext = useContext(EditorContext)
5253
const {inject, injectFunction} = editorContext
5354
const {queries, activeQuery} = data
54-
const query = queries[activeQuery]
55+
// NOTE: this is to migrate bad data from an EAR, not part of the spec
56+
// the first condition is the correct one
57+
const query = Array.isArray(queries) ? queries[activeQuery] : queries
5558
const {variables} = useContext(VariablesContext)
5659

60+
// NOTE: this is to migrate bad data from an EAR, not part of the spec
61+
// the first condition is the correct one, no need to call build query
62+
const queryText = query?.text ?? buildQuery(query)
63+
64+
// NOTE: this should apply the migration
65+
useEffect(() => {
66+
if (Array.isArray(queries)) {
67+
return
68+
}
69+
70+
if (!query.text) {
71+
query.text = buildQuery(query)
72+
}
73+
74+
update({...data, queries: [{...query}]})
75+
}, [id])
76+
5777
useEffect(() => {
5878
if (isFlagEnabled('fluxInjectSecrets')) {
5979
register(id, [
@@ -130,7 +150,7 @@ const Query: FC<PipeProp> = ({Context}) => {
130150
}
131151
>
132152
<FluxMonacoEditor
133-
script={query.text}
153+
script={queryText}
134154
variables={variables}
135155
onChangeScript={updateText}
136156
wrapLines="on"
@@ -141,7 +161,7 @@ const Query: FC<PipeProp> = ({Context}) => {
141161
),
142162
[
143163
RemoteDataState.Loading,
144-
query.text,
164+
queryText,
145165
updateText,
146166
editorContext.editor,
147167
variables,

0 commit comments

Comments
 (0)