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