Remove GraphExplorerAdapter (#736)

This commit is contained in:
Jordi Bunster 2021-04-29 14:46:31 -07:00 committed by GitHub
parent 9d0bc86197
commit 5e0523c7d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 72 deletions

View File

@ -1,63 +0,0 @@
import * as React from "react";
import { ReactAdapter } from "../../../Bindings/ReactBindingHandler";
import { GraphConfig } from "../../Tabs/GraphTab";
import * as ViewModels from "../../../Contracts/ViewModels";
import { GraphExplorer, GraphAccessor } 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;
graphConfigUiData: ViewModels.GraphConfigUiData;
graphConfig?: GraphConfig;
collectionPartitionKeyProperty: string;
graphBackendEndpoint: string;
databaseId: string;
collectionId: string;
masterKey: string;
onLoadStartKey: number;
onLoadStartKeyChange: (newKey: number) => void;
resourceId: string;
}
export class GraphExplorerAdapter implements ReactAdapter {
public params: Parameter;
public parameters = {};
public isNewVertexDisabled: boolean;
public constructor(params: Parameter) {
this.params = params;
}
public renderComponent(): JSX.Element {
return (
<GraphExplorer
onIsNewVertexDisabledChange={this.params.onIsNewVertexDisabledChange}
onGraphAccessorCreated={this.params.onGraphAccessorCreated}
onIsFilterQueryLoadingChange={this.params.onIsFilterQueryLoading}
onIsValidQueryChange={this.params.onIsValidQuery}
onIsPropertyEditing={this.params.onIsPropertyEditing}
onIsGraphDisplayed={this.params.onIsGraphDisplayed}
onResetDefaultGraphConfigValues={this.params.onResetDefaultGraphConfigValues}
collectionPartitionKeyProperty={this.params.collectionPartitionKeyProperty}
graphBackendEndpoint={this.params.graphBackendEndpoint}
databaseId={this.params.databaseId}
collectionId={this.params.collectionId}
masterKey={this.params.masterKey}
onLoadStartKey={this.params.onLoadStartKey}
onLoadStartKeyChange={this.params.onLoadStartKeyChange}
resourceId={this.params.resourceId}
/* TODO Figure out how to make this Knockout-free */
graphConfigUiData={this.params.graphConfigUiData}
graphConfig={this.params.graphConfig}
/>
);
}
}

View File

