From 2c296ede35a6491ddf098bb450ffef6a2444564a Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Mon, 7 Jun 2021 21:14:05 -0700 Subject: [PATCH] Remove unused KO->React Adapters (#863) --- .eslintignore | 1 - .../GraphExplorerAdapter.tsx | 74 ------------------- .../Menus/NavBar/ControlBarComponent.tsx | 33 --------- .../NavBar/ControlBarComponentAdapter.tsx | 28 ------- 4 files changed, 136 deletions(-) delete mode 100644 src/Explorer/Graph/GraphExplorerComponent/GraphExplorerAdapter.tsx delete mode 100644 src/Explorer/Menus/NavBar/ControlBarComponent.tsx delete mode 100644 src/Explorer/Menus/NavBar/ControlBarComponentAdapter.tsx diff --git a/.eslintignore b/.eslintignore index 02b4d7eb7..6ad6058d4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -263,7 +263,6 @@ src/Explorer/Graph/GraphExplorerComponent/EditorNodePropertiesComponent.test.tsx src/Explorer/Graph/GraphExplorerComponent/EditorNodePropertiesComponent.tsx src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.test.tsx src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.tsx -src/Explorer/Graph/GraphExplorerComponent/GraphExplorerAdapter.tsx src/Explorer/Graph/GraphExplorerComponent/GraphVizComponent.tsx src/Explorer/Graph/GraphExplorerComponent/LeftPaneComponent.tsx src/Explorer/Graph/GraphExplorerComponent/MiddlePaneComponent.tsx diff --git a/src/Explorer/Graph/GraphExplorerComponent/GraphExplorerAdapter.tsx b/src/Explorer/Graph/GraphExplorerComponent/GraphExplorerAdapter.tsx deleted file mode 100644 index 984419398..000000000 --- a/src/Explorer/Graph/GraphExplorerComponent/GraphExplorerAdapter.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import * as React from "react"; -import { ReactAdapter } from "../../../Bindings/ReactBindingHandler"; -import * as ViewModels from "../../../Contracts/ViewModels"; -import { IGraphConfig } from "../../Tabs/GraphTab"; -import { GraphAccessor, GraphExplorer } from "./GraphExplorer"; -interface Parameter { - onIsNewVertexDisabledChange: (isEnabled: boolean) => void; - onGraphAccessorCreated: (instance: GraphAccessor) => void; - onIsFilterQueryLoading: (isFilterQueryLoading: boolean) => void; - onIsValidQuery: (isValidQuery: boolean) => void; - onIsPropertyEditing: (isEditing: boolean) => void; - onIsGraphDisplayed: (isDisplayed: boolean) => void; - onResetDefaultGraphConfigValues: () => void; - - collectionPartitionKeyProperty: string; - graphBackendEndpoint: string; - databaseId: string; - collectionId: string; - masterKey: string; - - onLoadStartKey: number; - onLoadStartKeyChange: (newKey: number) => void; - resourceId: string; - - igraphConfigUiData: ViewModels.IGraphConfigUiData; - igraphConfig: IGraphConfig; - setIConfigUiData?: (data: string[]) => void; -} - -interface IGraphExplorerProps { - isChanged: boolean; -} - -interface IGraphExplorerStates { - isChangedState: boolean; -} - -export interface GraphExplorerAdapter - extends ReactAdapter, - React.Component {} -export class GraphExplorerAdapter implements ReactAdapter { - public params: Parameter; - public parameters = {}; - public isNewVertexDisabled: boolean; - - public constructor(params: Parameter, props?: IGraphExplorerProps) { - this.params = params; - } - - public renderComponent(): JSX.Element { - return ( - - ); - } -} diff --git a/src/Explorer/Menus/NavBar/ControlBarComponent.tsx b/src/Explorer/Menus/NavBar/ControlBarComponent.tsx deleted file mode 100644 index 26864cea5..000000000 --- a/src/Explorer/Menus/NavBar/ControlBarComponent.tsx +++ /dev/null @@ -1,33 +0,0 @@ -/** - * React component for control bar - */ - -import * as React from "react"; -import { - CommandButtonComponent, - CommandButtonComponentProps, -} from "../../Controls/CommandButton/CommandButtonComponent"; - -export interface ControlBarComponentProps { - buttons: CommandButtonComponentProps[]; -} - -export class ControlBarComponent extends React.Component { - private static renderButtons(commandButtonOptions: CommandButtonComponentProps[]): JSX.Element[] { - return commandButtonOptions.map( - (btn: CommandButtonComponentProps, index: number): JSX.Element => { - // Remove label - btn.commandButtonLabel = undefined; - return CommandButtonComponent.renderButton(btn, `${index}`); - } - ); - } - - public render(): JSX.Element { - if (!this.props.buttons || this.props.buttons.length < 1) { - return ; - } - - return {ControlBarComponent.renderButtons(this.props.buttons)}; - } -} diff --git a/src/Explorer/Menus/NavBar/ControlBarComponentAdapter.tsx b/src/Explorer/Menus/NavBar/ControlBarComponentAdapter.tsx deleted file mode 100644 index b6af77dbe..000000000 --- a/src/Explorer/Menus/NavBar/ControlBarComponentAdapter.tsx +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This adapter is responsible to render the React component - * If the component signals a change through the callback passed in the properties, it must render the React component when appropriate - * and update any knockout observables passed from the parent. - */ - -import * as ko from "knockout"; -import * as React from "react"; -import { ReactAdapter } from "../../../Bindings/ReactBindingHandler"; -import { ControlBarComponent } from "./ControlBarComponent"; -import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent"; - -export class ControlBarComponentAdapter implements ReactAdapter { - public parameters: ko.Observable; - - constructor(private buttons: ko.ObservableArray) { - this.buttons.subscribe(() => this.forceRender()); - this.parameters = ko.observable(Date.now()); - } - - public renderComponent(): JSX.Element { - return ; - } - - public forceRender(): void { - window.requestAnimationFrame(() => this.parameters(Date.now())); - } -}