Remove OpenActionsStubs (#106)

This commit is contained in:
Steve Faulkner 2020-07-21 13:50:51 -05:00 committed by GitHub
parent 46cca859e3
commit 4f86015be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 157 additions and 681 deletions

View File

@ -24,6 +24,7 @@ import { MessageHandler } from "./MessageHandler";
import { MessageTypes } from "../Contracts/ExplorerContracts"; import { MessageTypes } from "../Contracts/ExplorerContracts";
import { OfferUtils } from "../Utils/OfferUtils"; import { OfferUtils } from "../Utils/OfferUtils";
import { RequestOptions } from "@azure/cosmos/dist-esm"; import { RequestOptions } from "@azure/cosmos/dist-esm";
import StoredProcedure from "../Explorer/Tree/StoredProcedure";
export function getCommonQueryOptions(options: FeedOptions): any { export function getCommonQueryOptions(options: FeedOptions): any {
const storedItemPerPageSetting: number = LocalStorageUtility.getEntryNumber(StorageKey.ActualItemPerPage); const storedItemPerPageSetting: number = LocalStorageUtility.getEntryNumber(StorageKey.ActualItemPerPage);
@ -142,7 +143,7 @@ export abstract class DataAccessUtilityBase {
public executeStoredProcedure( public executeStoredProcedure(
collection: ViewModels.Collection, collection: ViewModels.Collection,
storedProcedure: ViewModels.StoredProcedure, storedProcedure: StoredProcedure,
partitionKeyValue: any, partitionKeyValue: any,
params: any[] params: any[]
): Q.Promise<any> { ): Q.Promise<any> {

View File

@ -12,6 +12,7 @@ import { MessageTypes } from "../Contracts/ExplorerContracts";
import { MinimalQueryIterator, nextPage } from "./IteratorUtilities"; import { MinimalQueryIterator, nextPage } from "./IteratorUtilities";
import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils"; import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils";
import { RequestOptions } from "@azure/cosmos/dist-esm"; import { RequestOptions } from "@azure/cosmos/dist-esm";
import StoredProcedure from "../Explorer/Tree/StoredProcedure";
// TODO: Log all promise resolutions and errors with verbosity levels // TODO: Log all promise resolutions and errors with verbosity levels
export default class DocumentClientUtilityBase { export default class DocumentClientUtilityBase {
@ -164,7 +165,7 @@ export default class DocumentClientUtilityBase {
public executeStoredProcedure( public executeStoredProcedure(
collection: ViewModels.Collection, collection: ViewModels.Collection,
storedProcedure: ViewModels.StoredProcedure, storedProcedure: StoredProcedure,
partitionKeyValue: any, partitionKeyValue: any,
params: any[] params: any[]
): Q.Promise<any> { ): Q.Promise<any> {

View File

@ -12,6 +12,10 @@ import { NotebookContentItem } from "../Explorer/Notebook/NotebookContentItem";
import { QueryMetrics } from "@azure/cosmos"; import { QueryMetrics } from "@azure/cosmos";
import { UploadDetails } from "../workers/upload/definitions"; import { UploadDetails } from "../workers/upload/definitions";
import Explorer from "../Explorer/Explorer"; import Explorer from "../Explorer/Explorer";
import UserDefinedFunction from "../Explorer/Tree/UserDefinedFunction";
import StoredProcedure from "../Explorer/Tree/StoredProcedure";
import ConflictsTab from "../Explorer/Tabs/ConflictsTab";
import Trigger from "../Explorer/Tree/Trigger";
export interface ExplorerOptions { export interface ExplorerOptions {
documentClientUtility: DocumentClientUtilityBase; documentClientUtility: DocumentClientUtilityBase;
@ -27,34 +31,12 @@ export interface NavbarButtonConfig extends CommandButtonComponentProps {}
export interface DatabaseAccount extends DataModels.DatabaseAccount {} export interface DatabaseAccount extends DataModels.DatabaseAccount {}
export interface NotebookWorkspaceManager {
getNotebookWorkspacesAsync(cosmosAccountResourceId: string): Promise<DataModels.NotebookWorkspace[]>;
getNotebookWorkspaceAsync(
cosmosAccountResourceId: string,
notebookWorkspaceId: string
): Promise<DataModels.NotebookWorkspace>;
createNotebookWorkspaceAsync(cosmosdbResourceId: string, notebookWorkspaceId: string): Promise<void>;
deleteNotebookWorkspaceAsync(cosmosdbResourceId: string, notebookWorkspaceId: string): Promise<void>;
getNotebookConnectionInfoAsync(
cosmosAccountResourceId: string,
notebookWorkspaceId: string
): Promise<DataModels.NotebookWorkspaceConnectionInfo>;
startNotebookWorkspaceAsync(cosmosdbResourceId: string, notebookWorkspaceId: string): Promise<void>;
}
export interface KernelConnectionMetadata { export interface KernelConnectionMetadata {
name: string; name: string;
configurationEndpoints: DataModels.NotebookConfigurationEndpoints; configurationEndpoints: DataModels.NotebookConfigurationEndpoints;
notebookConnectionInfo: DataModels.NotebookWorkspaceConnectionInfo; notebookConnectionInfo: DataModels.NotebookWorkspaceConnectionInfo;
} }
export interface ArcadiaResourceManager {
getWorkspacesAsync(arcadiaResourceId: string): Promise<DataModels.ArcadiaWorkspace[]>;
getWorkspaceAsync(arcadiaResourceId: string, workspaceId: string): Promise<DataModels.ArcadiaWorkspace>;
listWorkspacesAsync(subscriptionIds: string[]): Promise<DataModels.ArcadiaWorkspace[]>;
listSparkPoolsAsync(resourceId: string): Promise<DataModels.SparkPool[]>;
}
export interface TokenProvider { export interface TokenProvider {
getAuthHeader(): Promise<Headers>; getAuthHeader(): Promise<Headers>;
} }
@ -258,48 +240,6 @@ export interface ConflictId {
loadConflict(): Q.Promise<any>; loadConflict(): Q.Promise<any>;
} }
export interface StoredProcedure extends TreeNode {
container: Explorer;
collection: Collection;
rid: string;
self: string;
id: ko.Observable<string>;
body: ko.Observable<string>;
delete(): void;
open: () => void;
select(): void;
execute(params: string[], partitionKeyValue?: string): void;
}
export interface UserDefinedFunction extends TreeNode {
container: Explorer;
collection: Collection;
rid: string;
self: string;
id: ko.Observable<string>;
body: ko.Observable<string>;
delete(): void;
open: () => void;
select(): void;
}
export interface Trigger extends TreeNode {
container: Explorer;
collection: Collection;
rid: string;
self: string;
id: ko.Observable<string>;
body: ko.Observable<string>;
triggerType: ko.Observable<string>;
triggerOperation: ko.Observable<string>;
delete(): void;
open: () => void;
select(): void;
}
/** /**
* Options used to initialize pane * Options used to initialize pane
*/ */
@ -623,111 +563,6 @@ export interface DocumentsTab extends Tab {
loadNextPage(): Q.Promise<any>; loadNextPage(): Q.Promise<any>;
} }
export interface ConflictsTab extends Tab {
/* Conflicts Grid */
selectedConflictId: ko.Observable<ConflictId>;
selectedConflictContent: Editable<any>;
selectedConflictCurrent: Editable<any>;
onConflictIdClick(conflictId: ConflictId): Q.Promise<any>;
dataContentsGridScrollHeight: ko.Observable<string>;
accessibleDocumentList: AccessibleVerticalList;
documentContentsGridId: string;
partitionKey: DataModels.PartitionKey;
partitionKeyPropertyHeader: string;
partitionKeyProperty: string;
conflictIds: ko.ObservableArray<ConflictId>;
/* Document Editor */
isEditorDirty: ko.Computed<boolean>;
editorState: ko.Observable<DocumentExplorerState>;
onValidDocumentEdit(content: any): Q.Promise<any>;
onInvalidDocumentEdit(content: any): Q.Promise<any>;
loadingConflictData: ko.Observable<boolean>;
onAcceptChangesClick(): Q.Promise<any>;
onDiscardClick(): Q.Promise<any>;
initDocumentEditorForCreate(documentId: ConflictId, documentToInsert: any): Q.Promise<any>;
initDocumentEditorForReplace(documentId: ConflictId, conflictContent: any, currentContent: any): Q.Promise<any>;
initDocumentEditorForDelete(documentId: ConflictId, documentToDelete: any): Q.Promise<any>;
initDocumentEditorForNoOp(conflictId: ConflictId): Q.Promise<any>;
loadNextPage(): Q.Promise<any>;
}
export interface SettingsTab extends Tab {
/*state*/
throughput: ko.Observable<number>;
timeToLive: ko.Observable<string>;
timeToLiveSeconds: ko.Observable<number>;
geospatialVisible: ko.Computed<boolean>;
geospatialConfigType: ko.Observable<string>;
indexingPolicyContent: ko.Observable<DataModels.IndexingPolicy>;
rupm: ko.Observable<string>;
requestUnitsUsageCost: ko.Computed<string>;
canThroughputExceedMaximumValue: ko.Computed<boolean>;
shouldDisplayPortalUsePrompt: ko.Computed<boolean>;
warningMessage: ko.Computed<string>;
ttlOffFocused: ko.Observable<boolean>;
ttlOnDefaultFocused: ko.Observable<boolean>;
ttlOnFocused: ko.Observable<boolean>;
indexingPolicyElementFocused: ko.Observable<boolean>;
notificationStatusInfo: ko.Observable<string>;
shouldShowNotificationStatusPrompt: ko.Computed<boolean>;
shouldShowStatusBar: ko.Computed<boolean>;
pendingNotification: ko.Observable<DataModels.Notification>;
conflictResolutionPolicyMode: ko.Observable<string>;
conflictResolutionPolicyPath: ko.Observable<string>;
conflictResolutionPolicyProcedure: ko.Observable<string>;
rupmVisible: ko.Computed<boolean>;
costsVisible: ko.Computed<boolean>;
minRUAnotationVisible: ko.Computed<boolean>;
/* Command Bar */
saveSettingsButton: Button;
discardSettingsChangesButton: Button;
onSaveClick(): Q.Promise<any>;
onRevertClick(): Q.Promise<any>;
/* Indexing Policy Editor */
isIndexingPolicyEditorInitializing: ko.Observable<boolean>;
indexingPolicyEditor: ko.Observable<monaco.editor.IStandaloneCodeEditor>;
onValidIndexingPolicyEdit(content: any): Q.Promise<any>;
onInvalidIndexingPolicyEdit(content: any): Q.Promise<any>;
onSaveClick(): Q.Promise<any>;
onRevertClick(): Q.Promise<any>;
}
export interface DatabaseSettingsTab extends Tab {
/*state*/
throughput: ko.Observable<number>;
requestUnitsUsageCost: ko.PureComputed<string>;
canThroughputExceedMaximumValue: ko.Computed<boolean>;
warningMessage: ko.Computed<string>;
notificationStatusInfo: ko.Observable<string>;
shouldShowNotificationStatusPrompt: ko.Computed<boolean>;
shouldShowStatusBar: ko.Computed<boolean>;
pendingNotification: ko.Observable<DataModels.Notification>;
costsVisible: ko.Computed<boolean>;
minRUAnotationVisible: ko.Computed<boolean>;
/* Command Bar */
saveSettingsButton: Button;
discardSettingsChangesButton: Button;
onSaveClick(): Q.Promise<any>;
onRevertClick(): Q.Promise<any>;
/* Errors */
displayedError: ko.Observable<string>;
onSaveClick(): Q.Promise<any>;
onRevertClick(): Q.Promise<any>;
}
export interface WaitsForTemplate { export interface WaitsForTemplate {
isTemplateReady: ko.Observable<boolean>; isTemplateReady: ko.Observable<boolean>;
} }

View File

@ -13,6 +13,9 @@ import DeleteTriggerIcon from "../../images/DeleteTrigger.svg";
import DeleteUDFIcon from "../../images/DeleteUDF.svg"; import DeleteUDFIcon from "../../images/DeleteUDF.svg";
import DeleteSprocIcon from "../../images/DeleteSproc.svg"; import DeleteSprocIcon from "../../images/DeleteSproc.svg";
import Explorer from "./Explorer"; import Explorer from "./Explorer";
import UserDefinedFunction from "./Tree/UserDefinedFunction";
import StoredProcedure from "./Tree/StoredProcedure";
import Trigger from "./Tree/Trigger";
export interface CollectionContextMenuButtonParams { export interface CollectionContextMenuButtonParams {
databaseId: string; databaseId: string;
@ -117,7 +120,7 @@ export class ResourceTreeContextMenuButtonFactory {
public static createStoreProcedureContextMenuItems( public static createStoreProcedureContextMenuItems(
container: Explorer, container: Explorer,
storedProcedure: ViewModels.StoredProcedure storedProcedure: StoredProcedure
): TreeNodeMenuItem[] { ): TreeNodeMenuItem[] {
if (container.isPreferredApiCassandra()) { if (container.isPreferredApiCassandra()) {
return []; return [];
@ -132,7 +135,7 @@ export class ResourceTreeContextMenuButtonFactory {
]; ];
} }
public static createTriggerContextMenuItems(container: Explorer, trigger: ViewModels.Trigger): TreeNodeMenuItem[] { public static createTriggerContextMenuItems(container: Explorer, trigger: Trigger): TreeNodeMenuItem[] {
if (container.isPreferredApiCassandra()) { if (container.isPreferredApiCassandra()) {
return []; return [];
} }
@ -148,7 +151,7 @@ export class ResourceTreeContextMenuButtonFactory {
public static createUserDefinedFunctionContextMenuItems( public static createUserDefinedFunctionContextMenuItems(
container: Explorer, container: Explorer,
userDefinedFunction: ViewModels.UserDefinedFunction userDefinedFunction: UserDefinedFunction
): TreeNodeMenuItem[] { ): TreeNodeMenuItem[] {
if (container.isPreferredApiCassandra()) { if (container.isPreferredApiCassandra()) {
return []; return [];

View File

@ -3,7 +3,6 @@ import * as sinon from "sinon";
import * as ViewModels from "../../Contracts/ViewModels"; import * as ViewModels from "../../Contracts/ViewModels";
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase"; import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
import Q from "q"; import Q from "q";
import { CollectionStub, DatabaseStub } from "../OpenActionsStubs";
import { ContainerSampleGenerator } from "./ContainerSampleGenerator"; import { ContainerSampleGenerator } from "./ContainerSampleGenerator";
import { CosmosClient } from "../../Common/CosmosClient"; import { CosmosClient } from "../../Common/CosmosClient";
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient"; import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
@ -54,11 +53,11 @@ describe("ContainerSampleGenerator", () => {
} }
] ]
}; };
const collection = new CollectionStub({ id: ko.observable(sampleCollectionId) }); const collection = { id: ko.observable(sampleCollectionId) } as ViewModels.Collection;
const database = new DatabaseStub({ const database = {
id: ko.observable(sampleDatabaseId), id: ko.observable(sampleDatabaseId),
collections: ko.observableArray([collection]) collections: ko.observableArray<ViewModels.Collection>([collection])
}); } as ViewModels.Database;
database.findCollectionWithId = () => collection; database.findCollectionWithId = () => collection;
const explorerStub = createExplorerStub(database); const explorerStub = createExplorerStub(database);
@ -99,11 +98,11 @@ describe("ContainerSampleGenerator", () => {
"g.addV('person').property(id, '1').property('_partitionKey','pk').property('name', 'Eva').property('age', 44)" "g.addV('person').property(id, '1').property('_partitionKey','pk').property('name', 'Eva').property('age', 44)"
] ]
}; };
const collection = new CollectionStub({ id: ko.observable(sampleCollectionId) }); const collection = { id: ko.observable(sampleCollectionId) } as ViewModels.Collection;
const database = new DatabaseStub({ const database = {
id: ko.observable(sampleDatabaseId), id: ko.observable(sampleDatabaseId),
collections: ko.observableArray([collection]) collections: ko.observableArray<ViewModels.Collection>([collection])
}); } as ViewModels.Database;
database.findCollectionWithId = () => collection; database.findCollectionWithId = () => collection;
collection.databaseId = database.id(); collection.databaseId = database.id();

View File

@ -1,20 +1,20 @@
import { DatabaseStub, CollectionStub } from "../OpenActionsStubs";
import { DataSamplesUtil } from "./DataSamplesUtil"; import { DataSamplesUtil } from "./DataSamplesUtil";
import * as sinon from "sinon"; import * as sinon from "sinon";
import { ContainerSampleGenerator } from "./ContainerSampleGenerator"; import { ContainerSampleGenerator } from "./ContainerSampleGenerator";
import * as ko from "knockout"; import * as ko from "knockout";
import Explorer from "../Explorer"; import Explorer from "../Explorer";
import { Database, Collection } from "../../Contracts/ViewModels";
describe("DataSampleUtils", () => { describe("DataSampleUtils", () => {
const sampleCollectionId = "sampleCollectionId"; const sampleCollectionId = "sampleCollectionId";
const sampleDatabaseId = "sampleDatabaseId"; const sampleDatabaseId = "sampleDatabaseId";
it("should not create sample collection if collection already exists", async () => { it("should not create sample collection if collection already exists", async () => {
const collection = new CollectionStub({ id: ko.observable(sampleCollectionId) }); const collection = { id: ko.observable(sampleCollectionId) } as Collection;
const database = new DatabaseStub({ const database = {
id: ko.observable(sampleDatabaseId), id: ko.observable(sampleDatabaseId),
collections: ko.observableArray([collection]) collections: ko.observableArray<Collection>([collection])
}); } as Database;
const explorer = {} as Explorer; const explorer = {} as Explorer;
explorer.nonSystemDatabases = ko.computed(() => [database]); explorer.nonSystemDatabases = ko.computed(() => [database]);
explorer.showOkModalDialog = () => {}; explorer.showOkModalDialog = () => {};

View File

@ -79,6 +79,9 @@ import { UploadItemsPane } from "./Panes/UploadItemsPane";
import { UploadItemsPaneAdapter } from "./Panes/UploadItemsPaneAdapter"; import { UploadItemsPaneAdapter } from "./Panes/UploadItemsPaneAdapter";
import { ReactAdapter } from "../Bindings/ReactBindingHandler"; import { ReactAdapter } from "../Bindings/ReactBindingHandler";
import { toRawContentUri, fromContentUri } from "../Utils/GitHubUtils"; import { toRawContentUri, fromContentUri } from "../Utils/GitHubUtils";
import UserDefinedFunction from "./Tree/UserDefinedFunction";
import StoredProcedure from "./Tree/StoredProcedure";
import Trigger from "./Tree/Trigger";
BindingHandlersRegisterer.registerBindingHandlers(); BindingHandlersRegisterer.registerBindingHandlers();
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import // Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
@ -214,7 +217,7 @@ export default class Explorer {
public isNotebookEnabled: ko.Observable<boolean>; public isNotebookEnabled: ko.Observable<boolean>;
public isNotebooksEnabledForAccount: ko.Observable<boolean>; public isNotebooksEnabledForAccount: ko.Observable<boolean>;
public notebookServerInfo: ko.Observable<DataModels.NotebookWorkspaceConnectionInfo>; public notebookServerInfo: ko.Observable<DataModels.NotebookWorkspaceConnectionInfo>;
public notebookWorkspaceManager: ViewModels.NotebookWorkspaceManager; public notebookWorkspaceManager: NotebookWorkspaceManager;
public sparkClusterConnectionInfo: ko.Observable<DataModels.SparkClusterConnectionInfo>; public sparkClusterConnectionInfo: ko.Observable<DataModels.SparkClusterConnectionInfo>;
public isSparkEnabled: ko.Observable<boolean>; public isSparkEnabled: ko.Observable<boolean>;
public isSparkEnabledForAccount: ko.Observable<boolean>; public isSparkEnabledForAccount: ko.Observable<boolean>;
@ -231,7 +234,7 @@ export default class Explorer {
private _isInitializingNotebooks: boolean; private _isInitializingNotebooks: boolean;
private _isInitializingSparkConnectionInfo: boolean; private _isInitializingSparkConnectionInfo: boolean;
private notebookBasePath: ko.Observable<string>; private notebookBasePath: ko.Observable<string>;
private _arcadiaManager: ViewModels.ArcadiaResourceManager; private _arcadiaManager: ArcadiaResourceManager;
private notebookToImport: { private notebookToImport: {
name: string; name: string;
content: string; content: string;
@ -1955,9 +1958,9 @@ export default class Explorer {
} }
// TODO: Refactor below methods, minimize dependencies and add unit tests where necessary // TODO: Refactor below methods, minimize dependencies and add unit tests where necessary
public findSelectedStoredProcedure(): ViewModels.StoredProcedure { public findSelectedStoredProcedure(): StoredProcedure {
const selectedCollection: ViewModels.Collection = this.findSelectedCollection(); const selectedCollection: ViewModels.Collection = this.findSelectedCollection();
return _.find(selectedCollection.storedProcedures(), (storedProcedure: ViewModels.StoredProcedure) => { return _.find(selectedCollection.storedProcedures(), (storedProcedure: StoredProcedure) => {
const openedSprocTab = this.tabsManager.getTabs( const openedSprocTab = this.tabsManager.getTabs(
ViewModels.CollectionTabKind.StoredProcedures, ViewModels.CollectionTabKind.StoredProcedures,
(tab: ViewModels.Tab) => tab.node && tab.node.rid === storedProcedure.rid (tab: ViewModels.Tab) => tab.node && tab.node.rid === storedProcedure.rid
@ -1969,9 +1972,9 @@ export default class Explorer {
}); });
} }
public findSelectedUDF(): ViewModels.UserDefinedFunction { public findSelectedUDF(): UserDefinedFunction {
const selectedCollection: ViewModels.Collection = this.findSelectedCollection(); const selectedCollection: ViewModels.Collection = this.findSelectedCollection();
return _.find(selectedCollection.userDefinedFunctions(), (userDefinedFunction: ViewModels.UserDefinedFunction) => { return _.find(selectedCollection.userDefinedFunctions(), (userDefinedFunction: UserDefinedFunction) => {
const openedUdfTab = this.tabsManager.getTabs( const openedUdfTab = this.tabsManager.getTabs(
ViewModels.CollectionTabKind.UserDefinedFunctions, ViewModels.CollectionTabKind.UserDefinedFunctions,
(tab: ViewModels.Tab) => tab.node && tab.node.rid === userDefinedFunction.rid (tab: ViewModels.Tab) => tab.node && tab.node.rid === userDefinedFunction.rid
@ -1983,9 +1986,9 @@ export default class Explorer {
}); });
} }
public findSelectedTrigger(): ViewModels.Trigger { public findSelectedTrigger(): Trigger {
const selectedCollection: ViewModels.Collection = this.findSelectedCollection(); const selectedCollection: ViewModels.Collection = this.findSelectedCollection();
return _.find(selectedCollection.triggers(), (trigger: ViewModels.Trigger) => { return _.find(selectedCollection.triggers(), (trigger: Trigger) => {
const openedTriggerTab = this.tabsManager.getTabs( const openedTriggerTab = this.tabsManager.getTabs(
ViewModels.CollectionTabKind.Triggers, ViewModels.CollectionTabKind.Triggers,
(tab: ViewModels.Tab) => tab.node && tab.node.rid === trigger.rid (tab: ViewModels.Tab) => tab.node && tab.node.rid === trigger.rid

View File

@ -1,7 +1,6 @@
import * as ko from "knockout"; import * as ko from "knockout";
import { handleOpenAction } from "./OpenActions"; import { handleOpenAction } from "./OpenActions";
import * as ViewModels from "../Contracts/ViewModels"; import * as ViewModels from "../Contracts/ViewModels";
import { DatabaseStub, CollectionStub } from "./OpenActionsStubs";
import { ActionContracts } from "../Contracts/ExplorerContracts"; import { ActionContracts } from "../Contracts/ExplorerContracts";
import Explorer from "./Explorer"; import Explorer from "./Explorer";
import CassandraAddCollectionPane from "./Panes/CassandraAddCollectionPane"; import CassandraAddCollectionPane from "./Panes/CassandraAddCollectionPane";
@ -14,14 +13,6 @@ describe("OpenActions", () => {
let collection: ViewModels.Collection; let collection: ViewModels.Collection;
let databases: ViewModels.Database[]; let databases: ViewModels.Database[];
let expandCollection: jasmine.Spy;
let onDocumentDBDocumentsClick: jasmine.Spy;
let onMongoDBDocumentsClick: jasmine.Spy;
let onTableEntitiesClick: jasmine.Spy;
let onGraphDocumentsClick: jasmine.Spy;
let onNewQueryClick: jasmine.Spy;
let onSettingsClick: jasmine.Spy;
beforeEach(() => { beforeEach(() => {
explorer = {} as Explorer; explorer = {} as Explorer;
explorer.addCollectionPane = {} as AddCollectionPane; explorer.addCollectionPane = {} as AddCollectionPane;
@ -31,22 +22,22 @@ describe("OpenActions", () => {
explorer.closeAllPanes = () => {}; explorer.closeAllPanes = () => {};
explorer.isConnectExplorerVisible = () => false; explorer.isConnectExplorerVisible = () => false;
database = new DatabaseStub({ database = {
id: ko.observable("db"), id: ko.observable("db"),
collections: ko.observableArray<ViewModels.Collection>([]) collections: ko.observableArray<ViewModels.Collection>([])
}); } as ViewModels.Database;
databases = [database]; databases = [database];
collection = new CollectionStub({ collection = {
id: ko.observable("coll") id: ko.observable("coll")
}); } as ViewModels.Collection;
expandCollection = spyOn(collection, "expandCollection"); collection.expandCollection = jest.fn();
onDocumentDBDocumentsClick = spyOn(collection, "onDocumentDBDocumentsClick"); collection.onDocumentDBDocumentsClick = jest.fn();
onMongoDBDocumentsClick = spyOn(collection, "onMongoDBDocumentsClick"); collection.onMongoDBDocumentsClick = jest.fn();
onTableEntitiesClick = spyOn(collection, "onTableEntitiesClick"); collection.onTableEntitiesClick = jest.fn();
onGraphDocumentsClick = spyOn(collection, "onGraphDocumentsClick"); collection.onGraphDocumentsClick = jest.fn();
onNewQueryClick = spyOn(collection, "onNewQueryClick"); collection.onNewQueryClick = jest.fn();
onSettingsClick = spyOn(collection, "onSettingsClick"); collection.onSettingsClick = jest.fn();
}); });
describe("unknown action type", () => { describe("unknown action type", () => {
@ -146,10 +137,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(expandCollection).not.toHaveBeenCalled(); expect(collection.expandCollection).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(expandCollection).toHaveBeenCalled(); expect(collection.expandCollection).toHaveBeenCalled();
}); });
it("should expand collection node when handleOpenAction is called", () => { it("should expand collection node when handleOpenAction is called", () => {
@ -161,7 +152,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(expandCollection).toHaveBeenCalled(); expect(collection.expandCollection).toHaveBeenCalled();
}); });
describe("SQLDocuments tab kind", () => { describe("SQLDocuments tab kind", () => {
@ -174,10 +165,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onDocumentDBDocumentsClick).not.toHaveBeenCalled(); expect(collection.onDocumentDBDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onDocumentDBDocumentsClick).toHaveBeenCalled(); expect(collection.onDocumentDBDocumentsClick).toHaveBeenCalled();
}); });
it("string value should call onDocumentDBDocumentsClick", () => { it("string value should call onDocumentDBDocumentsClick", () => {
@ -190,7 +181,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onDocumentDBDocumentsClick).toHaveBeenCalled(); expect(collection.onDocumentDBDocumentsClick).toHaveBeenCalled();
}); });
it("enum value should call onDocumentDBDocumentsClick before collections are fetched", () => { it("enum value should call onDocumentDBDocumentsClick before collections are fetched", () => {
@ -202,10 +193,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onDocumentDBDocumentsClick).not.toHaveBeenCalled(); expect(collection.onDocumentDBDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onDocumentDBDocumentsClick).toHaveBeenCalled(); expect(collection.onDocumentDBDocumentsClick).toHaveBeenCalled();
}); });
it("enum value should call onDocumentDBDocumentsClick", () => { it("enum value should call onDocumentDBDocumentsClick", () => {
@ -218,7 +209,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onDocumentDBDocumentsClick).toHaveBeenCalled(); expect(collection.onDocumentDBDocumentsClick).toHaveBeenCalled();
}); });
}); });
@ -232,10 +223,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onMongoDBDocumentsClick).not.toHaveBeenCalled(); expect(collection.onMongoDBDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onMongoDBDocumentsClick).toHaveBeenCalled(); expect(collection.onMongoDBDocumentsClick).toHaveBeenCalled();
}); });
it("string value should call onMongoDBDocumentsClick", () => { it("string value should call onMongoDBDocumentsClick", () => {
@ -248,7 +239,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onMongoDBDocumentsClick).toHaveBeenCalled(); expect(collection.onMongoDBDocumentsClick).toHaveBeenCalled();
}); });
it("enum value should call onMongoDBDocumentsClick before collections are fetched", () => { it("enum value should call onMongoDBDocumentsClick before collections are fetched", () => {
@ -260,10 +251,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onMongoDBDocumentsClick).not.toHaveBeenCalled(); expect(collection.onMongoDBDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onMongoDBDocumentsClick).toHaveBeenCalled(); expect(collection.onMongoDBDocumentsClick).toHaveBeenCalled();
}); });
it("enum value should call onMongoDBDocumentsClick", () => { it("enum value should call onMongoDBDocumentsClick", () => {
@ -276,7 +267,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onMongoDBDocumentsClick).toHaveBeenCalled(); expect(collection.onMongoDBDocumentsClick).toHaveBeenCalled();
}); });
}); });
@ -290,10 +281,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onTableEntitiesClick).not.toHaveBeenCalled(); expect(collection.onTableEntitiesClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onTableEntitiesClick).toHaveBeenCalled(); expect(collection.onTableEntitiesClick).toHaveBeenCalled();
}); });
it("string value should call onTableEntitiesClick", () => { it("string value should call onTableEntitiesClick", () => {
@ -306,7 +297,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onTableEntitiesClick).toHaveBeenCalled(); expect(collection.onTableEntitiesClick).toHaveBeenCalled();
}); });
it("enum value should call onTableEntitiesClick before collections are fetched", () => { it("enum value should call onTableEntitiesClick before collections are fetched", () => {
@ -319,7 +310,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onTableEntitiesClick).toHaveBeenCalled(); expect(collection.onTableEntitiesClick).toHaveBeenCalled();
}); });
it("enum value should call onTableEntitiesClick", () => { it("enum value should call onTableEntitiesClick", () => {
@ -331,10 +322,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onTableEntitiesClick).not.toHaveBeenCalled(); expect(collection.onTableEntitiesClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onTableEntitiesClick).toHaveBeenCalled(); expect(collection.onTableEntitiesClick).toHaveBeenCalled();
}); });
}); });
@ -348,10 +339,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onGraphDocumentsClick).not.toHaveBeenCalled(); expect(collection.onGraphDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onGraphDocumentsClick).toHaveBeenCalled(); expect(collection.onGraphDocumentsClick).toHaveBeenCalled();
}); });
it("string value should call onGraphDocumentsClick", () => { it("string value should call onGraphDocumentsClick", () => {
@ -364,7 +355,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onGraphDocumentsClick).toHaveBeenCalled(); expect(collection.onGraphDocumentsClick).toHaveBeenCalled();
}); });
it("enum value should call onGraphDocumentsClick before collections are fetched", () => { it("enum value should call onGraphDocumentsClick before collections are fetched", () => {
@ -376,10 +367,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onGraphDocumentsClick).not.toHaveBeenCalled(); expect(collection.onGraphDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onGraphDocumentsClick).toHaveBeenCalled(); expect(collection.onGraphDocumentsClick).toHaveBeenCalled();
}); });
it("enum value should call onGraphDocumentsClick", () => { it("enum value should call onGraphDocumentsClick", () => {
@ -392,7 +383,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onGraphDocumentsClick).toHaveBeenCalled(); expect(collection.onGraphDocumentsClick).toHaveBeenCalled();
}); });
}); });
@ -406,10 +397,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onNewQueryClick).not.toHaveBeenCalled(); expect(collection.onNewQueryClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onNewQueryClick).toHaveBeenCalled(); expect(collection.onNewQueryClick).toHaveBeenCalled();
}); });
it("string value should call onNewQueryClick", () => { it("string value should call onNewQueryClick", () => {
@ -422,7 +413,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onNewQueryClick).toHaveBeenCalled(); expect(collection.onNewQueryClick).toHaveBeenCalled();
}); });
it("enum value should call onNewQueryClick before collections are fetched", () => { it("enum value should call onNewQueryClick before collections are fetched", () => {
@ -434,10 +425,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onNewQueryClick).not.toHaveBeenCalled(); expect(collection.onNewQueryClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onNewQueryClick).toHaveBeenCalled(); expect(collection.onNewQueryClick).toHaveBeenCalled();
}); });
it("enum value should call onNewQueryClick", () => { it("enum value should call onNewQueryClick", () => {
@ -450,7 +441,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onNewQueryClick).toHaveBeenCalled(); expect(collection.onNewQueryClick).toHaveBeenCalled();
}); });
}); });
@ -464,10 +455,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onSettingsClick).not.toHaveBeenCalled(); expect(collection.onSettingsClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onSettingsClick).toHaveBeenCalled(); expect(collection.onSettingsClick).toHaveBeenCalled();
}); });
it("string value should call onSettingsClick", () => { it("string value should call onSettingsClick", () => {
@ -480,7 +471,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onSettingsClick).toHaveBeenCalled(); expect(collection.onSettingsClick).toHaveBeenCalled();
}); });
it("enum value should call onSettingsClick before collections are fetched", () => { it("enum value should call onSettingsClick before collections are fetched", () => {
@ -492,10 +483,10 @@ describe("OpenActions", () => {
}; };
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onSettingsClick).not.toHaveBeenCalled(); expect(collection.onSettingsClick).not.toHaveBeenCalled();
database.collections([collection]); database.collections([collection]);
expect(onSettingsClick).toHaveBeenCalled(); expect(collection.onSettingsClick).toHaveBeenCalled();
}); });
it("enum value should call onSettingsClick", () => { it("enum value should call onSettingsClick", () => {
@ -508,7 +499,7 @@ describe("OpenActions", () => {
database.collections([collection]); database.collections([collection]);
handleOpenAction(action, [database], explorer); handleOpenAction(action, [database], explorer);
expect(onSettingsClick).toHaveBeenCalled(); expect(collection.onSettingsClick).toHaveBeenCalled();
}); });
}); });
}); });

