mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 17:30:46 +00:00
Migrate Query Tab to React (#852)
Co-authored-by: Steve Faulkner <southpolesteve@gmail.com>
This commit is contained in:
@@ -8,7 +8,6 @@ import { useSidePanel } from "../../../hooks/useSidePanel";
|
||||
import { userContext } from "../../../UserContext";
|
||||
import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../../../Utils/NotificationConsoleUtils";
|
||||
import Explorer from "../../Explorer";
|
||||
import QueryTab from "../../Tabs/QueryTab";
|
||||
import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm";
|
||||
|
||||
interface LoadQueryPaneProps {
|
||||
@@ -60,20 +59,19 @@ export const LoadQueryPane: FunctionComponent<LoadQueryPaneProps> = ({ explorer
|
||||
|
||||
const loadQueryFromFile = async (file: File): Promise<void> => {
|
||||
const selectedCollection: Collection = explorer?.findSelectedCollection();
|
||||
if (!selectedCollection) {
|
||||
logError("No collection was selected", "LoadQueryPane.loadQueryFromFile");
|
||||
} else if (userContext.apiType === "Mongo") {
|
||||
selectedCollection.onNewMongoQueryClick(selectedCollection, undefined);
|
||||
} else {
|
||||
selectedCollection.onNewQueryClick(selectedCollection, undefined);
|
||||
}
|
||||
const reader = new FileReader();
|
||||
let fileData: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
reader.onload = (evt: any): void => {
|
||||
const fileData: string = evt.target.result;
|
||||
const queryTab = explorer.tabsManager.activeTab() as QueryTab;
|
||||
queryTab.initialEditorContent(fileData);
|
||||
queryTab.sqlQueryEditorContent(fileData);
|
||||
fileData = evt.target.result;
|
||||
|
||||
if (!selectedCollection) {
|
||||
logError("No collection was selected", "LoadQueryPane.loadQueryFromFile");
|
||||
} else if (userContext.apiType === "Mongo") {
|
||||
selectedCollection.onNewMongoQueryClick(selectedCollection, undefined);
|
||||
} else {
|
||||
selectedCollection.onNewQueryClick(selectedCollection, undefined, fileData);
|
||||
}
|
||||
};
|
||||
|
||||
reader.onerror = (): void => {
|
||||
|
||||
Reference in New Issue
Block a user