Compare commits

..

3 Commits

Author SHA1 Message Date
hardiknai-techm
0897c75114 resolve_eslint_ReadOnlyNodePropertiesComponent 2021-10-14 11:13:35 +05:30
hardiknai-techm
b9e06858c5 resolve master code conflict 2021-10-12 20:59:27 +05:30
hardiknai-techm
043541b0dc resolve eslint ReadOnlyNodePropertiesComponent 2021-08-20 08:10:58 +05:30
12 changed files with 91 additions and 106 deletions

View File

@@ -2,8 +2,6 @@
src/**/__mocks__/**/*
dist/
Contracts/
src/Api/Apis.ts
src/AuthType.ts
src/Bindings/BindingHandlersRegisterer.ts
src/Bindings/ReactBindingHandler.ts
src/Common/Constants.ts
@@ -37,7 +35,6 @@ src/Definitions/svg.d.ts
src/Explorer/ComponentRegisterer.test.ts
src/Explorer/ComponentRegisterer.ts
src/Explorer/Controls/DiffEditor/DiffEditorComponent.ts
src/Explorer/Controls/Editor/EditorComponent.ts
src/Explorer/Controls/JsonEditor/JsonEditorComponent.ts
src/Explorer/DataSamples/ContainerSampleGenerator.test.ts
@@ -46,8 +43,8 @@ src/Explorer/DataSamples/DataSamplesUtil.test.ts
src/Explorer/DataSamples/DataSamplesUtil.ts
src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.test.ts
src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.ts
# src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.test.ts
# src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.ts
src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.test.ts
src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.ts
src/Explorer/Graph/GraphExplorerComponent/EdgeInfoCache.ts
src/Explorer/Graph/GraphExplorerComponent/GraphData.test.ts
src/Explorer/Graph/GraphExplorerComponent/GraphData.ts
@@ -116,12 +113,8 @@ src/ReactDevTools.ts
src/Shared/Constants.ts
src/Shared/DefaultExperienceUtility.test.ts
src/Shared/DefaultExperienceUtility.ts
src/Shared/appInsights.ts
src/SparkClusterManager/ArcadiaResourceManager.ts
src/SparkClusterManager/SparkClusterManager.ts
src/Terminal/JupyterLabAppFactory.ts
src/Terminal/NotebookAppContracts.d.ts
src/applyExplorerBindings.ts
src/global.d.ts
src/setupTests.ts
src/Explorer/Controls/InputTypeahead/InputTypeaheadComponent.tsx
@@ -131,8 +124,6 @@ src/Explorer/Controls/NotebookViewer/NotebookViewerComponent.tsx
src/Explorer/Controls/TreeComponent/TreeComponent.tsx
src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.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/VirtualCommandBarComponent.tsx
@@ -141,7 +132,6 @@ src/Explorer/Notebook/NotebookRenderer/NotebookRenderer.tsx
src/Explorer/Notebook/NotebookRenderer/decorators/draggable/index.tsx
src/Explorer/Notebook/NotebookRenderer/decorators/hijack-scroll/index.tsx
src/Explorer/Notebook/NotebookRenderer/decorators/kbd-shortcuts/index.tsx
src/Explorer/Notebook/temp/inputs/connected-editors/codemirror.tsx
src/Explorer/Tree/ResourceTreeAdapter.tsx
__mocks__/monaco-editor.ts
src/Explorer/Tree/ResourceTree.tsx

View File

@@ -1,4 +1,4 @@
/**
* Data Explorer version {major.minor.patch}
*/
export const DataExplorer: string = "1.0.1";
export const DataExplorer = "1.0.1";

View File