View File

@ -1,349 +0,0 @@
import * as DataModels from "../../src/Contracts/DataModels";
import * as ko from "knockout";
import * as ViewModels from "../../src/Contracts/ViewModels";
import DocumentClientUtilityBase from "../Common/DocumentClientUtilityBase";
import Q from "q";
import { CassandraTableKey, CassandraTableKeys } from "../../src/Explorer/Tables/TableDataClient";
import { UploadDetails } from "../workers/upload/definitions";
import Explorer from "./Explorer";
export class DatabaseStub implements ViewModels.Database {
public nodeKind: string;
public container: Explorer;
public self: string;
public rid: string;
public id: ko.Observable<string>;
public collections: ko.ObservableArray<ViewModels.Collection>;
public isDatabaseExpanded: ko.Observable<boolean>;
public isDatabaseShared: ko.Computed<boolean>;
public selectedSubnodeKind: ko.Observable<ViewModels.CollectionTabKind>;
public offer: ko.Observable<DataModels.Offer>;
constructor(options?: any) {
this.nodeKind = options.nodeKind;
this.container = options.container;
this.self = options.self;
this.rid = options.rid;
this.id = options.id;
this.collections = options.collections;
this.isDatabaseExpanded = options.isDatabaseExpanded;
this.offer = options.offer;
this.selectedSubnodeKind = options.selectedSubnodeKind;
}
public onKeyPress = (source: any, event: KeyboardEvent): boolean => {
throw new Error("Not implemented");
};
public onKeyDown = (source: any, event: KeyboardEvent): boolean => {
throw new Error("Not implemented");
};
public onMenuKeyDown = (source: any, event: KeyboardEvent): boolean => {
throw new Error("Not implemented");
};
public onDeleteDatabaseContextMenuClick(source: ViewModels.Database, event: MouseEvent | KeyboardEvent) {
throw new Error("Not implemented");
}
public selectDatabase() {
throw new Error("Not implemented");
}
public expandCollapseDatabase() {
throw new Error("Not implemented");
}
public expandDatabase() {
throw new Error("Not implemented");
}
public collapseDatabase() {
throw new Error("Not implemented");
}
public loadCollections(): Q.Promise<void> {
throw new Error("Not implemented");
}
public findCollectionWithId(collectionId: string): ViewModels.Collection {
throw new Error("Not implemented");
}
public openAddCollection(database: ViewModels.Database, event: MouseEvent) {
throw new Error("Not implemented");
}
public readSettings() {
throw new Error("Not implemented");
}
public onSettingsClick(): void {
throw new Error("Not implemented");
}
}
export class CollectionStub implements ViewModels.Collection {
public nodeKind: string;
public container: Explorer;
public rawDataModel: DataModels.Collection;
public self: string;
public rid: string;
public databaseId: string;
public partitionKey: DataModels.PartitionKey;
public partitionKeyPropertyHeader: string;
public partitionKeyProperty: string;
public id: ko.Observable<string>;
public defaultTtl: ko.Observable<number>;
public analyticalStorageTtl: ko.Observable<number>;
public indexingPolicy: ko.Observable<DataModels.IndexingPolicy>;
public uniqueKeyPolicy: DataModels.UniqueKeyPolicy;
public quotaInfo: ko.Observable<DataModels.CollectionQuotaInfo>;
public offer: ko.Observable<DataModels.Offer>;
public partitions: ko.Computed<number>;
public throughput: ko.Computed<number>;
public cassandraKeys: CassandraTableKeys;
public cassandraSchema: CassandraTableKey[];
public documentIds: ko.ObservableArray<ViewModels.DocumentId>;
public children: ko.ObservableArray<ViewModels.TreeNode>;
public storedProcedures: ko.Computed<ViewModels.StoredProcedure[]>;
public userDefinedFunctions: ko.Computed<ViewModels.UserDefinedFunction[]>;
public triggers: ko.Computed<ViewModels.Trigger[]>;
public showStoredProcedures: ko.Observable<boolean>;
public showTriggers: ko.Observable<boolean>;
public showUserDefinedFunctions: ko.Observable<boolean>;
public selectedDocumentContent: ViewModels.Editable<any>;
public selectedSubnodeKind: ko.Observable<ViewModels.CollectionTabKind>;
public focusedSubnodeKind: ko.Observable<ViewModels.CollectionTabKind>;
public isCollectionExpanded: ko.Observable<boolean>;
public isStoredProceduresExpanded: ko.Observable<boolean>;
public isUserDefinedFunctionsExpanded: ko.Observable<boolean>;
public isTriggersExpanded: ko.Observable<boolean>;
public documentsFocused: ko.Observable<boolean>;
public settingsFocused: ko.Observable<boolean>;
public storedProceduresFocused: ko.Observable<boolean>;
public userDefinedFunctionsFocused: ko.Observable<boolean>;
public triggersFocused: ko.Observable<boolean>;
public conflictResolutionPolicy: ko.Observable<DataModels.ConflictResolutionPolicy>;
public changeFeedPolicy: ko.Observable<DataModels.ChangeFeedPolicy>;
public geospatialConfig: ko.Observable<DataModels.GeospatialConfig>;
constructor(options: any) {
this.nodeKind = options.nodeKind;
this.container = options.container;
this.self = options.self;
this.rid = options.rid;
this.databaseId = options.databaseId;
this.partitionKey = options.partitionKey;
this.partitionKeyPropertyHeader = options.partitionKeyPropertyHeader;
this.partitionKeyProperty = options.partitionKeyProperty;
this.id = options.id;
this.defaultTtl = options.defaultTtl;
this.analyticalStorageTtl = options.analyticalStorageTtl;
this.indexingPolicy = options.indexingPolicy;
this.uniqueKeyPolicy = options.uniqueKeyPolicy;
this.quotaInfo = options.quotaInfo;
this.offer = options.offer;
this.partitions = options.partitions;
this.throughput = options.throughput;
this.cassandraKeys = options.cassandraKeys;
this.cassandraSchema = options.cassandraSchema;
this.documentIds = options.documentIds;
this.children = options.children;
this.storedProcedures = options.storedProcedures;
this.userDefinedFunctions = options.userDefinedFunctions;
this.triggers = options.triggers;
this.showStoredProcedures = options.showStoredProcedures;
this.showTriggers = options.showTriggers;
this.showUserDefinedFunctions = options.showUserDefinedFunctions;
this.selectedDocumentContent = options.selectedDocumentContent;
this.selectedSubnodeKind = options.selectedSubnodeKind;
this.focusedSubnodeKind = options.focusedSubnodeKind;
this.isCollectionExpanded = options.isCollectionExpanded;
this.isStoredProceduresExpanded = options.isStoredProceduresExpanded;
this.isUserDefinedFunctionsExpanded = options.isUserDefinedFunctionsExpanded;
this.isTriggersExpanded = options.isTriggersExpanded;
this.documentsFocused = options.documentsFocused;
this.settingsFocused = options.settingsFocused;
this.storedProceduresFocused = options.storedProceduresFocused;
this.userDefinedFunctionsFocused = options.userDefinedFunctionsFocused;
this.triggersFocused = options.triggersFocused;
}
public expandCollapseCollection() {
throw new Error("Not implemented");
}
public collapseCollection() {
throw new Error("Not implemented");
}
public expandCollection(): Q.Promise<void> {
throw new Error("Not implemented");
}
public onDocumentDBDocumentsClick() {
throw new Error("onDocumentDBDocumentsClick");
}
public onTableEntitiesClick() {
throw new Error("Not implemented");
}
public onGraphDocumentsClick() {
throw new Error("Not implemented");
}
public onMongoDBDocumentsClick = () => {
throw new Error("Not implemented");
};
public openTab = () => {
throw new Error("Not implemented");
};
public onSettingsClick() {
throw new Error("Not implemented");
}
public onConflictsClick() {
throw new Error("Not implemented");
}
public readSettings(): Q.Promise<void> {
throw new Error("Not implemented");
}
public onNewQueryClick(source: any, event: MouseEvent, queryText?: string) {
throw new Error("Not implemented");
}
public onNewMongoQueryClick(source: any, event: MouseEvent, queryText?: string) {
throw new Error("Not implemented");
}
public onNewGraphClick() {
throw new Error("Not implemented");
}
public onNewMongoShellClick() {
throw new Error("Not implemented");
}
public onNewStoredProcedureClick(source: ViewModels.Collection, event: MouseEvent) {
throw new Error("Not implemented");
}
public onNewUserDefinedFunctionClick(source: ViewModels.Collection, event: MouseEvent) {
throw new Error("Not implemented");
}
public onNewTriggerClick(source: ViewModels.Collection, event: MouseEvent) {
throw new Error("Not implemented");
}
public createStoredProcedureNode(data: DataModels.StoredProcedure): ViewModels.StoredProcedure {
throw new Error("Not implemented");
}
public createUserDefinedFunctionNode(data: DataModels.UserDefinedFunction): ViewModels.UserDefinedFunction {
throw new Error("Not implemented");
}
public createTriggerNode(data: DataModels.Trigger): ViewModels.Trigger {
throw new Error("Not implemented");
}
public expandCollapseStoredProcedures() {
throw new Error("Not implemented");
}
public expandStoredProcedures() {
throw new Error("Not implemented");
}
public collapseStoredProcedures() {
throw new Error("Not implemented");
}
public expandCollapseUserDefinedFunctions() {
throw new Error("Not implemented");
}
public expandUserDefinedFunctions() {
throw new Error("Not implemented");
}
public collapseUserDefinedFunctions() {
throw new Error("Not implemented");
}
public expandCollapseTriggers() {
throw new Error("Not implemented");
}
public expandTriggers() {
throw new Error("Not implemented");
}
public collapseTriggers() {
throw new Error("Not implemented");
}
public loadStoredProcedures(): Q.Promise<any> {
throw new Error("Not implemented");
}
public loadUserDefinedFunctions(): Q.Promise<any> {
throw new Error("Not implemented");
}
public loadTriggers(): Q.Promise<any> {
throw new Error("Not implemented");
}
public onDragOver(source: ViewModels.Collection, event: { originalEvent: DragEvent }) {
throw new Error("Not implemented");
}
public onDrop(source: ViewModels.Collection, event: { originalEvent: DragEvent }) {
throw new Error("Not implemented");
}
public isCollectionNodeSelected(): boolean {
throw new Error("Not implemented");
}
public isSubNodeSelected(nodeKind: ViewModels.CollectionTabKind): boolean {
throw new Error("Not implemented");
}
public onDeleteCollectionContextMenuClick(source: ViewModels.Collection, event: MouseEvent | KeyboardEvent) {
throw new Error("Not implemented");
}
public findStoredProcedureWithId(sprocId: string): ViewModels.StoredProcedure {
throw new Error("Not implemented");
}
public findTriggerWithId(triggerId: string): ViewModels.Trigger {
throw new Error("Not implemented");
}
public findUserDefinedFunctionWithId(userDefinedFunctionId: string): ViewModels.UserDefinedFunction {
throw new Error("Not implemented");
}
public uploadFiles = (fileList: FileList): Q.Promise<UploadDetails> => {
throw new Error("Not implemented");
};
public getLabel(): string {
throw new Error("Not implemented");
}
public getDatabase(): ViewModels.Database {
throw new Error("Not implemented");
}
}

