-
Notifications
You must be signed in to change notification settings - Fork 84
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: add query panel tab #1231
Conversation
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.
What happens if vscode is restarted?
I don't think we should allow to clear the results of result document.
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.
LGTM I would not name it tab but VirtualDocument
as in https://github.com/microsoft/vscode-extension-samples/blob/main/virtual-document-sample/README.md
usersService, | ||
); | ||
|
||
const t = this; |
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.
What's this for?
@@ -30,8 +31,9 @@ const QueryPanel = (): JSX.Element => { | |||
/> | |||
</Stack> | |||
<Stack> | |||
<ShowOldUxButton /> | |||
{!isTab && <ShowOldUxButton />} |
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.
{!isTab && <ShowOldUxButton />} | |
{isPanel && <ShowOldUxButton />} |
@@ -29,6 +29,7 @@ import { UsersService } from "../services/usersService"; | |||
import { ConversationProvider } from "../comment_provider/conversationProvider"; | |||
import { DbtDocsView } from "./DbtDocsView"; | |||
import { ConversationService } from "../services/conversationService"; | |||
import { QueryResultTab } from "./QueryResultTab"; |
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 part of queryResultPanel.ts. I have added DbtDocsView, because it was related to doc editor
@@ -30,8 +31,9 @@ const QueryPanel = (): JSX.Element => { | |||
/> | |||
</Stack> | |||
<Stack> | |||
<ShowOldUxButton /> | |||
{!isTab && <ShowOldUxButton />} | |||
<ClearResultsButton /> |
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.
clear results is also not needed in tab
void executeRequestInSync("getQueryTabData", {}).then((data) => { | ||
if (data) { | ||
const typedData = data as QueryPanelStateProps; | ||
setTabData(data as Record<string, unknown>); |
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.
why is this typecasted to unknown? can you use QueryPanelStateProps
?
@@ -154,7 +158,24 @@ const useQueryPanelListeners = (): { loading: boolean } => { | |||
}; | |||
}, [onMesssage]); | |||
|
|||
return { loading }; | |||
useEffect(() => { | |||
if (!tabData) { |
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.
Looks like you can avoid storing all the data in tabData. This is only needed to store whether this is a tab or not. You can just store this state value as boolean. This will avoid storing duplicate data in memory
import { UsersService } from "../services/usersService"; | ||
|
||
@provideSingleton(QueryResultTab) | ||
export class QueryResultTab extends AltimateWebviewProvider { |
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 new class can be avoided and can be combined with existing queryResultsPanel.
@gaurpulkit make sure we add some tests for this as well. Also, please make sure to test it out manually in both native desktop environment and also in codespaces |
…er-user into add-query-panel-tab
It clears the tabs for now |
|
||
protected _panel: WebviewView | undefined; | ||
protected _tabPanel: WebviewPanel | undefined = undefined; |
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 private
return; | ||
} | ||
|
||
this._webview.onDidReceiveMessage(this.handleCommand, this, []); |
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.
use setupWebviewHooks
import Tooltip from "../tooltip/Tooltip"; | ||
import classes from "./styles.module.scss"; | ||
|
||
export const GradientButton = (props: ButtonProps): JSX.Element => ( |
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.
add a sample in webview_panels\src\uiCore\uiToolkitStories\Components.stories.tsx
{isPanel && <ShowOldUxButton />} | ||
{isPanel && <ClearResultsButton />} | ||
{isPanel && <ShowInTabButton />} | ||
<HelpButton /> |
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.
{isPanel && <ShowOldUxButton />} | |
{isPanel && <ClearResultsButton />} | |
{isPanel && <ShowInTabButton />} | |
<HelpButton /> | |
{isPanel && ( | |
<> | |
<ShowOldUxButton /> | |
<ClearResultsButton /> | |
<ShowInTabButton /> | |
</> | |
)} | |
<HelpButton /> |
@@ -312,6 +354,32 @@ export class QueryResultPanel extends AltimateWebviewProvider { | |||
this._panel!.onDidChangeVisibility(sendQueryPanelViewEvent); | |||
} | |||
|
|||
private setupTabWebviewHooks() { | |||
this._tabPanel!.webview.onDidReceiveMessage( |
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.
it will be better to reuse the existing onDidReceiveMessage handler, otherwise this tab will lose the other command handling. You should be using existing setupWebviewHooks
so that all the commands will go through same flow. Otherwise it will be difficult to maintain multiple versions of the query results panel
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.
I already tried to do that but the webview of tab isn't available when only panel opens. So, we need to set it when it opens.
|
||
this.setupTabWebviewHooks(); | ||
|
||
this._webview.html = this.getHtml( |
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.
It is better to use renderWebviewView
, which has few conditions to render different type of views based on configuration.
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.
Again, the setup time of tab and panel will be different
this, | ||
this._disposables, | ||
); | ||
const sendQueryTabViewEvent = () => { |
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.
extract this as separate private function to avoid multiple bindings
Overview
Problem
#683 (comment)
Solution
Showing query panel in tabs
Screenshot/Demo
A picture is worth a thousand words. Please highlight the changes if applicable.
![Screenshot 2024-06-19 at 6 18 31 PM](https://private-user-images.githubusercontent.com/30400626/341079847-c1121c7b-4a80-4238-9547-a820aa8b3ec7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAwOTExMjcsIm5iZiI6MTcyMDA5MDgyNywicGF0aCI6Ii8zMDQwMDYyNi8zNDEwNzk4NDctYzExMjFjN2ItNGE4MC00MjM4LTk1NDctYTgyMGFhOGIzZWM3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA0VDExMDAyN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE0ZDkwYmNkNDVkMjY4MDk1NDQzODMxYzM0MWU0MzNiYmY0YTBiNTIxNTRjNGUxMWY0NGU2YWE2ZWRlY2QwZWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.sh4P8kjATh2t5mSZSJ4nMmY9ecHuEUyG7CeJzkatqo0)
How to test
Checklist
README.md
updated and added information about my change