mirror of
https://github.com/chartdb/chartdb.git
synced 2025-11-03 05:23:26 +00:00
add loader for loading scripts (#265)
This commit is contained in:
@@ -71,12 +71,7 @@ export const ImportDatabase: React.FC<ImportDatabaseProps> = ({
|
||||
>();
|
||||
const { t } = useTranslation();
|
||||
const [importMetadataScripts, setImportMetadataScripts] =
|
||||
useState<ImportMetadataScripts>(
|
||||
Object.values(DatabaseType).reduce((acc, val) => {
|
||||
acc[val] = () => '';
|
||||
return acc;
|
||||
}, {} as ImportMetadataScripts)
|
||||
);
|
||||
useState<ImportMetadataScripts | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const loadScripts = async () => {
|
||||
@@ -252,19 +247,25 @@ export const ImportDatabase: React.FC<ImportDatabaseProps> = ({
|
||||
</div>
|
||||
<CodeSnippet
|
||||
className="max-h-40 w-full"
|
||||
code={importMetadataScripts[databaseType]({
|
||||
databaseEdition,
|
||||
databaseClient,
|
||||
})}
|
||||
loading={!importMetadataScripts}
|
||||
code={
|
||||
importMetadataScripts?.[databaseType]?.({
|
||||
databaseEdition,
|
||||
databaseClient,
|
||||
}) ?? ''
|
||||
}
|
||||
language={databaseClient ? 'bash' : 'sql'}
|
||||
/>
|
||||
</Tabs>
|
||||
) : (
|
||||
<CodeSnippet
|
||||
className="max-h-40 w-full"
|
||||
code={importMetadataScripts[databaseType]({
|
||||
databaseEdition,
|
||||
})}
|
||||
loading={!importMetadataScripts}
|
||||
code={
|
||||
importMetadataScripts?.[databaseType]?.({
|
||||
databaseEdition,
|
||||
}) ?? ''
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user