@@ -1,5 +1,4 @@
/*eslint-disable jest/no-test-callback */
import * as sinon from "sinon";
import * as sinon from "sinon";
import GraphTab from "../../Tabs/GraphTab";
import { D3Link, D3Node, GraphData } from "../GraphExplorerComponent/GraphData";
import { D3ForceGraph, D3GraphNodeData, LoadMoreDataAction } from "./D3ForceGraph";
@@ -71,7 +70,6 @@ describe("D3ForceGraph", () => {
forceGraph = new D3ForceGraph({
igraphConfig: GraphTab.createIGraphConfig(),
onHighlightedNode: sinon.spy(),
//eslint-disable-next-line
onLoadMoreData: (action: LoadMoreDataAction): void => {},
// parent to graph

View File

@@ -1,6 +1,4 @@
/*eslint-disable @typescript-eslint/no-explicit-any*/
/*eslint-disable @typescript-eslint/no-this-alias*/
import { BaseType } from "d3";
import { BaseType } from "d3";
import { map as d3Map } from "d3-collection";
import { D3DragEvent, drag } from "d3-drag";
import { forceCollide, forceLink, forceManyBody, forceSimulation } from "d3-force";
@@ -263,10 +261,10 @@ export class D3ForceGraph implements GraphRenderer {
return;
}
const self = this;
var self = this;
// Select this node id
selectAll(".node")
.filter((d: D3Node) => {
.filter(function (d: D3Node, i) {
return d.id === newVal;
})
.each(function (d: D3Node) {
@@ -279,15 +277,15 @@ export class D3ForceGraph implements GraphRenderer {
} // initialize
private updateUniqueValues(key: string) {
for (let i = 0; i < this.graphDataWrapper.vertices.length; i++) {
const vertex = this.graphDataWrapper.vertices[i];
for (var i = 0; i < this.graphDataWrapper.vertices.length; i++) {
let vertex = this.graphDataWrapper.vertices[i];
const props = D3ForceGraph.getNodeProperties(vertex);
let props = D3ForceGraph.getNodeProperties(vertex);
if (props.indexOf(key) === -1) {
// Vertex doesn't have the property
continue;
}
const val = GraphData.getNodePropValue(vertex, key);
let val = GraphData.getNodePropValue(vertex, key);
if (typeof val !== "string" && typeof val !== "number") {
// Not a type we can map
continue;
@@ -315,7 +313,7 @@ export class D3ForceGraph implements GraphRenderer {
*/
private static getNodeProperties(node: D3Node): string[] {
let props = ["id", "label"];
//eslint-disable-next-line
if (node.hasOwnProperty("properties")) {
props = props.concat(Object.keys(node.properties));
}
@@ -407,7 +405,7 @@ export class D3ForceGraph implements GraphRenderer {
// Remember nodes current position
const posMap = new Map<string, Point2D>();
this.simulation.nodes().forEach((d: D3Node) => {
if (d.x === undefined || d.y === undefined) {
if (d.x == undefined || d.y == undefined) {
return;
}
posMap.set(d.id, { x: d.x, y: d.y });
@@ -551,7 +549,7 @@ export class D3ForceGraph implements GraphRenderer {
.transition()
.delay(D3ForceGraph.TRANSITION_STEP3_MS - 100)
.duration(D3ForceGraph.TRANSITION_STEP3_MS)
.attrTween("fill", () => {
.attrTween("fill", (t: any) => {
const ic = interpolate("#ffffff", "#000000");
return (t: number) => {
return ic(t);
@@ -569,7 +567,7 @@ export class D3ForceGraph implements GraphRenderer {
// Distribute nodes initial position before simulation
const nodes = graph.vertices;
for (let i = 0; i < nodes.length; i++) {
const v = nodes[i];
let v = nodes[i];
if (v._isRoot) {
this.rootVertex = v;
@@ -613,20 +611,6 @@ export class D3ForceGraph implements GraphRenderer {
const self = this;
const ticked = () => {
self.linkSelection.select(".link").attr("d", (l: D3Link) => {
return self.positionLink(l);
});
if (!D3ForceGraph.useSvgMarkerEnd()) {
self.linkSelection.select(".markerEnd").attr("transform", (l: D3Link) => {
return self.positionLinkEnd(l);
});
}
self.nodeSelection.attr("transform", (d: D3Node) => {
return self.positionNode(d);
});
};
this.simulation.nodes(nodes).on("tick", ticked);
this.simulation.force<d3.ForceLink<D3Node, D3Link>>("link").links(graph.edges);
@@ -650,6 +634,20 @@ export class D3ForceGraph implements GraphRenderer {
this.simulation.alpha(1).restart();
this.params.onGraphUpdated(new Date().getTime());
});
function ticked() {
self.linkSelection.select(".link").attr("d", (l: D3Link) => {
return self.positionLink(l);
});
if (!D3ForceGraph.useSvgMarkerEnd()) {
self.linkSelection.select(".markerEnd").attr("transform", (l: D3Link) => {
return self.positionLinkEnd(l);
});
}
self.nodeSelection.attr("transform", (d: D3Node) => {
return self.positionNode(d);
});
}
}
private addNewLinks(): d3.Selection<Element, any, any, any> {
@@ -679,7 +677,7 @@ export class D3ForceGraph implements GraphRenderer {
}
private addNewNodes(): d3.Selection<Element, any, any, any> {
const self = this;
var self = this;
const newNodes = this.nodeSelection
.enter()
@@ -707,7 +705,7 @@ export class D3ForceGraph implements GraphRenderer {
this.highlightNode(this, d);
this.simulation.stop();
})
.on("mouseout", () => {
.on("mouseout", (_: MouseEvent, d: D3Node) => {
if (this.isHighlightDisabled || this.selectedNode || this.isDragging) {
return;
}
@@ -728,7 +726,7 @@ export class D3ForceGraph implements GraphRenderer {
.attr("class", "main")
.attr("r", this.igraphConfig.nodeSize);
const iconGroup = newNodes
var iconGroup = newNodes
.append("g")
.attr("class", "iconContainer")
.attr("tabindex", 0)
@@ -751,8 +749,8 @@ export class D3ForceGraph implements GraphRenderer {
self.onNodeClicked(this.parentNode, d);
}
});
const nodeSize = this.igraphConfig.nodeSize;
const bgsize = nodeSize + 1;
var nodeSize = this.igraphConfig.nodeSize;
var bgsize = nodeSize + 1;
iconGroup
.append("rect")
@@ -760,7 +758,7 @@ export class D3ForceGraph implements GraphRenderer {
.attr("y", -bgsize)
.attr("width", bgsize * 2)
.attr("height", bgsize * 2)
.attr("fill-opacity", () => {
.attr("fill-opacity", (d: D3Node) => {
return this.igraphConfig.nodeIconKey ? 1 : 0;
})
.attr("class", "icon-background");
@@ -832,10 +830,10 @@ export class D3ForceGraph implements GraphRenderer {
self.loadNeighbors(d, PAGE_ACTION.NEXT_PAGE);
}
}) as any)
.on("mouseover", ((e: MouseEvent) => {
.on("mouseover", ((e: MouseEvent, d: D3Node) => {
select(e.target as any).classed("active", true);
}) as any)
.on("mouseout", ((e: MouseEvent) => {
.on("mouseout", ((e: MouseEvent, d: D3Node) => {
select(e.target as any).classed("active", false);
}) as any)
.attr("visibility", (d: D3Node) => (!d._outEAllLoaded || !d._inEAllLoaded ? "visible" : "hidden"));
@@ -861,10 +859,10 @@ export class D3ForceGraph implements GraphRenderer {
self.loadNeighbors(d, PAGE_ACTION.PREVIOUS_PAGE);
}
}) as any)
.on("mouseover", ((e: MouseEvent) => {
.on("mouseover", ((e: MouseEvent, d: D3Node) => {
select(e.target as any).classed("active", true);
}) as any)
.on("mouseout", ((e: MouseEvent) => {
.on("mouseout", ((e: MouseEvent, d: D3Node) => {
select(e.target as any).classed("active", false);
}) as any)
.attr("visibility", (d: D3Node) =>
@@ -957,10 +955,10 @@ export class D3ForceGraph implements GraphRenderer {
self.loadNeighbors(d, PAGE_ACTION.FIRST_PAGE);
}
}) as any)
.on("mouseover", ((e: MouseEvent) => {
.on("mouseover", ((e: MouseEvent, d: D3Node) => {
select(e.target as any).classed("active", true);
}) as any)
.on("mouseout", ((e: MouseEvent) => {
.on("mouseout", ((e: MouseEvent, d: D3Node) => {
select(e.target as any).classed("active", false);
}) as any);
}
@@ -969,9 +967,10 @@ export class D3ForceGraph implements GraphRenderer {
* Remove LoadMore subassembly for existing nodes that show all their children in the graph
*/
private updateLoadMore(nodeSelection: d3.Selection<Element, any, any, any>) {
const self = this;
nodeSelection.selectAll(".loadmore").remove();
const nodeSize = this.igraphConfig.nodeSize;
var nodeSize = this.igraphConfig.nodeSize;
const rootSelectionG = nodeSelection
.filter((d: D3Node) => {
return !!d._isRoot && !!d._pagination;
@@ -1091,7 +1090,7 @@ export class D3ForceGraph implements GraphRenderer {
private fadeNonNeighbors(nodeId: string) {
this.g.selectAll(".node").classed("inactive", (d: D3Node) => {
const neighbors = ((showNeighborType) => {
var neighbors = ((showNeighborType) => {
switch (showNeighborType) {
case NeighborType.SOURCES_ONLY:
return this.graphDataWrapper.getSourcesForId(nodeId);
@@ -1152,7 +1151,7 @@ export class D3ForceGraph implements GraphRenderer {
}
private retrieveNodeCaption(d: D3Node) {
const key = this.igraphConfig.nodeCaption;
let key = this.igraphConfig.nodeCaption;
let value: string = d.id || d.label;
if (key) {
value = <string>GraphData.getNodePropValue(d, key) || "";
@@ -1203,14 +1202,14 @@ export class D3ForceGraph implements GraphRenderer {
y: (<D3Node>l.target).y,
};
const d1 = D3ForceGraph.calculateControlPoint(source, target);
const radius = this.igraphConfig.nodeSize + 3;
var radius = this.igraphConfig.nodeSize + 3;
// End
const dx = target.x - d1.x;
const dy = target.y - d1.y;
const angle = Math.atan2(dy, dx);
const ux = target.x - Math.cos(angle) * radius;
const uy = target.y - Math.sin(angle) * radius;
var ux = target.x - Math.cos(angle) * radius;
var uy = target.y - Math.sin(angle) * radius;
return `translate(${ux},${uy}) rotate(${(angle * 180) / Math.PI})`;
}
@@ -1225,21 +1224,21 @@ export class D3ForceGraph implements GraphRenderer {
y: (<D3Node>l.target).y,
};
const d1 = D3ForceGraph.calculateControlPoint(source, target);
const radius = this.igraphConfig.nodeSize + 3;
var radius = this.igraphConfig.nodeSize + 3;
// Start
let dx = d1.x - source.x;
let dy = d1.y - source.y;
let angle = Math.atan2(dy, dx);
const tx = source.x + Math.cos(angle) * radius;
const ty = source.y + Math.sin(angle) * radius;
var dx = d1.x - source.x;
var dy = d1.y - source.y;
var angle = Math.atan2(dy, dx);
var tx = source.x + Math.cos(angle) * radius;
var ty = source.y + Math.sin(angle) * radius;
// End
dx = target.x - d1.x;
dy = target.y - d1.y;
angle = Math.atan2(dy, dx);
const ux = target.x - Math.cos(angle) * radius;
const uy = target.y - Math.sin(angle) * radius;
var ux = target.x - Math.cos(angle) * radius;
var uy = target.y - Math.sin(angle) * radius;
return "M" + tx + "," + ty + "S" + d1.x + "," + d1.y + " " + ux + "," + uy;
}
@@ -1261,9 +1260,9 @@ export class D3ForceGraph implements GraphRenderer {
}
private static computeImageData(d: D3Node, config: IGraphConfig): string {
const propValue = <string>GraphData.getNodePropValue(d, config.nodeIconKey) || "";
let propValue = <string>GraphData.getNodePropValue(d, config.nodeIconKey) || "";
// Trim leading and trailing spaces to make comparison more forgiving.
const value = config.iconsMap[propValue.trim()];
let value = config.iconsMap[propValue.trim()];
if (!value) {
return undefined;
}
@@ -1289,7 +1288,7 @@ export class D3ForceGraph implements GraphRenderer {
// clear icons
this.g.selectAll(".node .icon").attr("xlink:href", undefined);
}
this.g.selectAll(".node .icon-background").attr("fill-opacity", () => {
this.g.selectAll(".node .icon-background").attr("fill-opacity", (d: D3Node) => {
return config.nodeIconKey ? 1 : 0;
});
this.g.selectAll(".node text.caption").text((d: D3Node) => {

View File

@@ -1,7 +1,6 @@
import React from "react";
import { shallow } from "enzyme";
import React from "react";
import { GraphHighlightedNodeData } from "./GraphExplorer";
import {
ReadOnlyNodePropertiesComponent,
ReadOnlyNodePropertiesComponentProps,
@@ -44,7 +43,7 @@ describe("<ReadOnlyNodePropertiesComponent />", () => {
const mockNode2 = {
...mockNode,
properties: {
key3: ["abcd", 1234, true, false, undefined, null],
key3: ["abcd", 1234, true, false, undefined],
},
};
const props: ReadOnlyNodePropertiesComponentProps = { node: mockNode2 };

View File

@@ -60,9 +60,7 @@ export class ReadOnlyNodePropertiesComponent extends React.Component<ReadOnlyNod
}
public static singlePropertyValueToString(value: ViewModels.GremlinPropertyValueType): string {
if (value === null) {
return "null";
} else if (typeof value === "undefined") {
if (typeof value === "undefined") {
return "undefined";
} else {
return value.toString();
@@ -71,11 +69,8 @@ export class ReadOnlyNodePropertiesComponent extends React.Component<ReadOnlyNod
public static renderSinglePropertyValue(value: ViewModels.GremlinPropertyValueType): JSX.Element {
let singlePropValue = value;
let className = "propertyValue";
if (singlePropValue === null) {
singlePropValue = "null";
className += " isNull";
} else if (typeof singlePropValue === "undefined") {
const className = "propertyValue";
if (typeof singlePropValue === "undefined") {
singlePropValue = "undefined";
} else {
singlePropValue = value.toString();

View File

@@ -123,7 +123,7 @@ exports[`<ReadOnlyNodePropertiesComponent /> renders properties (with multiple v
</td>
<td
className="valueCol"
title="abcd, 1234, true, false, undefined, null"
title="abcd, 1234, true, false, undefined"
>
<div
className="propertyValue"
@@ -155,12 +155,6 @@ exports[`<ReadOnlyNodePropertiesComponent /> renders properties (with multiple v
>
undefined
</div>
<div
className="propertyValue isNull"
key="null"
>
null
</div>
</td>
</tr>
</tbody>

View File

@@ -307,11 +307,18 @@ function createOpenSynapseLinkDialogButton(container: Explorer): CommandButtonCo
function createNewDatabase(container: Explorer): CommandButtonComponentProps {
const label = "New " + getDatabaseName();
const newDatabaseButton = document.activeElement as HTMLElement;
return {
iconSrc: AddDatabaseIcon,
iconAlt: label,
onCommandClick: () =>
useSidePanel.getState().openSidePanel("New " + getDatabaseName(), <AddDatabasePanel explorer={container} />),
useSidePanel
.getState()
.openSidePanel(
"New " + getDatabaseName(),
<AddDatabasePanel explorer={container} buttonElement={newDatabaseButton} />
),
commandButtonLabel: label,
ariaLabel: label,
hasPopup: true,

View File

@@ -23,10 +23,12 @@ import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneFor
export interface AddDatabasePaneProps {
explorer: Explorer;
buttonElement?: HTMLElement;
}
export const AddDatabasePanel: FunctionComponent<AddDatabasePaneProps> = ({
explorer: container,
buttonElement,
}: AddDatabasePaneProps) => {
const closeSidePanel = useSidePanel((state) => state.closeSidePanel);
let throughput: number;
@@ -77,6 +79,7 @@ export const AddDatabasePanel: FunctionComponent<AddDatabasePaneProps> = ({
dataExplorerArea: Constants.Areas.ContextualPane,
};
TelemetryProcessor.trace(Action.CreateDatabase, ActionModifiers.Open, addDatabasePaneOpenMessage);
buttonElement.focus();
}, []);
const onSubmit = () => {

View File

@@ -307,16 +307,23 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
iconSrc: AddDatabaseIcon,
title: "New " + getDatabaseName(),
description: undefined,
onClick: () =>
useSidePanel
.getState()
.openSidePanel("New " + getDatabaseName(), <AddDatabasePanel explorer={this.container} />),
onClick: () => this.openAddDatabasePanel(),
});
}
return items;
}
private openAddDatabasePanel() {
const newDatabaseButton = document.activeElement as HTMLElement;
useSidePanel
.getState()
.openSidePanel(
"New " + getDatabaseName(),
<AddDatabasePanel explorer={this.container} buttonElement={newDatabaseButton} />
);
}
private decorateOpenCollectionActivity({ databaseId, collectionId }: MostRecentActivity.OpenCollectionItem) {
return {
iconSrc: NotebookIcon,

View File

@@ -202,21 +202,14 @@ export class CassandraAPIDataClient extends TableDataClient {
let updateQuery = `UPDATE ${collection.databaseId}.${collection.id()}`;
let isPropertyUpdated = false;
let isFirstPropertyToUpdate = true;
for (let property in newEntity) {
if (
!originalDocument[property] ||
newEntity[property]._.toString() !== originalDocument[property]._.toString()
) {
let propertyQuerySegment = this.isStringType(newEntity[property].$)
? `${property} = '${newEntity[property]._}',`
: `${property} = ${newEntity[property]._},`;
// Only add the "SET" keyword once
if (isFirstPropertyToUpdate) {
propertyQuerySegment = " SET " + propertyQuerySegment;
isFirstPropertyToUpdate = false;
}
updateQuery += propertyQuerySegment;
updateQuery += this.isStringType(newEntity[property].$)
? ` SET ${property} = '${newEntity[property]._}',`
: ` SET ${property} = ${newEntity[property]._},`;
isPropertyUpdated = true;
}
}

View File

@@ -3,7 +3,7 @@ import { BindingHandlersRegisterer } from "./Bindings/BindingHandlersRegisterer"
import Explorer from "./Explorer/Explorer";
export const applyExplorerBindings = (explorer: Explorer) => {
if (!!explorer) {
if (explorer) {
window.dataExplorer = explorer;
BindingHandlersRegisterer.registerBindingHandlers();
ko.applyBindings(explorer);