@ -5,8 +5,12 @@ import StyleIcon from "../../../images/Style.svg";
import { DatabaseAccount } from "../../Contracts/DataModels"; import { DatabaseAccount } from "../../Contracts/DataModels";
import * as ViewModels from "../../Contracts/ViewModels"; import * as ViewModels from "../../Contracts/ViewModels";
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent"; import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
import { GraphAccessor, GraphExplorerError } from "../Graph/GraphExplorerComponent/GraphExplorer"; import {
import { GraphExplorerAdapter } from "../Graph/GraphExplorerComponent/GraphExplorerAdapter"; GraphAccessor,
GraphExplorer,
GraphExplorerError,
GraphExplorerProps,
} from "../Graph/GraphExplorerComponent/GraphExplorer";
import { ContextualPaneBase } from "../Panes/ContextualPaneBase"; import { ContextualPaneBase } from "../Panes/ContextualPaneBase";
import GraphStylingPane from "../Panes/GraphStylingPane"; import GraphStylingPane from "../Panes/GraphStylingPane";
import { NewVertexPanel } from "../Panes/NewVertexPanel/NewVertexPanel"; import { NewVertexPanel } from "../Panes/NewVertexPanel/NewVertexPanel";
@ -36,15 +40,13 @@ interface GraphTabOptions extends ViewModels.TabOptions {
} }
export default class GraphTab extends TabsBase { export default class GraphTab extends TabsBase {
public readonly html =
'<div class="graphExplorerContainer" role="tabpanel" data-bind="react:graphExplorerAdapter, attr: {id: tabId}"></div>';
// Graph default configuration // Graph default configuration
public static readonly DEFAULT_NODE_CAPTION = "id"; public static readonly DEFAULT_NODE_CAPTION = "id";
private static readonly LINK_COLOR = "#aaa"; private static readonly LINK_COLOR = "#aaa";
private static readonly NODE_SIZE = 10; private static readonly NODE_SIZE = 10;
private static readonly NODE_COLOR = "orange"; private static readonly NODE_COLOR = "orange";
private static readonly LINK_WIDTH = 1; private static readonly LINK_WIDTH = 1;
private graphExplorerAdapter: GraphExplorerAdapter; private graphExplorerProps: GraphExplorerProps;
private isNewVertexDisabled: ko.Observable<boolean>; private isNewVertexDisabled: ko.Observable<boolean>;
private isPropertyEditing: ko.Observable<boolean>; private isPropertyEditing: ko.Observable<boolean>;
private isGraphDisplayed: ko.Observable<boolean>; private isGraphDisplayed: ko.Observable<boolean>;
@ -70,7 +72,7 @@ export default class GraphTab extends TabsBase {
this.graphConfig = GraphTab.createGraphConfig(); this.graphConfig = GraphTab.createGraphConfig();
// TODO Merge this with this.graphConfig // TODO Merge this with this.graphConfig
this.graphConfigUiData = GraphTab.createGraphConfigUiData(this.graphConfig); this.graphConfigUiData = GraphTab.createGraphConfigUiData(this.graphConfig);
this.graphExplorerAdapter = new GraphExplorerAdapter({ this.graphExplorerProps = {
onGraphAccessorCreated: (instance: GraphAccessor): void => { onGraphAccessorCreated: (instance: GraphAccessor): void => {
this.graphAccessor = instance; this.graphAccessor = instance;
}, },
@ -89,8 +91,9 @@ export default class GraphTab extends TabsBase {
onResetDefaultGraphConfigValues: () => this.setDefaultGraphConfigValues(), onResetDefaultGraphConfigValues: () => this.setDefaultGraphConfigValues(),
graphConfig: this.graphConfig, graphConfig: this.graphConfig,
graphConfigUiData: this.graphConfigUiData, graphConfigUiData: this.graphConfigUiData,
onIsFilterQueryLoading: (isFilterQueryLoading: boolean): void => this.isFilterQueryLoading(isFilterQueryLoading), onIsFilterQueryLoadingChange: (isFilterQueryLoading: boolean): void =>
onIsValidQuery: (isValidQuery: boolean): void => this.isValidQuery(isValidQuery), this.isFilterQueryLoading(isFilterQueryLoading),
onIsValidQueryChange: (isValidQuery: boolean): void => this.isValidQuery(isValidQuery),
collectionPartitionKeyProperty: options.collectionPartitionKeyProperty, collectionPartitionKeyProperty: options.collectionPartitionKeyProperty,
graphBackendEndpoint: GraphTab.getGremlinEndpoint(options.account), graphBackendEndpoint: GraphTab.getGremlinEndpoint(options.account),
databaseId: options.databaseId, databaseId: options.databaseId,
@ -103,7 +106,7 @@ export default class GraphTab extends TabsBase {
} }
}, },
resourceId: options.account.id, resourceId: options.account.id,
}); };
this.isFilterQueryLoading = ko.observable(false); this.isFilterQueryLoading = ko.observable(false);
this.isValidQuery = ko.observable(true); this.isValidQuery = ko.observable(true);
@ -115,6 +118,14 @@ export default class GraphTab extends TabsBase {
: `${account.name}.graphs.azure.com:443/`; : `${account.name}.graphs.azure.com:443/`;
} }
public render(): JSX.Element {
return (
<div className="graphExplorerContainer" role="tabpanel" id={this.tabId}>
<GraphExplorer {...this.graphExplorerProps} />
</div>
);
}
public onTabClick(): void { public onTabClick(): void {
super.onTabClick(); super.onTabClick();
this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Graph); this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Graph);