reviewed the files

This commit is contained in:
Archie Agarwal
2025-07-08 20:19:21 +05:30
parent d510ce408e
commit d1ba9b7bce
3 changed files with 29 additions and 22 deletions
@@ -330,7 +330,6 @@ 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)
// @ts-expect-error: rawDataModel is intentionally accessed for test validation // @ts-expect-error: rawDataModel is intentionally accessed for test validation
expect(instance.collection.rawDataModel.indexingPolicy).toEqual(mockIndexingPolicy); expect(instance.collection.rawDataModel.indexingPolicy).toEqual(mockIndexingPolicy);
}); });
@@ -1,4 +1,7 @@
import { CircleFilled } from "@fluentui/react-icons";
import type { IIndexMetric } from "Explorer/Tabs/QueryTab/ResultsView"; import type { IIndexMetric } from "Explorer/Tabs/QueryTab/ResultsView";
import { useIndexAdvisorStyles } from "Explorer/Tabs/QueryTab/StylesAdvisor";
import * as React from "react";
interface IndexObject { interface IndexObject {
index: string; index: string;
impact: string; impact: string;
@@ -86,3 +89,26 @@ export function parseIndexMetrics(indexMetrics: string | IndexMetricsJson): {
} }
return { included, notIncluded }; return { included, notIncluded };
} }
export const renderImpactDots = (impact: string): JSX.Element => {
const style = useIndexAdvisorStyles();
let count = 0;
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) => (
<CircleFilled key={i} className={style.indexAdvisorImpactDot} />
))}
</div>
);
};
+3 -21
View File
@@ -26,15 +26,14 @@ import {
ArrowDownloadRegular, ArrowDownloadRegular,
ChevronDown20Regular, ChevronDown20Regular,
ChevronRight20Regular, ChevronRight20Regular,
CircleFilled, CopyRegular
CopyRegular,
} from "@fluentui/react-icons"; } from "@fluentui/react-icons";
import copy from "clipboard-copy"; import copy from "clipboard-copy";
import { HttpHeaders } from "Common/Constants"; import { HttpHeaders } from "Common/Constants";
import MongoUtility from "Common/MongoUtility"; import MongoUtility from "Common/MongoUtility";
import { QueryMetrics } from "Contracts/DataModels"; import { QueryMetrics } from "Contracts/DataModels";
import { EditorReact } from "Explorer/Controls/Editor/EditorReact"; import { EditorReact } from "Explorer/Controls/Editor/EditorReact";
import { parseIndexMetrics } from "Explorer/Tabs/QueryTab/IndexAdvisorUtils"; import { parseIndexMetrics, renderImpactDots } from "Explorer/Tabs/QueryTab/IndexAdvisorUtils";
import { IDocument, useQueryMetadataStore } from "Explorer/Tabs/QueryTab/QueryTabComponent"; import { IDocument, useQueryMetadataStore } from "Explorer/Tabs/QueryTab/QueryTabComponent";
import { useQueryTabStyles } from "Explorer/Tabs/QueryTab/Styles"; import { useQueryTabStyles } from "Explorer/Tabs/QueryTab/Styles";
import React, { useCallback, useEffect, useState } from "react"; import React, { useCallback, useEffect, useState } from "react";
@@ -569,7 +568,7 @@ export const IndexAdvisorTab: React.FC = () => {
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 = {
query: userQuery || "SELECT TOP 10 c.id FROM c WHERE c.Item = 'value1234' ", query: userQuery,
}; };
const sdkResponse = await client() const sdkResponse = await client()
.database(databaseId) .database(databaseId)
@@ -687,23 +686,6 @@ export const IndexAdvisorTab: React.FC = () => {
setIsUpdating(false); setIsUpdating(false);
} }
}; };
const renderImpactDots = (impact: string) => {
let count = 0;
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) => (
<CircleFilled key={i} className={style.indexAdvisorImpactDot} />
))}
</div>
);
};
const renderRow = (item: IIndexMetric, index: number) => { const renderRow = (item: IIndexMetric, index: number) => {
const isHeader = item.section === "Header"; const isHeader = item.section === "Header";