View File

@ -9,7 +9,6 @@ import DeleteFeedback from "../../Common/DeleteFeedback";
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase"; import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
import Explorer from "../Explorer"; import Explorer from "../Explorer";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import { DatabaseStub } from "../OpenActionsStubs";
import { TreeNode } from "../../Contracts/ViewModels"; import { TreeNode } from "../../Contracts/ViewModels";
describe("Delete Collection Confirmation Pane", () => { describe("Delete Collection Confirmation Pane", () => {
@ -21,14 +20,14 @@ describe("Delete Collection Confirmation Pane", () => {
}); });
it("should be true if 1 database and 1 collection", () => { it("should be true if 1 database and 1 collection", () => {
let database: ViewModels.Database = new DatabaseStub({}); let database = {} as ViewModels.Database;
database.collections = ko.observableArray<ViewModels.Collection>([{} as ViewModels.Collection]); database.collections = ko.observableArray<ViewModels.Collection>([{} as ViewModels.Collection]);
explorer.databases = ko.observableArray<ViewModels.Database>([database]); explorer.databases = ko.observableArray<ViewModels.Database>([database]);
expect(explorer.isLastCollection()).toBe(true); expect(explorer.isLastCollection()).toBe(true);
}); });
it("should be false if if 1 database and 2 collection", () => { it("should be false if if 1 database and 2 collection", () => {
let database: ViewModels.Database = new DatabaseStub({}); let database = {} as ViewModels.Database;
database.collections = ko.observableArray<ViewModels.Collection>([ database.collections = ko.observableArray<ViewModels.Collection>([
{} as ViewModels.Collection, {} as ViewModels.Collection,
{} as ViewModels.Collection {} as ViewModels.Collection
@ -38,16 +37,16 @@ describe("Delete Collection Confirmation Pane", () => {
}); });
it("should be false if 2 database and 1 collection each", () => { it("should be false if 2 database and 1 collection each", () => {
let database: ViewModels.Database = new DatabaseStub({}); let database = {} as ViewModels.Database;
database.collections = ko.observableArray<ViewModels.Collection>([{} as ViewModels.Collection]); database.collections = ko.observableArray<ViewModels.Collection>([{} as ViewModels.Collection]);
let database2: ViewModels.Database = new DatabaseStub({}); let database2 = {} as ViewModels.Database;
database2.collections = ko.observableArray<ViewModels.Collection>([{} as ViewModels.Collection]); database2.collections = ko.observableArray<ViewModels.Collection>([{} as ViewModels.Collection]);
explorer.databases = ko.observableArray<ViewModels.Database>([database, database2]); explorer.databases = ko.observableArray<ViewModels.Database>([database, database2]);
expect(explorer.isLastCollection()).toBe(false); expect(explorer.isLastCollection()).toBe(false);
}); });
it("should be false if 0 databases", () => { it("should be false if 0 databases", () => {
let database: ViewModels.Database = new DatabaseStub({}); let database = {} as ViewModels.Database;
explorer.databases = ko.observableArray<ViewModels.Database>(); explorer.databases = ko.observableArray<ViewModels.Database>();
database.collections = ko.observableArray<ViewModels.Collection>(); database.collections = ko.observableArray<ViewModels.Collection>();
expect(explorer.isLastCollection()).toBe(false); expect(explorer.isLastCollection()).toBe(false);

View File

@ -8,7 +8,6 @@ import DeleteDatabaseConfirmationPane from "./DeleteDatabaseConfirmationPane";
import DeleteFeedback from "../../Common/DeleteFeedback"; import DeleteFeedback from "../../Common/DeleteFeedback";
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase"; import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
import Explorer from "../Explorer"; import Explorer from "../Explorer";
import { CollectionStub, DatabaseStub } from "../OpenActionsStubs";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import { TreeNode } from "../../Contracts/ViewModels"; import { TreeNode } from "../../Contracts/ViewModels";
import { TabsManager } from "../Tabs/TabsManager"; import { TabsManager } from "../Tabs/TabsManager";
@ -22,27 +21,27 @@ describe("Delete Database Confirmation Pane", () => {
}); });
it("should be true if only 1 database", () => { it("should be true if only 1 database", () => {
let database: ViewModels.Database = new DatabaseStub({}); let database = {} as ViewModels.Database;
explorer.databases = ko.observableArray<ViewModels.Database>([database]); explorer.databases = ko.observableArray<ViewModels.Database>([database]);
expect(explorer.isLastDatabase()).toBe(true); expect(explorer.isLastDatabase()).toBe(true);
}); });
it("should be false if only 2 databases", () => { it("should be false if only 2 databases", () => {
let database: ViewModels.Database = new DatabaseStub({}); let database = {} as ViewModels.Database;
let database2: ViewModels.Database = new DatabaseStub({}); let database2 = {} as ViewModels.Database;
explorer.databases = ko.observableArray<ViewModels.Database>([database, database2]); explorer.databases = ko.observableArray<ViewModels.Database>([database, database2]);
expect(explorer.isLastDatabase()).toBe(false); expect(explorer.isLastDatabase()).toBe(false);
}); });
it("should be false if not last empty database", () => { it("should be false if not last empty database", () => {
let database: ViewModels.Database = new DatabaseStub({}); let database = {} as ViewModels.Database;
explorer.databases = ko.observableArray<ViewModels.Database>([database]); explorer.databases = ko.observableArray<ViewModels.Database>([database]);
expect(explorer.isLastNonEmptyDatabase()).toBe(false); expect(explorer.isLastNonEmptyDatabase()).toBe(false);
}); });
it("should be true if last non empty database", () => { it("should be true if last non empty database", () => {
let database: ViewModels.Database = new DatabaseStub({}); let database = {} as ViewModels.Database;
database.collections = ko.observableArray<ViewModels.Collection>([new CollectionStub({})]); database.collections = ko.observableArray<ViewModels.Collection>([{} as ViewModels.Collection]);
explorer.databases = ko.observableArray<ViewModels.Database>([database]); explorer.databases = ko.observableArray<ViewModels.Database>([database]);
expect(explorer.isLastNonEmptyDatabase()).toBe(true); expect(explorer.isLastNonEmptyDatabase()).toBe(true);
}); });
@ -94,12 +93,13 @@ describe("Delete Database Confirmation Pane", () => {
let fakeDocumentClientUtility = {} as DocumentClientUtilityBase; let fakeDocumentClientUtility = {} as DocumentClientUtilityBase;
fakeDocumentClientUtility.deleteDatabase = () => Q.resolve(null); fakeDocumentClientUtility.deleteDatabase = () => Q.resolve(null);
let fakeExplorer = {} as Explorer; let fakeExplorer = {} as Explorer;
fakeExplorer.findSelectedDatabase = () => fakeExplorer.findSelectedDatabase = () => {
new DatabaseStub({ return {
id: ko.observable<string>(selectedDatabaseId), id: ko.observable<string>(selectedDatabaseId),
rid: "test", rid: "test",
collections: ko.observableArray<ViewModels.Collection>() collections: ko.observableArray<ViewModels.Collection>()
}); } as ViewModels.Database;
};
fakeExplorer.refreshAllDatabases = () => Q.resolve(); fakeExplorer.refreshAllDatabases = () => Q.resolve();
fakeExplorer.isNotificationConsoleExpanded = ko.observable<boolean>(false); fakeExplorer.isNotificationConsoleExpanded = ko.observable<boolean>(false);
fakeExplorer.selectedDatabaseId = ko.computed<string>(() => selectedDatabaseId); fakeExplorer.selectedDatabaseId = ko.computed<string>(() => selectedDatabaseId);

View File

@ -3,6 +3,7 @@ import * as _ from "underscore";
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 { ContextualPaneBase } from "./ContextualPaneBase"; import { ContextualPaneBase } from "./ContextualPaneBase";
import StoredProcedure from "../Tree/StoredProcedure";
export interface ExecuteSprocParam { export interface ExecuteSprocParam {
type: ko.Observable<string>; type: ko.Observable<string>;
@ -22,7 +23,7 @@ export class ExecuteSprocParamsPane extends ContextualPaneBase {
public addNewParamLabel: string = "Add New Param"; public addNewParamLabel: string = "Add New Param";
public executeButtonEnabled: ko.Computed<boolean>; public executeButtonEnabled: ko.Computed<boolean>;
private _selectedSproc: ViewModels.StoredProcedure; private _selectedSproc: StoredProcedure;
constructor(options: ViewModels.PaneOptions) { constructor(options: ViewModels.PaneOptions) {
super(options); super(options);
@ -39,8 +40,7 @@ export class ExecuteSprocParamsPane extends ContextualPaneBase {
public open() { public open() {
super.open(); super.open();
const currentSelectedSproc: ViewModels.StoredProcedure = const currentSelectedSproc = this.container && this.container.findSelectedStoredProcedure();
this.container && this.container.findSelectedStoredProcedure();
if (!!currentSelectedSproc && !!this._selectedSproc && this._selectedSproc.rid !== currentSelectedSproc.rid) { if (!!currentSelectedSproc && !!this._selectedSproc && this._selectedSproc.rid !== currentSelectedSproc.rid) {
this.params([]); this.params([]);
this.partitionKeyValue(""); this.partitionKeyValue("");

View File

@ -22,7 +22,7 @@ import { QueryIterator, ItemDefinition, Resource, ConflictDefinition } from "@az
import { MinimalQueryIterator } from "../../Common/IteratorUtilities"; import { MinimalQueryIterator } from "../../Common/IteratorUtilities";
import Explorer from "../Explorer"; import Explorer from "../Explorer";
export default class ConflictsTab extends TabsBase implements ViewModels.ConflictsTab { export default class ConflictsTab extends TabsBase {
public selectedConflictId: ko.Observable<ViewModels.ConflictId>; public selectedConflictId: ko.Observable<ViewModels.ConflictId>;
public selectedConflictContent: ViewModels.Editable<string>; public selectedConflictContent: ViewModels.Editable<string>;
public selectedConflictCurrent: ViewModels.Editable<string>; public selectedConflictCurrent: ViewModels.Editable<string>;

View File

@ -48,8 +48,7 @@ const throughputApplyLongDelayMessage = (isAutoscale: boolean, throughput: numbe
This operation will take 1-3 business days to complete. View the latest status in Notifications.<br /> This operation will take 1-3 business days to complete. View the latest status in Notifications.<br />
Database: ${databaseName}, ${currentThroughput(isAutoscale, throughput)}`; Database: ${databaseName}, ${currentThroughput(isAutoscale, throughput)}`;
export default class DatabaseSettingsTab extends TabsBase export default class DatabaseSettingsTab extends TabsBase implements ViewModels.WaitsForTemplate {
implements ViewModels.DatabaseSettingsTab, ViewModels.WaitsForTemplate {
// editables // editables
public isAutoPilotSelected: ViewModels.Editable<boolean>; public isAutoPilotSelected: ViewModels.Editable<boolean>;
public throughput: ViewModels.Editable<number>; public throughput: ViewModels.Editable<number>;

View File

@ -2,21 +2,22 @@ import * as ko from "knockout";
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 Explorer from "../Explorer"; import Explorer from "../Explorer";
import { CollectionStub, DatabaseStub } from "../../Explorer/OpenActionsStubs";
import QueryTab from "./QueryTab"; import QueryTab from "./QueryTab";
import { View } from "@nteract/data-explorer/lib/utilities/types";
import { PartitionKey } from "../../Contracts/DataModels";
describe("Query Tab", () => { describe("Query Tab", () => {
function getNewQueryTabForContainer(container: Explorer): ViewModels.QueryTab { function getNewQueryTabForContainer(container: Explorer): ViewModels.QueryTab {
const database: ViewModels.Database = new DatabaseStub({ const database = {
container: container, container: container,
id: ko.observable<string>("test"), id: ko.observable<string>("test"),
isDatabaseShared: () => false isDatabaseShared: () => false
}); } as ViewModels.Database;
const collection: ViewModels.Collection = new CollectionStub({ const collection = {
container: container, container: container,
databaseId: "test", databaseId: "test",
id: ko.observable<string>("test") id: ko.observable<string>("test")
}); } as ViewModels.Collection;
return new QueryTab({ return new QueryTab({
tabKind: ViewModels.CollectionTabKind.Query, tabKind: ViewModels.CollectionTabKind.Query,
@ -33,19 +34,12 @@ describe("Query Tab", () => {
} }
describe("shouldSetSystemPartitionKeyContainerPartitionKeyValueUndefined", () => { describe("shouldSetSystemPartitionKeyContainerPartitionKeyValueUndefined", () => {
const collection: ViewModels.Collection = new CollectionStub({ const collection = {
id: "withoutsystempk", id: ko.observable<string>("withoutsystempk"),
partitionKey: { partitionKey: {
systemKey: true systemKey: true
} }
}); } as ViewModels.Collection;
const collectionSystemPK: ViewModels.Collection = new CollectionStub({
id: "withsystempk",
partitionKey: {
systemKey: true
}
});
it("no container with system pk, should not set partition key option", () => { it("no container with system pk, should not set partition key option", () => {
const iteratorOptions = QueryTab.getIteratorOptions(collection); const iteratorOptions = QueryTab.getIteratorOptions(collection);

View File

@ -125,7 +125,7 @@ enum ChangeFeedPolicyToggledState {
On = "On" On = "On"
} }
export default class SettingsTab extends TabsBase implements ViewModels.SettingsTab, ViewModels.WaitsForTemplate { export default class SettingsTab extends TabsBase implements ViewModels.WaitsForTemplate {
public GEOGRAPHY: string = "Geography"; public GEOGRAPHY: string = "Geography";
public GEOMETRY: string = "Geometry"; public GEOMETRY: string = "Geometry";

View File

@ -9,6 +9,7 @@ import editable from "../../Common/EditableUtility";
import ScriptTabBase from "./ScriptTabBase"; import ScriptTabBase from "./ScriptTabBase";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import ExecuteQueryIcon from "../../../images/ExecuteQuery.svg"; import ExecuteQueryIcon from "../../../images/ExecuteQuery.svg";
import StoredProcedure from "../Tree/StoredProcedure";
enum ToggleState { enum ToggleState {
Result = "result", Result = "result",
@ -17,7 +18,7 @@ enum ToggleState {
export default class StoredProcedureTab extends ScriptTabBase implements ViewModels.StoredProcedureTab { export default class StoredProcedureTab extends ScriptTabBase implements ViewModels.StoredProcedureTab {
public collection: ViewModels.Collection; public collection: ViewModels.Collection;
public node: ViewModels.StoredProcedure; public node: StoredProcedure;
public executeResultsEditorId: string; public executeResultsEditorId: string;
public executeLogsEditorId: string; public executeLogsEditorId: string;
public toggleState: ko.Observable<ToggleState>; public toggleState: ko.Observable<ToggleState>;

View File

@ -1,6 +1,5 @@
import * as ko from "knockout"; import * as ko from "knockout";
import * as ViewModels from "../../Contracts/ViewModels"; import * as ViewModels from "../../Contracts/ViewModels";
import { CollectionStub, DatabaseStub } from "../../Explorer/OpenActionsStubs";
import { DataAccessUtility } from "../../Platform/Portal/DataAccessUtility"; import { DataAccessUtility } from "../../Platform/Portal/DataAccessUtility";
import { TabsManager } from "./TabsManager"; import { TabsManager } from "./TabsManager";
import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase"; import DocumentClientUtilityBase from "../../Common/DocumentClientUtilityBase";
@ -28,19 +27,19 @@ describe("Tabs manager tests", () => {
properties: undefined properties: undefined
}); });
database = new DatabaseStub({ database = {
container: explorer, container: explorer,
id: ko.observable<string>("test"), id: ko.observable<string>("test"),
isDatabaseShared: () => false isDatabaseShared: () => false
}); } as ViewModels.Database;
database.isDatabaseExpanded = ko.observable<boolean>(true); database.isDatabaseExpanded = ko.observable<boolean>(true);
database.selectedSubnodeKind = ko.observable<ViewModels.CollectionTabKind>(); database.selectedSubnodeKind = ko.observable<ViewModels.CollectionTabKind>();
collection = new CollectionStub({ collection = {
container: explorer, container: explorer,
databaseId: "test", databaseId: "test",
id: ko.observable<string>("test") id: ko.observable<string>("test")
}); } as ViewModels.Collection;
collection.getDatabase = (): ViewModels.Database => database; collection.getDatabase = (): ViewModels.Database => database;
collection.isCollectionExpanded = ko.observable<boolean>(true); collection.isCollectionExpanded = ko.observable<boolean>(true);
collection.selectedSubnodeKind = ko.observable<ViewModels.CollectionTabKind>(); collection.selectedSubnodeKind = ko.observable<ViewModels.CollectionTabKind>();

View File

@ -6,10 +6,11 @@ import { Action } from "../../Shared/Telemetry/TelemetryConstants";
import ScriptTabBase from "./ScriptTabBase"; import ScriptTabBase from "./ScriptTabBase";
import editable from "../../Common/EditableUtility"; import editable from "../../Common/EditableUtility";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import Trigger from "../Tree/Trigger";
export default class TriggerTab extends ScriptTabBase implements ViewModels.TriggerTab { export default class TriggerTab extends ScriptTabBase implements ViewModels.TriggerTab {
public collection: ViewModels.Collection; public collection: ViewModels.Collection;
public node: ViewModels.Trigger; public node: Trigger;
public triggerType: ViewModels.Editable<string>; public triggerType: ViewModels.Editable<string>;
public triggerOperation: ViewModels.Editable<string>; public triggerOperation: ViewModels.Editable<string>;

View File

@ -5,10 +5,11 @@ import * as ViewModels from "../../Contracts/ViewModels";
import { Action } from "../../Shared/Telemetry/TelemetryConstants"; import { Action } from "../../Shared/Telemetry/TelemetryConstants";
import ScriptTabBase from "./ScriptTabBase"; import ScriptTabBase from "./ScriptTabBase";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import UserDefinedFunction from "../Tree/UserDefinedFunction";
export default class UserDefinedFunctionTab extends ScriptTabBase implements ViewModels.UserDefinedFunctionTab { export default class UserDefinedFunctionTab extends ScriptTabBase implements ViewModels.UserDefinedFunctionTab {
public collection: ViewModels.Collection; public collection: ViewModels.Collection;
public node: ViewModels.UserDefinedFunction; public node: UserDefinedFunction;
constructor(options: ViewModels.ScriptTabOption) { constructor(options: ViewModels.ScriptTabOption) {
super(options); super(options);
this.ariaLabel("User Defined Function Body"); this.ariaLabel("User Defined Function Body");

View File

@ -63,9 +63,9 @@ export default class Collection implements ViewModels.Collection {
public documentIds: ko.ObservableArray<DocumentId>; public documentIds: ko.ObservableArray<DocumentId>;
public children: ko.ObservableArray<ViewModels.TreeNode>; public children: ko.ObservableArray<ViewModels.TreeNode>;
public storedProcedures: ko.Computed<ViewModels.StoredProcedure[]>; public storedProcedures: ko.Computed<StoredProcedure[]>;
public userDefinedFunctions: ko.Computed<ViewModels.UserDefinedFunction[]>; public userDefinedFunctions: ko.Computed<UserDefinedFunction[]>;
public triggers: ko.Computed<ViewModels.Trigger[]>; public triggers: ko.Computed<Trigger[]>;
public showStoredProcedures: ko.Observable<boolean>; public showStoredProcedures: ko.Observable<boolean>;
public showTriggers: ko.Observable<boolean>; public showTriggers: ko.Observable<boolean>;
@ -180,19 +180,19 @@ export default class Collection implements ViewModels.Collection {
this.storedProcedures = ko.computed(() => { this.storedProcedures = ko.computed(() => {
return this.children() return this.children()
.filter(node => node.nodeKind === "StoredProcedure") .filter(node => node.nodeKind === "StoredProcedure")
.map(node => <ViewModels.StoredProcedure>node); .map(node => <StoredProcedure>node);
}); });
this.userDefinedFunctions = ko.computed(() => { this.userDefinedFunctions = ko.computed(() => {
return this.children() return this.children()
.filter(node => node.nodeKind === "UserDefinedFunction") .filter(node => node.nodeKind === "UserDefinedFunction")
.map(node => <ViewModels.UserDefinedFunction>node); .map(node => <UserDefinedFunction>node);
}); });
this.triggers = ko.computed(() => { this.triggers = ko.computed(() => {
return this.children() return this.children()
.filter(node => node.nodeKind === "Trigger") .filter(node => node.nodeKind === "Trigger")
.map(node => <ViewModels.Trigger>node); .map(node => <Trigger>node);
}); });
const showScriptsMenus: boolean = container.isPreferredApiDocumentDB() || container.isPreferredApiGraph(); const showScriptsMenus: boolean = container.isPreferredApiDocumentDB() || container.isPreferredApiGraph();
@ -880,21 +880,18 @@ export default class Collection implements ViewModels.Collection {
return node; return node;
} }
public findStoredProcedureWithId(sprocId: string): ViewModels.StoredProcedure { public findStoredProcedureWithId(sprocId: string): StoredProcedure {
return _.find( return _.find(this.storedProcedures(), (storedProcedure: StoredProcedure) => storedProcedure.id() === sprocId);
this.storedProcedures(),
(storedProcedure: ViewModels.StoredProcedure) => storedProcedure.id() === sprocId
);
} }
public findTriggerWithId(triggerId: string): ViewModels.Trigger { public findTriggerWithId(triggerId: string): Trigger {
return _.find(this.triggers(), (trigger: ViewModels.Trigger) => trigger.id() === triggerId); return _.find(this.triggers(), (trigger: Trigger) => trigger.id() === triggerId);
} }
public findUserDefinedFunctionWithId(userDefinedFunctionId: string): ViewModels.UserDefinedFunction { public findUserDefinedFunctionWithId(userDefinedFunctionId: string): UserDefinedFunction {
return _.find( return _.find(
this.userDefinedFunctions(), this.userDefinedFunctions(),
(userDefinedFunction: ViewModels.Trigger) => userDefinedFunction.id() === userDefinedFunctionId (userDefinedFunction: Trigger) => userDefinedFunction.id() === userDefinedFunctionId
); );
} }

View File

@ -5,9 +5,10 @@ import DocumentId from "./DocumentId";
import * as DataModels from "../../Contracts/DataModels"; import * as DataModels from "../../Contracts/DataModels";
import * as ViewModels from "../../Contracts/ViewModels"; import * as ViewModels from "../../Contracts/ViewModels";
import { extractPartitionKey } from "@azure/cosmos"; import { extractPartitionKey } from "@azure/cosmos";
import ConflictsTab from "../Tabs/ConflictsTab";
export default class ConflictId implements ViewModels.ConflictId { export default class ConflictId implements ViewModels.ConflictId {
public container: ViewModels.ConflictsTab; public container: ConflictsTab;
public rid: string; public rid: string;
public self: string; public self: string;
public ts: string; public ts: string;
@ -23,7 +24,7 @@ export default class ConflictId implements ViewModels.ConflictId {
public parsedContent: any; public parsedContent: any;
public isDirty: ko.Observable<boolean>; public isDirty: ko.Observable<boolean>;
constructor(container: ViewModels.ConflictsTab, data: any) { constructor(container: ConflictsTab, data: any) {
this.container = container; this.container = container;
this.self = data._self; this.self = data._self;
this.rid = data._rid; this.rid = data._rid;

View File

@ -27,6 +27,9 @@ import GalleryIcon from "../../../images/GalleryIcon.svg";
import { Callout, Text, Link, DirectionalHint, Stack, ICalloutProps, ILinkProps } from "office-ui-fabric-react"; import { Callout, Text, Link, DirectionalHint, Stack, ICalloutProps, ILinkProps } from "office-ui-fabric-react";
import { LocalStorageUtility, StorageKey } from "../../Shared/StorageUtility"; import { LocalStorageUtility, StorageKey } from "../../Shared/StorageUtility";
import Explorer from "../Explorer"; import Explorer from "../Explorer";
import UserDefinedFunction from "./UserDefinedFunction";
import StoredProcedure from "./StoredProcedure";
import Trigger from "./Trigger";
export class ResourceTreeAdapter implements ReactAdapter { export class ResourceTreeAdapter implements ReactAdapter {
private static readonly DataTitle = "DATA"; private static readonly DataTitle = "DATA";
@ -290,7 +293,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
private buildStoredProcedureNode(collection: ViewModels.Collection): TreeNode { private buildStoredProcedureNode(collection: ViewModels.Collection): TreeNode {
return { return {
label: "Stored Procedures", label: "Stored Procedures",
children: collection.storedProcedures().map((sp: ViewModels.StoredProcedure) => ({ children: collection.storedProcedures().map((sp: StoredProcedure) => ({
label: sp.id(), label: sp.id(),
onClick: sp.open.bind(sp), onClick: sp.open.bind(sp),
isSelected: () => isSelected: () =>
@ -309,7 +312,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
private buildUserDefinedFunctionsNode(collection: ViewModels.Collection): TreeNode { private buildUserDefinedFunctionsNode(collection: ViewModels.Collection): TreeNode {
return { return {
label: "User Defined Functions", label: "User Defined Functions",
children: collection.userDefinedFunctions().map((udf: ViewModels.UserDefinedFunction) => ({ children: collection.userDefinedFunctions().map((udf: UserDefinedFunction) => ({
label: udf.id(), label: udf.id(),
onClick: udf.open.bind(udf), onClick: udf.open.bind(udf),
isSelected: () => isSelected: () =>
@ -328,7 +331,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
private buildTriggerNode(collection: ViewModels.Collection): TreeNode { private buildTriggerNode(collection: ViewModels.Collection): TreeNode {
return { return {
label: "Triggers", label: "Triggers",
children: collection.triggers().map((trigger: ViewModels.Trigger) => ({ children: collection.triggers().map((trigger: Trigger) => ({
label: trigger.id(), label: trigger.id(),
onClick: trigger.open.bind(trigger), onClick: trigger.open.bind(trigger),
isSelected: () => this.isDataNodeSelected(collection.rid, "Collection", ViewModels.CollectionTabKind.Triggers), isSelected: () => this.isDataNodeSelected(collection.rid, "Collection", ViewModels.CollectionTabKind.Triggers),

View File

@ -35,7 +35,7 @@ function sample(prefix) {
if (!isAccepted) throw new Error('The query was not accepted by the server.'); if (!isAccepted) throw new Error('The query was not accepted by the server.');
}`; }`;
export default class StoredProcedure implements ViewModels.StoredProcedure { export default class StoredProcedure {
public nodeKind: string; public nodeKind: string;
public container: Explorer; public container: Explorer;
public collection: ViewModels.Collection; public collection: ViewModels.Collection;

View File

@ -7,7 +7,7 @@ import TriggerTab from "../Tabs/TriggerTab";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import Explorer from "../Explorer"; import Explorer from "../Explorer";
export default class Trigger implements ViewModels.Trigger { export default class Trigger {
public nodeKind: string; public nodeKind: string;
public container: Explorer; public container: Explorer;
public collection: ViewModels.Collection; public collection: ViewModels.Collection;

View File

@ -7,7 +7,7 @@ import UserDefinedFunctionTab from "../Tabs/UserDefinedFunctionTab";
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor"; import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import Explorer from "../Explorer"; import Explorer from "../Explorer";
export default class UserDefinedFunction implements ViewModels.UserDefinedFunction { export default class UserDefinedFunction {
public nodeKind: string; public nodeKind: string;
public container: Explorer; public container: Explorer;
public collection: ViewModels.Collection; public collection: ViewModels.Collection;

View File

@ -1,4 +1,3 @@
import * as ViewModels from "../Contracts/ViewModels";
import { ArmApiVersions } from "../Common/Constants"; import { ArmApiVersions } from "../Common/Constants";
import { IResourceProviderClient, IResourceProviderClientFactory } from "../ResourceProvider/IResourceProviderClient"; import { IResourceProviderClient, IResourceProviderClientFactory } from "../ResourceProvider/IResourceProviderClient";
import * as Logger from "../Common/Logger"; import * as Logger from "../Common/Logger";
@ -9,7 +8,7 @@ import {
} from "../Contracts/DataModels"; } from "../Contracts/DataModels";
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory"; import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
export class NotebookWorkspaceManager implements ViewModels.NotebookWorkspaceManager { export class NotebookWorkspaceManager {
private resourceProviderClientFactory: IResourceProviderClientFactory<any>; private resourceProviderClientFactory: IResourceProviderClientFactory<any>;
constructor(private _armEndpoint: string) { constructor(private _armEndpoint: string) {

View File

@ -290,8 +290,7 @@ export class TabRouteHandler {
const collection: ViewModels.Collection = this._findMatchingCollectionForResource(databaseId, collectionId); const collection: ViewModels.Collection = this._findMatchingCollectionForResource(databaseId, collectionId);
collection && collection &&
collection.expandCollection().then(() => { collection.expandCollection().then(() => {
const storedProcedure: ViewModels.StoredProcedure = const storedProcedure = collection && collection.findStoredProcedureWithId(sprocId);
collection && collection.findStoredProcedureWithId(sprocId);
storedProcedure && storedProcedure.open(); storedProcedure && storedProcedure.open();
}); });
}); });
@ -322,7 +321,7 @@ export class TabRouteHandler {
const collection: ViewModels.Collection = this._findMatchingCollectionForResource(databaseId, collectionId); const collection: ViewModels.Collection = this._findMatchingCollectionForResource(databaseId, collectionId);
collection && collection &&
collection.expandCollection().then(() => { collection.expandCollection().then(() => {
const trigger: ViewModels.Trigger = collection && collection.findTriggerWithId(triggerId); const trigger = collection && collection.findTriggerWithId(triggerId);
trigger && trigger.open(); trigger && trigger.open();
}); });
}); });
@ -353,8 +352,7 @@ export class TabRouteHandler {
const collection: ViewModels.Collection = this._findMatchingCollectionForResource(databaseId, collectionId); const collection: ViewModels.Collection = this._findMatchingCollectionForResource(databaseId, collectionId);
collection && collection &&
collection.expandCollection().then(() => { collection.expandCollection().then(() => {
const userDefinedFunction: ViewModels.UserDefinedFunction = const userDefinedFunction = collection && collection.findUserDefinedFunctionWithId(udfId);
collection && collection.findUserDefinedFunctionWithId(udfId);
userDefinedFunction && userDefinedFunction.open(); userDefinedFunction && userDefinedFunction.open();
}); });
}); });

View File

@ -11,7 +11,7 @@ import * as Logger from "../Common/Logger";
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory"; import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
import { config } from "../Config"; import { config } from "../Config";
export class ArcadiaResourceManager implements ViewModels.ArcadiaResourceManager { export class ArcadiaResourceManager {
private resourceProviderClientFactory: IResourceProviderClientFactory<any>; private resourceProviderClientFactory: IResourceProviderClientFactory<any>;
constructor(private armEndpoint = config.ARM_ENDPOINT) { constructor(private armEndpoint = config.ARM_ENDPOINT) {