-
Notifications
You must be signed in to change notification settings - Fork 108
data explorer: create "Copy as Code" modal #8537
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
Conversation
Co-authored-by: Dhruvi Sompura <dhruvisompura@users.noreply.github.com>
E2E Tests 🚀 |
@@ -19,6 +19,8 @@ import { DataExplorerClientInstance } from '../../languageRuntime/common/languag | |||
import { DataExplorerSummaryCollapseEnabled, DefaultDataExplorerSummaryLayout } from './positronDataExplorerSummary.js'; | |||
import { CodeSyntaxName } from '../../languageRuntime/common/positronDataExplorerComm.js'; | |||
import { ClipboardCell, ClipboardCellRange, ClipboardColumnIndexes, ClipboardColumnRange, ClipboardRowIndexes, ClipboardRowRange } from '../../../browser/positronDataGrid/classes/dataGridInstance.js'; | |||
import { POSITRON_DATA_EXPLORER_IS_CONVERT_TO_CODE_ENABLED } from '../../../contrib/positronDataExplorerEditor/browser/positronDataExplorerContextKeys.js'; |
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.
locally i saw this message on commit:
[16:51:21] /Users/isabelizimm/code/positron/src/vs/workbench/services/positronDataExplorer/browser/positronDataExplorerInstance.ts: line 22, col 67, Warning - Imports violates 'vs/base/{common,browser}/** or vs/base/parts/*/{common,browser}/** or vs/platform/*/{common,browser}/** or vs/editor/{common,browser}/** or vs/editor/contrib/*/{common,browser}/** or vs/workbench/{common,browser}/** or vs/workbench/services/*/{common,browser}/** or tas-client-umd or vscode-textmate or @vscode/vscode-languagedetection or @vscode/tree-sitter-wasm or @xterm/xterm or vs/nls.js or vs/amdX.js' restrictions. See https://github.com/microsoft/vscode/wiki/Source-Code-Organization (local/code-import-patterns)
I don't know if it is a Very Bad Thing or something that is okay to ignore? There are no other errors for build, lint, etc, but want to call it out just in case?
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.
Thanks for calling this out! I do think we want to address this eslint import error. I just messaged you about this via slack.
src/vs/workbench/browser/positronModalDialogs/convertToCodeModalDialog.tsx
Outdated
Show resolved
Hide resolved
@@ -19,6 +19,8 @@ import { DataExplorerClientInstance } from '../../languageRuntime/common/languag | |||
import { DataExplorerSummaryCollapseEnabled, DefaultDataExplorerSummaryLayout } from './positronDataExplorerSummary.js'; | |||
import { CodeSyntaxName } from '../../languageRuntime/common/positronDataExplorerComm.js'; | |||
import { ClipboardCell, ClipboardCellRange, ClipboardColumnIndexes, ClipboardColumnRange, ClipboardRowIndexes, ClipboardRowRange } from '../../../browser/positronDataGrid/classes/dataGridInstance.js'; | |||
import { POSITRON_DATA_EXPLORER_IS_CONVERT_TO_CODE_ENABLED } from '../../../contrib/positronDataExplorerEditor/browser/positronDataExplorerContextKeys.js'; |
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.
Thanks for calling this out! I do think we want to address this eslint import error. I just messaged you about this via slack.
src/vs/workbench/contrib/positronDataExplorerEditor/browser/positronDataExplorerActions.ts
Outdated
Show resolved
Hide resolved
…alDialog.tsx Co-authored-by: Dhruvi Sompura <dhruvi.sompura@posit.co> Signed-off-by: Isabel Zimmerman <54685329+isabelizimm@users.noreply.github.com>
related issue: #8531 related pr for Ark: posit-dev/ark#873 I'm not exactly sure of the flow of these PRs with Ark, but I believe we'll want to merge that PR, release Ark, and then pick up the new release in this PR before this PR is merged. This PR implements makes 3 major changes to the comms: - **add `convert_to_code` as a supported feature:** there are other supported features, such as row filters and column filters. This structure includes if it is supported as well as supported syntaxes, as an array of values. - **`suggest_code_syntax` message:** for a particular data explorer instance, decide what options a user has for generating code. I would expect the return value of this to be `base-r` or something to that effect. - **`convert_to_code` message:** for a particular data explorer instance, this message sends over the filters and sorts applied to the data and the desired syntax. The expectation is that this will return a code snippet string. The front end will (eventually) apply code highlighting and formatting. Below is a diagram of the general flow through comms. Note that these comm messages will not call each other; they will be triggered by a modal in Positron core. ```mermaid flowchart TD A["Data explorer instance is created"] --> B["Get all potential syntaxes from language pack via the **supported_features**." ] B --> C["Also set suggested syntax with **suggest_code_syntax**"] C --> D[Open modal] D --> E["Use **dataExplorerInstance.suggestedSyntax**"] E --> F["Translate data view (filters, sorts) to code with **_translate_to_code_**"] F --> G[Display code for user to copy] G -->|user chooses another syntax from modal dropdown| F ``` There is an open PR that builds off this branch to use these comms, so you can actually fire them off/interact with them #8537 ### Release Notes <!-- Optionally, replace `N/A` with text to be included in the next release notes. The `N/A` bullets are ignored. If you refer to one or more Positron issues, these issues are used to collect information about the feature or bugfix, such as the relevant language pack as determined by Github labels of type `lang: `. The note will automatically be tagged with the language. These notes are typically filled by the Positron team. If you are an external contributor, you may ignore this section. --> #### New Features - N/A #### Bug Fixes - N/A ### QA Notes It doesn't look like we have much testing for comms, but open to ideas! Currently I plan on adding unit tests on each language runtime and then e2e tests for the UI pieces. --------- Signed-off-by: Isabel Zimmerman <54685329+isabelizimm@users.noreply.github.com> Co-authored-by: Jennifer (Jenny) Bryan <jenny.f.bryan@gmail.com>
Signed-off-by: Isabel Zimmerman <54685329+isabelizimm@users.noreply.github.com>
failing test is unrelated! |
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.
There are just two comments left.
<div className='dropdown-entry-title'> | ||
{props.title} | ||
</div> | ||
{props.group ? <div className='dropdown-entry-group'>{props.group}</div> : null} |
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 can be simplified as:
{props.group && <div className='dropdown-entry-group'>{props.group}</div>}
src/vs/workbench/browser/positronModalDialogs/convertToCodeModalDialog.tsx
Show resolved
Hide resolved
src/vs/workbench/browser/positronModalDialogs/convertToCodeModalDialog.tsx
Show resolved
Hide resolved
src/vs/workbench/browser/positronModalDialogs/convertToCodeModalDialog.tsx
Show resolved
Hide resolved
"Convert to Code" | ||
))()} | ||
width={400} | ||
onAccept={async () => { |
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.
async
doesn't seem to be needed.
onAccept={() => renderer.dispose()}
This PR implements the actions and modal dialog for the
Copy as Code
data explorer button.A modal dialog was chosen over a modal popup since we cannot use a modal popup in the editor action bar at this point in time. Notes from @dhruvisompura:
Note that this is just the first implementation! Things like the "Copy to Clipboard" functionality, real code editor block, etc will come in a follow up PR.
Release Notes
New Features
Bug Fixes
QA Notes
Intended behavior is that the modal has a dropdown that is populated with the name of a syntax, eg,
pandas
, + generated code. At this point, the code generation piece is not implemented, so we won't have to check the code is correct (yet).On the Python side, a
pandas
dataframe will fill the dropdown withpandas
. Apolars
dataframe will fill the dropdown withpolars
. For the R side, unless you have a locally built Ark, the button should be greyed out since there are no syntaxes available.