mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-22 02:11:29 +00:00
More ViewModel cleanup (#116)
This commit is contained in:
@@ -1,39 +1,16 @@
|
||||
import * as DataModels from "./DataModels";
|
||||
import * as monaco from "monaco-editor";
|
||||
import Q from "q";
|
||||
import { AccessibleVerticalList } from "../Explorer/Tree/AccessibleVerticalList";
|
||||
import { CassandraTableKey, CassandraTableKeys } from "../Explorer/Tables/TableDataClient";
|
||||
import { CommandButtonComponentProps } from "../Explorer/Controls/CommandButton/CommandButtonComponent";
|
||||
import { ConsoleData } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { GitHubClient } from "../GitHub/GitHubClient";
|
||||
import { JunoClient, IGalleryItem } from "../Juno/JunoClient";
|
||||
import { NotebookContentItem } from "../Explorer/Notebook/NotebookContentItem";
|
||||
import { QueryMetrics } from "@azure/cosmos";
|
||||
import { UploadDetails } from "../workers/upload/definitions";
|
||||
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 {
|
||||
notificationsClient: NotificationsClient;
|
||||
isEmulator: boolean;
|
||||
}
|
||||
|
||||
export interface Capability extends DataModels.Capability {}
|
||||
|
||||
export interface ConfigurationOverrides extends DataModels.ConfigurationOverrides {}
|
||||
|
||||
export interface NavbarButtonConfig extends CommandButtonComponentProps {}
|
||||
|
||||
export interface DatabaseAccount extends DataModels.DatabaseAccount {}
|
||||
|
||||
export interface KernelConnectionMetadata {
|
||||
name: string;
|
||||
configurationEndpoints: DataModels.NotebookConfigurationEndpoints;
|
||||
notebookConnectionInfo: DataModels.NotebookWorkspaceConnectionInfo;
|
||||
}
|
||||
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||
import ConflictId from "../Explorer/Tree/ConflictId";
|
||||
|
||||
export interface TokenProvider {
|
||||
getAuthHeader(): Promise<Headers>;
|
||||
@@ -73,11 +50,6 @@ export interface WaitsForTemplate {
|
||||
isTemplateReady: ko.Observable<boolean>;
|
||||
}
|
||||
|
||||
export interface AdHocAccessData {
|
||||
readWriteUrl: string;
|
||||
readUrl: string;
|
||||
}
|
||||
|
||||
export interface TreeNode {
|
||||
nodeKind: string;
|
||||
rid: string;
|
||||
@@ -199,45 +171,6 @@ export interface Collection extends CollectionBase {
|
||||
getLabel(): string;
|
||||
}
|
||||
|
||||
export interface DocumentId {
|
||||
container: DocumentsTab;
|
||||
rid: string;
|
||||
self: string;
|
||||
ts: string;
|
||||
partitionKeyValue: any;
|
||||
partitionKeyProperty: string;
|
||||
partitionKey: DataModels.PartitionKey;
|
||||
stringPartitionKeyValue: string;
|
||||
id: ko.Observable<string>;
|
||||
|
||||
isDirty: ko.Observable<boolean>;
|
||||
click(): void;
|
||||
getPartitionKeyValueAsString(): string;
|
||||
loadDocument(): Q.Promise<any>;
|
||||
partitionKeyHeader(): Object;
|
||||
}
|
||||
|
||||
export interface ConflictId {
|
||||
container: ConflictsTab;
|
||||
rid: string;
|
||||
self: string;
|
||||
ts: string;
|
||||
partitionKeyValue: any;
|
||||
partitionKeyProperty: string;
|
||||
partitionKey: DataModels.PartitionKey;
|
||||
stringPartitionKeyValue: string;
|
||||
id: ko.Observable<string>;
|
||||
operationType: string;
|
||||
resourceId: string;
|
||||
resourceType: string;
|
||||
|
||||
isDirty: ko.Observable<boolean>;
|
||||
click(): void;
|
||||
buildDocumentIdFromConflict(partitionKeyValue: any): DocumentId;
|
||||
getPartitionKeyValueAsString(): string;
|
||||
loadConflict(): Q.Promise<any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options used to initialize pane
|
||||
*/
|
||||
@@ -247,68 +180,6 @@ export interface PaneOptions {
|
||||
container?: Explorer;
|
||||
}
|
||||
|
||||
export interface ContextualPane {
|
||||
formErrors: ko.Observable<string>;
|
||||
formErrorsDetails: ko.Observable<string>;
|
||||
id: string;
|
||||
title: ko.Observable<string>;
|
||||
visible: ko.Observable<boolean>;
|
||||
firstFieldHasFocus: ko.Observable<boolean>;
|
||||
isExecuting: ko.Observable<boolean>;
|
||||
|
||||
submit: () => void;
|
||||
cancel: () => void;
|
||||
open: () => void;
|
||||
close: () => void;
|
||||
resetData: () => void;
|
||||
showErrorDetails: () => void;
|
||||
onCloseKeyPress(source: any, event: KeyboardEvent): void;
|
||||
onPaneKeyDown(source: any, event: KeyboardEvent): boolean;
|
||||
}
|
||||
|
||||
export interface GitHubReposPaneOptions extends PaneOptions {
|
||||
gitHubClient: GitHubClient;
|
||||
junoClient: JunoClient;
|
||||
}
|
||||
|
||||
export interface PublishNotebookPaneOptions extends PaneOptions {
|
||||
junoClient: JunoClient;
|
||||
}
|
||||
|
||||
export interface PublishNotebookPaneOpenOptions {
|
||||
name: string;
|
||||
author: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface AddCollectionPaneOptions extends PaneOptions {
|
||||
isPreferredApiTable: ko.Computed<boolean>;
|
||||
databaseId?: string;
|
||||
databaseSelfLink?: string;
|
||||
}
|
||||
|
||||
export interface UploadFilePaneOpenOptions {
|
||||
paneTitle: string;
|
||||
selectFileInputLabel: string;
|
||||
errorMessage: string; // Could not upload notebook
|
||||
inProgressMessage: string; // Uploading notebook
|
||||
successMessage: string; // Successfully uploaded notebook
|
||||
onSubmit: (file: File) => Promise<any>;
|
||||
extensions?: string; // input accept field. E.g: .ipynb
|
||||
submitButtonLabel?: string;
|
||||
}
|
||||
|
||||
export interface StringInputPaneOpenOptions {
|
||||
paneTitle: string;
|
||||
inputLabel: string;
|
||||
errorMessage: string;
|
||||
inProgressMessage: string;
|
||||
successMessage: string;
|
||||
onSubmit: (input: string) => Promise<any>;
|
||||
submitButtonLabel: string;
|
||||
defaultInput?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Graph configuration
|
||||
*/
|
||||
@@ -378,19 +249,6 @@ export interface DocumentRequestContainer {
|
||||
resourceName?: string;
|
||||
}
|
||||
|
||||
export interface NotificationsClient {
|
||||
fetchNotifications(): Q.Promise<DataModels.Notification[]>;
|
||||
setExtensionEndpoint(extensionEndpoint: string): void;
|
||||
}
|
||||
|
||||
export interface QueriesClient {
|
||||
setupQueriesCollection(): Promise<DataModels.Collection>;
|
||||
saveQuery(query: DataModels.Query): Promise<void>;
|
||||
getQueries(): Promise<DataModels.Query[]>;
|
||||
deleteQuery(query: DataModels.Query): Promise<void>;
|
||||
getResourceId(): string;
|
||||
}
|
||||
|
||||
export interface DocumentClientOption {
|
||||
endpoint?: string;
|
||||
masterKey?: string;
|
||||
@@ -405,7 +263,7 @@ export interface TabOptions {
|
||||
selfLink: string;
|
||||
isActive: ko.Observable<boolean>;
|
||||
hashLocation: string;
|
||||
onUpdateTabsButtons: (buttons: NavbarButtonConfig[]) => void;
|
||||
onUpdateTabsButtons: (buttons: CommandButtonComponentProps[]) => void;
|
||||
isTabsContentExpanded?: ko.Observable<boolean>;
|
||||
onLoadStartKey?: number;
|
||||
|
||||
@@ -418,47 +276,6 @@ export interface TabOptions {
|
||||
theme?: string;
|
||||
}
|
||||
|
||||
export interface SparkMasterTabOptions extends TabOptions {
|
||||
clusterConnectionInfo: DataModels.SparkClusterConnectionInfo;
|
||||
container: Explorer;
|
||||
}
|
||||
|
||||
export interface GraphTabOptions extends TabOptions {
|
||||
account: DatabaseAccount;
|
||||
masterKey: string;
|
||||
collectionId: string;
|
||||
databaseId: string;
|
||||
collectionPartitionKeyProperty: string;
|
||||
}
|
||||
|
||||
export interface NotebookTabOptions extends TabOptions {
|
||||
account: DatabaseAccount;
|
||||
masterKey: string;
|
||||
container: Explorer;
|
||||
notebookContentItem: NotebookContentItem;
|
||||
}
|
||||
|
||||
export interface TerminalTabOptions extends TabOptions {
|
||||
account: DatabaseAccount;
|
||||
container: Explorer;
|
||||
kind: TerminalKind;
|
||||
}
|
||||
|
||||
export interface GalleryTabOptions extends TabOptions {
|
||||
account: DatabaseAccount;
|
||||
container: Explorer;
|
||||
junoClient: JunoClient;
|
||||
notebookUrl?: string;
|
||||
galleryItem?: IGalleryItem;
|
||||
isFavorite?: boolean;
|
||||
}
|
||||
|
||||
export interface NotebookViewerTabOptions extends TabOptions {
|
||||
account: DatabaseAccount;
|
||||
container: Explorer;
|
||||
notebookUrl: string;
|
||||
}
|
||||
|
||||
export interface DocumentsTabOptions extends TabOptions {
|
||||
partitionKey: DataModels.PartitionKey;
|
||||
documentIds: ko.ObservableArray<DocumentId>;
|
||||
@@ -486,155 +303,15 @@ export interface ScriptTabOption extends TabOptions {
|
||||
partitionKey?: DataModels.PartitionKey;
|
||||
}
|
||||
|
||||
// Tabs
|
||||
export interface Tab {
|
||||
node: TreeNode; // Can be null
|
||||
collection: CollectionBase;
|
||||
rid: string;
|
||||
tabKind: CollectionTabKind;
|
||||
tabId: string;
|
||||
isActive: ko.Observable<boolean>;
|
||||
isMouseOver: ko.Observable<boolean>;
|
||||
tabPath: ko.Observable<string>;
|
||||
tabTitle: ko.Observable<string>;
|
||||
hashLocation: ko.Observable<string>;
|
||||
closeTabButton: Button;
|
||||
onCloseTabButtonClick(): void;
|
||||
onTabClick(): Q.Promise<any>;
|
||||
onKeyPressActivate(source: any, event: KeyboardEvent): void;
|
||||
onKeyPressClose(source: any, event: KeyboardEvent): void;
|
||||
onActivate(): Q.Promise<any>;
|
||||
refresh(): void;
|
||||
closeButtonTabIndex: ko.Computed<number>;
|
||||
isExecutionError: ko.Observable<boolean>;
|
||||
isExecuting: ko.Observable<boolean>;
|
||||
}
|
||||
|
||||
export interface DocumentsTab extends Tab {
|
||||
/* Documents Grid */
|
||||
selectDocument(documentId: DocumentId): Q.Promise<any>;
|
||||
selectedDocumentId: ko.Observable<DocumentId>;
|
||||
selectedDocumentContent: Editable<any>;
|
||||
onDocumentIdClick(documentId: DocumentId): Q.Promise<any>;
|
||||
dataContentsGridScrollHeight: ko.Observable<string>;
|
||||
accessibleDocumentList: AccessibleVerticalList;
|
||||
documentContentsGridId: string;
|
||||
|
||||
partitionKey: DataModels.PartitionKey;
|
||||
idHeader: string;
|
||||
partitionKeyPropertyHeader: string;
|
||||
partitionKeyProperty: string;
|
||||
documentIds: ko.ObservableArray<DocumentId>;
|
||||
|
||||
/* Documents Filter */
|
||||
filterContent: ko.Observable<string>;
|
||||
appliedFilter: ko.Observable<string>;
|
||||
lastFilterContents: ko.ObservableArray<string>;
|
||||
isFilterExpanded: ko.Observable<boolean>;
|
||||
applyFilterButton: Button;
|
||||
onShowFilterClick(): Q.Promise<any>;
|
||||
onHideFilterClick(): Q.Promise<any>;
|
||||
onApplyFilterClick(): Q.Promise<any>;
|
||||
|
||||
/* Document Editor */
|
||||
isEditorDirty: ko.Computed<boolean>;
|
||||
editorState: ko.Observable<DocumentExplorerState>;
|
||||
onValidDocumentEdit(content: any): Q.Promise<any>;
|
||||
onInvalidDocumentEdit(content: any): Q.Promise<any>;
|
||||
|
||||
onNewDocumentClick(): Q.Promise<any>;
|
||||
onSaveNewDocumentClick(): Q.Promise<any>;
|
||||
onRevertNewDocumentClick(): Q.Promise<any>;
|
||||
onSaveExisitingDocumentClick(): Q.Promise<any>;
|
||||
onRevertExisitingDocumentClick(): Q.Promise<any>;
|
||||
onDeleteExisitingDocumentClick(): Q.Promise<any>;
|
||||
|
||||
/* Errors */
|
||||
displayedError: ko.Observable<string>;
|
||||
|
||||
initDocumentEditor(documentId: DocumentId, content: any): Q.Promise<any>;
|
||||
loadNextPage(): Q.Promise<any>;
|
||||
}
|
||||
|
||||
export interface WaitsForTemplate {
|
||||
isTemplateReady: ko.Observable<boolean>;
|
||||
}
|
||||
|
||||
export interface QueryTab extends Tab {
|
||||
queryEditorId: string;
|
||||
isQueryMetricsEnabled: ko.Computed<boolean>;
|
||||
activityId: ko.Observable<string>;
|
||||
|
||||
/* Command Bar */
|
||||
executeQueryButton: Button;
|
||||
fetchNextPageButton: Button;
|
||||
saveQueryButton: Button;
|
||||
onExecuteQueryClick(): Q.Promise<any>;
|
||||
onFetchNextPageClick(): Q.Promise<any>;
|
||||
|
||||
/*Query Editor*/
|
||||
initialEditorContent: ko.Observable<string>;
|
||||
sqlQueryEditorContent: ko.Observable<string>;
|
||||
sqlStatementToExecute: ko.Observable<string>;
|
||||
|
||||
/* Results */
|
||||
allResultsMetadata: ko.ObservableArray<QueryResultsMetadata>;
|
||||
|
||||
/* Errors */
|
||||
errors: ko.ObservableArray<QueryError>;
|
||||
|
||||
/* Status */
|
||||
statusMessge: ko.Observable<string>;
|
||||
statusIcon: ko.Observable<string>;
|
||||
}
|
||||
|
||||
export interface ScriptTab extends Tab {
|
||||
id: Editable<string>;
|
||||
editorId: string;
|
||||
|
||||
saveButton: Button;
|
||||
updateButton: Button;
|
||||
discardButton: Button;
|
||||
deleteButton: Button;
|
||||
|
||||
editorState: ko.Observable<ScriptEditorState>;
|
||||
editorContent: ko.Observable<string>;
|
||||
editor: ko.Observable<monaco.editor.IStandaloneCodeEditor>;
|
||||
|
||||
errors: ko.ObservableArray<QueryError>;
|
||||
statusMessge: ko.Observable<string>;
|
||||
statusIcon: ko.Observable<string>;
|
||||
|
||||
formFields: ko.ObservableArray<Editable<any>>;
|
||||
formIsValid: ko.Computed<boolean>;
|
||||
formIsDirty: ko.Computed<boolean>;
|
||||
|
||||
isNew: ko.Observable<boolean>;
|
||||
resource: ko.Observable<DataModels.Resource>;
|
||||
|
||||
setBaselines(): void;
|
||||
}
|
||||
|
||||
export interface StoredProcedureTab extends ScriptTab {
|
||||
onExecuteSprocsResult(result: any, logsData: any): void;
|
||||
onExecuteSprocsError(error: string): void;
|
||||
}
|
||||
|
||||
export interface UserDefinedFunctionTab extends ScriptTab {}
|
||||
|
||||
export interface TriggerTab extends ScriptTab {
|
||||
triggerType: Editable<string>;
|
||||
triggerOperation: Editable<string>;
|
||||
}
|
||||
|
||||
export interface GraphTab extends Tab {}
|
||||
export interface EditorPosition {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
|
||||
export interface MongoShellTab extends Tab {}
|
||||
|
||||
export enum DocumentExplorerState {
|
||||
noDocumentSelected,
|
||||
newDocumentValid,
|
||||
@@ -752,40 +429,8 @@ export interface AuthorizationTokenHeaderMetadata {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface TelemetryActions {
|
||||
sendEvent(name: string, telemetryProperties?: { [propertyName: string]: string }): Q.Promise<any>;
|
||||
sendError(errorInfo: DataModels.ITelemetryError): Q.Promise<any>;
|
||||
sendMetric(
|
||||
name: string,
|
||||
metricNumber: number,
|
||||
telemetryProperties?: { [propertyName: string]: string }
|
||||
): Q.Promise<any>;
|
||||
}
|
||||
|
||||
export interface ConfigurationOverrides {
|
||||
EnableBsonSchema: string;
|
||||
}
|
||||
|
||||
export interface CosmosDbApi {
|
||||
isSystemDatabasePredicate: (database: Database) => boolean;
|
||||
}
|
||||
|
||||
export interface DropdownOption<T> {
|
||||
text: string;
|
||||
value: T;
|
||||
disable?: boolean;
|
||||
}
|
||||
|
||||
export interface INotebookContainerClient {
|
||||
resetWorkspace: () => Promise<void>;
|
||||
}
|
||||
|
||||
export interface INotebookContentClient {
|
||||
updateItemChildren: (item: NotebookContentItem) => Promise<void>;
|
||||
createNewNotebookFile: (parent: NotebookContentItem) => Promise<NotebookContentItem>;
|
||||
deleteContentItem: (item: NotebookContentItem) => Promise<void>;
|
||||
uploadFileAsync: (name: string, content: string, parent: NotebookContentItem) => Promise<NotebookContentItem>;
|
||||
renameNotebook: (item: NotebookContentItem, targetName: string) => Promise<NotebookContentItem>;
|
||||
createDirectory: (parent: NotebookContentItem, newDirectoryName: string) => Promise<NotebookContentItem>;
|
||||
readFileContent: (filePath: string) => Promise<string>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user