mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-10-13 15:28:05 +01:00
Updated the files
This commit is contained in:
parent
e164568aef
commit
9c868b29c9
@ -331,7 +331,7 @@ describe("SettingsComponent - indexing policy subscription", () => {
|
|||||||
expect(wrapper.state("indexingPolicyContent")).toEqual(mockIndexingPolicy);
|
expect(wrapper.state("indexingPolicyContent")).toEqual(mockIndexingPolicy);
|
||||||
expect(wrapper.state("indexingPolicyContentBaseline")).toEqual(mockIndexingPolicy);
|
expect(wrapper.state("indexingPolicyContentBaseline")).toEqual(mockIndexingPolicy);
|
||||||
// Optionally, check the collection's rawDataModel (ignore TS error in test)
|
// Optionally, check the collection's rawDataModel (ignore TS error in test)
|
||||||
// @ts-expect-error
|
// @ts-expect-error: rawDataModel is intentionally accessed for test validation
|
||||||
expect(instance.collection.rawDataModel.indexingPolicy).toEqual(mockIndexingPolicy);
|
expect(instance.collection.rawDataModel.indexingPolicy).toEqual(mockIndexingPolicy);
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -303,7 +303,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
if (this.props.settingsTab.isActive()) {
|
if (this.props.settingsTab.isActive()) {
|
||||||
useCommandBar.getState().setContextButtons(this.getTabsButtons());
|
useCommandBar.getState().setContextButtons(this.getTabsButtons());
|
||||||
}
|
}
|
||||||
this.unsubscribe = useIndexingPolicyStore.subscribe((_,) => {
|
this.unsubscribe = useIndexingPolicyStore.subscribe(() => {
|
||||||
this.refreshCollectionData();
|
this.refreshCollectionData();
|
||||||
},
|
},
|
||||||
(state) => state.indexingPolicies[this.collection.id()]
|
(state) => state.indexingPolicies[this.collection.id()]
|
||||||
@ -311,7 +311,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
this.refreshCollectionData();
|
this.refreshCollectionData();
|
||||||
}
|
}
|
||||||
componentWillUnmount(): void {
|
componentWillUnmount(): void {
|
||||||
if (this.unsubscribe) this.unsubscribe();
|
if (this.unsubscribe) { this.unsubscribe(); }
|
||||||
}
|
}
|
||||||
componentDidUpdate(): void {
|
componentDidUpdate(): void {
|
||||||
if (this.props.settingsTab.isActive()) {
|
if (this.props.settingsTab.isActive()) {
|
||||||
|
@ -43,12 +43,12 @@ export function parseIndexMetrics(indexMetrics: string | IndexMetricsJson): {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let path = "/unknown/*";
|
let path = "/unknown/*";
|
||||||
const pathRegex = /\/[^\/\s*?]+(?:\/[^\/\s*?]+)*(\/\*|\?)/;
|
const pathRegex = /\/[^/\s*?]+(?:\/[^/\s*?]+)*(\/\*|\?)/;
|
||||||
const match = index.match(pathRegex);
|
const match = index.match(pathRegex);
|
||||||
if (match) {
|
if (match) {
|
||||||
path = match[0];
|
path = match[0];
|
||||||
} else {
|
} else {
|
||||||
const simplePathRegex = /\/[^\/\s]+/;
|
const simplePathRegex = /\/[^/\s]+/;
|
||||||
const simpleMatch = index.match(simplePathRegex);
|
const simpleMatch = index.match(simplePathRegex);
|
||||||
if (simpleMatch) {
|
if (simpleMatch) {
|
||||||
path = simpleMatch[0] + "/*";
|
path = simpleMatch[0] + "/*";
|
||||||
|
@ -117,8 +117,6 @@ test("calls replace when update policy is confirmed", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("calls replace when update button is clicked", async () => {
|
test("calls replace when update button is clicked", async () => {
|
||||||
const cosmos = require("Common/CosmosClient");
|
|
||||||
const mockReplace = cosmos.client().database().container().replace;
|
|
||||||
render(<IndexAdvisorTab />);
|
render(<IndexAdvisorTab />);
|
||||||
await waitFor(() => expect(screen.getByText("/bar/?")).toBeInTheDocument());
|
await waitFor(() => expect(screen.getByText("/bar/?")).toBeInTheDocument());
|
||||||
const checkboxes = screen.getAllByRole("checkbox");
|
const checkboxes = screen.getAllByRole("checkbox");
|
||||||
@ -140,7 +138,7 @@ test("selects all indexes when select-all is clicked", async () => {
|
|||||||
const checkboxes = screen.getAllByRole("checkbox");
|
const checkboxes = screen.getAllByRole("checkbox");
|
||||||
|
|
||||||
fireEvent.click(checkboxes[0]);
|
fireEvent.click(checkboxes[0]);
|
||||||
checkboxes.forEach((cb, i) => {
|
checkboxes.forEach((cb) => {
|
||||||
expect(cb).toBeChecked();
|
expect(cb).toBeChecked();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -174,7 +172,6 @@ test("calls handleError if fetchIndexMetrics throws", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("calls handleError if fetchIndexMetrics throws2nd", async () => {
|
test("calls handleError if fetchIndexMetrics throws2nd", async () => {
|
||||||
const cosmos = require("Common/CosmosClient");
|
|
||||||
mockFetchAll.mockRejectedValueOnce(new Error("fail"));
|
mockFetchAll.mockRejectedValueOnce(new Error("fail"));
|
||||||
|
|
||||||
render(<IndexAdvisorTab />);
|
render(<IndexAdvisorTab />);
|
||||||
|
@ -28,6 +28,7 @@ import { TabsState, useTabs } from "hooks/useTabs";
|
|||||||
import React, { Fragment, createRef } from "react";
|
import React, { Fragment, createRef } from "react";
|
||||||
import "react-splitter-layout/lib/index.css";
|
import "react-splitter-layout/lib/index.css";
|
||||||
import { format } from "react-string-format";
|
import { format } from "react-string-format";
|
||||||
|
import create from "zustand";
|
||||||
import QueryCommandIcon from "../../../../images/CopilotCommand.svg";
|
import QueryCommandIcon from "../../../../images/CopilotCommand.svg";
|
||||||
import LaunchCopilot from "../../../../images/CopilotTabIcon.svg";
|
import LaunchCopilot from "../../../../images/CopilotTabIcon.svg";
|
||||||
import DownloadQueryIcon from "../../../../images/DownloadQuery.svg";
|
import DownloadQueryIcon from "../../../../images/DownloadQuery.svg";
|
||||||
@ -55,7 +56,6 @@ import { BrowseQueriesPane } from "../../Panes/BrowseQueriesPane/BrowseQueriesPa
|
|||||||
import { SaveQueryPane } from "../../Panes/SaveQueryPane/SaveQueryPane";
|
import { SaveQueryPane } from "../../Panes/SaveQueryPane/SaveQueryPane";
|
||||||
import TabsBase from "../TabsBase";
|
import TabsBase from "../TabsBase";
|
||||||
import "./QueryTabComponent.less";
|
import "./QueryTabComponent.less";
|
||||||
import create from "zustand";
|
|
||||||
|
|
||||||
export interface QueryMetadataStore {
|
export interface QueryMetadataStore {
|
||||||
userQuery: string;
|
userQuery: string;
|
||||||
@ -212,7 +212,7 @@ class QueryTabComponentImpl extends React.Component<QueryTabComponentImplProps,
|
|||||||
enabled: !!this.state.sqlQueryEditorContent && this.state.sqlQueryEditorContent.length > 0,
|
enabled: !!this.state.sqlQueryEditorContent && this.state.sqlQueryEditorContent.length > 0,
|
||||||
visible: true,
|
visible: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const isSaveQueryBtnEnabled = userContext.apiType === "SQL" || userContext.apiType === "Gremlin";
|
const isSaveQueryBtnEnabled = userContext.apiType === "SQL" || userContext.apiType === "Gremlin";
|
||||||
this.saveQueryButton = {
|
this.saveQueryButton = {
|
||||||
enabled: isSaveQueryBtnEnabled,
|
enabled: isSaveQueryBtnEnabled,
|
||||||
@ -276,9 +276,9 @@ class QueryTabComponentImpl extends React.Component<QueryTabComponentImplProps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onExecuteQueryClick = async (): Promise<void> => {
|
public onExecuteQueryClick = async (): Promise<void> => {
|
||||||
const query1=this.state.sqlQueryEditorContent;
|
const query1 = this.state.sqlQueryEditorContent;
|
||||||
const db = this.props.collection.databaseId;
|
const db = this.props.collection.databaseId;
|
||||||
const container = this.props.collection.id();
|
const container = this.props.collection.id();
|
||||||
useQueryMetadataStore.getState().setMetadata(query1, db, container);
|
useQueryMetadataStore.getState().setMetadata(query1, db, container);
|
||||||
this._iterator = undefined;
|
this._iterator = undefined;
|
||||||
|
|
||||||
@ -376,9 +376,9 @@ class QueryTabComponentImpl extends React.Component<QueryTabComponentImplProps,
|
|||||||
this._iterator = this.props.isPreferredApiMongoDB
|
this._iterator = this.props.isPreferredApiMongoDB
|
||||||
? queryIterator(this.props.collection.databaseId, this.props.viewModelcollection, query)
|
? queryIterator(this.props.collection.databaseId, this.props.viewModelcollection, query)
|
||||||
: queryDocuments(this.props.collection.databaseId, this.props.collection.id(), query, {
|
: queryDocuments(this.props.collection.databaseId, this.props.collection.id(), query, {
|
||||||
enableCrossPartitionQuery: HeadersUtility.shouldEnableCrossPartitionKey(),
|
enableCrossPartitionQuery: HeadersUtility.shouldEnableCrossPartitionKey(),
|
||||||
abortSignal: this.queryAbortController.signal,
|
abortSignal: this.queryAbortController.signal,
|
||||||
} as unknown as FeedOptions);
|
} as unknown as FeedOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this._queryDocumentsPage(firstItemIndex);
|
await this._queryDocumentsPage(firstItemIndex);
|
||||||
|
@ -558,7 +558,7 @@ export const IndexAdvisorTab: React.FC = () => {
|
|||||||
const [isUpdating, setIsUpdating] = useState(false);
|
const [isUpdating, setIsUpdating] = useState(false);
|
||||||
const [justUpdatedPolicy, setJustUpdatedPolicy] = useState(false);
|
const [justUpdatedPolicy, setJustUpdatedPolicy] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchIndexMetrics() {
|
const fetchIndexMetrics = async () => {
|
||||||
const clearMessage = logConsoleProgress(`Querying items with IndexMetrics in container ${containerId}`);
|
const clearMessage = logConsoleProgress(`Querying items with IndexMetrics in container ${containerId}`);
|
||||||
try {
|
try {
|
||||||
const querySpec = {
|
const querySpec = {
|
||||||
@ -585,7 +585,7 @@ export const IndexAdvisorTab: React.FC = () => {
|
|||||||
}, [userQuery, databaseId, containerId]);
|
}, [userQuery, databaseId, containerId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!indexMetrics) { return };
|
if (!indexMetrics) { return }
|
||||||
|
|
||||||
const { included, notIncluded } = parseIndexMetrics(indexMetrics);
|
const { included, notIncluded } = parseIndexMetrics(indexMetrics);
|
||||||
setIncludedIndexes(included);
|
setIncludedIndexes(included);
|
||||||
@ -686,9 +686,9 @@ export const IndexAdvisorTab: React.FC = () => {
|
|||||||
};
|
};
|
||||||
const renderImpactDots = (impact: string) => {
|
const renderImpactDots = (impact: string) => {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
if (impact === "High") count = 3;
|
if (impact === "High") { count = 3; }
|
||||||
else if (impact === "Medium") count = 2;
|
else if (impact === "Medium") { count = 2; }
|
||||||
else if (impact === "Low") count = 1;
|
else if (impact === "Low") { count = 1; }
|
||||||
return (
|
return (
|
||||||
<div className={style.indexAdvisorImpactDots}>
|
<div className={style.indexAdvisorImpactDots}>
|
||||||
{Array.from({ length: count }).map((_, i) => (
|
{Array.from({ length: count }).map((_, i) => (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user