mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-25 11:51:07 +00:00
* Implement copilot for user database * Fix minor bugs * fix bugs * Add user database copilot * Add placeholder text on copilot * Add AFEC adn killswitch * Add new v2 sampledatabase endpoint * Add telemetry * fix telemetry bug * Add query edited telemetry * add authorization header * Add back to the staging env for phoenix * point to stage for phoenix * Preview commit for test env * Preview link for staging * change the staging url * fix lint, unit tests * fix lint, unit tests * fix formatting
73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
import { CopilotProvider } from "Explorer/QueryCopilot/QueryCopilotContext";
|
|
import { userContext } from "UserContext";
|
|
import React from "react";
|
|
import * as DataModels from "../../../Contracts/DataModels";
|
|
import type { QueryTabOptions } from "../../../Contracts/ViewModels";
|
|
import { useTabs } from "../../../hooks/useTabs";
|
|
import Explorer from "../../Explorer";
|
|
import QueryTabComponent, {
|
|
IQueryTabComponentProps,
|
|
ITabAccessor,
|
|
QueryTabFunctionComponent,
|
|
} from "../../Tabs/QueryTab/QueryTabComponent";
|
|
import TabsBase from "../TabsBase";
|
|
|
|
export interface IQueryTabProps {
|
|
container: Explorer;
|
|
}
|
|
|
|
export class NewQueryTab extends TabsBase {
|
|
public queryText: string;
|
|
public currentQuery: string;
|
|
public partitionKey: DataModels.PartitionKey;
|
|
public iQueryTabComponentProps: IQueryTabComponentProps;
|
|
public iTabAccessor: ITabAccessor;
|
|
|
|
constructor(
|
|
options: QueryTabOptions,
|
|
private props: IQueryTabProps,
|
|
) {
|
|
super(options);
|
|
this.partitionKey = options.partitionKey;
|
|
this.iQueryTabComponentProps = {
|
|
collection: this.collection,
|
|
isExecutionError: this.isExecutionError(),
|
|
tabId: this.tabId,
|
|
tabsBaseInstance: this,
|
|
queryText: options.queryText,
|
|
partitionKey: this.partitionKey,
|
|
container: this.props.container,
|
|
onTabAccessor: (instance: ITabAccessor): void => {
|
|
this.iTabAccessor = instance;
|
|
},
|
|
isPreferredApiMongoDB: false,
|
|
};
|
|
}
|
|
|
|
public render(): JSX.Element {
|
|
return userContext.apiType === "SQL" ? (
|
|
<CopilotProvider>
|
|
<QueryTabFunctionComponent {...this.iQueryTabComponentProps} />
|
|
</CopilotProvider>
|
|
) : (
|
|
<QueryTabComponent {...this.iQueryTabComponentProps} />
|
|
);
|
|
}
|
|
|
|
public onTabClick(): void {
|
|
useTabs.getState().activateTab(this);
|
|
this.iTabAccessor.onTabClickEvent();
|
|
}
|
|
|
|
public onCloseTabButtonClick(): void {
|
|
useTabs.getState().closeTab(this);
|
|
if (this.iTabAccessor) {
|
|
this.iTabAccessor.onCloseClickEvent(true);
|
|
}
|
|
}
|
|
|
|
public getContainer(): Explorer {
|
|
return this.props.container;
|
|
}
|
|
}
|