Skip to content

Commit

Permalink
add loading indicator for data warehouse tables
Browse files Browse the repository at this point in the history
  • Loading branch information
EDsCODE committed Mar 27, 2024
1 parent 177d646 commit 227a79b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface TreeItemFolder {
name: string
items: TreeItemLeaf[]
emptyLabel?: JSX.Element
isLoading?: boolean
}

export interface TreeItemLeaf {
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/lib/components/DatabaseTableTree/TreeRow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './TreeRow.scss'

import { IconChevronDown } from '@posthog/icons'
import { Spinner } from '@posthog/lemon-ui'
import clsx from 'clsx'
import { IconChevronRight } from 'lib/lemon-ui/icons'
import { useCallback, useState } from 'react'
Expand Down Expand Up @@ -64,10 +65,16 @@ export function TreeFolderRow({ item, depth, onClick, selectedRow }: TreeFolderR
<div
// eslint-disable-next-line react/forbid-dom-props
style={{
marginLeft: `${2 * depth}rem`,
marginLeft: `${3 * depth}rem`,
}}
>
{emptyLabel ? emptyLabel : <span className="text-muted">No tables found</span>}
{item.isLoading ? (
<Spinner style={{ fontSize: 20, marginTop: 2 }} />

Check failure on line 72 in frontend/src/lib/components/DatabaseTableTree/TreeRow.tsx

View workflow job for this annotation

GitHub Actions / Code quality checks

Type '{ style: { fontSize: number; marginTop: number; }; }' is not assignable to type 'IntrinsicAttributes & SpinnerProps'.
) : emptyLabel ? (
emptyLabel
) : (
<span className="text-muted">No tables found</span>
)}
</div>
))}
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ import { dataWarehouseSceneLogic } from './dataWarehouseSceneLogic'
import SourceModal from './SourceModal'

export const DataWarehouseTables = (): JSX.Element => {
const { isSourceModalOpen, externalTables, posthogTables, savedQueriesFormatted, allTables, selectedRow } =
useValues(dataWarehouseSceneLogic)
const {
isSourceModalOpen,
externalTables,
dataWarehouseLoading,
posthogTables,
savedQueriesFormatted,
allTables,
selectedRow,
dataWarehouseSavedQueriesLoading,
} = useValues(dataWarehouseSceneLogic)
const { toggleSourceModal, selectRow, deleteDataWarehouseSavedQuery, deleteDataWarehouseTable } =
useActions(dataWarehouseSceneLogic)
const { featureFlags } = useValues(featureFlagLogic)
Expand Down Expand Up @@ -82,6 +90,7 @@ export const DataWarehouseTables = (): JSX.Element => {
</Link>
</span>
),
isLoading: dataWarehouseLoading,
},
{
name: 'PostHog',
Expand All @@ -99,6 +108,7 @@ export const DataWarehouseTables = (): JSX.Element => {
table: table,
icon: <IconBrackets />,
})),
isLoading: dataWarehouseSavedQueriesLoading,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export const dataWarehouseSceneLogic = kea<dataWarehouseSceneLogicType>([
userLogic,
['user'],
databaseTableListLogic,
['filteredTables', 'dataWarehouse'],
['filteredTables', 'dataWarehouse', 'dataWarehouseLoading'],
dataWarehouseSavedQueriesLogic,
['savedQueries'],
['savedQueries', 'dataWarehouseSavedQueriesLoading'],
featureFlagLogic,
['featureFlags'],
],
Expand Down

0 comments on commit 227a79b

Please sign in to comment.