mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-27 04:41:48 +00:00
Compare commits
7 Commits
fix_eslint
...
resolve_De
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
243329aa3d | ||
|
|
ae69fe30f2 | ||
|
|
a6a50297de | ||
|
|
c0bcd6294a | ||
|
|
5f356b509a | ||
|
|
ca5dbb856d | ||
|
|
a9e758f67c |
@@ -80,16 +80,19 @@ src/Explorer/Tables/DataTable/CacheBase.ts
|
||||
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/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/QueryBuilder/CustomTimestampHelper.ts
|
||||
# src/Explorer/Tables/Entities.ts
|
||||
src/Explorer/Tables/QueryBuilder/CustomTimestampHelper.ts
|
||||
src/Explorer/Tables/TableDataClient.ts
|
||||
src/Explorer/Tables/TableEntityProcessor.ts
|
||||
src/Explorer/Tables/Utilities.ts
|
||||
src/Explorer/Tabs/ConflictsTab.ts
|
||||
src/Explorer/Tabs/DatabaseSettingsTab.ts
|
||||
src/Explorer/Tabs/DocumentsTab.test.ts
|
||||
src/Explorer/Tabs/DocumentsTab.ts
|
||||
src/Explorer/Tabs/GraphTab.ts
|
||||
src/Explorer/Tabs/MongoDocumentsTab.ts
|
||||
@@ -114,8 +117,6 @@ src/Index.ts
|
||||
src/Platform/Hosted/Authorization.ts
|
||||
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
|
||||
@@ -130,13 +131,20 @@ 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
|
||||
|
||||
@@ -58,7 +58,7 @@ export class LeftPaneComponent extends React.Component<LeftPaneComponentProps> {
|
||||
className={className}
|
||||
as="tr"
|
||||
aria-label={node.caption}
|
||||
onActivated={() => this.props.onRootNodeSelected(node.id)}
|
||||
onActivated={(e) => this.props.onRootNodeSelected(node.id)}
|
||||
key={node.id}
|
||||
>
|
||||
<td className="resultItem">
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from "react";
|
||||
import { mount, ReactWrapper } from "enzyme";
|
||||
import * as Q from "q";
|
||||
import React from "react";
|
||||
import { GraphHighlightedNodeData, PossibleVertex } from "./GraphExplorer";
|
||||
import { Mode, NodePropertiesComponent, NodePropertiesComponentProps } from "./NodePropertiesComponent";
|
||||
import { NodePropertiesComponent, NodePropertiesComponentProps, Mode } from "./NodePropertiesComponent";
|
||||
import { GraphHighlightedNodeData, EditedProperties, EditedEdges, PossibleVertex } from "./GraphExplorer";
|
||||
|
||||
describe("Property pane", () => {
|
||||
const title = "My Title";
|
||||
@@ -37,18 +37,17 @@ describe("Property pane", () => {
|
||||
return {
|
||||
expandedTitle: title,
|
||||
isCollapsed: false,
|
||||
onCollapsedChanged: jest.fn(),
|
||||
onCollapsedChanged: (newValue: boolean): void => {},
|
||||
node: highlightedNode,
|
||||
getPkIdFromNodeData: (): string => undefined,
|
||||
collectionPartitionKeyProperty: undefined,
|
||||
updateVertexProperties: (): Q.Promise<void> => Q.resolve(),
|
||||
selectNode: jest.fn(),
|
||||
updatePossibleVertices: (): Q.Promise<PossibleVertex[]> => Q.resolve(undefined),
|
||||
possibleEdgeLabels: undefined,
|
||||
//eslint-disable-next-line
|
||||
editGraphEdges: (): Q.Promise<any> => Q.resolve(),
|
||||
deleteHighlightedNode: jest.fn(),
|
||||
onModeChanged: jest.fn(),
|
||||
getPkIdFromNodeData: (v: GraphHighlightedNodeData): string => null,
|
||||
collectionPartitionKeyProperty: null,
|
||||
updateVertexProperties: (editedProperties: EditedProperties): Q.Promise<void> => Q.resolve(),
|
||||
selectNode: (id: string): void => {},
|
||||
updatePossibleVertices: (): Q.Promise<PossibleVertex[]> => Q.resolve(null),
|
||||
possibleEdgeLabels: null,
|
||||
editGraphEdges: (editedEdges: EditedEdges): Q.Promise<any> => Q.resolve(),
|
||||
deleteHighlightedNode: (): void => {},
|
||||
onModeChanged: (newMode: Mode): void => {},
|
||||
viewMode: Mode.READONLY_PROP,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -72,7 +72,7 @@ export class NodePropertiesComponent extends React.Component<
|
||||
super(props);
|
||||
this.state = {
|
||||
editedProperties: {
|
||||
pkId: undefined,
|
||||
pkId: null,
|
||||
readOnlyProperties: [],
|
||||
existingProperties: [],
|
||||
addedProperties: [],
|
||||
@@ -98,12 +98,15 @@ export class NodePropertiesComponent extends React.Component<
|
||||
};
|
||||
}
|
||||
|
||||
public static getDerivedStateFromProps(props: NodePropertiesComponentProps): Partial<NodePropertiesComponentState> {
|
||||
public static getDerivedStateFromProps(
|
||||
props: NodePropertiesComponentProps,
|
||||
state: NodePropertiesComponentState
|
||||
): Partial<NodePropertiesComponentState> {
|
||||
if (props.viewMode !== Mode.READONLY_PROP) {
|
||||
return { isDeleteConfirm: false };
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
@@ -135,10 +138,10 @@ export class NodePropertiesComponent extends React.Component<
|
||||
* @param value
|
||||
*/
|
||||
private static getTypeOption(value: any): ViewModels.InputPropertyValueTypeString {
|
||||
if (value === undefined) {
|
||||
if (value == null) {
|
||||
return "null";
|
||||
}
|
||||
const type = typeof value;
|
||||
let type = typeof value;
|
||||
switch (type) {
|
||||
case "number":
|
||||
case "boolean":
|
||||
@@ -169,9 +172,10 @@ export class NodePropertiesComponent extends React.Component<
|
||||
];
|
||||
|
||||
const existingProps: ViewModels.InputProperty[] = [];
|
||||
|
||||
if (this.props.node.hasOwnProperty("properties")) {
|
||||
const hProps = this.props.node["properties"];
|
||||
for (const p in hProps) {
|
||||
for (let p in hProps) {
|
||||
const propValues = hProps[p];
|
||||
(p === partitionKeyProperty ? readOnlyProps : existingProps).push({
|
||||
key: p,
|
||||
@@ -433,7 +437,7 @@ export class NodePropertiesComponent extends React.Component<
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ import * as React from "react";
|
||||
import { useFullScreenURLs } from "../hooks/useFullScreenURLs";
|
||||
|
||||
export const OpenFullScreen: React.FunctionComponent = () => {
|
||||
const [isReadUrlCopy, setIsReadUrlCopy] = React.useState<boolean>(false);
|
||||
const [isReadWriteUrlCopy, setIsReadWriteUrlCopy] = React.useState<boolean>(false);
|
||||
const result = useFullScreenURLs();
|
||||
if (!result) {
|
||||
return <Spinner label="Generating URLs..." ariaLive="assertive" labelPosition="right" />;
|
||||
@@ -27,9 +25,8 @@ export const OpenFullScreen: React.FunctionComponent = () => {
|
||||
<DefaultButton
|
||||
onClick={() => {
|
||||
copyToClipboard(readWriteUrl);
|
||||
setIsReadWriteUrlCopy(true);
|
||||
}}
|
||||
text={isReadWriteUrlCopy ? "Copied" : "Copy"}
|
||||
text="Copy"
|
||||
iconProps={{ iconName: "Copy" }}
|
||||
/>
|
||||
<PrimaryButton
|
||||
@@ -44,10 +41,9 @@ export const OpenFullScreen: React.FunctionComponent = () => {
|
||||
<Stack horizontal tokens={{ childrenGap: 10 }}>
|
||||
<DefaultButton
|
||||
onClick={() => {
|
||||
setIsReadUrlCopy(true);
|
||||
copyToClipboard(readUrl);
|
||||
}}
|
||||
text={isReadUrlCopy ? "Copied" : "Copy"}
|
||||
text="Copy"
|
||||
iconProps={{ iconName: "Copy" }}
|
||||
/>
|
||||
<PrimaryButton
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Collection } from "Contracts/ViewModels";
|
||||
import { useSidePanel } from "hooks/useSidePanel";
|
||||
import { useTabs } from "hooks/useTabs";
|
||||
import React, { FunctionComponent, useState } from "react";
|
||||
import { DefaultExperienceUtility } from "Shared/DefaultExperienceUtility";
|
||||
import * as DefaultExperienceUtility from "Shared/DefaultExperienceUtility";
|
||||
import { Action, ActionModifiers } from "Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "Shared/Telemetry/TelemetryProcessor";
|
||||
import { userContext } from "UserContext";
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Collection, Database } from "Contracts/ViewModels";
|
||||
import { useSidePanel } from "hooks/useSidePanel";
|
||||
import { useTabs } from "hooks/useTabs";
|
||||
import React, { FunctionComponent, useState } from "react";
|
||||
import { DefaultExperienceUtility } from "Shared/DefaultExperienceUtility";
|
||||
import * as DefaultExperienceUtility from "Shared/DefaultExperienceUtility";
|
||||
import { Action, ActionModifiers } from "Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "Shared/Telemetry/TelemetryProcessor";
|
||||
import { userContext } from "UserContext";
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import ko from "knockout";
|
||||
import * as Constants from "../Constants";
|
||||
import * as Entities from "../Entities";
|
||||
import * as Utilities from "../Utilities";
|
||||
|
||||
import * as DataTableOperations from "./DataTableOperations";
|
||||
import * as Constants from "../Constants";
|
||||
import TableCommands from "./TableCommands";
|
||||
import TableEntityListViewModel from "./TableEntityListViewModel";
|
||||
import * as Utilities from "../Utilities";
|
||||
import * as Entities from "../Entities";
|
||||
|
||||
/*
|
||||
* Base class for data table row selection.
|
||||
@@ -24,7 +25,7 @@ export default class DataTableOperationManager {
|
||||
}
|
||||
|
||||
private click = (event: JQueryEventObject) => {
|
||||
const elem: JQuery = $(event.currentTarget);
|
||||
var elem: JQuery = $(event.currentTarget);
|
||||
this.updateLastSelectedItem(elem, event.shiftKey);
|
||||
|
||||
if (Utilities.isEnvironmentCtrlPressed(event)) {
|
||||
@@ -36,30 +37,30 @@ export default class DataTableOperationManager {
|
||||
}
|
||||
};
|
||||
|
||||
private doubleClick = () => {
|
||||
private doubleClick = (event: JQueryEventObject) => {
|
||||
this.tryOpenEditor();
|
||||
};
|
||||
|
||||
private keyDown = (event: JQueryEventObject): boolean => {
|
||||
const isUpArrowKey: boolean = event.keyCode === Constants.keyCodes.UpArrow,
|
||||
isDownArrowKey: boolean = event.keyCode === Constants.keyCodes.DownArrow;
|
||||
let handled = false;
|
||||
var isUpArrowKey: boolean = event.keyCode === Constants.keyCodes.UpArrow,
|
||||
isDownArrowKey: boolean = event.keyCode === Constants.keyCodes.DownArrow,
|
||||
handled: boolean = false;
|
||||
|
||||
if (isUpArrowKey || isDownArrowKey) {
|
||||
const lastSelectedItem: Entities.ITableEntity = this._tableEntityListViewModel.lastSelectedItem;
|
||||
const dataTableRows: JQuery = $(Constants.htmlSelectors.dataTableAllRowsSelector);
|
||||
const maximumIndex = dataTableRows.length - 1;
|
||||
var lastSelectedItem: Entities.ITableEntity = this._tableEntityListViewModel.lastSelectedItem;
|
||||
var dataTableRows: JQuery = $(Constants.htmlSelectors.dataTableAllRowsSelector);
|
||||
var maximumIndex = dataTableRows.length - 1;
|
||||
|
||||
// If can't find an index for lastSelectedItem, then either no item is previously selected or it goes across page.
|
||||
// Simply select the first item in this case.
|
||||
const lastSelectedItemIndex = lastSelectedItem
|
||||
var lastSelectedItemIndex = lastSelectedItem
|
||||
? this._tableEntityListViewModel.getItemIndexFromCurrentPage(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(lastSelectedItem.RowKey._)
|
||||
)
|
||||
: -1;
|
||||
const nextIndex: number = isUpArrowKey ? lastSelectedItemIndex - 1 : lastSelectedItemIndex + 1;
|
||||
const safeIndex: number = Utilities.ensureBetweenBounds(nextIndex, 0, maximumIndex);
|
||||
const selectedRowElement: JQuery = dataTableRows.eq(safeIndex);
|
||||
var nextIndex: number = isUpArrowKey ? lastSelectedItemIndex - 1 : lastSelectedItemIndex + 1;
|
||||
var safeIndex: number = Utilities.ensureBetweenBounds(nextIndex, 0, maximumIndex);
|
||||
var selectedRowElement: JQuery = dataTableRows.eq(safeIndex);
|
||||
|
||||
if (selectedRowElement) {
|
||||
if (event.shiftKey) {
|
||||
@@ -89,7 +90,7 @@ export default class DataTableOperationManager {
|
||||
// in contrast, there may be more than one key down and key
|
||||
// pressed events.
|
||||
private keyUp = (event: JQueryEventObject): boolean => {
|
||||
let handled = false;
|
||||
var handled: boolean = false;
|
||||
|
||||
switch (event.keyCode) {
|
||||
case Constants.keyCodes.Enter:
|
||||
@@ -104,9 +105,8 @@ export default class DataTableOperationManager {
|
||||
};
|
||||
|
||||
private itemDropped = (event: JQueryEventObject): boolean => {
|
||||
const handled = false;
|
||||
//eslint-disable-next-line
|
||||
const items = (<any>event.originalEvent).dataTransfer.items;
|
||||
var handled: boolean = false;
|
||||
var items = (<any>event.originalEvent).dataTransfer.items;
|
||||
|
||||
if (!items) {
|
||||
// On browsers outside of Chromium
|
||||
@@ -115,9 +115,9 @@ export default class DataTableOperationManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
const entry = item.webkitGetAsEntry();
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = items[i];
|
||||
var entry = item.webkitGetAsEntry();
|
||||
|
||||
if (entry.isFile) {
|
||||
// TODO: parse the file and insert content as entities
|
||||
@@ -132,8 +132,8 @@ export default class DataTableOperationManager {
|
||||
}
|
||||
|
||||
private tryHandleDeleteSelected(): boolean {
|
||||
const selectedEntities: Entities.ITableEntity[] = this._tableEntityListViewModel.selected();
|
||||
let handled = false;
|
||||
var selectedEntities: Entities.ITableEntity[] = this._tableEntityListViewModel.selected();
|
||||
var handled: boolean = false;
|
||||
|
||||
if (selectedEntities && selectedEntities.length) {
|
||||
this._tableCommands.deleteEntitiesCommand(this._tableEntityListViewModel);
|
||||
@@ -150,8 +150,8 @@ export default class DataTableOperationManager {
|
||||
}
|
||||
|
||||
private updateLastSelectedItem($elem: JQuery, isShiftSelect: boolean) {
|
||||
const entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
const entity = this._tableEntityListViewModel.getItemFromCurrentPage(
|
||||
var entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
var entity = this._tableEntityListViewModel.getItemFromCurrentPage(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(entityIdentity.RowKey)
|
||||
);
|
||||
|
||||
@@ -164,7 +164,7 @@ export default class DataTableOperationManager {
|
||||
|
||||
private applySingleSelection($elem: JQuery) {
|
||||
if ($elem) {
|
||||
const entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
var entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
|
||||
this._tableEntityListViewModel.clearSelection();
|
||||
this.addToSelection(entityIdentity.RowKey);
|
||||
@@ -180,12 +180,12 @@ export default class DataTableOperationManager {
|
||||
}
|
||||
|
||||
private applyCtrlSelection($elem: JQuery): void {
|
||||
const koSelected: ko.ObservableArray<Entities.ITableEntity> = this._tableEntityListViewModel
|
||||
var koSelected: ko.ObservableArray<Entities.ITableEntity> = this._tableEntityListViewModel
|
||||
? this._tableEntityListViewModel.selected
|
||||
: null;
|
||||
|
||||
if (koSelected) {
|
||||
const entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
var entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
|
||||
if (
|
||||
!this._tableEntityListViewModel.isItemSelected(
|
||||
@@ -201,7 +201,7 @@ export default class DataTableOperationManager {
|
||||
}
|
||||
|
||||
private applyShiftSelection($elem: JQuery): void {
|
||||
let anchorItem = this._tableEntityListViewModel.lastSelectedAnchorItem;
|
||||
var anchorItem = this._tableEntityListViewModel.lastSelectedAnchorItem;
|
||||
|
||||
// If anchor item doesn't exist, use the first available item of current page instead
|
||||
if (!anchorItem && this._tableEntityListViewModel.items().length > 0) {
|
||||
@@ -209,16 +209,16 @@ export default class DataTableOperationManager {
|
||||
}
|
||||
|
||||
if (anchorItem) {
|
||||
const entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
const elementIndex = this._tableEntityListViewModel.getItemIndexFromAllPages(
|
||||
var entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
var elementIndex = this._tableEntityListViewModel.getItemIndexFromAllPages(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(entityIdentity.RowKey)
|
||||
);
|
||||
const anchorIndex = this._tableEntityListViewModel.getItemIndexFromAllPages(
|
||||
var anchorIndex = this._tableEntityListViewModel.getItemIndexFromAllPages(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(anchorItem.RowKey._)
|
||||
);
|
||||
|
||||
const startIndex = Math.min(elementIndex, anchorIndex);
|
||||
const endIndex = Math.max(elementIndex, anchorIndex);
|
||||
var startIndex = Math.min(elementIndex, anchorIndex);
|
||||
var endIndex = Math.max(elementIndex, anchorIndex);
|
||||
|
||||
this._tableEntityListViewModel.clearSelection();
|
||||
ko.utils.arrayPushAll<Entities.ITableEntity>(
|
||||
@@ -229,7 +229,7 @@ export default class DataTableOperationManager {
|
||||
}
|
||||
|
||||
private applyContextMenuSelection($elem: JQuery) {
|
||||
const entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
var entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
|
||||
if (
|
||||
!this._tableEntityListViewModel.isItemSelected(
|
||||
@@ -244,26 +244,26 @@ export default class DataTableOperationManager {
|
||||
}
|
||||
|
||||
private addToSelection(rowKey: string) {
|
||||
const selectedEntity: Entities.ITableEntity = this._tableEntityListViewModel.getItemFromCurrentPage(
|
||||
var selectedEntity: Entities.ITableEntity = this._tableEntityListViewModel.getItemFromCurrentPage(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(rowKey)
|
||||
);
|
||||
|
||||
if (selectedEntity !== null) {
|
||||
if (selectedEntity != null) {
|
||||
this._tableEntityListViewModel.selected.push(selectedEntity);
|
||||
}
|
||||
}
|
||||
|
||||
// Selecting first row if the selection is empty.
|
||||
public selectFirstIfNeeded(): void {
|
||||
const koSelected: ko.ObservableArray<Entities.ITableEntity> = this._tableEntityListViewModel
|
||||
var koSelected: ko.ObservableArray<Entities.ITableEntity> = this._tableEntityListViewModel
|
||||
? this._tableEntityListViewModel.selected
|
||||
: null;
|
||||
const koEntities: ko.ObservableArray<Entities.ITableEntity> = this._tableEntityListViewModel
|
||||
var koEntities: ko.ObservableArray<Entities.ITableEntity> = this._tableEntityListViewModel
|
||||
? this._tableEntityListViewModel.items
|
||||
: null;
|
||||
|
||||
if (!koSelected().length && koEntities().length) {
|
||||
const firstEntity: Entities.ITableEntity = koEntities()[0];
|
||||
var firstEntity: Entities.ITableEntity = koEntities()[0];
|
||||
|
||||
// Clear last selection: lastSelectedItem and lastSelectedAnchorItem
|
||||
this._tableEntityListViewModel.clearLastSelected();
|
||||
@@ -278,7 +278,7 @@ export default class DataTableOperationManager {
|
||||
}
|
||||
}
|
||||
|
||||
public bind(): void {
|
||||
public bind() {
|
||||
this.dataTable.on("click", "tr", this.click);
|
||||
this.dataTable.on("dblclick", "tr", this.doubleClick);
|
||||
this.dataTable.on("keydown", "td", this.keyDown);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as DateTimeUtilities from "./DateTimeUtilities";
|
||||
import QueryBuilderViewModel from "./QueryBuilderViewModel";
|
||||
import QueryClauseViewModel from "./QueryClauseViewModel";
|
||||
import * as DateTimeUtilities from "./DateTimeUtilities";
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
export const utc = "utc";
|
||||
export const local = "local";
|
||||
export var utc = "utc";
|
||||
export var local = "local";
|
||||
|
||||
export interface ITimestampQuery {
|
||||
queryType: string; // valid values are "last" and "range"
|
||||
@@ -41,11 +41,11 @@ export function addRangeTimestamp(
|
||||
queryBuilderViewModel.addCustomRange(timestamp, queryClauseViewModel);
|
||||
}
|
||||
|
||||
export function getDefaultStart(localTime: boolean, durationHours = 24): string {
|
||||
let startTimestamp: string;
|
||||
export function getDefaultStart(localTime: boolean, durationHours: number = 24): string {
|
||||
var startTimestamp: string;
|
||||
|
||||
const utcNowString: string = new Date().toISOString();
|
||||
const yesterday: Date = new Date(utcNowString);
|
||||
var utcNowString: string = new Date().toISOString();
|
||||
var yesterday: Date = new Date(utcNowString);
|
||||
|
||||
yesterday.setHours(yesterday.getHours() - durationHours);
|
||||
startTimestamp = yesterday.toISOString();
|
||||
@@ -58,9 +58,9 @@ export function getDefaultStart(localTime: boolean, durationHours = 24): string
|
||||
}
|
||||
|
||||
export function getDefaultEnd(localTime: boolean): string {
|
||||
let endTimestamp: string;
|
||||
var endTimestamp: string;
|
||||
|
||||
const utcNowString: string = new Date().toISOString();
|
||||
var utcNowString: string = new Date().toISOString();
|
||||
|
||||
endTimestamp = utcNowString;
|
||||
|
||||
@@ -73,14 +73,14 @@ export function getDefaultEnd(localTime: boolean): string {
|
||||
|
||||
export function parseDate(dateString: string, isUTC: boolean): Date {
|
||||
// TODO validate dateString
|
||||
let date: Date = null;
|
||||
var date: Date = null;
|
||||
|
||||
if (dateString) {
|
||||
try {
|
||||
// Date string is assumed to be UTC in Storage Explorer Standalone.
|
||||
// Behavior may vary in other browsers.
|
||||
// Here's an example of how the string looks like "2015-10-24T21:44:12"
|
||||
const millisecondTime = Date.parse(dateString),
|
||||
var millisecondTime = Date.parse(dateString),
|
||||
parsed: Date = new Date(millisecondTime);
|
||||
|
||||
if (isUTC) {
|
||||
@@ -89,7 +89,7 @@ export function parseDate(dateString: string, isUTC: boolean): Date {
|
||||
// Since we parsed in UTC, accessors are flipped - we get local time from the getUTC* group
|
||||
// Reinstating, the date is parsed above as UTC, and here we are creating a new date object
|
||||
// in local time.
|
||||
const year = parsed.getUTCFullYear(),
|
||||
var year = parsed.getUTCFullYear(),
|
||||
month = parsed.getUTCMonth(),
|
||||
day = parsed.getUTCDate(),
|
||||
hours = parsed.getUTCHours(),
|
||||
@@ -109,8 +109,8 @@ export function parseDate(dateString: string, isUTC: boolean): Date {
|
||||
|
||||
export function utcFromLocalDateString(localDateString: string): string {
|
||||
// TODO validate localDateString
|
||||
const localDate = parseDate(localDateString, false);
|
||||
let utcDateString: string = null;
|
||||
var localDate = parseDate(localDateString, false),
|
||||
utcDateString: string = null;
|
||||
|
||||
if (localDate) {
|
||||
utcDateString = localDate.toISOString();
|
||||
@@ -120,7 +120,7 @@ export function utcFromLocalDateString(localDateString: string): string {
|
||||
}
|
||||
|
||||
function padIfNeeded(value: number): string {
|
||||
let padded = String(value);
|
||||
var padded: string = String(value);
|
||||
|
||||
if (0 <= value && value < 10) {
|
||||
padded = "0" + padded;
|
||||
@@ -130,7 +130,7 @@ function padIfNeeded(value: number): string {
|
||||
}
|
||||
|
||||
function toLocalDateString(date: Date): string {
|
||||
let localDateString: string = null;
|
||||
var localDateString: string = null;
|
||||
|
||||
if (date) {
|
||||
localDateString =
|
||||
@@ -152,8 +152,8 @@ function toLocalDateString(date: Date): string {
|
||||
|
||||
export function localFromUtcDateString(utcDateString: string): string {
|
||||
// TODO validate utcDateString
|
||||
const utcDate: Date = parseDate(utcDateString, true);
|
||||
let localDateString: string = null;
|
||||
var utcDate: Date = parseDate(utcDateString, true),
|
||||
localDateString: string = null;
|
||||
|
||||
if (utcDate) {
|
||||
localDateString = toLocalDateString(utcDate);
|
||||
@@ -164,8 +164,8 @@ export function localFromUtcDateString(utcDateString: string): string {
|
||||
|
||||
export function tryChangeTimestampTimeZone(koTimestamp: ko.Observable<string>, toUTC: boolean): void {
|
||||
if (koTimestamp) {
|
||||
const currentDateString: string = koTimestamp();
|
||||
let newDateString: string;
|
||||
var currentDateString: string = koTimestamp(),
|
||||
newDateString: string;
|
||||
|
||||
if (currentDateString) {
|
||||
if (toUTC) {
|
||||
@@ -189,16 +189,16 @@ export function tryChangeTimestampTimeZone(koTimestamp: ko.Observable<string>, t
|
||||
* Input validation helpers
|
||||
*/
|
||||
|
||||
export const noTooltip = "",
|
||||
export var noTooltip = "",
|
||||
invalidStartTimeTooltip = "Please provide a valid start time.", // localize
|
||||
invalidExpiryTimeRequiredTooltip = "Required field. Please provide a valid expiry time.", // localize
|
||||
invalidExpiryTimeGreaterThanStartTimeTooltip = "The expiry time must be greater than the start time."; // localize
|
||||
|
||||
export function isDateString(dateString: string): boolean {
|
||||
let success = false;
|
||||
var success: boolean = false;
|
||||
|
||||
if (dateString) {
|
||||
const date = Date.parse(dateString);
|
||||
var date: number = Date.parse(dateString);
|
||||
|
||||
success = $.isNumeric(date);
|
||||
}
|
||||
@@ -308,10 +308,10 @@ function _getLocalIsoDateStringFromParts(
|
||||
}
|
||||
|
||||
function _addDaysHours(time: Date, days: number, hours: number): Date {
|
||||
const msPerHour = 1000 * 60 * 60;
|
||||
const daysMs = days * msPerHour * 24;
|
||||
const hoursMs = hours * msPerHour;
|
||||
const newTimeMs = time.getTime() + daysMs + hoursMs;
|
||||
var msPerHour = 1000 * 60 * 60;
|
||||
var daysMs = days * msPerHour * 24;
|
||||
var hoursMs = hours * msPerHour;
|
||||
var newTimeMs = time.getTime() + daysMs + hoursMs;
|
||||
return new Date(newTimeMs);
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ function _daysHoursBeforeNow(days: number, hours: number): Date {
|
||||
|
||||
export function _queryLastDaysHours(days: number, hours: number): string {
|
||||
/* tslint:disable: no-unused-variable */
|
||||
let daysHoursAgo = _getLocalIsoDateTimeString(_daysHoursBeforeNow(days, hours));
|
||||
var daysHoursAgo = _getLocalIsoDateTimeString(_daysHoursBeforeNow(days, hours));
|
||||
daysHoursAgo = DateTimeUtilities.getUTCDateTime(daysHoursAgo);
|
||||
|
||||
return daysHoursAgo;
|
||||
@@ -329,21 +329,21 @@ export function _queryLastDaysHours(days: number, hours: number): string {
|
||||
}
|
||||
|
||||
export function _queryCurrentMonthLocal(): string {
|
||||
const now = new Date();
|
||||
let start = _getLocalIsoDateStringFromParts(now.getFullYear(), now.getMonth(), 1);
|
||||
var now = new Date();
|
||||
var start = _getLocalIsoDateStringFromParts(now.getFullYear(), now.getMonth(), 1);
|
||||
start = DateTimeUtilities.getUTCDateTime(start);
|
||||
return start;
|
||||
}
|
||||
|
||||
export function _queryCurrentYearLocal(): string {
|
||||
const now = new Date();
|
||||
let start = _getLocalIsoDateStringFromParts(now.getFullYear(), 0, 1); // Month is 0..11, date is 1..31
|
||||
var now = new Date();
|
||||
var start = _getLocalIsoDateStringFromParts(now.getFullYear(), 0, 1); // Month is 0..11, date is 1..31
|
||||
start = DateTimeUtilities.getUTCDateTime(start);
|
||||
return start;
|
||||
}
|
||||
|
||||
function _addTime(time: Date, lastNumber: number, timeUnit: string): Date {
|
||||
let timeMS: number;
|
||||
var timeMS: number;
|
||||
switch (TimeUnit[Number(timeUnit)]) {
|
||||
case TimeUnit.Days.toString():
|
||||
timeMS = lastNumber * 1000 * 60 * 60 * 24;
|
||||
@@ -360,7 +360,7 @@ function _addTime(time: Date, lastNumber: number, timeUnit: string): Date {
|
||||
default:
|
||||
//throw new Errors.ArgumentOutOfRangeError(timeUnit);
|
||||
}
|
||||
const newTimeMS = time.getTime() + timeMS;
|
||||
var newTimeMS = time.getTime() + timeMS;
|
||||
return new Date(newTimeMS);
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ function _timeBeforeNow(lastNumber: number, timeUnit: string): Date {
|
||||
|
||||
export function _queryLastTime(lastNumber: number, timeUnit: string): string {
|
||||
/* tslint:disable: no-unused-variable */
|
||||
let daysHoursAgo = _getLocalIsoDateTimeString(_timeBeforeNow(lastNumber, timeUnit));
|
||||
var daysHoursAgo = _getLocalIsoDateTimeString(_timeBeforeNow(lastNumber, timeUnit));
|
||||
daysHoursAgo = DateTimeUtilities.getUTCDateTime(daysHoursAgo);
|
||||
return daysHoursAgo;
|
||||
/* tslint:enable: no-unused-variable */
|
||||
|
||||
@@ -10,7 +10,7 @@ describe("Documents tab", () => {
|
||||
describe("buildQuery", () => {
|
||||
it("should generate the right select query for SQL API", () => {
|
||||
const documentsTab = new DocumentsTab({
|
||||
partitionKey: null,
|
||||
partitionKey: undefined,
|
||||
documentIds: ko.observableArray<DocumentId>(),
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
@@ -82,9 +82,9 @@ describe("Documents tab", () => {
|
||||
container: mongoExplorer,
|
||||
});
|
||||
|
||||
it("should be false for null or undefined collection", () => {
|
||||
it("should be false for undefined or undefined collection", () => {
|
||||
const documentsTab = new DocumentsTab({
|
||||
partitionKey: null,
|
||||
partitionKey: undefined,
|
||||
documentIds: ko.observableArray<DocumentId>(),
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
@@ -94,10 +94,10 @@ describe("Documents tab", () => {
|
||||
expect(documentsTab.showPartitionKey).toBe(false);
|
||||
});
|
||||
|
||||
it("should be false for null or undefined partitionKey", () => {
|
||||
it("should be false for undefined or undefined partitionKey", () => {
|
||||
const documentsTab = new DocumentsTab({
|
||||
collection: collectionWithoutPartitionKey,
|
||||
partitionKey: null,
|
||||
partitionKey: undefined,
|
||||
documentIds: ko.observableArray<DocumentId>(),
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
@@ -110,7 +110,7 @@ describe("Documents tab", () => {
|
||||
it("should be true for non-Mongo accounts with system partitionKey", () => {
|
||||
const documentsTab = new DocumentsTab({
|
||||
collection: collectionWithSystemPartitionKey,
|
||||
partitionKey: null,
|
||||
partitionKey: undefined,
|
||||
documentIds: ko.observableArray<DocumentId>(),
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
@@ -126,7 +126,7 @@ describe("Documents tab", () => {
|
||||
});
|
||||
const documentsTab = new DocumentsTab({
|
||||
collection: mongoCollectionWithSystemPartitionKey,
|
||||
partitionKey: null,
|
||||
partitionKey: undefined,
|
||||
documentIds: ko.observableArray<DocumentId>(),
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
@@ -139,7 +139,7 @@ describe("Documents tab", () => {
|
||||
it("should be true for non-system partitionKey", () => {
|
||||
const documentsTab = new DocumentsTab({
|
||||
collection: collectionWithNonSystemPartitionKey,
|
||||
partitionKey: null,
|
||||
partitionKey: undefined,
|
||||
documentIds: ko.observableArray<DocumentId>(),
|
||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||
title: "",
|
||||
|
||||
@@ -118,7 +118,7 @@ export default class NotebookTabV2 extends NotebookTabBase {
|
||||
const saveButtonChildren = [];
|
||||
if (this.container.notebookManager?.gitHubOAuthService.isLoggedIn()) {
|
||||
saveButtonChildren.push({
|
||||
iconName: copyToLabel,
|
||||
iconName: "Copy",
|
||||
onCommandClick: () => this.copyNotebook(),
|
||||
commandButtonLabel: copyToLabel,
|
||||
hasPopup: false,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as ko from "knockout";
|
||||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import * as Constants from "../Common/Constants";
|
||||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
|
||||
export abstract class WaitsForTemplateViewModel implements ViewModels.WaitsForTemplate {
|
||||
public isTemplateReady: ko.Observable<boolean>;
|
||||
@@ -14,11 +14,11 @@ export abstract class WaitsForTemplateViewModel implements ViewModels.WaitsForTe
|
||||
callback(value);
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", function (e: KeyboardEvent) {
|
||||
document.addEventListener("keydown", (e: KeyboardEvent) => {
|
||||
// To trap keyboard focus in AddCollection pane
|
||||
let firstFocusableElement = document.getElementById("closeBtnAddCollection");
|
||||
let lastFocusableElement = document.getElementById("submitBtnAddCollection");
|
||||
var isTabPressed = e.keyCode === Constants.KeyCodes.Tab;
|
||||
const firstFocusableElement = document.getElementById("closeBtnAddCollection");
|
||||
const lastFocusableElement = document.getElementById("submitBtnAddCollection");
|
||||
const isTabPressed = e.keyCode === Constants.KeyCodes.Tab;
|
||||
if (isTabPressed) {
|
||||
if (e.shiftKey) {
|
||||
/* shift + tab */ if (document.activeElement === firstFocusableElement) {
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import { configContext } from "../../ConfigContext";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
||||
import * as DefaultExperienceUtility from "../../Shared/DefaultExperienceUtility";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
export default class AuthHeadersUtil {
|
||||
public static async generateEncryptedToken(readOnly: boolean = false): Promise<DataModels.GenerateTokenResponse> {
|
||||
const url = configContext.BACKEND_ENDPOINT + "/api/tokens/generateToken" + AuthHeadersUtil._generateResourceUrl();
|
||||
const headers: any = { authorization: userContext.authorizationToken };
|
||||
headers[Constants.HttpHeaders.getReadOnlyKey] = readOnly;
|
||||
export const _generateResourceUrl = (): string => {
|
||||
const { databaseAccount, resourceGroup, subscriptionId } = userContext;
|
||||
const apiKind: DataModels.ApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(userContext.apiType);
|
||||
const accountEndpoint = databaseAccount?.properties?.documentEndpoint || "";
|
||||
const sid = subscriptionId || "";
|
||||
const rg = resourceGroup || "";
|
||||
const dba = databaseAccount?.name || "";
|
||||
const resourceUrl = encodeURIComponent(accountEndpoint);
|
||||
const rid = "";
|
||||
const rtype = "";
|
||||
return `?resourceUrl=${resourceUrl}&rid=${rid}&rtype=${rtype}&sid=${sid}&rg=${rg}&dba=${dba}&api=${apiKind}`;
|
||||
};
|
||||
|
||||
const response = await fetch(url, { method: "POST", headers });
|
||||
const result = await response.json();
|
||||
// This API has a quirk where the response must be parsed to JSON twice
|
||||
return JSON.parse(result);
|
||||
}
|
||||
export const generateEncryptedToken = async (readOnly = false): Promise<DataModels.GenerateTokenResponse> => {
|
||||
const url = configContext.BACKEND_ENDPOINT + "/api/tokens/generateToken" + _generateResourceUrl();
|
||||
const headers: any = { authorization: userContext.authorizationToken };
|
||||
headers[Constants.HttpHeaders.getReadOnlyKey] = readOnly;
|
||||
|
||||
private static _generateResourceUrl(): string {
|
||||
const { databaseAccount, resourceGroup, subscriptionId } = userContext;
|
||||
const apiKind: DataModels.ApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(userContext.apiType);
|
||||
const accountEndpoint = databaseAccount?.properties?.documentEndpoint || "";
|
||||
const sid = subscriptionId || "";
|
||||
const rg = resourceGroup || "";
|
||||
const dba = databaseAccount?.name || "";
|
||||
const resourceUrl = encodeURIComponent(accountEndpoint);
|
||||
const rid = "";
|
||||
const rtype = "";
|
||||
return `?resourceUrl=${resourceUrl}&rid=${rid}&rtype=${rtype}&sid=${sid}&rg=${rg}&dba=${dba}&api=${apiKind}`;
|
||||
}
|
||||
}
|
||||
const response = await fetch(url, { method: "POST", headers });
|
||||
const result = await response.json();
|
||||
// This API has a quirk where the response must be parsed to JSON twice
|
||||
return JSON.parse(result);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AccountKind, CapabilityNames } from "../../Common/Constants";
|
||||
import { AccessInputMetadata, ApiKind } from "../../Contracts/DataModels";
|
||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
||||
import * as DefaultExperienceUtility from "../../Shared/DefaultExperienceUtility";
|
||||
import { userContext } from "../../UserContext";
|
||||
|
||||
export function getDatabaseAccountPropertiesFromMetadata(metadata: AccessInputMetadata): unknown {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import { userContext } from "../UserContext";
|
||||
import { DefaultExperienceUtility } from "./DefaultExperienceUtility";
|
||||
import * as DefaultExperienceUtility from "./DefaultExperienceUtility";
|
||||
|
||||
describe("Default Experience Utility", () => {
|
||||
describe("getDefaultExperienceFromApiKind()", () => {
|
||||
function runScenario(apiKind: number, expectedExperience: typeof userContext.apiType): void {
|
||||
const runScenario = (apiKind: number, expectedExperience: typeof userContext.apiType): void => {
|
||||
const resolvedExperience = DefaultExperienceUtility.getDefaultExperienceFromApiKind(apiKind);
|
||||
expect(resolvedExperience).toEqual(expectedExperience);
|
||||
}
|
||||
};
|
||||
|
||||
describe("On SQL", () => {
|
||||
it("should return SQL", () => runScenario(DataModels.ApiKind.SQL, "SQL"));
|
||||
@@ -35,10 +35,10 @@ describe("Default Experience Utility", () => {
|
||||
});
|
||||
|
||||
describe("getApiKindFromDefaultExperience()", () => {
|
||||
function runScenario(defaultExperience: typeof userContext.apiType | null, expectedApiKind: number): void {
|
||||
const runScenario = (defaultExperience: typeof userContext.apiType | null, expectedApiKind: number): void => {
|
||||
const resolvedApiKind = DefaultExperienceUtility.getApiKindFromDefaultExperience(defaultExperience);
|
||||
expect(resolvedApiKind).toEqual(expectedApiKind);
|
||||
}
|
||||
};
|
||||
|
||||
describe("On SQL", () => {
|
||||
it("should return SQL", () => runScenario("SQL", DataModels.ApiKind.SQL));
|
||||
@@ -60,8 +60,8 @@ describe("Default Experience Utility", () => {
|
||||
it("should return Graph", () => runScenario("Gremlin", DataModels.ApiKind.Graph));
|
||||
});
|
||||
|
||||
describe("On null", () => {
|
||||
it("should return SQL", () => runScenario(null, DataModels.ApiKind.SQL));
|
||||
describe("On undefined", () => {
|
||||
it("should return SQL", () => runScenario(undefined, DataModels.ApiKind.SQL));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,47 +1,45 @@
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import { userContext } from "../UserContext";
|
||||
|
||||
export class DefaultExperienceUtility {
|
||||
public static getApiKindFromDefaultExperience(defaultExperience: typeof userContext.apiType): DataModels.ApiKind {
|
||||
if (!defaultExperience) {
|
||||
export const getApiKindFromDefaultExperience = (defaultExperience: typeof userContext.apiType): DataModels.ApiKind => {
|
||||
if (!defaultExperience) {
|
||||
return DataModels.ApiKind.SQL;
|
||||
}
|
||||
|
||||
switch (defaultExperience) {
|
||||
case "SQL":
|
||||
return DataModels.ApiKind.SQL;
|
||||
}
|
||||
case "Mongo":
|
||||
return DataModels.ApiKind.MongoDB;
|
||||
case "Tables":
|
||||
return DataModels.ApiKind.Table;
|
||||
case "Cassandra":
|
||||
return DataModels.ApiKind.Cassandra;
|
||||
case "Gremlin":
|
||||
return DataModels.ApiKind.Graph;
|
||||
default:
|
||||
return DataModels.ApiKind.SQL;
|
||||
}
|
||||
};
|
||||
|
||||
switch (defaultExperience) {
|
||||
case "SQL":
|
||||
return DataModels.ApiKind.SQL;
|
||||
case "Mongo":
|
||||
return DataModels.ApiKind.MongoDB;
|
||||
case "Tables":
|
||||
return DataModels.ApiKind.Table;
|
||||
case "Cassandra":
|
||||
return DataModels.ApiKind.Cassandra;
|
||||
case "Gremlin":
|
||||
return DataModels.ApiKind.Graph;
|
||||
default:
|
||||
return DataModels.ApiKind.SQL;
|
||||
}
|
||||
export const getDefaultExperienceFromApiKind = (apiKind: DataModels.ApiKind): typeof userContext.apiType => {
|
||||
if (apiKind === undefined) {
|
||||
return "SQL";
|
||||
}
|
||||
|
||||
public static getDefaultExperienceFromApiKind(apiKind: DataModels.ApiKind): typeof userContext.apiType {
|
||||
if (apiKind == null) {
|
||||
switch (apiKind) {
|
||||
case DataModels.ApiKind.SQL:
|
||||
return "SQL";
|
||||
case DataModels.ApiKind.MongoDB:
|
||||
case DataModels.ApiKind.MongoDBCompute:
|
||||
return "Mongo";
|
||||
case DataModels.ApiKind.Table:
|
||||
return "Tables";
|
||||
case DataModels.ApiKind.Cassandra:
|
||||
return "Cassandra";
|
||||
case DataModels.ApiKind.Graph:
|
||||
return "Gremlin";
|
||||
default:
|
||||
return "SQL";
|
||||
}
|
||||
|
||||
switch (apiKind) {
|
||||
case DataModels.ApiKind.SQL:
|
||||
return "SQL";
|
||||
case DataModels.ApiKind.MongoDB:
|
||||
case DataModels.ApiKind.MongoDBCompute:
|
||||
return "Mongo";
|
||||
case DataModels.ApiKind.Table:
|
||||
return "Tables";
|
||||
case DataModels.ApiKind.Cassandra:
|
||||
return "Cassandra";
|
||||
case DataModels.ApiKind.Graph:
|
||||
return "Gremlin";
|
||||
default:
|
||||
return "SQL";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,37 +5,35 @@ import { ServerConnection, TerminalManager } from "@jupyterlab/services";
|
||||
import { Terminal } from "@jupyterlab/terminal";
|
||||
import { Panel, Widget } from "@phosphor/widgets";
|
||||
|
||||
export class JupyterLabAppFactory {
|
||||
public static async createTerminalApp(serverSettings: ServerConnection.ISettings) {
|
||||
const manager = new TerminalManager({
|
||||
serverSettings: serverSettings,
|
||||
});
|
||||
const session = await manager.startNew();
|
||||
const term = new Terminal(session, { theme: "dark", shutdownOnClose: true });
|
||||
export const createTerminalApp = async (serverSettings: ServerConnection.ISettings) => {
|
||||
const manager = new TerminalManager({
|
||||
serverSettings: serverSettings,
|
||||
});
|
||||
const session = await manager.startNew();
|
||||
const term = new Terminal(session, { theme: "dark", shutdownOnClose: true });
|
||||
|
||||
if (!term) {
|
||||
console.error("Failed starting terminal");
|
||||
return;
|
||||
}
|
||||
|
||||
term.title.closable = false;
|
||||
term.addClass("terminalWidget");
|
||||
|
||||
let panel = new Panel();
|
||||
panel.addWidget(term as any);
|
||||
panel.id = "main";
|
||||
|
||||
// Attach the widget to the dom.
|
||||
Widget.attach(panel, document.body);
|
||||
|
||||
// Handle resize events.
|
||||
window.addEventListener("resize", () => {
|
||||
panel.update();
|
||||
});
|
||||
|
||||
// Dispose terminal when unloading.
|
||||
window.addEventListener("unload", () => {
|
||||
panel.dispose();
|
||||
});
|
||||
if (!term) {
|
||||
console.error("Failed starting terminal");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
term.title.closable = false;
|
||||
term.addClass("terminalWidget");
|
||||
|
||||
const panel = new Panel();
|
||||
panel.addWidget(term as any);
|
||||
panel.id = "main";
|
||||
|
||||
// Attach the widget to the dom.
|
||||
Widget.attach(panel, document.body);
|
||||
|
||||
// Handle resize events.
|
||||
window.addEventListener("resize", () => {
|
||||
panel.update();
|
||||
});
|
||||
|
||||
// Dispose terminal when unloading.
|
||||
window.addEventListener("unload", () => {
|
||||
panel.dispose();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Action } from "../Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
||||
import { updateUserContext } from "../UserContext";
|
||||
import "./index.css";
|
||||
import { JupyterLabAppFactory } from "./JupyterLabAppFactory";
|
||||
import { createTerminalApp } from "./JupyterLabAppFactory";
|
||||
import { TerminalProps } from "./TerminalProps";
|
||||
|
||||
const createServerSettings = (props: TerminalProps): ServerConnection.ISettings => {
|
||||
@@ -54,7 +54,7 @@ const initTerminal = async (props: TerminalProps) => {
|
||||
const startTime = TelemetryProcessor.traceStart(Action.OpenTerminal, data);
|
||||
|
||||
try {
|
||||
await JupyterLabAppFactory.createTerminalApp(serverSettings);
|
||||
await createTerminalApp(serverSettings);
|
||||
TelemetryProcessor.traceSuccess(Action.OpenTerminal, data, startTime);
|
||||
} catch (error) {
|
||||
TelemetryProcessor.traceFailure(Action.OpenTerminal, data, startTime);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { GenerateTokenResponse } from "../Contracts/DataModels";
|
||||
import AuthHeadersUtil from "../Platform/Hosted/Authorization";
|
||||
import * as AuthHeadersUtil from "../Platform/Hosted/Authorization";
|
||||
|
||||
export function useFullScreenURLs(): GenerateTokenResponse | undefined {
|
||||
const [state, setState] = useState<GenerateTokenResponse>();
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
getDatabaseAccountPropertiesFromMetadata,
|
||||
} from "../Platform/Hosted/HostedUtils";
|
||||
import { CollectionCreation } from "../Shared/Constants";
|
||||
import { DefaultExperienceUtility } from "../Shared/DefaultExperienceUtility";
|
||||
import * as DefaultExperienceUtility from "../Shared/DefaultExperienceUtility";
|
||||
import { PortalEnv, updateUserContext, userContext } from "../UserContext";
|
||||
import { listKeys } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||
import { DatabaseAccountListKeysResult } from "../Utils/arm/generatedClients/cosmos/types";
|
||||
|
||||
Reference in New Issue
Block a user