Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show loading indicator when runtime config is loading in query editor #3169

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ export default function QueryEditorPanel({ draft, saved }: QueryEditorProps) {
const { dom } = useAppState();
const projectApi = useProjectApi();

const { data: runtimeConfig, status: runtimeConfigFetchStatus } = projectApi.useQuery(
'getRuntimeConfig',
[],
);
const { data: runtimeConfig } = projectApi.useSuspenseQuery('getRuntimeConfig', []);

const connectionId =
appDom.deref(saved ? saved?.attributes?.connectionId : draft?.attributes?.connectionId) ?? null;
Expand Down Expand Up @@ -213,27 +210,25 @@ export default function QueryEditorPanel({ draft, saved }: QueryEditorProps) {
return dataSourceId && dataSource && queryEditorContext ? (
<ConnectionContextProvider value={queryEditorContext}>
<Box sx={{ height: '100%', p: 0, overflow: 'hidden' }}>
{draft && runtimeConfigFetchStatus === 'success' ? (
<dataSource.QueryEditor
connectionParams={connectionParams}
value={draft}
globalScope={pageState}
globalScopeMeta={globalScopeMeta}
execApi={execPrivate}
runtimeConfig={runtimeConfig}
settingsTab={
<QuerySettingsTab
{...{
draft,
liveEnabled,
pageState,
globalScopeMeta,
jsBrowserRuntime,
}}
/>
}
/>
) : null}
<dataSource.QueryEditor
connectionParams={connectionParams}
value={draft}
globalScope={pageState}
globalScopeMeta={globalScopeMeta}
execApi={execPrivate}
runtimeConfig={runtimeConfig}
settingsTab={
<QuerySettingsTab
{...{
draft,
liveEnabled,
pageState,
globalScopeMeta,
jsBrowserRuntime,
}}
/>
}
/>
</Box>
</ConnectionContextProvider>
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { NodeId } from '@mui/toolpad-core';
import { Stack, Chip, Tab, IconButton } from '@mui/material';
import { Stack, Chip, Tab, IconButton, LinearProgress } from '@mui/material';
import { LoadingButton, TabList, TabContext, TabPanel } from '@mui/lab';
import ClearOutlinedIcon from '@mui/icons-material/ClearOutlined';
import CircleIcon from '@mui/icons-material/Circle';
Expand Down Expand Up @@ -297,7 +297,9 @@ export default function QueryEditor() {
overflow: 'hidden',
}}
>
<QueryEditorPanel draft={query.draft} saved={query.saved} />
<React.Suspense fallback={<LinearProgress />}>
<QueryEditorPanel draft={query.draft} saved={query.saved} />
</React.Suspense>
</TabPanel>
);
}
Expand Down
Loading