mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-30 14:22:05 +00:00
Compare commits
8 Commits
eslint/fix
...
migrate/Qu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e20931fbfe | ||
|
|
1f12940d48 | ||
|
|
44315867ce | ||
|
|
1f979a5fb7 | ||
|
|
474ec70923 | ||
|
|
1277940fe9 | ||
|
|
2b8327d222 | ||
|
|
1b74f619ab |
@@ -121,6 +121,7 @@ src/Explorer/Tables/QueryBuilder/QueryBuilderViewModel.ts
|
|||||||
src/Explorer/Tables/QueryBuilder/QueryClauseViewModel.ts
|
src/Explorer/Tables/QueryBuilder/QueryClauseViewModel.ts
|
||||||
src/Explorer/Tables/TableDataClient.ts
|
src/Explorer/Tables/TableDataClient.ts
|
||||||
src/Explorer/Tables/TableEntityProcessor.ts
|
src/Explorer/Tables/TableEntityProcessor.ts
|
||||||
|
src/Explorer/Tables/Utilities.ts
|
||||||
src/Explorer/Tabs/ConflictsTab.ts
|
src/Explorer/Tabs/ConflictsTab.ts
|
||||||
src/Explorer/Tabs/DatabaseSettingsTab.ts
|
src/Explorer/Tabs/DatabaseSettingsTab.ts
|
||||||
src/Explorer/Tabs/DocumentsTab.test.ts
|
src/Explorer/Tabs/DocumentsTab.test.ts
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import { SnapshotRequest } from "./NotebookComponent/types";
|
|||||||
import { NotebookContainerClient } from "./NotebookContainerClient";
|
import { NotebookContainerClient } from "./NotebookContainerClient";
|
||||||
import { NotebookContentClient } from "./NotebookContentClient";
|
import { NotebookContentClient } from "./NotebookContentClient";
|
||||||
import { SchemaAnalyzerNotebook } from "./SchemaAnalyzer/SchemaAnalyzerUtils";
|
import { SchemaAnalyzerNotebook } from "./SchemaAnalyzer/SchemaAnalyzerUtils";
|
||||||
import { useNotebook } from "./useNotebook";
|
|
||||||
|
|
||||||
type NotebookPaneContent = string | ImmutableNotebook;
|
type NotebookPaneContent = string | ImmutableNotebook;
|
||||||
|
|
||||||
@@ -111,7 +110,6 @@ export default class NotebookManager {
|
|||||||
this.junoClient.subscribeToPinnedRepos((pinnedRepos) => {
|
this.junoClient.subscribeToPinnedRepos((pinnedRepos) => {
|
||||||
this.params.resourceTree.initializeGitHubRepos(pinnedRepos);
|
this.params.resourceTree.initializeGitHubRepos(pinnedRepos);
|
||||||
this.params.resourceTree.triggerRender();
|
this.params.resourceTree.triggerRender();
|
||||||
useNotebook.getState().initializeGitHubRepos(pinnedRepos);
|
|
||||||
});
|
});
|
||||||
this.refreshPinnedRepos();
|
this.refreshPinnedRepos();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ import { getErrorMessage } from "../../Common/ErrorHandlingUtils";
|
|||||||
import * as Logger from "../../Common/Logger";
|
import * as Logger from "../../Common/Logger";
|
||||||
import { configContext } from "../../ConfigContext";
|
import { configContext } from "../../ConfigContext";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import { IPinnedRepo } from "../../Juno/JunoClient";
|
|
||||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
import { getAuthorizationHeader } from "../../Utils/AuthorizationUtils";
|
import { getAuthorizationHeader } from "../../Utils/AuthorizationUtils";
|
||||||
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
|
||||||
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
||||||
import NotebookManager from "./NotebookManager";
|
import NotebookManager from "./NotebookManager";
|
||||||
|
|
||||||
@@ -41,7 +39,6 @@ interface NotebookState {
|
|||||||
updateNotebookItem: (item: NotebookContentItem) => void;
|
updateNotebookItem: (item: NotebookContentItem) => void;
|
||||||
deleteNotebookItem: (item: NotebookContentItem) => void;
|
deleteNotebookItem: (item: NotebookContentItem) => void;
|
||||||
initializeNotebooksTree: (notebookManager: NotebookManager) => Promise<void>;
|
initializeNotebooksTree: (notebookManager: NotebookManager) => Promise<void>;
|
||||||
initializeGitHubRepos: (pinnedRepos: IPinnedRepo[]) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
|
export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
|
||||||
@@ -205,31 +202,4 @@ export const useNotebook: UseStore<NotebookState> = create((set, get) => ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initializeGitHubRepos: (pinnedRepos: IPinnedRepo[]): void => {
|
|
||||||
const gitHubNotebooksContentRoot = cloneDeep(get().gitHubNotebooksContentRoot);
|
|
||||||
if (gitHubNotebooksContentRoot) {
|
|
||||||
gitHubNotebooksContentRoot.children = [];
|
|
||||||
pinnedRepos?.forEach((pinnedRepo) => {
|
|
||||||
const repoFullName = GitHubUtils.toRepoFullName(pinnedRepo.owner, pinnedRepo.name);
|
|
||||||
const repoTreeItem: NotebookContentItem = {
|
|
||||||
name: repoFullName,
|
|
||||||
path: "PsuedoDir",
|
|
||||||
type: NotebookContentItemType.Directory,
|
|
||||||
children: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
pinnedRepo.branches.forEach((branch) => {
|
|
||||||
repoTreeItem.children.push({
|
|
||||||
name: branch.name,
|
|
||||||
path: GitHubUtils.toContentUri(pinnedRepo.owner, pinnedRepo.name, branch.name, ""),
|
|
||||||
type: NotebookContentItemType.Directory,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
gitHubNotebooksContentRoot.children.push(repoTreeItem);
|
|
||||||
});
|
|
||||||
|
|
||||||
set({ gitHubNotebooksContentRoot });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import * as Entities from "../../Tables/Entities";
|
|||||||
import { CassandraAPIDataClient, CassandraTableKey, TableDataClient } from "../../Tables/TableDataClient";
|
import { CassandraAPIDataClient, CassandraTableKey, TableDataClient } from "../../Tables/TableDataClient";
|
||||||
import * as TableEntityProcessor from "../../Tables/TableEntityProcessor";
|
import * as TableEntityProcessor from "../../Tables/TableEntityProcessor";
|
||||||
import * as Utilities from "../../Tables/Utilities";
|
import * as Utilities from "../../Tables/Utilities";
|
||||||
import QueryTablesTab from "../../Tabs/QueryTablesTab";
|
import { NewQueryTablesTab } from "../../Tabs/QueryTablesTab/NewQueryTablesTab";
|
||||||
import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm";
|
import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm";
|
||||||
import {
|
import {
|
||||||
attributeNameLabel,
|
attributeNameLabel,
|
||||||
@@ -36,7 +36,7 @@ import {
|
|||||||
|
|
||||||
interface AddTableEntityPanelProps {
|
interface AddTableEntityPanelProps {
|
||||||
tableDataClient: TableDataClient;
|
tableDataClient: TableDataClient;
|
||||||
queryTablesTab: QueryTablesTab;
|
queryTablesTab: NewQueryTablesTab;
|
||||||
tableEntityListViewModel: TableEntityListViewModel;
|
tableEntityListViewModel: TableEntityListViewModel;
|
||||||
cassandraApiClient: CassandraAPIDataClient;
|
cassandraApiClient: CassandraAPIDataClient;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import TableEntityListViewModel from "../../Tables/DataTable/TableEntityListView
|
|||||||
import * as Entities from "../../Tables/Entities";
|
import * as Entities from "../../Tables/Entities";
|
||||||
import { CassandraAPIDataClient, TableDataClient } from "../../Tables/TableDataClient";
|
import { CassandraAPIDataClient, TableDataClient } from "../../Tables/TableDataClient";
|
||||||
import * as TableEntityProcessor from "../../Tables/TableEntityProcessor";
|
import * as TableEntityProcessor from "../../Tables/TableEntityProcessor";
|
||||||
import QueryTablesTab from "../../Tabs/QueryTablesTab";
|
import { NewQueryTablesTab } from "../../Tabs/QueryTablesTab/NewQueryTablesTab";
|
||||||
import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm";
|
import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm";
|
||||||
import {
|
import {
|
||||||
attributeNameLabel,
|
attributeNameLabel,
|
||||||
@@ -34,7 +34,7 @@ import {
|
|||||||
|
|
||||||
interface EditTableEntityPanelProps {
|
interface EditTableEntityPanelProps {
|
||||||
tableDataClient: TableDataClient;
|
tableDataClient: TableDataClient;
|
||||||
queryTablesTab: QueryTablesTab;
|
queryTablesTab: NewQueryTablesTab;
|
||||||
tableEntityListViewModel: TableEntityListViewModel;
|
tableEntityListViewModel: TableEntityListViewModel;
|
||||||
cassandraApiClient: CassandraAPIDataClient;
|
cassandraApiClient: CassandraAPIDataClient;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
|
import { ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as _ from "underscore";
|
import * as _ from "underscore";
|
||||||
|
|
||||||
import { Action } from "../../../Shared/Telemetry/TelemetryConstants";
|
|
||||||
import CacheBase from "./CacheBase";
|
|
||||||
import * as CommonConstants from "../../../Common/Constants";
|
import * as CommonConstants from "../../../Common/Constants";
|
||||||
|
import { Action } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||||
|
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||||
|
import { NewQueryTablesTab } from "../../Tabs/QueryTablesTab/NewQueryTablesTab";
|
||||||
import * as Constants from "../Constants";
|
import * as Constants from "../Constants";
|
||||||
import * as Entities from "../Entities";
|
import * as Entities from "../Entities";
|
||||||
import QueryTablesTab from "../../Tabs/QueryTablesTab";
|
import CacheBase from "./CacheBase";
|
||||||
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
|
||||||
import { QueryIterator, ItemDefinition, Resource } from "@azure/cosmos";
|
|
||||||
|
|
||||||
// This is the format of the data we will have to pass to Datatable render callback,
|
// This is the format of the data we will have to pass to Datatable render callback,
|
||||||
// and property names are defined by Datatable as well.
|
// and property names are defined by Datatable as well.
|
||||||
@@ -49,7 +49,7 @@ abstract class DataTableViewModel {
|
|||||||
|
|
||||||
private dataTableOperationManager: IDataTableOperation;
|
private dataTableOperationManager: IDataTableOperation;
|
||||||
|
|
||||||
public queryTablesTab: QueryTablesTab;
|
public queryTablesTab: NewQueryTablesTab;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.items([]);
|
this.items([]);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Action } from "../../../Shared/Telemetry/TelemetryConstants";
|
|||||||
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { userContext } from "../../../UserContext";
|
import { userContext } from "../../../UserContext";
|
||||||
import QueryTablesTab from "../../Tabs/QueryTablesTab";
|
import QueryTablesTab from "../../Tabs/QueryTablesTab";
|
||||||
|
import { NewQueryTablesTab } from "../../Tabs/QueryTablesTab/NewQueryTablesTab";
|
||||||
import * as Constants from "../Constants";
|
import * as Constants from "../Constants";
|
||||||
import { getQuotedCqlIdentifier } from "../CqlUtilities";
|
import { getQuotedCqlIdentifier } from "../CqlUtilities";
|
||||||
import * as Entities from "../Entities";
|
import * as Entities from "../Entities";
|
||||||
@@ -112,7 +113,7 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
|||||||
public queryErrorMessage: ko.Observable<string>;
|
public queryErrorMessage: ko.Observable<string>;
|
||||||
public id: string;
|
public id: string;
|
||||||
|
|
||||||
constructor(tableCommands: TableCommands, queryTablesTab: QueryTablesTab) {
|
constructor(tableCommands: TableCommands, queryTablesTab: NewQueryTablesTab) {
|
||||||
super();
|
super();
|
||||||
this.cache = new TableEntityCache();
|
this.cache = new TableEntityCache();
|
||||||
this.queryErrorMessage = ko.observable<string>();
|
this.queryErrorMessage = ko.observable<string>();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { KeyCodes } from "../../../Common/Constants";
|
|||||||
import { useSidePanel } from "../../../hooks/useSidePanel";
|
import { useSidePanel } from "../../../hooks/useSidePanel";
|
||||||
import { userContext } from "../../../UserContext";
|
import { userContext } from "../../../UserContext";
|
||||||
import { TableQuerySelectPanel } from "../../Panes/Tables/TableQuerySelectPanel/TableQuerySelectPanel";
|
import { TableQuerySelectPanel } from "../../Panes/Tables/TableQuerySelectPanel/TableQuerySelectPanel";
|
||||||
import QueryTablesTab from "../../Tabs/QueryTablesTab";
|
import { NewQueryTablesTab } from "../../Tabs/QueryTablesTab/NewQueryTablesTab";
|
||||||
import { getQuotedCqlIdentifier } from "../CqlUtilities";
|
import { getQuotedCqlIdentifier } from "../CqlUtilities";
|
||||||
import * as DataTableUtilities from "../DataTable/DataTableUtilities";
|
import * as DataTableUtilities from "../DataTable/DataTableUtilities";
|
||||||
import TableEntityListViewModel from "../DataTable/TableEntityListViewModel";
|
import TableEntityListViewModel from "../DataTable/TableEntityListViewModel";
|
||||||
@@ -39,14 +39,14 @@ export default class QueryViewModel {
|
|||||||
|
|
||||||
public columnOptions: ko.ObservableArray<string>;
|
public columnOptions: ko.ObservableArray<string>;
|
||||||
|
|
||||||
public queryTablesTab: QueryTablesTab;
|
public queryTablesTab: NewQueryTablesTab;
|
||||||
public id: string;
|
public id: string;
|
||||||
private _tableEntityListViewModel: TableEntityListViewModel;
|
private _tableEntityListViewModel: TableEntityListViewModel;
|
||||||
|
|
||||||
constructor(queryTablesTab: QueryTablesTab) {
|
constructor(queryTablesTab: NewQueryTablesTab) {
|
||||||
this.queryTablesTab = queryTablesTab;
|
this.queryTablesTab = queryTablesTab;
|
||||||
this.id = `queryViewModel${this.queryTablesTab.tabId}`;
|
this.id = `queryViewModel${this.queryTablesTab.tabId}`;
|
||||||
this._tableEntityListViewModel = queryTablesTab.tableEntityListViewModel();
|
this._tableEntityListViewModel = queryTablesTab.tableEntityListViewModel;
|
||||||
|
|
||||||
this.queryTextIsReadOnly = ko.computed<boolean>(() => {
|
this.queryTextIsReadOnly = ko.computed<boolean>(() => {
|
||||||
return userContext.apiType !== "Cassandra";
|
return userContext.apiType !== "Cassandra";
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
/**
|
|
||||||
* [Todo] disable any type of file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
import * as _ from "underscore";
|
import * as _ from "underscore";
|
||||||
import Q from "q";
|
import Q from "q";
|
||||||
import * as Entities from "./Entities";
|
import * as Entities from "./Entities";
|
||||||
@@ -13,11 +8,11 @@ import * as Constants from "./Constants";
|
|||||||
* Generates a pseudo-random GUID.
|
* Generates a pseudo-random GUID.
|
||||||
*/
|
*/
|
||||||
export function guid() {
|
export function guid() {
|
||||||
const s4 = () => {
|
function s4() {
|
||||||
return Math.floor((1 + Math.random()) * 0x10000)
|
return Math.floor((1 + Math.random()) * 0x10000)
|
||||||
.toString(16)
|
.toString(16)
|
||||||
.substring(1);
|
.substring(1);
|
||||||
};
|
}
|
||||||
return s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4();
|
return s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +39,7 @@ export function ensureBetweenBounds(value: number, minimum: number, maximum: num
|
|||||||
* If supplied, the original error will be added as "details".
|
* If supplied, the original error will be added as "details".
|
||||||
*/
|
*/
|
||||||
export function getErrorMessage(error: any, simpleMessage?: string): string {
|
export function getErrorMessage(error: any, simpleMessage?: string): string {
|
||||||
let detailsMessage: string;
|
var detailsMessage: string;
|
||||||
if (typeof error === "string" || error instanceof String) {
|
if (typeof error === "string" || error instanceof String) {
|
||||||
detailsMessage = error.toString();
|
detailsMessage = error.toString();
|
||||||
} else {
|
} else {
|
||||||
@@ -64,7 +59,7 @@ export function getErrorMessage(error: any, simpleMessage?: string): string {
|
|||||||
* Get the environment's new line characters
|
* Get the environment's new line characters
|
||||||
*/
|
*/
|
||||||
export function getEnvironmentNewLine(): string {
|
export function getEnvironmentNewLine(): string {
|
||||||
const platform = navigator.platform.toUpperCase();
|
var platform = navigator.platform.toUpperCase();
|
||||||
|
|
||||||
if (platform.indexOf("WIN") >= 0) {
|
if (platform.indexOf("WIN") >= 0) {
|
||||||
return "\r\n";
|
return "\r\n";
|
||||||
@@ -78,7 +73,7 @@ export function getEnvironmentNewLine(): string {
|
|||||||
* Tests whether two arrays have same elements in the same sequence.
|
* Tests whether two arrays have same elements in the same sequence.
|
||||||
*/
|
*/
|
||||||
export function isEqual<T>(a: T[], b: T[]): boolean {
|
export function isEqual<T>(a: T[], b: T[]): boolean {
|
||||||
let isEqual = false;
|
var isEqual: boolean = false;
|
||||||
if (!!a && !!b && a.length === b.length) {
|
if (!!a && !!b && a.length === b.length) {
|
||||||
isEqual = _.every(a, (value: T, index: number) => value === b[index]);
|
isEqual = _.every(a, (value: T, index: number) => value === b[index]);
|
||||||
}
|
}
|
||||||
@@ -90,13 +85,12 @@ export function isEqual<T>(a: T[], b: T[]): boolean {
|
|||||||
*/
|
*/
|
||||||
export function jQuerySelectorEscape(value: string): string {
|
export function jQuerySelectorEscape(value: string): string {
|
||||||
value = value || "";
|
value = value || "";
|
||||||
// removed Unnecessary escape character: \/.eslintno-useless-escape
|
return value.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, "\\$&");
|
||||||
return value.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function copyTableQuery(query: Entities.ITableQuery): Entities.ITableQuery {
|
export function copyTableQuery(query: Entities.ITableQuery): Entities.ITableQuery {
|
||||||
if (!query) {
|
if (!query) {
|
||||||
return undefined;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -110,7 +104,7 @@ export function copyTableQuery(query: Entities.ITableQuery): Entities.ITableQuer
|
|||||||
* Html encode
|
* Html encode
|
||||||
*/
|
*/
|
||||||
export function htmlEncode(value: string): string {
|
export function htmlEncode(value: string): string {
|
||||||
const _divElem: JQuery = $("<div/>");
|
var _divElem: JQuery = $("<div/>");
|
||||||
return _divElem.text(value).html();
|
return _divElem.text(value).html();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,22 +117,22 @@ export function onKey(
|
|||||||
event: any,
|
event: any,
|
||||||
eventKeyCode: number,
|
eventKeyCode: number,
|
||||||
action: ($sourceElement: JQuery) => void,
|
action: ($sourceElement: JQuery) => void,
|
||||||
metaKey?: boolean,
|
metaKey: boolean = null,
|
||||||
shiftKey?: boolean,
|
shiftKey: boolean = null,
|
||||||
altKey?: boolean
|
altKey: boolean = null
|
||||||
): boolean {
|
): boolean {
|
||||||
const source: unknown = event.target || event.srcElement,
|
var source: any = event.target || event.srcElement,
|
||||||
keyCode: number = event.keyCode,
|
keyCode: number = event.keyCode,
|
||||||
$sourceElement = $(source);
|
$sourceElement = $(source),
|
||||||
let handled = false;
|
handled: boolean = false;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$sourceElement.length &&
|
$sourceElement.length &&
|
||||||
keyCode === eventKeyCode &&
|
keyCode === eventKeyCode &&
|
||||||
$.isFunction(action) &&
|
$.isFunction(action) &&
|
||||||
(metaKey === undefined || metaKey === event.metaKey) &&
|
(metaKey === null || metaKey === event.metaKey) &&
|
||||||
(shiftKey === undefined || shiftKey === event.shiftKey) &&
|
(shiftKey === null || shiftKey === event.shiftKey) &&
|
||||||
(altKey === undefined || altKey === event.altKey)
|
(altKey === null || altKey === event.altKey)
|
||||||
) {
|
) {
|
||||||
action($sourceElement);
|
action($sourceElement);
|
||||||
handled = true;
|
handled = true;
|
||||||
@@ -153,9 +147,9 @@ export function onKey(
|
|||||||
export function onEnter(
|
export function onEnter(
|
||||||
event: any,
|
event: any,
|
||||||
action: ($sourceElement: JQuery) => void,
|
action: ($sourceElement: JQuery) => void,
|
||||||
metaKey?: boolean,
|
metaKey: boolean = null,
|
||||||
shiftKey?: boolean,
|
shiftKey: boolean = null,
|
||||||
altKey?: boolean
|
altKey: boolean = null
|
||||||
): boolean {
|
): boolean {
|
||||||
return onKey(event, Constants.keyCodes.Enter, action, metaKey, shiftKey, altKey);
|
return onKey(event, Constants.keyCodes.Enter, action, metaKey, shiftKey, altKey);
|
||||||
}
|
}
|
||||||
@@ -166,9 +160,9 @@ export function onEnter(
|
|||||||
export function onTab(
|
export function onTab(
|
||||||
event: any,
|
event: any,
|
||||||
action: ($sourceElement: JQuery) => void,
|
action: ($sourceElement: JQuery) => void,
|
||||||
metaKey?: boolean,
|
metaKey: boolean = null,
|
||||||
shiftKey?: boolean,
|
shiftKey: boolean = null,
|
||||||
altKey?: boolean
|
altKey: boolean = null
|
||||||
): boolean {
|
): boolean {
|
||||||
return onKey(event, Constants.keyCodes.Tab, action, metaKey, shiftKey, altKey);
|
return onKey(event, Constants.keyCodes.Tab, action, metaKey, shiftKey, altKey);
|
||||||
}
|
}
|
||||||
@@ -179,9 +173,9 @@ export function onTab(
|
|||||||
export function onEsc(
|
export function onEsc(
|
||||||
event: any,
|
event: any,
|
||||||
action: ($sourceElement: JQuery) => void,
|
action: ($sourceElement: JQuery) => void,
|
||||||
metaKey?: boolean,
|
metaKey: boolean = null,
|
||||||
shiftKey?: boolean,
|
shiftKey: boolean = null,
|
||||||
altKey?: boolean
|
altKey: boolean = null
|
||||||
): boolean {
|
): boolean {
|
||||||
return onKey(event, Constants.keyCodes.Esc, action, metaKey, shiftKey, altKey);
|
return onKey(event, Constants.keyCodes.Esc, action, metaKey, shiftKey, altKey);
|
||||||
}
|
}
|
||||||
@@ -206,21 +200,21 @@ export function isEnvironmentAltPressed(event: JQueryEventObject): boolean {
|
|||||||
* Returns whether the current platform is MacOS.
|
* Returns whether the current platform is MacOS.
|
||||||
*/
|
*/
|
||||||
export function isMac(): boolean {
|
export function isMac(): boolean {
|
||||||
const platform = navigator.platform.toUpperCase();
|
var platform = navigator.platform.toUpperCase();
|
||||||
return platform.indexOf("MAC") >= 0;
|
return platform.indexOf("MAC") >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MAX_SAFE_INTEGER and MIN_SAFE_INTEGER will be provided by ECMAScript 6's Number
|
// MAX_SAFE_INTEGER and MIN_SAFE_INTEGER will be provided by ECMAScript 6's Number
|
||||||
export const MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
export var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
||||||
export const MIN_SAFE_INTEGER = -MAX_SAFE_INTEGER;
|
export var MIN_SAFE_INTEGER = -MAX_SAFE_INTEGER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether a value a safe integer.
|
* Tests whether a value a safe integer.
|
||||||
* A safe integer is an integer that can be exactly represented as an IEEE-754 double precision number (all integers from (2^53 - 1) to -(2^53 - 1))
|
* A safe integer is an integer that can be exactly represented as an IEEE-754 double precision number (all integers from (2^53 - 1) to -(2^53 - 1))
|
||||||
* Note: Function and constants will be provided by ECMAScript 6's Number.
|
* Note: Function and constants will be provided by ECMAScript 6's Number.
|
||||||
*/
|
*/
|
||||||
export function isSafeInteger(value: number | string): boolean {
|
export function isSafeInteger(value: any): boolean {
|
||||||
const n: number = typeof value !== "number" ? Number(value) : value;
|
var n: number = typeof value !== "number" ? Number(value) : value;
|
||||||
|
|
||||||
return Math.round(n) === n && MIN_SAFE_INTEGER <= n && n <= MAX_SAFE_INTEGER;
|
return Math.round(n) === n && MIN_SAFE_INTEGER <= n && n <= MAX_SAFE_INTEGER;
|
||||||
}
|
}
|
||||||
@@ -246,7 +240,7 @@ export function getInputTypeFromDisplayedName(displayedName: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function padLongWithZeros(value: string): string {
|
export function padLongWithZeros(value: string): string {
|
||||||
const s = "0000000000000000000" + value;
|
var s = "0000000000000000000" + value;
|
||||||
return s.substr(s.length - 20);
|
return s.substr(s.length - 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,13 +249,13 @@ export function padLongWithZeros(value: string): string {
|
|||||||
* Notice: Not every header will have a data type since some headers don't even exist in entities.
|
* Notice: Not every header will have a data type since some headers don't even exist in entities.
|
||||||
*/
|
*/
|
||||||
export function getDataTypesFromEntities(headers: string[], entities: Entities.ITableEntity[]): any {
|
export function getDataTypesFromEntities(headers: string[], entities: Entities.ITableEntity[]): any {
|
||||||
let currentHeaders: string[] = _.clone(headers);
|
var currentHeaders: string[] = _.clone(headers);
|
||||||
const dataTypes: any = {};
|
var dataTypes: any = {};
|
||||||
entities = entities || [];
|
entities = entities || [];
|
||||||
entities.forEach((entity: Entities.ITableEntity) => {
|
entities.forEach((entity: Entities.ITableEntity, index: number) => {
|
||||||
if (currentHeaders.length) {
|
if (currentHeaders.length) {
|
||||||
const keys: string[] = _.keys(entity);
|
var keys: string[] = _.keys(entity);
|
||||||
const headersToProcess: string[] = _.intersection(currentHeaders, keys);
|
var headersToProcess: string[] = _.intersection(currentHeaders, keys);
|
||||||
headersToProcess &&
|
headersToProcess &&
|
||||||
headersToProcess.forEach((propertyName: string) => {
|
headersToProcess.forEach((propertyName: string) => {
|
||||||
dataTypes[propertyName] = entity[propertyName].$ || Constants.TableType.String;
|
dataTypes[propertyName] = entity[propertyName].$ || Constants.TableType.String;
|
||||||
@@ -276,9 +270,9 @@ export function getDataTypesFromEntities(headers: string[], entities: Entities.I
|
|||||||
* Set a data type for each header. The data type is inferred from Cassandra Schema.
|
* Set a data type for each header. The data type is inferred from Cassandra Schema.
|
||||||
*/
|
*/
|
||||||
export function getDataTypesFromCassandraSchema(schema: CassandraTableKey[]): any {
|
export function getDataTypesFromCassandraSchema(schema: CassandraTableKey[]): any {
|
||||||
const dataTypes: any = {};
|
var dataTypes: any = {};
|
||||||
schema &&
|
schema &&
|
||||||
schema.forEach((schemaItem: CassandraTableKey) => {
|
schema.forEach((schemaItem: CassandraTableKey, index: number) => {
|
||||||
dataTypes[schemaItem.property] = schemaItem.type;
|
dataTypes[schemaItem.property] = schemaItem.type;
|
||||||
});
|
});
|
||||||
return dataTypes;
|
return dataTypes;
|
||||||
|
|||||||
52
src/Explorer/Tabs/QueryTablesTab/NewQueryTablesTab.tsx
Normal file
52
src/Explorer/Tabs/QueryTablesTab/NewQueryTablesTab.tsx
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import React from "react";
|
||||||
|
import * as DataModels from "../../../Contracts/DataModels";
|
||||||
|
import type { TabOptions } from "../../../Contracts/ViewModels";
|
||||||
|
import { useTabs } from "../../../hooks/useTabs";
|
||||||
|
import Explorer from "../../Explorer";
|
||||||
|
import TableCommands from "../../Tables/DataTable/TableCommands";
|
||||||
|
import TableEntityListViewModel from "../../Tables/DataTable/TableEntityListViewModel";
|
||||||
|
import TabsBase from "../TabsBase";
|
||||||
|
import {
|
||||||
|
IQueryTablesTabAccessor,
|
||||||
|
IQueryTablesTabComponentProps,
|
||||||
|
QueryTablesTabComponent,
|
||||||
|
} from "./QueryTablesTabComponent";
|
||||||
|
|
||||||
|
export interface IQueryTablesTabProps {
|
||||||
|
container: Explorer;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class NewQueryTablesTab extends TabsBase {
|
||||||
|
public queryText: string;
|
||||||
|
public currentQuery: string;
|
||||||
|
public partitionKey: DataModels.PartitionKey;
|
||||||
|
public iQueryTablesTabComponentProps: IQueryTablesTabComponentProps;
|
||||||
|
public tableEntityListViewModel: TableEntityListViewModel;
|
||||||
|
public tableCommands: TableCommands;
|
||||||
|
public iQueryTablesTabAccessor: IQueryTablesTabAccessor;
|
||||||
|
|
||||||
|
constructor(options: TabOptions, private props: IQueryTablesTabProps) {
|
||||||
|
super(options);
|
||||||
|
this.tableCommands = new TableCommands(props.container);
|
||||||
|
this.tableEntityListViewModel = new TableEntityListViewModel(this.tableCommands, this);
|
||||||
|
this.iQueryTablesTabComponentProps = {
|
||||||
|
collection: this.collection,
|
||||||
|
tabId: this.tabId,
|
||||||
|
tabsBaseInstance: this,
|
||||||
|
queryTablesTab: this,
|
||||||
|
container: this.props.container,
|
||||||
|
onQueryTablesTabAccessor: (instance: IQueryTablesTabAccessor) => {
|
||||||
|
this.iQueryTablesTabAccessor = instance;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public render(): JSX.Element {
|
||||||
|
return <QueryTablesTabComponent {...this.iQueryTablesTabComponentProps} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
public onTabClick(): void {
|
||||||
|
useTabs.getState().activateTab(this);
|
||||||
|
this.iQueryTablesTabAccessor.onTabClickEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
619
src/Explorer/Tabs/QueryTablesTab/QueryTablesTabComponent.tsx
Normal file
619
src/Explorer/Tabs/QueryTablesTab/QueryTablesTabComponent.tsx
Normal file
@@ -0,0 +1,619 @@
|
|||||||
|
import React from "react";
|
||||||
|
import AddEntityIcon from "../../../../images/AddEntity.svg";
|
||||||
|
import DeleteEntitiesIcon from "../../../../images/DeleteEntities.svg";
|
||||||
|
import EditEntityIcon from "../../../../images/Edit-entity.svg";
|
||||||
|
import ExecuteQueryIcon from "../../../../images/ExecuteQuery.svg";
|
||||||
|
import QueryBuilderIcon from "../../../../images/Query-Builder.svg";
|
||||||
|
import QueryTextIcon from "../../../../images/Query-Text.svg";
|
||||||
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
|
import { useSidePanel } from "../../../hooks/useSidePanel";
|
||||||
|
import { userContext } from "../../../UserContext";
|
||||||
|
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
|
||||||
|
import Explorer from "../../Explorer";
|
||||||
|
import { AddTableEntityPanel } from "../../Panes/Tables/AddTableEntityPanel";
|
||||||
|
import { EditTableEntityPanel } from "../../Panes/Tables/EditTableEntityPanel";
|
||||||
|
import TableCommands from "../../Tables/DataTable/TableCommands";
|
||||||
|
import TableEntityListViewModel from "../../Tables/DataTable/TableEntityListViewModel";
|
||||||
|
import QueryViewModel from "../../Tables/QueryBuilder/QueryViewModel";
|
||||||
|
import { CassandraAPIDataClient, TableDataClient } from "../../Tables/TableDataClient";
|
||||||
|
import TabsBase from "../TabsBase";
|
||||||
|
import { NewQueryTablesTab } from "./NewQueryTablesTab";
|
||||||
|
|
||||||
|
export interface IQueryTablesTabAccessor {
|
||||||
|
onTabClickEvent: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Button {
|
||||||
|
visible: boolean;
|
||||||
|
enabled: boolean;
|
||||||
|
isSelected?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IQueryTablesTabComponentStates {
|
||||||
|
queryViewModel: QueryViewModel;
|
||||||
|
queryText: string;
|
||||||
|
selectedQueryText: string;
|
||||||
|
executeQueryButton: Button;
|
||||||
|
queryBuilderButton: Button;
|
||||||
|
queryTextButton: Button;
|
||||||
|
addEntityButton: Button;
|
||||||
|
editEntityButton: Button;
|
||||||
|
deleteEntityButton: Button;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IQueryTablesTabComponentProps {
|
||||||
|
collection: ViewModels.CollectionBase;
|
||||||
|
tabsBaseInstance: TabsBase;
|
||||||
|
tabId: string;
|
||||||
|
queryTablesTab: NewQueryTablesTab;
|
||||||
|
container: Explorer;
|
||||||
|
onQueryTablesTabAccessor: (instance: IQueryTablesTabAccessor) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class QueryTablesTabComponent extends React.Component<
|
||||||
|
IQueryTablesTabComponentProps,
|
||||||
|
IQueryTablesTabComponentStates
|
||||||
|
> {
|
||||||
|
public collection: ViewModels.Collection;
|
||||||
|
public tableEntityListViewModel: TableEntityListViewModel;
|
||||||
|
public tableCommands: TableCommands;
|
||||||
|
public tableDataClient: TableDataClient;
|
||||||
|
public container: Explorer;
|
||||||
|
public queryViewModel: QueryViewModel;
|
||||||
|
|
||||||
|
constructor(props: IQueryTablesTabComponentProps) {
|
||||||
|
super(props);
|
||||||
|
this.container = props.collection && props.collection.container;
|
||||||
|
this.tableCommands = new TableCommands(this.container);
|
||||||
|
this.tableDataClient = this.container.tableDataClient;
|
||||||
|
this.tableEntityListViewModel = new TableEntityListViewModel(this.tableCommands, props.queryTablesTab);
|
||||||
|
this.tableEntityListViewModel.queryTablesTab = props.queryTablesTab;
|
||||||
|
this.queryViewModel = new QueryViewModel(props.queryTablesTab);
|
||||||
|
this.state = {
|
||||||
|
queryViewModel: this.queryViewModel,
|
||||||
|
queryText: "PartitionKey eq 'partitionKey1'",
|
||||||
|
selectedQueryText: "",
|
||||||
|
executeQueryButton: {
|
||||||
|
enabled: true,
|
||||||
|
visible: true,
|
||||||
|
},
|
||||||
|
queryBuilderButton: {
|
||||||
|
enabled: true,
|
||||||
|
visible: true,
|
||||||
|
isSelected: this.queryViewModel ? this.queryViewModel.isHelperActive() : false,
|
||||||
|
},
|
||||||
|
queryTextButton: {
|
||||||
|
enabled: true,
|
||||||
|
visible: true,
|
||||||
|
isSelected: this.queryViewModel ? this.queryViewModel.isEditorActive() : false,
|
||||||
|
},
|
||||||
|
addEntityButton: {
|
||||||
|
enabled: true,
|
||||||
|
visible: true,
|
||||||
|
},
|
||||||
|
editEntityButton: {
|
||||||
|
enabled: this.tableCommands.isEnabled(
|
||||||
|
TableCommands.editEntityCommand,
|
||||||
|
this.tableEntityListViewModel.selected()
|
||||||
|
),
|
||||||
|
visible: true,
|
||||||
|
},
|
||||||
|
deleteEntityButton: {
|
||||||
|
enabled: this.tableCommands.isEnabled(
|
||||||
|
TableCommands.deleteEntitiesCommand,
|
||||||
|
this.tableEntityListViewModel.selected()
|
||||||
|
),
|
||||||
|
visible: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
if (this.tableEntityListViewModel.items().length > 0 && userContext.apiType === "Tables") {
|
||||||
|
const sampleQuerySubscription = this.state.queryViewModel.queryBuilderViewModel().setExample();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public onExecuteQueryClick(): void {
|
||||||
|
this.state.queryViewModel.runQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
public onQueryBuilderClick(): void {
|
||||||
|
this.state.queryViewModel.selectHelper();
|
||||||
|
}
|
||||||
|
|
||||||
|
public onQueryTextClick(): void {
|
||||||
|
this.state.queryViewModel.selectEditor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public onAddEntityClick(): void {
|
||||||
|
useSidePanel
|
||||||
|
.getState()
|
||||||
|
.openSidePanel(
|
||||||
|
"Add Table Row",
|
||||||
|
<AddTableEntityPanel
|
||||||
|
tableDataClient={this.tableDataClient}
|
||||||
|
queryTablesTab={this.props.queryTablesTab}
|
||||||
|
tableEntityListViewModel={this.tableEntityListViewModel}
|
||||||
|
cassandraApiClient={new CassandraAPIDataClient()}
|
||||||
|
/>,
|
||||||
|
"700px"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public onEditEntityClick(): void {
|
||||||
|
useSidePanel
|
||||||
|
.getState()
|
||||||
|
.openSidePanel(
|
||||||
|
"Edit Table Entity",
|
||||||
|
<EditTableEntityPanel
|
||||||
|
tableDataClient={this.tableDataClient}
|
||||||
|
queryTablesTab={this.props.queryTablesTab}
|
||||||
|
tableEntityListViewModel={this.tableEntityListViewModel}
|
||||||
|
cassandraApiClient={new CassandraAPIDataClient()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public onDeleteEntityClick(): void {
|
||||||
|
this.tableCommands.deleteEntitiesCommand(this.tableEntityListViewModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public onActivate(): void {
|
||||||
|
const columns =
|
||||||
|
!!this.tableEntityListViewModel &&
|
||||||
|
!!this.tableEntityListViewModel.table &&
|
||||||
|
this.tableEntityListViewModel.table.columns;
|
||||||
|
if (!!columns) {
|
||||||
|
columns.adjust();
|
||||||
|
$(window).resize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getTabsButtons(): CommandButtonComponentProps[] {
|
||||||
|
const buttons: CommandButtonComponentProps[] = [];
|
||||||
|
if (this.state.queryBuilderButton.visible) {
|
||||||
|
const label = userContext.apiType === "Cassandra" ? "CQL Query Builder" : "Query Builder";
|
||||||
|
buttons.push({
|
||||||
|
iconSrc: QueryBuilderIcon,
|
||||||
|
iconAlt: label,
|
||||||
|
onCommandClick: this.onQueryBuilderClick,
|
||||||
|
commandButtonLabel: label,
|
||||||
|
ariaLabel: label,
|
||||||
|
hasPopup: false,
|
||||||
|
disabled: !this.state.queryBuilderButton.enabled,
|
||||||
|
isSelected: this.state.queryBuilderButton.isSelected,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.queryTextButton.visible) {
|
||||||
|
const label = userContext.apiType === "Cassandra" ? "CQL Query Text" : "Query Text";
|
||||||
|
buttons.push({
|
||||||
|
iconSrc: QueryTextIcon,
|
||||||
|
iconAlt: label,
|
||||||
|
onCommandClick: this.onQueryTextClick,
|
||||||
|
commandButtonLabel: label,
|
||||||
|
ariaLabel: label,
|
||||||
|
hasPopup: false,
|
||||||
|
disabled: !this.state.queryTextButton.enabled,
|
||||||
|
isSelected: this.state.queryTextButton.isSelected,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.executeQueryButton.visible) {
|
||||||
|
const label = "Run Query";
|
||||||
|
buttons.push({
|
||||||
|
iconSrc: ExecuteQueryIcon,
|
||||||
|
iconAlt: label,
|
||||||
|
onCommandClick: this.onExecuteQueryClick,
|
||||||
|
commandButtonLabel: label,
|
||||||
|
ariaLabel: label,
|
||||||
|
hasPopup: false,
|
||||||
|
disabled: !this.state.executeQueryButton.enabled,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.addEntityButton.visible) {
|
||||||
|
const label = userContext.apiType === "Cassandra" ? "Add Row" : "Add Entity";
|
||||||
|
buttons.push({
|
||||||
|
iconSrc: AddEntityIcon,
|
||||||
|
iconAlt: label,
|
||||||
|
onCommandClick: this.onAddEntityClick,
|
||||||
|
commandButtonLabel: label,
|
||||||
|
ariaLabel: label,
|
||||||
|
hasPopup: true,
|
||||||
|
disabled: !this.state.addEntityButton.enabled,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.editEntityButton.visible) {
|
||||||
|
const label = userContext.apiType === "Cassandra" ? "Edit Row" : "Edit Entity";
|
||||||
|
buttons.push({
|
||||||
|
iconSrc: EditEntityIcon,
|
||||||
|
iconAlt: label,
|
||||||
|
onCommandClick: this.onEditEntityClick,
|
||||||
|
commandButtonLabel: label,
|
||||||
|
ariaLabel: label,
|
||||||
|
hasPopup: true,
|
||||||
|
disabled: !this.state.editEntityButton.enabled,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.deleteEntityButton.visible) {
|
||||||
|
const label = userContext.apiType === "Cassandra" ? "Delete Rows" : "Delete Entities";
|
||||||
|
buttons.push({
|
||||||
|
iconSrc: DeleteEntitiesIcon,
|
||||||
|
iconAlt: label,
|
||||||
|
onCommandClick: this.onDeleteEntityClick,
|
||||||
|
commandButtonLabel: label,
|
||||||
|
ariaLabel: label,
|
||||||
|
hasPopup: true,
|
||||||
|
disabled: !this.state.deleteEntityButton.enabled,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public render(): JSX.Element {
|
||||||
|
const { tabId } = this.props;
|
||||||
|
const { queryViewModel, queryText } = this.state;
|
||||||
|
const {
|
||||||
|
isEditorActive,
|
||||||
|
isHelperActive,
|
||||||
|
hasQueryError,
|
||||||
|
queryErrorMessage,
|
||||||
|
queryBuilderViewModel,
|
||||||
|
toggleAdvancedOptions,
|
||||||
|
ontoggleAdvancedOptionsKeyDown,
|
||||||
|
} = queryViewModel;
|
||||||
|
const {
|
||||||
|
canGroupClauses,
|
||||||
|
andLabel,
|
||||||
|
actionLabel,
|
||||||
|
groupClauses,
|
||||||
|
groupSelectedClauses,
|
||||||
|
fieldLabel,
|
||||||
|
dataTypeLabel,
|
||||||
|
operatorLabel,
|
||||||
|
valueLabel,
|
||||||
|
clauseArray,
|
||||||
|
columnOptions,
|
||||||
|
clauseRules,
|
||||||
|
operators,
|
||||||
|
insertNewFilterLine,
|
||||||
|
onAddClauseKeyDown,
|
||||||
|
addClauseIndex,
|
||||||
|
removeThisFilterLine,
|
||||||
|
onDeleteClauseKeyDown,
|
||||||
|
deleteClause,
|
||||||
|
getClauseGroupViewModels,
|
||||||
|
updateColumnOptions,
|
||||||
|
edmTypes,
|
||||||
|
addNewClause,
|
||||||
|
addNewClauseLine,
|
||||||
|
} = queryBuilderViewModel();
|
||||||
|
console.log("queryBuilderViewModel()", queryBuilderViewModel());
|
||||||
|
console.log("clauseArray()", clauseArray());
|
||||||
|
console.log("clauseRules()", clauseRules());
|
||||||
|
console.log("columnOptions()", columnOptions());
|
||||||
|
console.log("operators()", operators());
|
||||||
|
return (
|
||||||
|
<div className="tab-pane tableContainer" id={tabId} role="tabpanel">
|
||||||
|
<div className="query-builder" id={queryViewModel.id}>
|
||||||
|
<div className="error-bar">
|
||||||
|
{hasQueryError && (
|
||||||
|
<div className="error-message" aria-label="Error Message">
|
||||||
|
<span>
|
||||||
|
<img className="entity-error-Img" src="/error_red.svg" />
|
||||||
|
</span>
|
||||||
|
<span className="error-text" role="alert">
|
||||||
|
{queryErrorMessage}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isEditorActive() && (
|
||||||
|
<div className="query-editor-panel">
|
||||||
|
<div>
|
||||||
|
<textarea
|
||||||
|
className="query-editor-text"
|
||||||
|
data-bind="
|
||||||
|
css: { 'query-editor-text-invalid': hasQueryError },
|
||||||
|
readOnly: true"
|
||||||
|
name="query-editor"
|
||||||
|
rows={5}
|
||||||
|
cols={100}
|
||||||
|
>
|
||||||
|
{queryText}
|
||||||
|
</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{isHelperActive && (
|
||||||
|
<div style={{ paddingLeft: "13px" }}>
|
||||||
|
<div className="clause-table" data-bind="with: queryBuilderViewModel ">
|
||||||
|
<div className="scroll-box scrollable" id="scroll">
|
||||||
|
<table className="clause-table">
|
||||||
|
<thead>
|
||||||
|
<tr className="clause-table-row">
|
||||||
|
<th className="clause-table-cell header-background action-header">
|
||||||
|
<span>{actionLabel}</span>
|
||||||
|
</th>
|
||||||
|
<th className="clause-table-cell header-background group-control-header">
|
||||||
|
{canGroupClauses && (
|
||||||
|
<button type="button" onClick={groupClauses} title={groupSelectedClauses}>
|
||||||
|
<img className="and-or-svg" src="/And-Or.svg" alt="Group selected clauses" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</th>
|
||||||
|
<th className="clause-table-cell header-background"></th>
|
||||||
|
<th className="clause-table-cell header-background and-or-header">
|
||||||
|
<span>{andLabel}</span>
|
||||||
|
</th>
|
||||||
|
<th className="clause-table-cell header-background field-header">
|
||||||
|
<span>{fieldLabel}</span>
|
||||||
|
</th>
|
||||||
|
<th className="clause-table-cell header-background type-header">
|
||||||
|
<span>{dataTypeLabel}</span>
|
||||||
|
</th>
|
||||||
|
<th className="clause-table-cell header-background operator-header">
|
||||||
|
<span>{operatorLabel}</span>
|
||||||
|
</th>
|
||||||
|
<th className="clause-table-cell header-background value-header">
|
||||||
|
<span>{valueLabel}</span>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{clauseArray().map((data, index) => (
|
||||||
|
<tr className="clause-table-row">
|
||||||
|
<td className="clause-table-cell action-column">
|
||||||
|
<span
|
||||||
|
className="entity-Add-Cancel"
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
onClick={addClauseIndex.bind(data, index)}
|
||||||
|
onKeyDown={onAddClauseKeyDown.bind(data, index)}
|
||||||
|
title={insertNewFilterLine}
|
||||||
|
>
|
||||||
|
<img className="querybuilder-addpropertyImg" src="/Add-property.svg" alt="Add clause" />
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
className="entity-Add-Cancel"
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
data-bind="hasFocus: isDeleteButtonFocused"
|
||||||
|
onClick={deleteClause.bind(data, index)}
|
||||||
|
onKeyDown={onDeleteClauseKeyDown.bind(data, index)}
|
||||||
|
title={removeThisFilterLine}
|
||||||
|
>
|
||||||
|
<img className="querybuilder-cancelImg" src="/Entity_cancel.svg" alt="Delete clause" />
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
{/* <td className="clause-table-cell group-control-column">
|
||||||
|
<input type="checkbox" aria-label="And/Or" checked={checkedForGrouping} />
|
||||||
|
</td> */}
|
||||||
|
{/* <td>
|
||||||
|
<table className="group-indicator-table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
{getClauseGroupViewModels(data).map((gi, index) => (
|
||||||
|
<td
|
||||||
|
className="group-indicator-column"
|
||||||
|
style={{
|
||||||
|
backgroundColor: gi.backgroundColor,
|
||||||
|
borderTop: gi.showTopBorder.peek() ? "solid thin #CCCCCC" : "none",
|
||||||
|
borderLeft: gi.showLeftBorder.peek() ? "solid thin #CCCCCC" : "none",
|
||||||
|
borderBottom: gi.showBottomBorder.peek()
|
||||||
|
? "solid thin #CCCCCC"
|
||||||
|
: gi.borderBackgroundColor,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{gi.canUngroup && (
|
||||||
|
<button type="button" onClick={} title={ungroupClausesLabel}>
|
||||||
|
<img src="/QueryBuilder/UngroupClause_16x.png" alt="Ungroup clauses" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
<td className="clause-table-cell and-or-column">
|
||||||
|
{canAnd && (
|
||||||
|
<select
|
||||||
|
className="clause-table-field and-or-column"
|
||||||
|
data-bind=" value: and_or, "
|
||||||
|
autoFocus={isAndOrFocused}
|
||||||
|
aria-label=" and_or "
|
||||||
|
>
|
||||||
|
{clauseRules().map((data, index) => (
|
||||||
|
<option value={data}>{data}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td className="clause-table-cell field-column" onClick={updateColumnOptions}>
|
||||||
|
<select
|
||||||
|
aria-label={field}
|
||||||
|
className="clause-table-field field-column"
|
||||||
|
data-bind=" value: field"
|
||||||
|
>
|
||||||
|
{columnOptions().map((data, index) => (
|
||||||
|
<option value={data}>{data}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td className="clause-table-cell type-column">
|
||||||
|
{isTypeEditable && (
|
||||||
|
<select
|
||||||
|
className="clause-table-field type-column"
|
||||||
|
aria-label={type}
|
||||||
|
value={type}
|
||||||
|
data-bind="css: {'query-builder-isDisabled': !isTypeEditable()}"
|
||||||
|
>
|
||||||
|
{edmTypes.map((data) => (
|
||||||
|
<option>{parent.edmTypes} </option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td className="clause-table-cell operator-column">
|
||||||
|
{isOperaterEditable && (
|
||||||
|
<select
|
||||||
|
className="clause-table-field operator-column"
|
||||||
|
aria-label={operator}
|
||||||
|
data-bind="
|
||||||
|
value: operator,
|
||||||
|
css: {'query-builder-isDisabled': !isOperaterEditable()}"
|
||||||
|
>
|
||||||
|
{operators().map((data, index) => (
|
||||||
|
<option key={index}>{data}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td className="clause-table-cell value-column">
|
||||||
|
{isValue && (
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="clause-table-field value-column"
|
||||||
|
type="search"
|
||||||
|
data-bind="textInput: value"
|
||||||
|
aria-label={valueLabel}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isTimestamp && (
|
||||||
|
<select
|
||||||
|
className="clause-table-field time-column"
|
||||||
|
data-bind="options: $parent.timeOptions, value: timeValue"
|
||||||
|
></select>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isCustomLastTimestamp && (
|
||||||
|
<input
|
||||||
|
className="clause-table-field time-column"
|
||||||
|
value={customTimeValue}
|
||||||
|
onClick={customTimestampDialog}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{isCustomRangeTimestamp && (
|
||||||
|
<input
|
||||||
|
className="clause-table-field time-column"
|
||||||
|
type="datetime-local"
|
||||||
|
step="1"
|
||||||
|
value={customTimeValue}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
*/}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="addClause"
|
||||||
|
role="button"
|
||||||
|
onClick={addNewClause}
|
||||||
|
data-bind="event: { keydown: onAddNewClauseKeyDown }"
|
||||||
|
title={addNewClauseLine}
|
||||||
|
tabIndex={0}
|
||||||
|
>
|
||||||
|
<div className="addClause-heading">
|
||||||
|
<span className="clause-table addClause-title">
|
||||||
|
<img
|
||||||
|
className="addclauseProperty-Img"
|
||||||
|
style={{ marginBottom: "5px" }}
|
||||||
|
src="/Add-property.svg"
|
||||||
|
alt="Add new clause"
|
||||||
|
/>
|
||||||
|
<span style={{ marginLeft: "5px" }}>{addNewClauseLine}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="advanced-options-panel">
|
||||||
|
{/* <div className="advanced-heading">
|
||||||
|
<span
|
||||||
|
className="advanced-title"
|
||||||
|
role="button"
|
||||||
|
onClick={toggleAdvancedOptions}
|
||||||
|
onKeyDown={ontoggleAdvancedOptionsKeyDown}
|
||||||
|
aria-expanded={isExpanded() ? "true" : "false"}
|
||||||
|
tabIndex={0}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="themed-images"
|
||||||
|
type="text/html"
|
||||||
|
id="ExpandChevronRight"
|
||||||
|
data-bind="hasFocus: focusExpandIcon"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
className="imgiconwidth expand-triangle expand-triangle-right"
|
||||||
|
src="/Triangle-right.svg"
|
||||||
|
alt="toggle"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="themed-images" type="text/html" id="ExpandChevronDown">
|
||||||
|
<img className="imgiconwidth expand-triangle" src="/Triangle-down.svg" alt="toggle" />
|
||||||
|
</div>
|
||||||
|
<span>Advanced Options</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{isExpanded && (
|
||||||
|
<div className="advanced-options">
|
||||||
|
<div className="top">
|
||||||
|
<span>Show top results:</span>
|
||||||
|
<input
|
||||||
|
className="top-input"
|
||||||
|
type="number"
|
||||||
|
autoFocus={focusTopResult}
|
||||||
|
value={topValue}
|
||||||
|
title={topValueLimitMessage}
|
||||||
|
role="textbox"
|
||||||
|
aria-label="Show top results"
|
||||||
|
/>
|
||||||
|
{isExceedingLimit && (
|
||||||
|
<div role="alert" aria-atomic="true" className="inline-div">
|
||||||
|
<img className="advanced-options-icon" src="/QueryBuilder/StatusWarning_16x.png" />
|
||||||
|
<span>{topValueLimitMessage}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="select">
|
||||||
|
<span> Select fields for query: </span>
|
||||||
|
{isSelected && (
|
||||||
|
<div>
|
||||||
|
<img className="advanced-options-icon" src="/QueryBuilder/QueryInformation_16x.png" />
|
||||||
|
<span className="select-options-text">{selectMessage}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<a
|
||||||
|
className="select-options-link"
|
||||||
|
onKeyDown={onselectQueryOptionsKeyDown}
|
||||||
|
onClick={selectQueryOptions}
|
||||||
|
tabIndex={0}
|
||||||
|
role="link"
|
||||||
|
>
|
||||||
|
<span>Choose Columns... </span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)} */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="tablesQueryTab tableContainer" id={this.tableEntityListViewModel.id}>
|
||||||
|
<table
|
||||||
|
id="storageTable"
|
||||||
|
className="storage azure-table show-gridlines"
|
||||||
|
tabIndex={0}
|
||||||
|
data-bind="tableSource: items, tableSelection: selected"
|
||||||
|
></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ import MongoDocumentsTab from "../Tabs/MongoDocumentsTab";
|
|||||||
import { NewMongoQueryTab } from "../Tabs/MongoQueryTab/MongoQueryTab";
|
import { NewMongoQueryTab } from "../Tabs/MongoQueryTab/MongoQueryTab";
|
||||||
import { NewMongoShellTab } from "../Tabs/MongoShellTab/MongoShellTab";
|
import { NewMongoShellTab } from "../Tabs/MongoShellTab/MongoShellTab";
|
||||||
import { NewQueryTab } from "../Tabs/QueryTab/QueryTab";
|
import { NewQueryTab } from "../Tabs/QueryTab/QueryTab";
|
||||||
import QueryTablesTab from "../Tabs/QueryTablesTab";
|
import { NewQueryTablesTab } from "../Tabs/QueryTablesTab/NewQueryTablesTab";
|
||||||
import { CollectionSettingsTabV2 } from "../Tabs/SettingsTabV2";
|
import { CollectionSettingsTabV2 } from "../Tabs/SettingsTabV2";
|
||||||
import { useDatabases } from "../useDatabases";
|
import { useDatabases } from "../useDatabases";
|
||||||
import { useSelectedNode } from "../useSelectedNode";
|
import { useSelectedNode } from "../useSelectedNode";
|
||||||
@@ -391,13 +391,13 @@ export default class Collection implements ViewModels.Collection {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const queryTablesTabs: QueryTablesTab[] = useTabs
|
const queryTablesTabs: NewQueryTablesTab[] = useTabs
|
||||||
.getState()
|
.getState()
|
||||||
.getTabs(
|
.getTabs(
|
||||||
ViewModels.CollectionTabKind.QueryTables,
|
ViewModels.CollectionTabKind.QueryTables,
|
||||||
(tab) => tab.collection && tab.collection.databaseId === this.databaseId && tab.collection.id() === this.id()
|
(tab) => tab.collection && tab.collection.databaseId === this.databaseId && tab.collection.id() === this.id()
|
||||||
) as QueryTablesTab[];
|
) as NewQueryTablesTab[];
|
||||||
let queryTablesTab: QueryTablesTab = queryTablesTabs && queryTablesTabs[0];
|
let queryTablesTab: NewQueryTablesTab = queryTablesTabs && queryTablesTabs[0];
|
||||||
|
|
||||||
if (queryTablesTab) {
|
if (queryTablesTab) {
|
||||||
useTabs.getState().activateTab(queryTablesTab);
|
useTabs.getState().activateTab(queryTablesTab);
|
||||||
@@ -415,14 +415,14 @@ export default class Collection implements ViewModels.Collection {
|
|||||||
tabTitle: title,
|
tabTitle: title,
|
||||||
});
|
});
|
||||||
|
|
||||||
queryTablesTab = new QueryTablesTab({
|
queryTablesTab = new NewQueryTablesTab({
|
||||||
tabKind: ViewModels.CollectionTabKind.QueryTables,
|
tabKind: ViewModels.CollectionTabKind.QueryTables,
|
||||||
title: title,
|
title: title,
|
||||||
tabPath: "",
|
tabPath: "",
|
||||||
collection: this,
|
collection: this,
|
||||||
node: this,
|
node: this,
|
||||||
onLoadStartKey: startKey,
|
onLoadStartKey: startKey,
|
||||||
});
|
}, { container: this.container });
|
||||||
|
|
||||||
useTabs.getState().activateNewTab(queryTablesTab);
|
useTabs.getState().activateNewTab(queryTablesTab);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import _ from "underscore";
|
|||||||
import create, { UseStore } from "zustand";
|
import create, { UseStore } from "zustand";
|
||||||
import * as Constants from "../Common/Constants";
|
import * as Constants from "../Common/Constants";
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
import { userContext } from "../UserContext";
|
|
||||||
import { useSelectedNode } from "./useSelectedNode";
|
import { useSelectedNode } from "./useSelectedNode";
|
||||||
|
|
||||||
interface DatabasesState {
|
interface DatabasesState {
|
||||||
@@ -137,11 +136,6 @@ export const useDatabases: UseStore<DatabasesState> = create((set, get) => ({
|
|||||||
},
|
},
|
||||||
validateCollectionId: async (databaseId: string, collectionId: string): Promise<boolean> => {
|
validateCollectionId: async (databaseId: string, collectionId: string): Promise<boolean> => {
|
||||||
const database = get().databases.find((db) => db.id() === databaseId);
|
const database = get().databases.find((db) => db.id() === databaseId);
|
||||||
// For a new tables account, database is undefined when creating the first table
|
|
||||||
if (!database && userContext.apiType === "Tables") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
await database.loadCollections();
|
await database.loadCollections();
|
||||||
return !database.collections().some((collection) => collection.id() === collectionId);
|
return !database.collections().some((collection) => collection.id() === collectionId);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user