From bfd4948fb988307959a1984a7d0b9a257105a67c Mon Sep 17 00:00:00 2001 From: Hardikkumar Nai <80053762+hardiknai-techm@users.noreply.github.com> Date: Tue, 12 Oct 2021 20:08:34 +0530 Subject: [PATCH 1/3] absulte_path setting (#984) * absulte_path setting * resolve build time error --- .vscode/settings.json | 3 +- jest.config.js | 2 ++ src/Explorer/Panes/AddCollectionPanel.tsx | 28 +++++++++---------- .../CassandraAddCollectionPane.tsx | 18 ++++++------ .../DeleteCollectionConfirmationPane.tsx | 26 ++++++++--------- .../Panes/DeleteDatabaseConfirmationPanel.tsx | 24 ++++++++-------- .../Panes/SettingsPane/SettingsPane.tsx | 16 +++++------ .../Panes/StringInputPane/StringInputPane.tsx | 6 ++-- .../Panes/UploadFilePane/UploadFilePane.tsx | 6 ++-- .../Panes/UploadItemsPane/UploadItemsPane.tsx | 6 ++-- tsconfig.json | 22 ++++----------- webpack.config.js | 1 + 12 files changed, 76 insertions(+), 82 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ba70984cf..0716cae8f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,5 +22,6 @@ "editor.codeActionsOnSave": { "source.fixAll.eslint": true, "source.organizeImports": true - } + }, + "typescript.preferences.importModuleSpecifier": "non-relative" } diff --git a/jest.config.js b/jest.config.js index 7e8ceb81e..e08536252 100644 --- a/jest.config.js +++ b/jest.config.js @@ -129,6 +129,8 @@ module.exports = { // The test environment that will be used for testing // testEnvironment: "jest-environment-jsdom", + modulePaths: ["node_modules", "/src"], + // Options that will be passed to the testEnvironment // testEnvironmentOptions: {}, diff --git a/src/Explorer/Panes/AddCollectionPanel.tsx b/src/Explorer/Panes/AddCollectionPanel.tsx index 56a76fc97..028b3c426 100644 --- a/src/Explorer/Panes/AddCollectionPanel.tsx +++ b/src/Explorer/Panes/AddCollectionPanel.tsx @@ -13,21 +13,21 @@ import { Text, TooltipHost, } from "@fluentui/react"; +import * as Constants from "Common/Constants"; +import { createCollection } from "Common/dataAccess/createCollection"; +import { getErrorMessage, getErrorStack } from "Common/ErrorHandlingUtils"; +import { configContext, Platform } from "ConfigContext"; +import * as DataModels from "Contracts/DataModels"; +import { SubscriptionType } from "Contracts/SubscriptionType"; +import { useSidePanel } from "hooks/useSidePanel"; import React from "react"; -import * as Constants from "../../Common/Constants"; -import { createCollection } from "../../Common/dataAccess/createCollection"; -import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils"; -import { configContext, Platform } from "../../ConfigContext"; -import * as DataModels from "../../Contracts/DataModels"; -import { SubscriptionType } from "../../Contracts/SubscriptionType"; -import { useSidePanel } from "../../hooks/useSidePanel"; -import { CollectionCreation } from "../../Shared/Constants"; -import { Action } from "../../Shared/Telemetry/TelemetryConstants"; -import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; -import { userContext } from "../../UserContext"; -import { getCollectionName } from "../../Utils/APITypeUtils"; -import { isCapabilityEnabled, isServerlessAccount } from "../../Utils/CapabilityUtils"; -import { getUpsellMessage } from "../../Utils/PricingUtils"; +import { CollectionCreation } from "Shared/Constants"; +import { Action } from "Shared/Telemetry/TelemetryConstants"; +import * as TelemetryProcessor from "Shared/Telemetry/TelemetryProcessor"; +import { userContext } from "UserContext"; +import { getCollectionName } from "Utils/APITypeUtils"; +import { isCapabilityEnabled, isServerlessAccount } from "Utils/CapabilityUtils"; +import { getUpsellMessage } from "Utils/PricingUtils"; import { CollapsibleSectionComponent } from "../Controls/CollapsiblePanel/CollapsibleSectionComponent"; import { ThroughputInput } from "../Controls/ThroughputInput/ThroughputInput"; import Explorer from "../Explorer"; diff --git a/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.tsx b/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.tsx index 69e84ee03..64ee3fb3f 100644 --- a/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.tsx +++ b/src/Explorer/Panes/CassandraAddCollectionPane/CassandraAddCollectionPane.tsx @@ -1,14 +1,14 @@ import { Checkbox, Dropdown, IDropdownOption, Link, Stack, Text, TextField } from "@fluentui/react"; +import * as Constants from "Common/Constants"; +import { getErrorMessage, getErrorStack } from "Common/ErrorHandlingUtils"; +import { InfoTooltip } from "Common/Tooltip/InfoTooltip"; +import { useSidePanel } from "hooks/useSidePanel"; import React, { FunctionComponent, useState } from "react"; -import * as Constants from "../../../Common/Constants"; -import { getErrorMessage, getErrorStack } from "../../../Common/ErrorHandlingUtils"; -import { InfoTooltip } from "../../../Common/Tooltip/InfoTooltip"; -import { useSidePanel } from "../../../hooks/useSidePanel"; -import * as SharedConstants from "../../../Shared/Constants"; -import { Action } from "../../../Shared/Telemetry/TelemetryConstants"; -import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor"; -import { userContext } from "../../../UserContext"; -import { isServerlessAccount } from "../../../Utils/CapabilityUtils"; +import * as SharedConstants from "Shared/Constants"; +import { Action } from "Shared/Telemetry/TelemetryConstants"; +import * as TelemetryProcessor from "Shared/Telemetry/TelemetryProcessor"; +import { userContext } from "UserContext"; +import { isServerlessAccount } from "Utils/CapabilityUtils"; import { ThroughputInput } from "../../Controls/ThroughputInput/ThroughputInput"; import Explorer from "../../Explorer"; import { CassandraAPIDataClient } from "../../Tables/TableDataClient"; diff --git a/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx b/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx index 858ba3bc4..81eeb6621 100644 --- a/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx +++ b/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx @@ -1,18 +1,18 @@ import { Text, TextField } from "@fluentui/react"; +import { Areas } from "Common/Constants"; +import { deleteCollection } from "Common/dataAccess/deleteCollection"; +import DeleteFeedback from "Common/DeleteFeedback"; +import { getErrorMessage, getErrorStack } from "Common/ErrorHandlingUtils"; +import { Collection } from "Contracts/ViewModels"; +import { useSidePanel } from "hooks/useSidePanel"; +import { useTabs } from "hooks/useTabs"; import React, { FunctionComponent, useState } from "react"; -import { Areas } from "../../../Common/Constants"; -import { deleteCollection } from "../../../Common/dataAccess/deleteCollection"; -import DeleteFeedback from "../../../Common/DeleteFeedback"; -import { getErrorMessage, getErrorStack } from "../../../Common/ErrorHandlingUtils"; -import { Collection } from "../../../Contracts/ViewModels"; -import { useSidePanel } from "../../../hooks/useSidePanel"; -import { useTabs } from "../../../hooks/useTabs"; -import { DefaultExperienceUtility } from "../../../Shared/DefaultExperienceUtility"; -import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants"; -import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor"; -import { userContext } from "../../../UserContext"; -import { getCollectionName } from "../../../Utils/APITypeUtils"; -import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils"; +import { DefaultExperienceUtility } from "Shared/DefaultExperienceUtility"; +import { Action, ActionModifiers } from "Shared/Telemetry/TelemetryConstants"; +import * as TelemetryProcessor from "Shared/Telemetry/TelemetryProcessor"; +import { userContext } from "UserContext"; +import { getCollectionName } from "Utils/APITypeUtils"; +import * as NotificationConsoleUtils from "Utils/NotificationConsoleUtils"; import { useDatabases } from "../../useDatabases"; import { useSelectedNode } from "../../useSelectedNode"; import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm"; diff --git a/src/Explorer/Panes/DeleteDatabaseConfirmationPanel.tsx b/src/Explorer/Panes/DeleteDatabaseConfirmationPanel.tsx index 24fbb1cf5..88eb8d064 100644 --- a/src/Explorer/Panes/DeleteDatabaseConfirmationPanel.tsx +++ b/src/Explorer/Panes/DeleteDatabaseConfirmationPanel.tsx @@ -1,18 +1,18 @@ import { Text, TextField } from "@fluentui/react"; import { useBoolean } from "@fluentui/react-hooks"; +import { Areas } from "Common/Constants"; +import { deleteDatabase } from "Common/dataAccess/deleteDatabase"; +import DeleteFeedback from "Common/DeleteFeedback"; +import { getErrorMessage, getErrorStack } from "Common/ErrorHandlingUtils"; +import { Collection, Database } from "Contracts/ViewModels"; +import { useSidePanel } from "hooks/useSidePanel"; +import { useTabs } from "hooks/useTabs"; import React, { FunctionComponent, useState } from "react"; -import { Areas } from "../../Common/Constants"; -import { deleteDatabase } from "../../Common/dataAccess/deleteDatabase"; -import DeleteFeedback from "../../Common/DeleteFeedback"; -import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils"; -import { Collection, Database } from "../../Contracts/ViewModels"; -import { useSidePanel } from "../../hooks/useSidePanel"; -import { useTabs } from "../../hooks/useTabs"; -import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility"; -import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants"; -import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; -import { userContext } from "../../UserContext"; -import { logConsoleError } from "../../Utils/NotificationConsoleUtils"; +import { DefaultExperienceUtility } from "Shared/DefaultExperienceUtility"; +import { Action, ActionModifiers } from "Shared/Telemetry/TelemetryConstants"; +import * as TelemetryProcessor from "Shared/Telemetry/TelemetryProcessor"; +import { userContext } from "UserContext"; +import { logConsoleError } from "Utils/NotificationConsoleUtils"; import { useDatabases } from "../useDatabases"; import { useSelectedNode } from "../useSelectedNode"; import { PanelInfoErrorComponent, PanelInfoErrorProps } from "./PanelInfoErrorComponent"; diff --git a/src/Explorer/Panes/SettingsPane/SettingsPane.tsx b/src/Explorer/Panes/SettingsPane/SettingsPane.tsx index db0746276..92d432f34 100644 --- a/src/Explorer/Panes/SettingsPane/SettingsPane.tsx +++ b/src/Explorer/Panes/SettingsPane/SettingsPane.tsx @@ -1,13 +1,13 @@ import { Checkbox, ChoiceGroup, IChoiceGroupOption, SpinButton } from "@fluentui/react"; +import * as Constants from "Common/Constants"; +import { InfoTooltip } from "Common/Tooltip/InfoTooltip"; +import { configContext } from "ConfigContext"; +import { useSidePanel } from "hooks/useSidePanel"; import React, { FunctionComponent, MouseEvent, useState } from "react"; -import * as Constants from "../../../Common/Constants"; -import { InfoTooltip } from "../../../Common/Tooltip/InfoTooltip"; -import { configContext } from "../../../ConfigContext"; -import { useSidePanel } from "../../../hooks/useSidePanel"; -import { LocalStorageUtility, StorageKey } from "../../../Shared/StorageUtility"; -import * as StringUtility from "../../../Shared/StringUtility"; -import { userContext } from "../../../UserContext"; -import { logConsoleInfo } from "../../../Utils/NotificationConsoleUtils"; +import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility"; +import * as StringUtility from "Shared/StringUtility"; +import { userContext } from "UserContext"; +import { logConsoleInfo } from "Utils/NotificationConsoleUtils"; import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm"; export const SettingsPane: FunctionComponent = () => { diff --git a/src/Explorer/Panes/StringInputPane/StringInputPane.tsx b/src/Explorer/Panes/StringInputPane/StringInputPane.tsx index 8c8ce3b9e..eb9df4ad3 100644 --- a/src/Explorer/Panes/StringInputPane/StringInputPane.tsx +++ b/src/Explorer/Panes/StringInputPane/StringInputPane.tsx @@ -1,8 +1,8 @@ import { TextField } from "@fluentui/react"; +import * as ViewModels from "Contracts/ViewModels"; +import { useTabs } from "hooks/useTabs"; import React, { FormEvent, FunctionComponent, useState } from "react"; -import * as ViewModels from "../../../Contracts/ViewModels"; -import { useTabs } from "../../../hooks/useTabs"; -import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../../../Utils/NotificationConsoleUtils"; +import { logConsoleError, logConsoleInfo, logConsoleProgress } from "Utils/NotificationConsoleUtils"; import * as FileSystemUtil from "../../Notebook/FileSystemUtil"; import { NotebookContentItem } from "../../Notebook/NotebookContentItem"; import NotebookV2Tab from "../../Tabs/NotebookV2Tab"; diff --git a/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx b/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx index 7a5296adb..d60ee4b27 100644 --- a/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx +++ b/src/Explorer/Panes/UploadFilePane/UploadFilePane.tsx @@ -1,7 +1,7 @@ +import { Upload } from "Common/Upload/Upload"; +import { useSidePanel } from "hooks/useSidePanel"; import React, { ChangeEvent, FunctionComponent, useState } from "react"; -import { Upload } from "../../../Common/Upload/Upload"; -import { useSidePanel } from "../../../hooks/useSidePanel"; -import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../../../Utils/NotificationConsoleUtils"; +import { logConsoleError, logConsoleInfo, logConsoleProgress } from "Utils/NotificationConsoleUtils"; import { NotebookContentItem } from "../../Notebook/NotebookContentItem"; import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm"; diff --git a/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx b/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx index 62c8f67cf..388b8d944 100644 --- a/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx +++ b/src/Explorer/Panes/UploadItemsPane/UploadItemsPane.tsx @@ -1,8 +1,8 @@ import { DetailsList, DetailsListLayoutMode, IColumn, SelectionMode } from "@fluentui/react"; +import { Upload } from "Common/Upload/Upload"; +import { UploadDetailsRecord } from "Contracts/ViewModels"; import React, { ChangeEvent, FunctionComponent, useState } from "react"; -import { Upload } from "../../../Common/Upload/Upload"; -import { UploadDetailsRecord } from "../../../Contracts/ViewModels"; -import { logConsoleError } from "../../../Utils/NotificationConsoleUtils"; +import { logConsoleError } from "Utils/NotificationConsoleUtils"; import { getErrorMessage } from "../../Tables/Utilities"; import { useSelectedNode } from "../../useSelectedNode"; import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm"; diff --git a/tsconfig.json b/tsconfig.json index 45097fb68..39dad0788 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,18 +15,13 @@ "target": "es2017", "experimentalDecorators": true, "emitDecoratorMetadata": true, - "lib": [ - "es5", - "es6", - "dom" - ], + "lib": ["es5", "es6", "dom"], "jsx": "react", "moduleResolution": "node", "resolveJsonModule": true, "noEmit": true, - "types": [ - "jest" - ] + "types": ["jest"], + "baseUrl": "src" }, "typedocOptions": { "entryPoints": [ @@ -42,11 +37,6 @@ "includes": "./src/SelfServe/Documentation", "disableSources": true }, - "include": [ - "./src/**/*", - "./utils/**/*" - ], - "exclude": [ - "./src/**/__mocks__/**/*" - ] -} \ No newline at end of file + "include": ["src", "./src/**/*", "./utils/**/*"], + "exclude": ["./src/**/__mocks__/**/*"] +} diff --git a/webpack.config.js b/webpack.config.js index e6bcbe1e0..de87af5a2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -227,6 +227,7 @@ module.exports = function (_env = {}, argv = {}) { rules, }, resolve: { + modules: [path.resolve(__dirname, "src"), "node_modules"], alias: { process: "process/browser", }, From aff713309511c928e7e87ec1e95d6f2f9fc48fec Mon Sep 17 00:00:00 2001 From: vaidankarswapnil <81285216+vaidankarswapnil@users.noreply.github.com> Date: Tue, 12 Oct 2021 20:37:06 +0530 Subject: [PATCH 2/3] Fix eslint issues for TableCommands and other files (#1132) --- .eslintignore | 12 ++--- .../Tables/DataTable/DataTableOperations.ts | 45 ++++++++++--------- .../Tables/DataTable/TableCommands.ts | 24 +++++----- .../Tables/DataTable/TableEntityCache.ts | 4 +- src/Explorer/Tables/Entities.ts | 3 +- 5 files changed, 42 insertions(+), 46 deletions(-) diff --git a/.eslintignore b/.eslintignore index f8d1587bb..12dfbf9c2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -81,17 +81,13 @@ src/Explorer/Tables/DataTable/DataTableBindingManager.ts src/Explorer/Tables/DataTable/DataTableBuilder.ts src/Explorer/Tables/DataTable/DataTableContextMenu.ts src/Explorer/Tables/DataTable/DataTableOperationManager.ts -src/Explorer/Tables/DataTable/DataTableOperations.ts +# src/Explorer/Tables/DataTable/DataTableOperations.ts src/Explorer/Tables/DataTable/DataTableViewModel.ts -src/Explorer/Tables/DataTable/TableCommands.ts -src/Explorer/Tables/DataTable/TableEntityCache.ts +# src/Explorer/Tables/DataTable/TableCommands.ts +# src/Explorer/Tables/DataTable/TableEntityCache.ts src/Explorer/Tables/DataTable/TableEntityListViewModel.ts -src/Explorer/Tables/Entities.ts -# src/Explorer/Tables/QueryBuilder/ClauseGroup.ts -# src/Explorer/Tables/QueryBuilder/ClauseGroupViewModel.ts +# src/Explorer/Tables/Entities.ts src/Explorer/Tables/QueryBuilder/CustomTimestampHelper.ts -# src/Explorer/Tables/QueryBuilder/QueryBuilderViewModel.ts -# src/Explorer/Tables/QueryBuilder/QueryClauseViewModel.ts src/Explorer/Tables/TableDataClient.ts src/Explorer/Tables/TableEntityProcessor.ts src/Explorer/Tables/Utilities.ts diff --git a/src/Explorer/Tables/DataTable/DataTableOperations.ts b/src/Explorer/Tables/DataTable/DataTableOperations.ts index 0111787a3..8fffcc7c4 100644 --- a/src/Explorer/Tables/DataTable/DataTableOperations.ts +++ b/src/Explorer/Tables/DataTable/DataTableOperations.ts @@ -1,12 +1,11 @@ -import _ from "underscore"; import Q from "q"; - -import * as Entities from "../Entities"; +import _ from "underscore"; import * as QueryBuilderConstants from "../Constants"; +import * as Entities from "../Entities"; import * as Utilities from "../Utilities"; export function getRowSelector(selectorSchema: Entities.IProperty[]): string { - var selector: string = ""; + let selector = ""; selectorSchema && selectorSchema.forEach((p: Entities.IProperty) => { selector += "[" + p.key + '="' + Utilities.jQuerySelectorEscape(p.value) + '"]'; @@ -15,10 +14,10 @@ export function getRowSelector(selectorSchema: Entities.IProperty[]): string { } export function isRowVisible(dataTableScrollBodyQuery: JQuery, element: HTMLElement): boolean { - var isVisible = false; + let isVisible = false; if (dataTableScrollBodyQuery.length && element) { - var elementRect: ClientRect = element.getBoundingClientRect(), + const elementRect: ClientRect = element.getBoundingClientRect(), dataTableScrollBodyRect: ClientRect = dataTableScrollBodyQuery.get(0).getBoundingClientRect(); isVisible = elementRect.bottom <= dataTableScrollBodyRect.bottom && dataTableScrollBodyRect.top <= elementRect.top; @@ -29,17 +28,17 @@ export function isRowVisible(dataTableScrollBodyQuery: JQuery, element: HTMLElem export function scrollToRowIfNeeded(dataTableRows: JQuery, currentIndex: number, isScrollUp: boolean): void { if (dataTableRows.length) { - var dataTableScrollBodyQuery: JQuery = $(QueryBuilderConstants.htmlSelectors.dataTableScrollBodySelector), + const dataTableScrollBodyQuery: JQuery = $(QueryBuilderConstants.htmlSelectors.dataTableScrollBodySelector), selectedRowElement: HTMLElement = dataTableRows.get(currentIndex); if (dataTableScrollBodyQuery.length && selectedRowElement) { - var isVisible: boolean = isRowVisible(dataTableScrollBodyQuery, selectedRowElement); + const isVisible: boolean = isRowVisible(dataTableScrollBodyQuery, selectedRowElement); if (!isVisible) { - var selectedRowQuery: JQuery = $(selectedRowElement), + const selectedRowQuery: JQuery = $(selectedRowElement), scrollPosition: number = dataTableScrollBodyQuery.scrollTop(), - selectedElementPosition: number = selectedRowQuery.position().top, - newScrollPosition: number = 0; + selectedElementPosition: number = selectedRowQuery.position().top; + let newScrollPosition = 0; if (isScrollUp) { newScrollPosition = scrollPosition + selectedElementPosition; @@ -55,7 +54,7 @@ export function scrollToRowIfNeeded(dataTableRows: JQuery, currentIndex: number, } export function scrollToTopIfNeeded(): void { - var $dataTableRows: JQuery = $(QueryBuilderConstants.htmlSelectors.dataTableAllRowsSelector), + const $dataTableRows: JQuery = $(QueryBuilderConstants.htmlSelectors.dataTableAllRowsSelector), $dataTableScrollBody: JQuery = $(QueryBuilderConstants.htmlSelectors.dataTableScrollBodySelector); if ($dataTableRows.length && $dataTableScrollBody.length) { @@ -88,13 +87,14 @@ export function reorderColumns( table: DataTables.DataTable, targetOrder: number[], currentOrder?: number[] + //eslint-disable-next-line ): Q.Promise { - var columnsCount: number = targetOrder.length; - var isCurrentOrderPassedIn: boolean = !!currentOrder; + const columnsCount: number = targetOrder.length; + const isCurrentOrderPassedIn = !!currentOrder; if (!isCurrentOrderPassedIn) { currentOrder = getInitialOrder(columnsCount); } - var isSameOrder: boolean = Utilities.isEqual(currentOrder, targetOrder); + const isSameOrder: boolean = Utilities.isEqual(currentOrder, targetOrder); // if the targetOrder is the same as current order, do nothing. if (!isSameOrder) { @@ -104,7 +104,7 @@ export function reorderColumns( // Then the transformation order will be the same as target order. // If current order is specified, then a transformation order is calculated. // Refer to calculateTransformationOrder for details about transformation order. - var transformationOrder: number[] = isCurrentOrderPassedIn + const transformationOrder: number[] = isCurrentOrderPassedIn ? calculateTransformationOrder(currentOrder, targetOrder) : targetOrder; try { @@ -143,7 +143,7 @@ export function getCurrentOrder(table: DataTables.DataTable): number[] { * Result: [0, 1, 2, 5, 6, 7, 3, 4, 8] */ export function invertIndexValues(inputArray: number[]): number[] { - var invertedArray: number[] = []; + const invertedArray: number[] = []; if (inputArray) { inputArray.forEach((value: number, index: number) => { invertedArray[inputArray[index]] = index; @@ -170,20 +170,21 @@ export function invertIndexValues(inputArray: number[]): number[] { * transformation order: Trans = [0, 1, 2, 7, 3, 4, 8, 5, 6] */ export function calculateTransformationOrder(currentOrder: number[], targetOrder: number[]): number[] { - var transformationOrder: number[] = []; + let transformationOrder: number[] = []; if (currentOrder && targetOrder && currentOrder.length === targetOrder.length) { - var invertedCurrentOrder: number[] = invertIndexValues(currentOrder); + const invertedCurrentOrder: number[] = invertIndexValues(currentOrder); transformationOrder = targetOrder.map((value: number) => invertedCurrentOrder[value]); } return transformationOrder; } export function getDataTableHeaders(table: DataTables.DataTable): string[] { - var columns: DataTables.ColumnsMethods = table.columns(); - var headers: string[] = []; + const columns: DataTables.ColumnsMethods = table.columns(); + let headers: string[] = []; if (columns) { // table.columns() return ColumnsMethods which is an array of arrays - var columnIndexes: number[] = (columns)[0]; + //eslint-disable-next-line + const columnIndexes: number[] = (columns)[0]; if (columnIndexes) { headers = columnIndexes.map((value: number) => $(table.columns(value).header()).html()); } diff --git a/src/Explorer/Tables/DataTable/TableCommands.ts b/src/Explorer/Tables/DataTable/TableCommands.ts index c5a80f65e..96739c02e 100644 --- a/src/Explorer/Tables/DataTable/TableCommands.ts +++ b/src/Explorer/Tables/DataTable/TableCommands.ts @@ -8,11 +8,11 @@ import TableEntityListViewModel from "./TableEntityListViewModel"; export default class TableCommands { // Command Ids - public static editEntityCommand: string = "edit"; - public static deleteEntitiesCommand: string = "delete"; - public static reorderColumnsCommand: string = "reorder"; - public static resetColumnsCommand: string = "reset"; - public static customizeColumnsCommand: string = "customizeColumns"; + public static editEntityCommand = "edit"; + public static deleteEntitiesCommand = "delete"; + public static reorderColumnsCommand = "reorder"; + public static resetColumnsCommand = "reset"; + public static customizeColumnsCommand = "customizeColumns"; private _container: Explorer; @@ -21,8 +21,8 @@ export default class TableCommands { } public isEnabled(commandName: string, selectedEntites: Entities.ITableEntity[]): boolean { - var singleItemSelected: boolean = DataTableUtilities.containSingleItem(selectedEntites); - var atLeastOneItemSelected: boolean = DataTableUtilities.containItems(selectedEntites); + const singleItemSelected = DataTableUtilities.containSingleItem(selectedEntites); + const atLeastOneItemSelected = DataTableUtilities.containItems(selectedEntites); switch (commandName) { case TableCommands.editEntityCommand: return singleItemSelected; @@ -47,6 +47,7 @@ export default class TableCommands { /** * Edit entity */ + //eslint-disable-next-line public editEntityCommand(viewModel: TableEntityListViewModel): Q.Promise { if (!viewModel) { return null; // Error @@ -56,12 +57,9 @@ export default class TableCommands { return null; // Erorr } - var entityToUpdate: Entities.ITableEntity = viewModel.selected()[0]; - var originalNumberOfProperties = entityToUpdate ? 0 : Object.keys(entityToUpdate).length - 1; // .metadata is always a property for etag - return null; } - + //eslint-disable-next-line public deleteEntitiesCommand(viewModel: TableEntityListViewModel): Q.Promise { if (!viewModel) { return null; // Error @@ -69,7 +67,7 @@ export default class TableCommands { if (!DataTableUtilities.containItems(viewModel.selected())) { return null; // Error } - var entitiesToDelete: Entities.ITableEntity[] = viewModel.selected(); + const entitiesToDelete: Entities.ITableEntity[] = viewModel.selected(); const deleteMessage: string = userContext.apiType === "Cassandra" ? "Are you sure you want to delete the selected rows?" @@ -82,7 +80,7 @@ export default class TableCommands { () => { viewModel.queryTablesTab.container.tableDataClient .deleteDocuments(viewModel.queryTablesTab.collection, entitiesToDelete) - .then((results: any) => { + .then(() => { return viewModel.removeEntitiesFromCache(entitiesToDelete).then(() => { viewModel.redrawTableThrottled(); }); diff --git a/src/Explorer/Tables/DataTable/TableEntityCache.ts b/src/Explorer/Tables/DataTable/TableEntityCache.ts index 282b21d19..91cc885f9 100644 --- a/src/Explorer/Tables/DataTable/TableEntityCache.ts +++ b/src/Explorer/Tables/DataTable/TableEntityCache.ts @@ -1,5 +1,5 @@ -import * as Utilities from "../Utilities"; import * as Entities from "../Entities"; +import * as Utilities from "../Utilities"; import CacheBase from "./CacheBase"; export default class TableEntityCache extends CacheBase { @@ -21,7 +21,7 @@ export default class TableEntityCache extends CacheBase { this._tableQuery = Utilities.copyTableQuery(tableQuery); } - public preClear() { + public preClear(): void { this.tableQuery = null; } } diff --git a/src/Explorer/Tables/Entities.ts b/src/Explorer/Tables/Entities.ts index fc9bef70b..9584520cb 100644 --- a/src/Explorer/Tables/Entities.ts +++ b/src/Explorer/Tables/Entities.ts @@ -1,4 +1,4 @@ -import { QueryIterator, ItemDefinition, Resource } from "@azure/cosmos"; +import { ItemDefinition, QueryIterator, Resource } from "@azure/cosmos"; export interface ITableEntity { [property: string]: ITableEntityAttribute; @@ -17,6 +17,7 @@ export interface ITableEntityAttribute { export interface IListTableEntitiesResult { Results: ITableEntity[]; + //eslint-disable-next-line ContinuationToken: any; iterator?: QueryIterator; } From 271256bffbd3aa43be393b22401a6393a5a2afb5 Mon Sep 17 00:00:00 2001 From: Hardikkumar Nai <80053762+hardiknai-techm@users.noreply.github.com> Date: Tue, 12 Oct 2021 21:13:35 +0530 Subject: [PATCH 3/3] resolve_eslint_NodePropertiesComponent (#921) * resolve_eslint_NodePropertiesComponent * address commit * Open new screen: Screen reader does not pass the 'Copied' information after selecting 'Copy' button. * resolve lint error --- .eslintignore | 11 -------- .../LeftPaneComponent.tsx | 2 +- .../NodePropertiesComponent.test.tsx | 27 ++++++++++--------- .../NodePropertiesComponent.tsx | 18 +++++-------- src/Explorer/OpenFullScreen.tsx | 8 ++++-- src/Explorer/Tabs/NotebookV2Tab.ts | 2 +- 6 files changed, 29 insertions(+), 39 deletions(-) diff --git a/.eslintignore b/.eslintignore index 12dfbf9c2..c1e8c4948 100644 --- a/.eslintignore +++ b/.eslintignore @@ -81,12 +81,8 @@ src/Explorer/Tables/DataTable/DataTableBindingManager.ts src/Explorer/Tables/DataTable/DataTableBuilder.ts src/Explorer/Tables/DataTable/DataTableContextMenu.ts src/Explorer/Tables/DataTable/DataTableOperationManager.ts -# src/Explorer/Tables/DataTable/DataTableOperations.ts src/Explorer/Tables/DataTable/DataTableViewModel.ts -# src/Explorer/Tables/DataTable/TableCommands.ts -# src/Explorer/Tables/DataTable/TableEntityCache.ts src/Explorer/Tables/DataTable/TableEntityListViewModel.ts -# src/Explorer/Tables/Entities.ts src/Explorer/Tables/QueryBuilder/CustomTimestampHelper.ts src/Explorer/Tables/TableDataClient.ts src/Explorer/Tables/TableEntityProcessor.ts @@ -134,20 +130,13 @@ src/Explorer/Controls/Notebook/NotebookTerminalComponent.tsx src/Explorer/Controls/NotebookViewer/NotebookViewerComponent.tsx src/Explorer/Controls/TreeComponent/TreeComponent.tsx src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.test.tsx -; src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.tsx -src/Explorer/Graph/GraphExplorerComponent/GraphVizComponent.tsx -src/Explorer/Graph/GraphExplorerComponent/LeftPaneComponent.tsx -src/Explorer/Graph/GraphExplorerComponent/MiddlePaneComponent.tsx -src/Explorer/Graph/GraphExplorerComponent/NodePropertiesComponent.test.tsx src/Explorer/Graph/GraphExplorerComponent/NodePropertiesComponent.tsx src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNodePropertiesComponent.test.tsx src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNodePropertiesComponent.tsx src/Explorer/Menus/CommandBar/CommandBarUtil.tsx src/Explorer/Notebook/NotebookComponent/NotebookComponentAdapter.tsx -; src/Explorer/Notebook/NotebookComponent/NotebookComponentBootstrapper.tsx src/Explorer/Notebook/NotebookComponent/VirtualCommandBarComponent.tsx src/Explorer/Notebook/NotebookComponent/contents/index.tsx -; src/Explorer/Notebook/NotebookRenderer/NotebookReadOnlyRenderer.tsx src/Explorer/Notebook/NotebookRenderer/NotebookRenderer.tsx src/Explorer/Notebook/NotebookRenderer/decorators/draggable/index.tsx src/Explorer/Notebook/NotebookRenderer/decorators/hijack-scroll/index.tsx diff --git a/src/Explorer/Graph/GraphExplorerComponent/LeftPaneComponent.tsx b/src/Explorer/Graph/GraphExplorerComponent/LeftPaneComponent.tsx index f6525e54d..6e3963f06 100644 --- a/src/Explorer/Graph/GraphExplorerComponent/LeftPaneComponent.tsx +++ b/src/Explorer/Graph/GraphExplorerComponent/LeftPaneComponent.tsx @@ -58,7 +58,7 @@ export class LeftPaneComponent extends React.Component { className={className} as="tr" aria-label={node.caption} - onActivated={(e) => this.props.onRootNodeSelected(node.id)} + onActivated={() => this.props.onRootNodeSelected(node.id)} key={node.id} > diff --git a/src/Explorer/Graph/GraphExplorerComponent/NodePropertiesComponent.test.tsx b/src/Explorer/Graph/GraphExplorerComponent/NodePropertiesComponent.test.tsx index bd894129f..df49ee81d 100644 --- a/src/Explorer/Graph/GraphExplorerComponent/NodePropertiesComponent.test.tsx +++ b/src/Explorer/Graph/GraphExplorerComponent/NodePropertiesComponent.test.tsx @@ -1,8 +1,8 @@ -import React from "react"; import { mount, ReactWrapper } from "enzyme"; import * as Q from "q"; -import { NodePropertiesComponent, NodePropertiesComponentProps, Mode } from "./NodePropertiesComponent"; -import { GraphHighlightedNodeData, EditedProperties, EditedEdges, PossibleVertex } from "./GraphExplorer"; +import React from "react"; +import { GraphHighlightedNodeData, PossibleVertex } from "./GraphExplorer"; +import { Mode, NodePropertiesComponent, NodePropertiesComponentProps } from "./NodePropertiesComponent"; describe("Property pane", () => { const title = "My Title"; @@ -37,17 +37,18 @@ describe("Property pane", () => { return { expandedTitle: title, isCollapsed: false, - onCollapsedChanged: (newValue: boolean): void => {}, + onCollapsedChanged: jest.fn(), node: highlightedNode, - getPkIdFromNodeData: (v: GraphHighlightedNodeData): string => null, - collectionPartitionKeyProperty: null, - updateVertexProperties: (editedProperties: EditedProperties): Q.Promise => Q.resolve(), - selectNode: (id: string): void => {}, - updatePossibleVertices: (): Q.Promise => Q.resolve(null), - possibleEdgeLabels: null, - editGraphEdges: (editedEdges: EditedEdges): Q.Promise => Q.resolve(), - deleteHighlightedNode: (): void => {}, - onModeChanged: (newMode: Mode): void => {}, + getPkIdFromNodeData: (): string => undefined, + collectionPartitionKeyProperty: undefined, + updateVertexProperties: (): Q.Promise => Q.resolve(), + selectNode: jest.fn(), + updatePossibleVertices: (): Q.Promise => Q.resolve(undefined), + possibleEdgeLabels: undefined, + //eslint-disable-next-line + editGraphEdges: (): Q.Promise => Q.resolve(), + deleteHighlightedNode: jest.fn(), + onModeChanged: jest.fn(), viewMode: Mode.READONLY_PROP, }; }; diff --git a/src/Explorer/Graph/GraphExplorerComponent/NodePropertiesComponent.tsx b/src/Explorer/Graph/GraphExplorerComponent/NodePropertiesComponent.tsx index 55f641a30..62b6169fe 100644 --- a/src/Explorer/Graph/GraphExplorerComponent/NodePropertiesComponent.tsx +++ b/src/Explorer/Graph/GraphExplorerComponent/NodePropertiesComponent.tsx @@ -72,7 +72,7 @@ export class NodePropertiesComponent extends React.Component< super(props); this.state = { editedProperties: { - pkId: null, + pkId: undefined, readOnlyProperties: [], existingProperties: [], addedProperties: [], @@ -98,15 +98,12 @@ export class NodePropertiesComponent extends React.Component< }; } - public static getDerivedStateFromProps( - props: NodePropertiesComponentProps, - state: NodePropertiesComponentState - ): Partial { + public static getDerivedStateFromProps(props: NodePropertiesComponentProps): Partial { if (props.viewMode !== Mode.READONLY_PROP) { return { isDeleteConfirm: false }; } - return null; + return undefined; } public render(): JSX.Element { @@ -138,10 +135,10 @@ export class NodePropertiesComponent extends React.Component< * @param value */ private static getTypeOption(value: any): ViewModels.InputPropertyValueTypeString { - if (value == null) { + if (value === undefined) { return "null"; } - let type = typeof value; + const type = typeof value; switch (type) { case "number": case "boolean": @@ -172,10 +169,9 @@ export class NodePropertiesComponent extends React.Component< ]; const existingProps: ViewModels.InputProperty[] = []; - if (this.props.node.hasOwnProperty("properties")) { const hProps = this.props.node["properties"]; - for (let p in hProps) { + for (const p in hProps) { const propValues = hProps[p]; (p === partitionKeyProperty ? readOnlyProps : existingProps).push({ key: p, @@ -437,7 +433,7 @@ export class NodePropertiesComponent extends React.Component< ); } else { - return null; + return undefined; } } diff --git a/src/Explorer/OpenFullScreen.tsx b/src/Explorer/OpenFullScreen.tsx index b36feeb48..7dabbc107 100644 --- a/src/Explorer/OpenFullScreen.tsx +++ b/src/Explorer/OpenFullScreen.tsx @@ -4,6 +4,8 @@ import * as React from "react"; import { useFullScreenURLs } from "../hooks/useFullScreenURLs"; export const OpenFullScreen: React.FunctionComponent = () => { + const [isReadUrlCopy, setIsReadUrlCopy] = React.useState(false); + const [isReadWriteUrlCopy, setIsReadWriteUrlCopy] = React.useState(false); const result = useFullScreenURLs(); if (!result) { return ; @@ -25,8 +27,9 @@ export const OpenFullScreen: React.FunctionComponent = () => { { copyToClipboard(readWriteUrl); + setIsReadWriteUrlCopy(true); }} - text="Copy" + text={isReadWriteUrlCopy ? "Copied" : "Copy"} iconProps={{ iconName: "Copy" }} /> { { + setIsReadUrlCopy(true); copyToClipboard(readUrl); }} - text="Copy" + text={isReadUrlCopy ? "Copied" : "Copy"} iconProps={{ iconName: "Copy" }} /> this.copyNotebook(), commandButtonLabel: copyToLabel, hasPopup: false,