- Notifications
You must be signed in to change notification settings - Fork 14
eng: Added docs for canvas code#26
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -16,6 +16,17 @@ | ||
| from local_app.benchling_app.views.constants import SEARCH_BUTTON_ID, SEARCH_TEXT_ID | ||
| """ | ||
| This file contains examples of how create a canvas at initialization | ||
| For examples of updates, check out canvas_interaction.py | ||
| Use a CanvasBuilder to create or update a canvas associated with your app | ||
| This sdk tool can be used for easy creation and updates | ||
Contributor 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. nit: instead of "sdk tool" i think "this helper" sounds a little better, neither is wrong though | ||
| Check out https://benchling.com/sdk-docs/1.22.0/benchling_sdk.apps.canvas.framework.html | ||
| for more details on the CanvasBuilder class | ||
| """ | ||
| def render_search_canvas(app: App, canvas_initialized: CanvasInitializeWebhookV2) -> None: | ||
| with app.create_session_context("Show Sync Search", timeout_seconds=20): | ||
| @@ -24,7 +35,11 @@ def render_search_canvas(app: App, canvas_initialized: CanvasInitializeWebhookV2 | ||
| feature_id=canvas_initialized.feature_id, | ||
| resource_id=canvas_initialized.resource_id, | ||
| ) | ||
| # Add the input blocks to the canvas | ||
| canvas_builder.blocks.append(input_blocks()) | ||
| # Create the canvas | ||
| app.benchling.apps.create_canvas(canvas_builder.to_create()) | ||
| @@ -36,6 +51,13 @@ def render_search_canvas_for_created_canvas(app: App, canvas_created: CanvasCrea | ||
| def input_blocks() -> list[UiBlock]: | ||
| """ | ||
| Create 3 blocks to populate the canvas: | ||
| Markdown block to display text | ||
| TextInput block to capture user input | ||
| Button block to trigger the search | ||
| """ | ||
| return [ | ||
| MarkdownUiBlock( | ||
| id="top_instructions", | ||
Uh oh!
There was an error while loading. Please reload this page.
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.