From a0853c916743a86885ff3405018013355a97d5a5 Mon Sep 17 00:00:00 2001 From: Sung-Hyun Kang Date: Tue, 14 Jan 2025 14:45:19 -0600 Subject: [PATCH 1/2] testing --- package.json | 1 + src/Common/IteratorUtilities.ts | 12 ++++------- src/Common/dataAccess/queryDocumentsPage.ts | 6 +++--- .../Tabs/QueryTab/QueryTabComponent.tsx | 20 +++++++++---------- webpack.config.js | 10 +++++++++- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 16e80c5e5..7ddbe9e28 100644 --- a/package.json +++ b/package.json @@ -228,6 +228,7 @@ "compile:fullStrict": "tsc -p ./tsconfig.json --strictNullChecks", "generateARMClients": "npx ts-node utils/armClientGenerator/generator.ts" }, + "sideEffects": false, "repository": { "type": "git", "url": "git+https://github.com/Azure/cosmos-explorer" diff --git a/src/Common/IteratorUtilities.ts b/src/Common/IteratorUtilities.ts index 6283488b8..87ce976c5 100644 --- a/src/Common/IteratorUtilities.ts +++ b/src/Common/IteratorUtilities.ts @@ -1,4 +1,4 @@ -import { QueryOperationOptions } from "@azure/cosmos"; +// import { QueryOperationOptions } from "@azure/cosmos"; import { QueryResults } from "../Contracts/ViewModels"; interface QueryResponse { @@ -11,17 +11,13 @@ interface QueryResponse { } export interface MinimalQueryIterator { - fetchNext: (queryOperationOptions?: QueryOperationOptions) => Promise; + fetchNext: () => Promise; } // Pick, "fetchNext">; -export function nextPage( - documentsIterator: MinimalQueryIterator, - firstItemIndex: number, - queryOperationOptions?: QueryOperationOptions, -): Promise { - return documentsIterator.fetchNext(queryOperationOptions).then((response) => { +export function nextPage(documentsIterator: MinimalQueryIterator, firstItemIndex: number): Promise { + return documentsIterator.fetchNext().then((response) => { const documents = response.resources; // eslint-disable-next-line @typescript-eslint/no-explicit-any const headers = (response as any).headers || {}; // TODO this is a private key. Remove any diff --git a/src/Common/dataAccess/queryDocumentsPage.ts b/src/Common/dataAccess/queryDocumentsPage.ts index 17e84ba28..1c9388898 100644 --- a/src/Common/dataAccess/queryDocumentsPage.ts +++ b/src/Common/dataAccess/queryDocumentsPage.ts @@ -1,4 +1,4 @@ -import { QueryOperationOptions } from "@azure/cosmos"; +// import { QueryOperationOptions } from "@azure/cosmos"; import { QueryResults } from "../../Contracts/ViewModels"; import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils"; import { getEntityName } from "../DocumentUtility"; @@ -9,13 +9,13 @@ export const queryDocumentsPage = async ( resourceName: string, documentsIterator: MinimalQueryIterator, firstItemIndex: number, - queryOperationOptions?: QueryOperationOptions, + // queryOperationOptions?: QueryOperationOptions, ): Promise => { const entityName = getEntityName(); const clearMessage = logConsoleProgress(`Querying ${entityName} for container ${resourceName}`); try { - const result: QueryResults = await nextPage(documentsIterator, firstItemIndex, queryOperationOptions); + const result: QueryResults = await nextPage(documentsIterator, firstItemIndex); const itemCount = (result.documents && result.documents.length) || 0; logConsoleInfo(`Successfully fetched ${itemCount} ${entityName} for container ${resourceName}`); return result; diff --git a/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx b/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx index 2347e0822..055a3c5a7 100644 --- a/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx +++ b/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable no-console */ -import { FeedOptions, QueryOperationOptions } from "@azure/cosmos"; +import { FeedOptions } from "@azure/cosmos"; import QueryError, { createMonacoErrorLocationResolver, createMonacoMarkersForQueryErrors } from "Common/QueryError"; import { SplitterDirection } from "Common/Splitter"; import { Platform, configContext } from "ConfigContext"; @@ -18,7 +18,7 @@ import { CosmosFluentProvider } from "Explorer/Theme/ThemeUtil"; import { useSelectedNode } from "Explorer/useSelectedNode"; import { KeyboardAction } from "KeyboardShortcuts"; import { QueryConstants } from "Shared/Constants"; -import { LocalStorageUtility, StorageKey, getRUThreshold, ruThresholdEnabled } from "Shared/StorageUtility"; +import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility"; import { Action } from "Shared/Telemetry/TelemetryConstants"; import { Allotment } from "allotment"; import { QueryCopilotState, useQueryCopilot } from "hooks/useQueryCopilot"; @@ -368,19 +368,19 @@ class QueryTabComponentImpl extends React.Component await queryDocumentsPage( this.props.collection && this.props.collection.id(), this._iterator, firstItemIndex, - queryOperationOptions, + // queryOperationOptions, ); this.props.tabsBaseInstance.isExecuting(true); this.setState({ diff --git a/webpack.config.js b/webpack.config.js index c21baf3ef..98a817542 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -193,7 +193,12 @@ module.exports = function (_env = {}, argv = {}) { ]; if (argv.analyze) { - plugins.push(new BundleAnalyzerPlugin()); + plugins.push( + new BundleAnalyzerPlugin({ + analyzerMode: "static", + reportFilename: "bundle-report.html", + }), + ); } return { @@ -256,6 +261,9 @@ module.exports = function (_env = {}, argv = {}) { }, }), ], + splitChunks: { + chunks: "all", + }, }, watch: false, // Hack since it is hard to disable watch entirely with webpack dev server https://github.com/webpack/webpack-dev-server/issues/1251#issuecomment-654240734 From 3ae92f2398b750cc59610c859211a60c518c9195 Mon Sep 17 00:00:00 2001 From: Sung-Hyun Kang Date: Tue, 14 Jan 2025 17:16:02 -0600 Subject: [PATCH 2/2] testing icons --- package.json | 1 - src/GalleryViewer/GalleryViewer.tsx | 4 ++-- src/HostedExplorer.tsx | 4 ++-- src/Main.tsx | 4 ++-- src/NotebookViewer/NotebookViewer.tsx | 4 ++-- src/SelfServe/SelfServe.tsx | 4 ++-- src/setupTests.ts | 4 ++-- webpack.config.js | 8 ++++++++ 8 files changed, 20 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 7ddbe9e28..16e80c5e5 100644 --- a/package.json +++ b/package.json @@ -228,7 +228,6 @@ "compile:fullStrict": "tsc -p ./tsconfig.json --strictNullChecks", "generateARMClients": "npx ts-node utils/armClientGenerator/generator.ts" }, - "sideEffects": false, "repository": { "type": "git", "url": "git+https://github.com/Azure/cosmos-explorer" diff --git a/src/GalleryViewer/GalleryViewer.tsx b/src/GalleryViewer/GalleryViewer.tsx index 2026415af..9d7693be1 100644 --- a/src/GalleryViewer/GalleryViewer.tsx +++ b/src/GalleryViewer/GalleryViewer.tsx @@ -1,4 +1,4 @@ -import { initializeIcons, Link, Text } from "@fluentui/react"; +import { Link, Text } from "@fluentui/react"; import "bootstrap/dist/css/bootstrap.css"; import * as React from "react"; import * as ReactDOM from "react-dom"; @@ -20,7 +20,7 @@ const createAccountUrl = "https://aka.ms/cosmos-create-account-portal"; const onInit = async () => { const dataExplorerUrl = new URL("./", window.location.href).href; - initializeIcons(); + // initializeIcons(); await initializeConfiguration(); const galleryViewerProps = GalleryUtils.getGalleryViewerProps(window.location.search); diff --git a/src/HostedExplorer.tsx b/src/HostedExplorer.tsx index 4dc26fb4e..edb275fa3 100644 --- a/src/HostedExplorer.tsx +++ b/src/HostedExplorer.tsx @@ -1,4 +1,4 @@ -import { initializeIcons } from "@fluentui/react"; +// import { initializeIcons } from "@fluentui/react"; import { useBoolean } from "@fluentui/react-hooks"; import { AadAuthorizationFailure } from "Platform/Hosted/Components/AadAuthorizationFailure"; import * as React from "react"; @@ -22,7 +22,7 @@ import { useAADAuth } from "./hooks/useAADAuth"; import { useConfig } from "./hooks/useConfig"; import { useTokenMetadata } from "./hooks/usePortalAccessToken"; -initializeIcons(); +// initializeIcons(); const App: React.FunctionComponent = () => { // For handling encrypted portal tokens sent via query paramter diff --git a/src/Main.tsx b/src/Main.tsx index 52972b462..2f0c399c0 100644 --- a/src/Main.tsx +++ b/src/Main.tsx @@ -2,7 +2,7 @@ import "./ReactDevTools"; // CSS Dependencies -import { initializeIcons, loadTheme } from "@fluentui/react"; +import { loadTheme } from "@fluentui/react"; import { QuickstartCarousel } from "Explorer/Quickstart/QuickstartCarousel"; import { MongoQuickstartTutorial } from "Explorer/Quickstart/Tutorials/MongoQuickstartTutorial"; import { SQLQuickstartTutorial } from "Explorer/Quickstart/Tutorials/SQLQuickstartTutorial"; @@ -62,7 +62,7 @@ import "./Shared/appInsights"; import { useConfig } from "./hooks/useConfig"; import { useKnockoutExplorer } from "./hooks/useKnockoutExplorer"; -initializeIcons(); +// initializeIcons(); const App: React.FunctionComponent = () => { const isCarouselOpen = useCarousel((state) => state.shouldOpen); diff --git a/src/NotebookViewer/NotebookViewer.tsx b/src/NotebookViewer/NotebookViewer.tsx index 2bb1441b2..63c19dee0 100644 --- a/src/NotebookViewer/NotebookViewer.tsx +++ b/src/NotebookViewer/NotebookViewer.tsx @@ -1,4 +1,4 @@ -import { initializeIcons } from "@fluentui/react"; +// import { initializeIcons } from "@fluentui/react"; import "bootstrap/dist/css/bootstrap.css"; import React from "react"; import * as ReactDOM from "react-dom"; @@ -14,7 +14,7 @@ import { IGalleryItem, JunoClient } from "../Juno/JunoClient"; import * as GalleryUtils from "../Utils/GalleryUtils"; const onInit = async () => { - initializeIcons(); + // initializeIcons(); await initializeConfiguration(); const galleryViewerProps = GalleryUtils.getGalleryViewerProps(window.location.search); const notebookViewerProps = GalleryUtils.getNotebookViewerProps(window.location.search); diff --git a/src/SelfServe/SelfServe.tsx b/src/SelfServe/SelfServe.tsx index 932951b34..5b4c02b85 100644 --- a/src/SelfServe/SelfServe.tsx +++ b/src/SelfServe/SelfServe.tsx @@ -1,4 +1,4 @@ -import { initializeIcons, Spinner, SpinnerSize } from "@fluentui/react"; +import { Spinner, SpinnerSize } from "@fluentui/react"; import * as React from "react"; import ReactDOM from "react-dom"; import { withTranslation } from "react-i18next"; @@ -13,7 +13,7 @@ import "./SelfServe.less"; import { SelfServeComponent } from "./SelfServeComponent"; import { SelfServeDescriptor } from "./SelfServeTypes"; import { SelfServeType } from "./SelfServeUtils"; -initializeIcons(); +// initializeIcons(); const loadTranslationFile = async (className: string): Promise => { const language = i18n.languages[0]; diff --git a/src/setupTests.ts b/src/setupTests.ts index 04c470c83..cde2c80b7 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -1,11 +1,11 @@ -import { initializeIcons } from "@fluentui/react"; +// import { initializeIcons } from "@fluentui/react"; import { configure } from "enzyme"; import Adapter from "enzyme-adapter-react-16"; import "jest-canvas-mock"; import enableHooks from "jest-react-hooks-shallow"; import { TextDecoder, TextEncoder } from "util"; configure({ adapter: new Adapter() }); -initializeIcons(); +// initializeIcons(); if (typeof window.URL.createObjectURL === "undefined") { Object.defineProperty(window.URL, "createObjectURL", { value: () => {} }); diff --git a/webpack.config.js b/webpack.config.js index 98a817542..d9e34e1a9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -263,6 +263,14 @@ module.exports = function (_env = {}, argv = {}) { ], splitChunks: { chunks: "all", + cacheGroups: { + fluentIcons: { + test: /[\\/]node_modules[\\/]@fluentui[\\/](font-icons-mdl2|react-icons)/, + name: "fluent-icons", + chunks: "all", + enforce: true, + }, + }, }, }, watch: false,