-
Notifications
You must be signed in to change notification settings - Fork 112
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
feat: database_schema support in dust apps #2624
Merged
+509
−31
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 pt-4 xl:flex-row"> | ||
<div className="flex flex-col xl:flex-row xl:space-x-2"> | ||
<div className="mr-1 flex flex-initial 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"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we try to put them on the same line on wide screen (and vertical alignment on small screens? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
<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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because
database_schema
was too long?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup