Skip to content

Commit 086d24e

Browse files
authored
fix: sql graph optimizations, handling various edge cases with data returned (#6558)
* fix: have flux language components be behind own flag, and do not hide the sidebar for sql (because we use it for graphOptions). * fix: keep graph options sidebar often under various edge cases, and provide meaningful feedback. fix: surface graph subquery errors to the user
1 parent 16259ca commit 086d24e

File tree

5 files changed

+48
-19
lines changed

5 files changed

+48
-19
lines changed

cypress/e2e/shared/editor.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ describe('Editor+LSP communication', () => {
127127
newDataExplorer: true,
128128
schemaComposition: false,
129129
saveAsScript: true,
130+
enableFluxInScriptBuilder: true,
130131
})
131132
cy.get('@org').then(({id}: Organization) => {
132133
cy.visit(`/orgs/${id}/data-explorer`)

cypress/e2e/shared/scriptQueryBuilder.flux.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ describe('Script Builder', () => {
171171
loginWithFlags({
172172
schemaComposition: false,
173173
newDataExplorer: true,
174+
enableFluxInScriptBuilder: true,
174175
}).then(() => {
175176
cy.getByTestID('editor-sync--toggle').should('not.exist')
176177
cy.getByTestID('script-query-builder--menu').contains('New Script')
@@ -325,6 +326,7 @@ describe('Script Builder', () => {
325326
schemaComposition: true,
326327
newDataExplorer: true,
327328
saveAsScript: true,
329+
enableFluxInScriptBuilder: true,
328330
}).then(() => {
329331
clearSession()
330332
cy.getByTestID('editor-sync--toggle')

cypress/e2e/shared/scriptQueryBuilder.results.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ describe('Script Builder', () => {
170170
schemaComposition: true,
171171
newDataExplorer: true,
172172
saveAsScript: true,
173+
enableFluxInScriptBuilder: true,
173174
}).then(() => {
174175
cy.get('@org').then(({id: orgID}: Organization) => {
175176
route = `/orgs/${orgID}/data-explorer`

src/dataExplorer/components/Results.tsx

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,26 @@ const TableResults: FC<{search: string}> = ({search}) => {
158158
)
159159
}
160160

161+
const ErrorResults: FC<{error: string}> = ({error}) => {
162+
return (
163+
<div className="data-explorer-results--empty">
164+
<div className="data-explorer-results--empty-header">
165+
<h3>Graph Query Results</h3>
166+
<p>{error}</p>
167+
</div>
168+
</div>
169+
)
170+
}
171+
161172
const GraphResults: FC = () => {
162173
const {view} = useContext(ResultsViewContext)
163174
const {result, status} = useContext(ChildResultsContext)
164175
const {range} = useContext(PersistanceContext)
165176

177+
if (result.error) {
178+
return <ErrorResults error={result.error} />
179+
}
180+
166181
return (
167182
<div className="data-explorer-results--view">
168183
<SpinnerContainer loading={status} spinnerComponent={<TechnoSpinner />}>
@@ -179,11 +194,13 @@ const GraphResults: FC = () => {
179194
}
180195

181196
const WrappedOptions: FC = () => {
197+
const {result: parentResult} = useContext(ResultsContext)
182198
const {result} = useContext(ChildResultsContext)
183199
const {view, setView, selectViewOptions, viewOptions, selectedViewOptions} =
184200
useContext(ResultsViewContext)
185201
const {resource} = useContext(PersistanceContext)
186-
const dataExists = !!result?.parsed
202+
const graphDataExists = !!result?.parsed
203+
const parentDataExists = !!parentResult?.parsed
187204

188205
const updateChildResults = update => {
189206
setView({
@@ -195,10 +212,6 @@ const WrappedOptions: FC = () => {
195212
})
196213
}
197214

198-
if (!dataExists) {
199-
return null
200-
}
201-
202215
const subQueryOptions =
203216
resource?.language === LanguageType.SQL &&
204217
view.state == ViewStateType.Graph ? (
@@ -212,11 +225,23 @@ const WrappedOptions: FC = () => {
212225
return (
213226
<>
214227
{subQueryOptions}
215-
<ViewOptions
216-
properties={view.properties}
217-
results={result.parsed}
218-
update={updateChildResults}
219-
/>
228+
{graphDataExists ? (
229+
<ViewOptions
230+
properties={view.properties}
231+
results={result.parsed}
232+
update={updateChildResults}
233+
/>
234+
) : (
235+
<div className="view-options">
236+
<p>Data cannot be graphed. Requires 2+ data points.</p>
237+
{parentDataExists && viewOptions.smoothing.applied && (
238+
<p>
239+
If you are using Graph Smooth, please increase the percentage
240+
retained or turn it off.
241+
</p>
242+
)}
243+
</div>
244+
)}
220245
</>
221246
)
222247
}
@@ -229,26 +254,25 @@ const NOT_SUPPORTED_GRAPH_TYPES = [
229254
SUPPORTED_VISUALIZATIONS['single-stat'].type,
230255
]
231256
const GraphHeader: FC = () => {
232-
const {view, setView, viewOptions} = useContext(ResultsViewContext)
257+
const {view, setView} = useContext(ResultsViewContext)
233258
const {result} = useContext(ResultsContext)
234259
const {result: subQueryResult} = useContext(ChildResultsContext)
235260
const {launch, clear: closeSidebar} = useContext(SidebarContext)
236261

237-
const dataExists = !!result?.parsed
262+
const dataExists =
263+
!!result?.parsed && result.parsed.resultColumnNames.length > 0
238264

239265
const launcher = () => {
240266
launch(<WrappedOptions />)
241267
}
268+
242269
useEffect(() => {
243270
if (dataExists) {
244271
launcher()
245-
}
246-
}, [viewOptions])
247-
useEffect(() => {
248-
if (!dataExists) {
272+
} else {
249273
closeSidebar()
250274
}
251-
}, [dataExists])
275+
}, [result])
252276

253277
const updateType = viewType => {
254278
setView({

src/dataExplorer/components/ScriptQueryBuilder.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ const ScriptQueryBuilder: FC = () => {
6868
const org = useSelector(getOrg)
6969
const isNewIOxOrg =
7070
useSelector(selectIsNewIOxOrg) &&
71-
!isFlagEnabled('showOldDataExplorerInNewIOx')
71+
!isFlagEnabled('showOldDataExplorerInNewIOx') &&
72+
!isFlagEnabled('enableFluxInScriptBuilder')
7273

7374
const handleClear = useCallback(() => {
7475
cancel()
@@ -226,7 +227,7 @@ const ScriptQueryBuilder: FC = () => {
226227
<ResultsPane />
227228
</DraggableResizer.Panel>
228229
<DraggableResizer.Panel isCollapsible={true}>
229-
{!isNewIOxOrg && <Sidebar />}
230+
<Sidebar />
230231
</DraggableResizer.Panel>
231232
</DraggableResizer>
232233
</FlexBox>

0 commit comments

Comments
 (0)