mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-30 17:37:01 +00:00
Merge branch 'master' of https://github.com/Azure/cosmos-explorer into eslit/fixed-lint-notebook-utils
This commit is contained in:
commit
efe458da3d
@ -11,8 +11,6 @@ src/Common/CosmosClient.test.ts
|
||||
src/Common/CosmosClient.ts
|
||||
src/Common/DataAccessUtilityBase.test.ts
|
||||
src/Common/DataAccessUtilityBase.ts
|
||||
src/Common/DeleteFeedback.ts
|
||||
src/Common/DocumentClientUtilityBase.ts
|
||||
src/Common/EditableUtility.ts
|
||||
src/Common/HashMap.test.ts
|
||||
src/Common/HashMap.ts
|
||||
@ -28,7 +26,6 @@ src/Common/ObjectCache.test.ts
|
||||
src/Common/ObjectCache.ts
|
||||
src/Common/QueriesClient.ts
|
||||
src/Common/Splitter.ts
|
||||
src/Common/ThemeUtility.ts
|
||||
src/Common/UrlUtility.ts
|
||||
src/Config.ts
|
||||
src/Contracts/ActionContracts.ts
|
||||
@ -56,8 +53,6 @@ src/Explorer/ComponentRegisterer.test.ts
|
||||
src/Explorer/ComponentRegisterer.ts
|
||||
src/Explorer/ContextMenuButtonFactory.ts
|
||||
src/Explorer/Controls/CollapsiblePanel/CollapsiblePanelComponent.ts
|
||||
src/Explorer/Controls/CommandButton/CommandButton.test.ts
|
||||
src/Explorer/Controls/CommandButton/CommandButton.ts
|
||||
src/Explorer/Controls/DiffEditor/DiffEditorComponent.ts
|
||||
src/Explorer/Controls/DynamicList/DynamicList.test.ts
|
||||
src/Explorer/Controls/DynamicList/DynamicListComponent.ts
|
||||
@ -93,8 +88,6 @@ 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
|
||||
src/Explorer/Graph/GraphExplorerComponent/GraphUtil.test.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GraphUtil.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GremlinClient.test.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GremlinClient.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.test.ts
|
||||
@ -167,7 +160,6 @@ 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/DataTableUtilities.ts
|
||||
src/Explorer/Tables/DataTable/DataTableViewModel.ts
|
||||
src/Explorer/Tables/DataTable/TableCommands.ts
|
||||
src/Explorer/Tables/DataTable/TableEntityCache.ts
|
||||
@ -176,8 +168,6 @@ src/Explorer/Tables/Entities.ts
|
||||
src/Explorer/Tables/QueryBuilder/ClauseGroup.ts
|
||||
src/Explorer/Tables/QueryBuilder/ClauseGroupViewModel.ts
|
||||
src/Explorer/Tables/QueryBuilder/CustomTimestampHelper.ts
|
||||
src/Explorer/Tables/QueryBuilder/DateTimeUtilities.test.ts
|
||||
src/Explorer/Tables/QueryBuilder/DateTimeUtilities.ts
|
||||
src/Explorer/Tables/QueryBuilder/QueryBuilderViewModel.ts
|
||||
src/Explorer/Tables/QueryBuilder/QueryClauseViewModel.ts
|
||||
src/Explorer/Tables/QueryBuilder/QueryViewModel.ts
|
||||
@ -270,23 +260,14 @@ src/Terminal/NotebookAppContracts.d.ts
|
||||
src/Terminal/index.ts
|
||||
src/TokenProviders/PortalTokenProvider.ts
|
||||
src/TokenProviders/TokenProviderFactory.ts
|
||||
src/Utils/AuthorizationUtils.test.ts
|
||||
src/Utils/AuthorizationUtils.ts
|
||||
src/Utils/AutoPilotUtils.test.ts
|
||||
src/Utils/AutoPilotUtils.ts
|
||||
src/Utils/DatabaseAccountUtils.test.ts
|
||||
src/Utils/DatabaseAccountUtils.ts
|
||||
src/Utils/JunoUtils.ts
|
||||
src/Utils/MessageValidation.ts
|
||||
src/Utils/NotebookConfigurationUtils.ts
|
||||
src/Utils/PricingUtils.test.ts
|
||||
src/Utils/QueryUtils.test.ts
|
||||
src/Utils/QueryUtils.ts
|
||||
src/Utils/StringUtils.test.ts
|
||||
src/Utils/StringUtils.ts
|
||||
src/applyExplorerBindings.ts
|
||||
src/global.d.ts
|
||||
src/quickstart.ts
|
||||
src/setupTests.ts
|
||||
src/workers/upload/index.ts
|
||||
src/Explorer/Controls/AccessibleElement/AccessibleElement.tsx
|
||||
|
@ -2,18 +2,16 @@
|
||||
* Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
export default class ThemeUtility {
|
||||
public static getMonacoTheme(theme: string): string {
|
||||
switch (theme) {
|
||||
case "default":
|
||||
case "hc-white":
|
||||
return "vs";
|
||||
case "dark":
|
||||
return "vs-dark";
|
||||
case "hc-black":
|
||||
return "hc-black";
|
||||
default:
|
||||
return "vs";
|
||||
}
|
||||
export function getMonacoTheme(theme: string): string {
|
||||
switch (theme) {
|
||||
case "default":
|
||||
case "hc-white":
|
||||
return "vs";
|
||||
case "dark":
|
||||
return "vs-dark";
|
||||
case "hc-black":
|
||||
return "hc-black";
|
||||
default:
|
||||
return "vs";
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { StringUtils } from "../../../Utils/StringUtils";
|
||||
import * as StringUtils from "../../../Utils/StringUtils";
|
||||
import { KeyCodes } from "../../../Common/Constants";
|
||||
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
import * as React from "react";
|
||||
import * as DataModels from "../../../Contracts/DataModels";
|
||||
import { StringUtils } from "../../../Utils/StringUtils";
|
||||
import * as StringUtils from "../../../Utils/StringUtils";
|
||||
import { userContext } from "../../../UserContext";
|
||||
import { TerminalQueryParams } from "../../../Common/Constants";
|
||||
import { handleError } from "../../../Common/ErrorHandlingUtils";
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
import * as React from "react";
|
||||
import { NeighborVertexBasicInfo, EditedEdges, GraphNewEdgeData, PossibleVertex } from "./GraphExplorer";
|
||||
import { GraphUtil } from "./GraphUtil";
|
||||
import * as GraphUtil from "./GraphUtil";
|
||||
import * as InputTypeaheadComponent from "../../Controls/InputTypeahead/InputTypeaheadComponent";
|
||||
import DeleteIcon from "../../../../images/delete.svg";
|
||||
import AddPropertyIcon from "../../../../images/Add-property.svg";
|
||||
|
@ -9,7 +9,7 @@ import { GraphVizComponentProps } from "./GraphVizComponent";
|
||||
import * as GraphData from "./GraphData";
|
||||
import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils";
|
||||
import { GraphUtil } from "./GraphUtil";
|
||||
import * as GraphUtil from "./GraphUtil";
|
||||
import * as DataModels from "../../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||
import * as GremlinClient from "./GremlinClient";
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { GraphUtil } from "./GraphUtil";
|
||||
import * as GraphUtil from "./GraphUtil";
|
||||
import { GraphData, GremlinVertex, GremlinEdge } from "./GraphData";
|
||||
import * as sinon from "sinon";
|
||||
import { GraphExplorer } from "./GraphExplorer";
|
||||
@ -69,7 +69,7 @@ describe("Process Gremlin vertex", () => {
|
||||
describe("getLimitedArrayString()", () => {
|
||||
const expectedEmptyResult = { result: "", consumedCount: 0 };
|
||||
it("should handle null array", () => {
|
||||
expect(GraphUtil.getLimitedArrayString(null, 10)).toEqual(expectedEmptyResult);
|
||||
expect(GraphUtil.getLimitedArrayString(undefined, 10)).toEqual(expectedEmptyResult);
|
||||
});
|
||||
|
||||
it("should handle empty array", () => {
|
||||
|
@ -7,180 +7,184 @@ interface JoinArrayMaxCharOutput {
|
||||
consumedCount: number; // Number of items consumed
|
||||
}
|
||||
|
||||
export class GraphUtil {
|
||||
public static getNeighborTitle(neighbor: NeighborVertexBasicInfo): string {
|
||||
return `edge id: ${neighbor.edgeId}, vertex id: ${neighbor.id}`;
|
||||
}
|
||||
interface EdgePropertyType {
|
||||
id: string;
|
||||
outV?: string;
|
||||
inV?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect all edges from this node
|
||||
* @param vertex
|
||||
* @param graphData
|
||||
* @param newNodes (optional) object describing new nodes encountered
|
||||
*/
|
||||
public static createEdgesfromNode(
|
||||
vertex: GraphData.GremlinVertex,
|
||||
graphData: GraphData.GraphData<GraphData.GremlinVertex, GraphData.GremlinEdge>,
|
||||
newNodes?: { [id: string]: boolean }
|
||||
): void {
|
||||
if (vertex.hasOwnProperty("outE")) {
|
||||
let outE = vertex.outE;
|
||||
for (var label in outE) {
|
||||
$.each(outE[label], (index: number, edge: any) => {
|
||||
// We create our own edge. No need to fetch
|
||||
let e = {
|
||||
id: edge.id,
|
||||
label: label,
|
||||
inV: edge.inV,
|
||||
outV: vertex.id,
|
||||
};
|
||||
export function getNeighborTitle(neighbor: NeighborVertexBasicInfo): string {
|
||||
return `edge id: ${neighbor.edgeId}, vertex id: ${neighbor.id}`;
|
||||
}
|
||||
|
||||
graphData.addEdge(e);
|
||||
if (newNodes) {
|
||||
newNodes[edge.inV] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (vertex.hasOwnProperty("inE")) {
|
||||
let inE = vertex.inE;
|
||||
for (var label in inE) {
|
||||
$.each(inE[label], (index: number, edge: any) => {
|
||||
// We create our own edge. No need to fetch
|
||||
let e = {
|
||||
id: edge.id,
|
||||
label: label,
|
||||
inV: vertex.id,
|
||||
outV: edge.outV,
|
||||
};
|
||||
/**
|
||||
* Collect all edges from this node
|
||||
* @param vertex
|
||||
* @param graphData
|
||||
* @param newNodes (optional) object describing new nodes encountered
|
||||
*/
|
||||
export function createEdgesfromNode(
|
||||
vertex: GraphData.GremlinVertex,
|
||||
graphData: GraphData.GraphData<GraphData.GremlinVertex, GraphData.GremlinEdge>,
|
||||
newNodes?: { [id: string]: boolean }
|
||||
): void {
|
||||
if (Object.prototype.hasOwnProperty.call(vertex, "outE")) {
|
||||
const outE = vertex.outE;
|
||||
for (const label in outE) {
|
||||
$.each(outE[label], (index: number, edge: EdgePropertyType) => {
|
||||
// We create our own edge. No need to fetch
|
||||
const e = {
|
||||
id: edge.id,
|
||||
label: label,
|
||||
inV: edge.inV,
|
||||
outV: vertex.id,
|
||||
};
|
||||
|
||||
graphData.addEdge(e);
|
||||
if (newNodes) {
|
||||
newNodes[edge.outV] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
graphData.addEdge(e);
|
||||
if (newNodes) {
|
||||
newNodes[edge.inV] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(vertex, "inE")) {
|
||||
const inE = vertex.inE;
|
||||
for (const label in inE) {
|
||||
$.each(inE[label], (index: number, edge: EdgePropertyType) => {
|
||||
// We create our own edge. No need to fetch
|
||||
const e = {
|
||||
id: edge.id,
|
||||
label: label,
|
||||
inV: vertex.id,
|
||||
outV: edge.outV,
|
||||
};
|
||||
|
||||
/**
|
||||
* From ['id1', 'id2', 'idn'] build the following string "'id1','id2','idn'".
|
||||
* The string length cannot exceed maxSize.
|
||||
* @param array
|
||||
* @param maxSize
|
||||
* @return
|
||||
*/
|
||||
public static getLimitedArrayString(array: string[], maxSize: number): JoinArrayMaxCharOutput {
|
||||
if (!array || array.length === 0 || array[0].length + 2 > maxSize) {
|
||||
return { result: "", consumedCount: 0 };
|
||||
graphData.addEdge(e);
|
||||
if (newNodes) {
|
||||
newNodes[edge.outV] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const end = array.length - 1;
|
||||
let output = `'${array[0]}'`;
|
||||
let i = 0;
|
||||
for (; i < end; i++) {
|
||||
const candidate = `${output},'${array[i + 1]}'`;
|
||||
if (candidate.length <= maxSize) {
|
||||
output = candidate;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
result: output,
|
||||
consumedCount: i + 1,
|
||||
};
|
||||
}
|
||||
|
||||
public static createFetchEdgePairQuery(
|
||||
outE: boolean,
|
||||
pkid: string,
|
||||
excludedEdgeIds: string[],
|
||||
startIndex: number,
|
||||
pageSize: number,
|
||||
withoutStepArgMaxLenght: number
|
||||
): string {
|
||||
let gremlinQuery: string;
|
||||
if (excludedEdgeIds.length > 0) {
|
||||
// build a string up to max char
|
||||
const joined = GraphUtil.getLimitedArrayString(excludedEdgeIds, withoutStepArgMaxLenght);
|
||||
const hasWithoutStep = !!joined.result ? `.has(id, without(${joined.result}))` : "";
|
||||
|
||||
if (joined.consumedCount === excludedEdgeIds.length) {
|
||||
gremlinQuery = `g.V(${pkid}).${outE ? "outE" : "inE"}()${hasWithoutStep}.limit(${pageSize}).as('e').${
|
||||
outE ? "inV" : "outV"
|
||||
}().as('v').select('e', 'v')`;
|
||||
} else {
|
||||
const start = startIndex - joined.consumedCount;
|
||||
gremlinQuery = `g.V(${pkid}).${outE ? "outE" : "inE"}()${hasWithoutStep}.range(${start},${
|
||||
start + pageSize
|
||||
}).as('e').${outE ? "inV" : "outV"}().as('v').select('e', 'v')`;
|
||||
}
|
||||
} else {
|
||||
gremlinQuery = `g.V(${pkid}).${outE ? "outE" : "inE"}().limit(${pageSize}).as('e').${
|
||||
outE ? "inV" : "outV"
|
||||
}().as('v').select('e', 'v')`;
|
||||
}
|
||||
return gremlinQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim graph
|
||||
*/
|
||||
public static trimGraph(
|
||||
currentRoot: GraphData.GremlinVertex,
|
||||
graphData: GraphData.GraphData<GraphData.GremlinVertex, GraphData.GremlinEdge>
|
||||
) {
|
||||
const importantNodes = [currentRoot.id].concat(currentRoot._ancestorsId);
|
||||
graphData.unloadAllVertices(importantNodes);
|
||||
|
||||
// Keep only ancestors node in fixed position
|
||||
$.each(graphData.ids, (index: number, id: string) => {
|
||||
graphData.getVertexById(id)._isFixedPosition = importantNodes.indexOf(id) !== -1;
|
||||
});
|
||||
}
|
||||
|
||||
public static addRootChildToGraph(
|
||||
root: GraphData.GremlinVertex,
|
||||
child: GraphData.GremlinVertex,
|
||||
graphData: GraphData.GraphData<GraphData.GremlinVertex, GraphData.GremlinEdge>
|
||||
) {
|
||||
child._ancestorsId = (root._ancestorsId || []).concat([root.id]);
|
||||
graphData.addVertex(child);
|
||||
GraphUtil.createEdgesfromNode(child, graphData);
|
||||
graphData.addNeighborInfo(child);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Perform minimal substitution to prevent breaking gremlin query and allow \"" for now.
|
||||
* @param value
|
||||
*/
|
||||
public static escapeDoubleQuotes(value: string): string {
|
||||
return value == null ? value : value.replace(/"/g, '\\"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Surround with double-quotes if val is a string.
|
||||
* @param val
|
||||
*/
|
||||
public static getQuotedPropValue(ip: ViewModels.InputPropertyValue): string {
|
||||
switch (ip.type) {
|
||||
case "number":
|
||||
case "boolean":
|
||||
return `${ip.value}`;
|
||||
case "null":
|
||||
return null;
|
||||
default:
|
||||
return `"${GraphUtil.escapeDoubleQuotes(ip.value as string)}"`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Perform minimal substitution to prevent breaking gremlin query and allow \' for now.
|
||||
* @param value
|
||||
*/
|
||||
public static escapeSingleQuotes(value: string): string {
|
||||
return value == null ? value : value.replace(/'/g, "\\'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* From ['id1', 'id2', 'idn'] build the following string "'id1','id2','idn'".
|
||||
* The string length cannot exceed maxSize.
|
||||
* @param array
|
||||
* @param maxSize
|
||||
* @return
|
||||
*/
|
||||
export function getLimitedArrayString(array: string[], maxSize: number): JoinArrayMaxCharOutput {
|
||||
if (!array || array.length === 0 || array[0].length + 2 > maxSize) {
|
||||
return { result: "", consumedCount: 0 };
|
||||
}
|
||||
|
||||
const end = array.length - 1;
|
||||
let output = `'${array[0]}'`;
|
||||
let i = 0;
|
||||
for (; i < end; i++) {
|
||||
const candidate = `${output},'${array[i + 1]}'`;
|
||||
if (candidate.length <= maxSize) {
|
||||
output = candidate;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
result: output,
|
||||
consumedCount: i + 1,
|
||||
};
|
||||
}
|
||||
|
||||
export function createFetchEdgePairQuery(
|
||||
outE: boolean,
|
||||
pkid: string,
|
||||
excludedEdgeIds: string[],
|
||||
startIndex: number,
|
||||
pageSize: number,
|
||||
withoutStepArgMaxLenght: number
|
||||
): string {
|
||||
let gremlinQuery: string;
|
||||
if (excludedEdgeIds.length > 0) {
|
||||
// build a string up to max char
|
||||
const joined = getLimitedArrayString(excludedEdgeIds, withoutStepArgMaxLenght);
|
||||
const hasWithoutStep = joined.result ? `.has(id, without(${joined.result}))` : "";
|
||||
|
||||
if (joined.consumedCount === excludedEdgeIds.length) {
|
||||
gremlinQuery = `g.V(${pkid}).${outE ? "outE" : "inE"}()${hasWithoutStep}.limit(${pageSize}).as('e').${
|
||||
outE ? "inV" : "outV"
|
||||
}().as('v').select('e', 'v')`;
|
||||
} else {
|
||||
const start = startIndex - joined.consumedCount;
|
||||
gremlinQuery = `g.V(${pkid}).${outE ? "outE" : "inE"}()${hasWithoutStep}.range(${start},${
|
||||
start + pageSize
|
||||
}).as('e').${outE ? "inV" : "outV"}().as('v').select('e', 'v')`;
|
||||
}
|
||||
} else {
|
||||
gremlinQuery = `g.V(${pkid}).${outE ? "outE" : "inE"}().limit(${pageSize}).as('e').${
|
||||
outE ? "inV" : "outV"
|
||||
}().as('v').select('e', 'v')`;
|
||||
}
|
||||
return gremlinQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim graph
|
||||
*/
|
||||
export function trimGraph(
|
||||
currentRoot: GraphData.GremlinVertex,
|
||||
graphData: GraphData.GraphData<GraphData.GremlinVertex, GraphData.GremlinEdge>
|
||||
) {
|
||||
const importantNodes = [currentRoot.id].concat(currentRoot._ancestorsId);
|
||||
graphData.unloadAllVertices(importantNodes);
|
||||
|
||||
// Keep only ancestors node in fixed position
|
||||
$.each(graphData.ids, (index: number, id: string) => {
|
||||
graphData.getVertexById(id)._isFixedPosition = importantNodes.indexOf(id) !== -1;
|
||||
});
|
||||
}
|
||||
|
||||
export function addRootChildToGraph(
|
||||
root: GraphData.GremlinVertex,
|
||||
child: GraphData.GremlinVertex,
|
||||
graphData: GraphData.GraphData<GraphData.GremlinVertex, GraphData.GremlinEdge>
|
||||
) {
|
||||
child._ancestorsId = (root._ancestorsId || []).concat([root.id]);
|
||||
graphData.addVertex(child);
|
||||
createEdgesfromNode(child, graphData);
|
||||
graphData.addNeighborInfo(child);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Perform minimal substitution to prevent breaking gremlin query and allow \"" for now.
|
||||
* @param value
|
||||
*/
|
||||
export function escapeDoubleQuotes(value: string): string {
|
||||
return value === undefined ? value : value.replace(/"/g, '\\"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Surround with double-quotes if val is a string.
|
||||
* @param val
|
||||
*/
|
||||
export function getQuotedPropValue(ip: ViewModels.InputPropertyValue): string {
|
||||
switch (ip.type) {
|
||||
case "number":
|
||||
case "boolean":
|
||||
return `${ip.value}`;
|
||||
case "null":
|
||||
return undefined;
|
||||
default:
|
||||
return `"${escapeDoubleQuotes(ip.value as string)}"`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Perform minimal substitution to prevent breaking gremlin query and allow \' for now.
|
||||
* @param value
|
||||
*/
|
||||
export function escapeSingleQuotes(value: string): string {
|
||||
return value === undefined ? value : value.replace(/'/g, "\\'");
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
import * as React from "react";
|
||||
import { GraphHighlightedNodeData, NeighborVertexBasicInfo } from "./GraphExplorer";
|
||||
import { GraphUtil } from "./GraphUtil";
|
||||
import * as GraphUtil from "./GraphUtil";
|
||||
import { AccessibleElement } from "../../Controls/AccessibleElement/AccessibleElement";
|
||||
|
||||
export interface ReadOnlyNeighborsComponentProps {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { StringUtils } from "../../../../../Utils/StringUtils";
|
||||
import * as StringUtils from "../../../../../Utils/StringUtils";
|
||||
import { actions, AppState, ContentRef, selectors } from "@nteract/core";
|
||||
import { IMonacoProps as MonacoEditorProps } from "@nteract/monaco-editor";
|
||||
import * as React from "react";
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
||||
import { StringUtils } from "../../Utils/StringUtils";
|
||||
import * as StringUtils from "../../Utils/StringUtils";
|
||||
import { FileSystemUtil } from "./FileSystemUtil";
|
||||
import * as NotebookUtil from "./NotebookUtil";
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import path from "path";
|
||||
import { ImmutableNotebook, ImmutableCodeCell } from "@nteract/commutable";
|
||||
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
||||
import { StringUtils } from "../../Utils/StringUtils";
|
||||
import * as StringUtils from "../../Utils/StringUtils";
|
||||
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
||||
|
||||
// Must match rx-jupyter' FileType
|
||||
|
@ -6,7 +6,7 @@ import { IPinnedRepo, JunoClient } from "../../Juno/JunoClient";
|
||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
||||
import { JunoUtils } from "../../Utils/JunoUtils";
|
||||
import * as JunoUtils from "../../Utils/JunoUtils";
|
||||
import { AuthorizeAccessComponent } from "../Controls/GitHub/AuthorizeAccessComponent";
|
||||
import { GitHubReposComponent, GitHubReposComponentProps, RepoListItem } from "../Controls/GitHub/GitHubReposComponent";
|
||||
import { GitHubReposComponentAdapter } from "../Controls/GitHub/GitHubReposComponentAdapter";
|
||||
|
@ -37,23 +37,6 @@ export function containItems<T>(items: T[]): boolean {
|
||||
return items && items.length > 0;
|
||||
}
|
||||
|
||||
// export function setTargetIcon(idToIconHandlerMap: CloudHub.Common.IToolbarElementIdIconMap, $sourceElement: JQuery, toIconState: IconState): void {
|
||||
// if (idToIconHandlerMap) {
|
||||
// var iconId: string = $sourceElement.attr("id");
|
||||
// var iconHandler = idToIconHandlerMap[iconId];
|
||||
// switch (toIconState) {
|
||||
// case IconState.default:
|
||||
// iconHandler.observable(iconHandler.default);
|
||||
// break;
|
||||
// case IconState.hoverState:
|
||||
// iconHandler.observable(iconHandler.hoverState);
|
||||
// break;
|
||||
// default:
|
||||
// window.console.log("error");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
export function addCssClass($sourceElement: JQuery, cssClassName: string): void {
|
||||
if (!$sourceElement.hasClass(cssClassName)) {
|
||||
$sourceElement.addClass(cssClassName);
|
||||
@ -78,8 +61,9 @@ export function getPropertyIntersectionFromTableEntities(
|
||||
entities: Entities.ITableEntity[],
|
||||
isCassandraApi: boolean
|
||||
): string[] {
|
||||
var headerUnion: string[] = [];
|
||||
const headerUnion: string[] = [];
|
||||
entities &&
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
entities.forEach((row: any) => {
|
||||
const keys = Object.keys(row);
|
||||
keys &&
|
||||
|
@ -2,26 +2,26 @@ const epochTicks = 621355968000000000;
|
||||
const ticksPerMillisecond = 10000;
|
||||
|
||||
export function getLocalDateTime(dateTime: string): string {
|
||||
var dateTimeObject: Date = new Date(dateTime);
|
||||
var year: number = dateTimeObject.getFullYear();
|
||||
var month: string = ensureDoubleDigits(dateTimeObject.getMonth() + 1); // Month ranges from 0 to 11
|
||||
var day: string = ensureDoubleDigits(dateTimeObject.getDate());
|
||||
var hours: string = ensureDoubleDigits(dateTimeObject.getHours());
|
||||
var minutes: string = ensureDoubleDigits(dateTimeObject.getMinutes());
|
||||
var seconds: string = ensureDoubleDigits(dateTimeObject.getSeconds());
|
||||
var milliseconds: string = ensureTripleDigits(dateTimeObject.getMilliseconds());
|
||||
const dateTimeObject: Date = new Date(dateTime);
|
||||
const year: number = dateTimeObject.getFullYear();
|
||||
const month: string = ensureDoubleDigits(dateTimeObject.getMonth() + 1); // Month ranges from 0 to 11
|
||||
const day: string = ensureDoubleDigits(dateTimeObject.getDate());
|
||||
const hours: string = ensureDoubleDigits(dateTimeObject.getHours());
|
||||
const minutes: string = ensureDoubleDigits(dateTimeObject.getMinutes());
|
||||
const seconds: string = ensureDoubleDigits(dateTimeObject.getSeconds());
|
||||
const milliseconds: string = ensureTripleDigits(dateTimeObject.getMilliseconds());
|
||||
|
||||
var localDateTime: string = `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${milliseconds}`;
|
||||
const localDateTime = `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${milliseconds}`;
|
||||
return localDateTime;
|
||||
}
|
||||
|
||||
export function getUTCDateTime(dateTime: string): string {
|
||||
var dateTimeObject: Date = new Date(dateTime);
|
||||
const dateTimeObject = new Date(dateTime);
|
||||
return dateTimeObject.toISOString();
|
||||
}
|
||||
|
||||
export function ensureDoubleDigits(num: number): string {
|
||||
var doubleDigitsString: string = num.toString();
|
||||
let doubleDigitsString: string = num.toString();
|
||||
if (num < 10) {
|
||||
doubleDigitsString = `0${doubleDigitsString}`;
|
||||
} else if (num > 99) {
|
||||
@ -31,7 +31,7 @@ export function ensureDoubleDigits(num: number): string {
|
||||
}
|
||||
|
||||
export function ensureTripleDigits(num: number): string {
|
||||
var tripleDigitsString: string = num.toString();
|
||||
let tripleDigitsString: string = num.toString();
|
||||
if (num < 10) {
|
||||
tripleDigitsString = `00${tripleDigitsString}`;
|
||||
} else if (num < 100) {
|
||||
@ -51,17 +51,17 @@ export function convertJSDateToUnix(dateTime: string): number {
|
||||
}
|
||||
|
||||
export function convertTicksToJSDate(ticks: string): Date {
|
||||
var ticksJSBased = Number(ticks) - epochTicks;
|
||||
var timeInMillisecond = ticksJSBased / ticksPerMillisecond;
|
||||
const ticksJSBased = Number(ticks) - epochTicks;
|
||||
const timeInMillisecond = ticksJSBased / ticksPerMillisecond;
|
||||
return new Date(timeInMillisecond);
|
||||
}
|
||||
|
||||
export function convertJSDateToTicksWithPadding(dateTime: string): string {
|
||||
var ticks = epochTicks + new Date(dateTime).getTime() * ticksPerMillisecond;
|
||||
const ticks = epochTicks + new Date(dateTime).getTime() * ticksPerMillisecond;
|
||||
return padDateTicksWithZeros(ticks.toString());
|
||||
}
|
||||
|
||||
function padDateTicksWithZeros(value: string): string {
|
||||
var s = "0000000000000000000" + value;
|
||||
const s = "0000000000000000000" + value;
|
||||
return s.substr(s.length - 20);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstan
|
||||
import { RouteHandler } from "../../RouteHandlers/RouteHandler";
|
||||
import { WaitsForTemplateViewModel } from "../WaitsForTemplateViewModel";
|
||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import ThemeUtility from "../../Common/ThemeUtility";
|
||||
import * as ThemeUtility from "../../Common/ThemeUtility";
|
||||
import Explorer from "../Explorer";
|
||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
import * as Constants from "../Common/Constants";
|
||||
import * as AuthorizationUtils from "./AuthorizationUtils";
|
||||
import { AuthType } from "../AuthType";
|
||||
import Explorer from "../Explorer/Explorer";
|
||||
import { updateUserContext } from "../UserContext";
|
||||
import { Platform, updateConfigContext } from "../ConfigContext";
|
||||
jest.mock("../Explorer/Explorer");
|
||||
|
||||
describe("AuthorizationUtils", () => {
|
||||
@ -34,10 +32,6 @@ describe("AuthorizationUtils", () => {
|
||||
expect(() => AuthorizationUtils.decryptJWTToken(undefined)).toThrowError();
|
||||
});
|
||||
|
||||
it("should throw an error if token is null", () => {
|
||||
expect(() => AuthorizationUtils.decryptJWTToken(null)).toThrowError();
|
||||
});
|
||||
|
||||
it("should throw an error if token is empty", () => {
|
||||
expect(() => AuthorizationUtils.decryptJWTToken("")).toThrowError();
|
||||
});
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { AuthType } from "../AuthType";
|
||||
import * as Constants from "../Common/Constants";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { configContext, Platform } from "../ConfigContext";
|
||||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { RepoListItem } from "../Explorer/Controls/GitHub/GitHubReposComponent";
|
||||
import { IPinnedRepo } from "../Juno/JunoClient";
|
||||
import { JunoUtils } from "./JunoUtils";
|
||||
import * as JunoUtils from "./JunoUtils";
|
||||
import { IGitHubRepo } from "../GitHub/GitHubClient";
|
||||
|
||||
const gitHubRepo: IGitHubRepo = {
|
||||
|
@ -2,21 +2,19 @@ import { RepoListItem } from "../Explorer/Controls/GitHub/GitHubReposComponent";
|
||||
import { IGitHubRepo } from "../GitHub/GitHubClient";
|
||||
import { IPinnedRepo } from "../Juno/JunoClient";
|
||||
|
||||
export class JunoUtils {
|
||||
public static toPinnedRepo(item: RepoListItem): IPinnedRepo {
|
||||
return {
|
||||
owner: item.repo.owner,
|
||||
name: item.repo.name,
|
||||
private: item.repo.private,
|
||||
branches: item.branches.map((element) => ({ name: element.name })),
|
||||
};
|
||||
}
|
||||
|
||||
public static toGitHubRepo(pinnedRepo: IPinnedRepo): IGitHubRepo {
|
||||
return {
|
||||
owner: pinnedRepo.owner,
|
||||
name: pinnedRepo.name,
|
||||
private: pinnedRepo.private,
|
||||
};
|
||||
}
|
||||
export function toPinnedRepo(item: RepoListItem): IPinnedRepo {
|
||||
return {
|
||||
owner: item.repo.owner,
|
||||
name: item.repo.name,
|
||||
private: item.repo.private,
|
||||
branches: item.branches.map((element) => ({ name: element.name })),
|
||||
};
|
||||
}
|
||||
|
||||
export function toGitHubRepo(pinnedRepo: IPinnedRepo): IGitHubRepo {
|
||||
return {
|
||||
owner: pinnedRepo.owner,
|
||||
name: pinnedRepo.name,
|
||||
private: pinnedRepo.private,
|
||||
};
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { StringUtils } from "./StringUtils";
|
||||
import * as StringUtils from "./StringUtils";
|
||||
|
||||
describe("StringUtils", () => {
|
||||
describe("stripSpacesFromString()", () => {
|
||||
@ -12,9 +12,9 @@ describe("StringUtils", () => {
|
||||
expect(transformedString).toBe("abc");
|
||||
});
|
||||
|
||||
it("should return null if input is null", () => {
|
||||
const transformedString: string = StringUtils.stripSpacesFromString(null);
|
||||
expect(transformedString).toBeNull();
|
||||
it("should return undefined if input is undefined", () => {
|
||||
const transformedString: string = StringUtils.stripSpacesFromString(undefined);
|
||||
expect(transformedString).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should return undefined if input is undefiend", () => {
|
||||
|
@ -1,21 +1,19 @@
|
||||
export class StringUtils {
|
||||
public static stripSpacesFromString(inputString: string): string {
|
||||
if (inputString == null || typeof inputString !== "string") {
|
||||
return inputString;
|
||||
}
|
||||
return inputString.replace(/ /g, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of endsWith which works for IE
|
||||
* @param stringToTest
|
||||
* @param suffix
|
||||
*/
|
||||
public static endsWith(stringToTest: string, suffix: string): boolean {
|
||||
return stringToTest.indexOf(suffix, stringToTest.length - suffix.length) !== -1;
|
||||
}
|
||||
|
||||
public static startsWith(stringToTest: string, prefix: string): boolean {
|
||||
return stringToTest.indexOf(prefix) === 0;
|
||||
export function stripSpacesFromString(inputString: string): string {
|
||||
if (inputString === undefined || typeof inputString !== "string") {
|
||||
return inputString;
|
||||
}
|
||||
return inputString.replace(/ /g, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of endsWith which works for IE
|
||||
* @param stringToTest
|
||||
* @param suffix
|
||||
*/
|
||||
export function endsWith(stringToTest: string, suffix: string): boolean {
|
||||
return stringToTest.indexOf(suffix, stringToTest.length - suffix.length) !== -1;
|
||||
}
|
||||
|
||||
export function startsWith(stringToTest: string, prefix: string): boolean {
|
||||
return stringToTest.indexOf(prefix) === 0;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import { createDatabase, onClickSaveButton } from "../utils/shared";
|
||||
import { generateUniqueName } from "../utils/shared";
|
||||
import { ApiKind } from "../../src/Contracts/DataModels";
|
||||
|
||||
const LOADING_STATE_DELAY = 3000;
|
||||
const LOADING_STATE_DELAY = 5000;
|
||||
jest.setTimeout(300000);
|
||||
|
||||
describe("MongoDB Index policy tests", () => {
|
||||
@ -74,6 +74,7 @@ describe("MongoDB Index policy tests", () => {
|
||||
let singleFieldIndexInserted = false,
|
||||
wildCardIndexInserted = false;
|
||||
await frame.waitFor("div[data-automationid='DetailsRowCell'] > span"), { visible: true };
|
||||
await frame.waitFor(20000);
|
||||
|
||||
const elements = await frame.$$("div[data-automationid='DetailsRowCell'] > span");
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
|
@ -3,6 +3,14 @@ import "expect-puppeteer";
|
||||
import { Frame } from "puppeteer";
|
||||
import { generateDatabaseName, generateUniqueName } from "../utils/shared";
|
||||
import { CosmosClient, PermissionMode } from "@azure/cosmos";
|
||||
import { CosmosDBManagementClient } from "@azure/arm-cosmosdb";
|
||||
import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";
|
||||
|
||||
const clientId = process.env["NOTEBOOKS_TEST_RUNNER_CLIENT_ID"];
|
||||
const secret = process.env["NOTEBOOKS_TEST_RUNNER_CLIENT_SECRET"];
|
||||
const tenantId = "72f988bf-86f1-41af-91ab-2d7cd011db47";
|
||||
const subscriptionId = "69e02f2d-f059-4409-9eac-97e8a276ae2c";
|
||||
const resourceGroupName = "runners";
|
||||
|
||||
jest.setTimeout(300000);
|
||||
const RETRY_DELAY = 5000;
|
||||
@ -10,11 +18,16 @@ const CREATE_DELAY = 10000;
|
||||
|
||||
describe("Collection Add and Delete SQL spec", () => {
|
||||
it("creates a collection", async () => {
|
||||
const credentials = await msRestNodeAuth.loginWithServicePrincipalSecret(clientId, secret, tenantId);
|
||||
const armClient = new CosmosDBManagementClient(credentials, subscriptionId);
|
||||
const account = await armClient.databaseAccounts.get(resourceGroupName, "portal-sql-runner");
|
||||
const keys = await armClient.databaseAccounts.listKeys(resourceGroupName, "portal-sql-runner");
|
||||
const dbId = generateDatabaseName();
|
||||
const collectionId = generateUniqueName("col");
|
||||
const connectionString = process.env.PORTAL_RUNNER_CONNECTION_STRING;
|
||||
const client = new CosmosClient(connectionString);
|
||||
const endpoint = /AccountEndpoint=(.*);/.exec(connectionString)[1];
|
||||
const client = new CosmosClient({
|
||||
endpoint: account.documentEndpoint,
|
||||
key: keys.primaryMasterKey,
|
||||
});
|
||||
const { database } = await client.databases.createIfNotExists({ id: dbId });
|
||||
const { container } = await database.containers.createIfNotExists({ id: collectionId });
|
||||
const { user } = await database.users.upsert({ id: "testUser" });
|
||||
@ -23,7 +36,7 @@ describe("Collection Add and Delete SQL spec", () => {
|
||||
permissionMode: PermissionMode.All,
|
||||
resource: container.url,
|
||||
});
|
||||
const resourceTokenConnectionString = `AccountEndpoint=${endpoint};DatabaseId=${database.id};CollectionId=${container.id};${containerPermission._token}`;
|
||||
const resourceTokenConnectionString = `AccountEndpoint=${account.documentEndpoint};DatabaseId=${database.id};CollectionId=${container.id};${containerPermission._token}`;
|
||||
try {
|
||||
await page.goto(process.env.DATA_EXPLORER_ENDPOINT);
|
||||
await page.waitFor("div > p.switchConnectTypeText", { visible: true });
|
||||
|
@ -30,7 +30,7 @@ export function generateDatabaseName(baseName = "db", length = 1): string {
|
||||
return `${baseName}${crypto.randomBytes(length).toString("hex")}-${Date.now()}`;
|
||||
}
|
||||
|
||||
export async function createDatabase(frame: Frame) {
|
||||
export async function createDatabase(frame: Frame): Promise<string> {
|
||||
const dbId = generateDatabaseName();
|
||||
const collectionId = generateUniqueName("col");
|
||||
const shardKey = "partitionKey";
|
||||
@ -70,7 +70,7 @@ export async function createDatabase(frame: Frame) {
|
||||
return dbId;
|
||||
}
|
||||
|
||||
export async function onClickSaveButton(frame: Frame) {
|
||||
export async function onClickSaveButton(frame: Frame): Promise<void> {
|
||||
await frame.waitFor(`button[data-test="Save"]`), { visible: true };
|
||||
await frame.waitFor(LOADING_STATE_DELAY);
|
||||
await frame.click(`button[data-test="Save"]`);
|
||||
|
Loading…
Reference in New Issue
Block a user