-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: database_schema support in dust apps (#2624)
* Add database block * add io-ts-types * add front support for database schema block * rm debug log * improve copy * nits * extra nit
- Loading branch information
1 parent
aa36405
commit 1934f72
Showing
13 changed files
with
509 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import "@uiw/react-textarea-code-editor/dist.css"; | ||
|
||
import DataSourcePicker from "@app/components/data_source/DataSourcePicker"; | ||
import DatabasePicker from "@app/components/database/DatabasePicker"; | ||
import { shallowBlockClone } from "@app/lib/utils"; | ||
import { SpecificationBlockType, SpecificationType } from "@app/types/app"; | ||
import { AppType } from "@app/types/app"; | ||
import { BlockType } from "@app/types/run"; | ||
import { RunType } from "@app/types/run"; | ||
import { WorkspaceType } from "@app/types/user"; | ||
|
||
import Block from "./Block"; | ||
|
||
export default function DatabaseSchema({ | ||
owner, | ||
app, | ||
spec, | ||
run, | ||
block, | ||
status, | ||
running, | ||
readOnly, | ||
onBlockUpdate, | ||
onBlockDelete, | ||
onBlockUp, | ||
onBlockDown, | ||
onBlockNew, | ||
}: React.PropsWithChildren<{ | ||
owner: WorkspaceType; | ||
app: AppType; | ||
spec: SpecificationType; | ||
run: RunType | null; | ||
block: SpecificationBlockType; | ||
status: any; | ||
running: boolean; | ||
readOnly: boolean; | ||
onBlockUpdate: (block: SpecificationBlockType) => void; | ||
onBlockDelete: () => void; | ||
onBlockUp: () => void; | ||
onBlockDown: () => void; | ||
onBlockNew: (blockType: BlockType | "map_reduce" | "while_end") => void; | ||
}>) { | ||
return ( | ||
<Block | ||
owner={owner} | ||
app={app} | ||
spec={spec} | ||
run={run} | ||
block={block} | ||
status={status} | ||
running={running} | ||
readOnly={readOnly} | ||
canUseCache={false} | ||
onBlockUpdate={onBlockUpdate} | ||
onBlockDelete={onBlockDelete} | ||
onBlockUp={onBlockUp} | ||
onBlockDown={onBlockDown} | ||
onBlockNew={onBlockNew} | ||
> | ||
<div className="mx-4 flex w-full flex-col flex-col gap-2 pt-4 xl:flex-row"> | ||
<div className="flex flex-col xl:flex-row xl:space-x-2"> | ||
<div className="mr-1 flex flex-initial text-sm font-medium leading-8 text-gray-700"> | ||
Database: | ||
</div> | ||
<div className="mr-2 flex flex-initial flex-row items-center space-x-1 text-sm font-medium leading-8 text-gray-700"> | ||
<DataSourcePicker | ||
owner={owner} | ||
readOnly={readOnly} | ||
currentDataSources={ | ||
block.config.database?.data_source_id | ||
? [ | ||
{ | ||
data_source_id: block.config.database.data_source_id, | ||
workspace_id: block.config.database.workspace_id, | ||
}, | ||
] | ||
: [] | ||
} | ||
onDataSourcesUpdate={(dataSources) => { | ||
if (dataSources.length === 0) { | ||
return; | ||
} | ||
const ds = dataSources[0]; | ||
const b = shallowBlockClone(block); | ||
b.config.database = { | ||
workspace_id: ds.workspace_id, | ||
data_source_id: ds.data_source_id, | ||
}; | ||
onBlockUpdate(b); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
{block.config.database?.data_source_id && ( | ||
<div className="flex flex-col xl:flex-row xl:space-x-2"> | ||
<div className="mr-2 flex flex-initial flex-row items-center space-x-1 text-sm font-medium leading-8 text-gray-700"> | ||
<DatabasePicker | ||
owner={owner} | ||
dataSource={{ | ||
workspace_id: block.config.database.workspace_id, | ||
data_source_id: block.config.database.data_source_id, | ||
}} | ||
readOnly={readOnly} | ||
currentDatabaseId={block.config.database?.database_id} | ||
onDatabaseUpdate={(database) => { | ||
const b = shallowBlockClone(block); | ||
b.config.database.database_id = database.database_id; | ||
onBlockUpdate(b); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
</Block> | ||
); | ||
} |
Oops, something went wrong.