Skip to content

Commit

Permalink
feat(insights): add loading state to sql insights (#19328)
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr authored Dec 14, 2023
1 parent 3e9aad2 commit fed2153
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 10 additions & 2 deletions frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LemonDivider } from '@posthog/lemon-ui'
import { BindLogic, useValues } from 'kea'
import { AnimationType } from 'lib/animations/animations'
import { Animation } from 'lib/components/Animation/Animation'
import { useCallback, useState } from 'react'
import { insightLogic } from 'scenes/insights/insightLogic'

Expand Down Expand Up @@ -52,7 +54,7 @@ export function DataTableVisualization(props: DataTableVisualizationProps): JSX.
cachedResults: props.cachedResults,
}

const { query, visualizationType, showEditingUI, showResultControls, sourceFeatures } =
const { query, visualizationType, showEditingUI, showResultControls, sourceFeatures, response, responseLoading } =
useValues(builtDataVisualizationLogic)

const setQuerySource = useCallback(
Expand All @@ -61,7 +63,13 @@ export function DataTableVisualization(props: DataTableVisualizationProps): JSX.
)

let component: JSX.Element | null = null
if (visualizationType === ChartDisplayType.ActionsTable) {
if (!response && responseLoading) {
return (
<div className="flex flex-col flex-1 justify-center items-center border rounded">
<Animation type={AnimationType.LaptopHog} />
</div>
)
} else if (visualizationType === ChartDisplayType.ActionsTable) {
component = (
<DataTable
uniqueKey={key}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ export const dataVisualizationLogic = kea<dataVisualizationLogicType>([
key((props) => props.key),
path(['queries', 'nodes', 'DataVisualization', 'dataVisualizationLogic']),
connect({
values: [teamLogic, ['currentTeamId'], insightSceneLogic, ['insightMode'], dataNodeLogic, ['response']],
values: [
teamLogic,
['currentTeamId'],
insightSceneLogic,
['insightMode'],
dataNodeLogic,
['response', 'responseLoading'],
],
actions: [dataNodeLogic, ['loadDataSuccess']],
}),
props({ query: {} } as DataVisualizationLogicProps),
Expand Down

0 comments on commit fed2153

Please sign in to comment.