Compare commits

..

2 Commits

8 changed files with 59 additions and 55 deletions

View File

@@ -87,16 +87,13 @@ src/Explorer/Tables/QueryBuilder/CustomTimestampHelper.ts
src/Explorer/Tables/TableDataClient.ts src/Explorer/Tables/TableDataClient.ts
src/Explorer/Tables/TableEntityProcessor.ts src/Explorer/Tables/TableEntityProcessor.ts
src/Explorer/Tables/Utilities.ts src/Explorer/Tables/Utilities.ts
src/Explorer/Tabs/ConflictsTab.ts
src/Explorer/Tabs/DatabaseSettingsTab.ts src/Explorer/Tabs/DatabaseSettingsTab.ts
src/Explorer/Tabs/DocumentsTab.test.ts src/Explorer/Tabs/DocumentsTab.test.ts
src/Explorer/Tabs/DocumentsTab.ts src/Explorer/Tabs/DocumentsTab.ts
src/Explorer/Tabs/GraphTab.ts src/Explorer/Tabs/GraphTab.ts
src/Explorer/Tabs/MongoDocumentsTab.ts src/Explorer/Tabs/MongoDocumentsTab.ts
src/Explorer/Tabs/NotebookV2Tab.ts
src/Explorer/Tabs/ScriptTabBase.ts
src/Explorer/Tabs/TabComponents.ts
src/Explorer/Tabs/TabsBase.ts src/Explorer/Tabs/TabsBase.ts
src/Explorer/Tabs/TriggerTab.ts
src/Explorer/Tabs/UserDefinedFunctionTab.ts src/Explorer/Tabs/UserDefinedFunctionTab.ts
src/Explorer/Tree/AccessibleVerticalList.ts src/Explorer/Tree/AccessibleVerticalList.ts
src/Explorer/Tree/Collection.ts src/Explorer/Tree/Collection.ts

View File

@@ -307,11 +307,18 @@ function createOpenSynapseLinkDialogButton(container: Explorer): CommandButtonCo
function createNewDatabase(container: Explorer): CommandButtonComponentProps { function createNewDatabase(container: Explorer): CommandButtonComponentProps {
const label = "New " + getDatabaseName(); const label = "New " + getDatabaseName();
const newDatabaseButton = document.activeElement as HTMLElement;
return { return {
iconSrc: AddDatabaseIcon, iconSrc: AddDatabaseIcon,
iconAlt: label, iconAlt: label,
onCommandClick: () => onCommandClick: () =>
useSidePanel.getState().openSidePanel("New " + getDatabaseName(), <AddDatabasePanel explorer={container} />), useSidePanel
.getState()
.openSidePanel(
"New " + getDatabaseName(),
<AddDatabasePanel explorer={container} buttonElement={newDatabaseButton} />
),
commandButtonLabel: label, commandButtonLabel: label,
ariaLabel: label, ariaLabel: label,
hasPopup: true, hasPopup: true,

View File

@@ -23,10 +23,12 @@ import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneFor
export interface AddDatabasePaneProps { export interface AddDatabasePaneProps {
explorer: Explorer; explorer: Explorer;
buttonElement?: HTMLElement;
} }
export const AddDatabasePanel: FunctionComponent<AddDatabasePaneProps> = ({ export const AddDatabasePanel: FunctionComponent<AddDatabasePaneProps> = ({
explorer: container, explorer: container,
buttonElement,
}: AddDatabasePaneProps) => { }: AddDatabasePaneProps) => {
const closeSidePanel = useSidePanel((state) => state.closeSidePanel); const closeSidePanel = useSidePanel((state) => state.closeSidePanel);
let throughput: number; let throughput: number;
@@ -77,6 +79,7 @@ export const AddDatabasePanel: FunctionComponent<AddDatabasePaneProps> = ({
dataExplorerArea: Constants.Areas.ContextualPane, dataExplorerArea: Constants.Areas.ContextualPane,
}; };
TelemetryProcessor.trace(Action.CreateDatabase, ActionModifiers.Open, addDatabasePaneOpenMessage); TelemetryProcessor.trace(Action.CreateDatabase, ActionModifiers.Open, addDatabasePaneOpenMessage);
buttonElement.focus();
}, []); }, []);
const onSubmit = () => { const onSubmit = () => {

View File

@@ -307,16 +307,23 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
iconSrc: AddDatabaseIcon, iconSrc: AddDatabaseIcon,
title: "New " + getDatabaseName(), title: "New " + getDatabaseName(),
description: undefined, description: undefined,
onClick: () => onClick: () => this.openAddDatabasePanel(),
useSidePanel
.getState()
.openSidePanel("New " + getDatabaseName(), <AddDatabasePanel explorer={this.container} />),
}); });
} }
return items; return items;
} }
private openAddDatabasePanel() {
const newDatabaseButton = document.activeElement as HTMLElement;
useSidePanel
.getState()
.openSidePanel(
"New " + getDatabaseName(),
<AddDatabasePanel explorer={this.container} buttonElement={newDatabaseButton} />
);
}
private decorateOpenCollectionActivity({ databaseId, collectionId }: MostRecentActivity.OpenCollectionItem) { private decorateOpenCollectionActivity({ databaseId, collectionId }: MostRecentActivity.OpenCollectionItem) {
return { return {
iconSrc: NotebookIcon, iconSrc: NotebookIcon,

View File

@@ -202,21 +202,14 @@ export class CassandraAPIDataClient extends TableDataClient {
let updateQuery = `UPDATE ${collection.databaseId}.${collection.id()}`; let updateQuery = `UPDATE ${collection.databaseId}.${collection.id()}`;
let isPropertyUpdated = false; let isPropertyUpdated = false;
let isFirstPropertyToUpdate = true;
for (let property in newEntity) { for (let property in newEntity) {
if ( if (
!originalDocument[property] || !originalDocument[property] ||
newEntity[property]._.toString() !== originalDocument[property]._.toString() newEntity[property]._.toString() !== originalDocument[property]._.toString()
) { ) {
let propertyQuerySegment = this.isStringType(newEntity[property].$) updateQuery += this.isStringType(newEntity[property].$)
? `${property} = '${newEntity[property]._}',` ? ` SET ${property} = '${newEntity[property]._}',`
: `${property} = ${newEntity[property]._},`; : ` SET ${property} = ${newEntity[property]._},`;
// Only add the "SET" keyword once
if (isFirstPropertyToUpdate) {
propertyQuerySegment = " SET " + propertyQuerySegment;
isFirstPropertyToUpdate = false;
}
updateQuery += propertyQuerySegment;
isPropertyUpdated = true; isPropertyUpdated = true;
} }
} }

View File

@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/switch-exhaustiveness-check */
import { ConflictDefinition, FeedOptions, QueryIterator, Resource } from "@azure/cosmos"; import { ConflictDefinition, FeedOptions, QueryIterator, Resource } from "@azure/cosmos";
import * as ko from "knockout"; import * as ko from "knockout";
import Q from "q"; import Q from "q";
@@ -71,13 +69,13 @@ export default class ConflictsTab extends TabsBase {
ViewModels.DocumentExplorerState.noDocumentSelected ViewModels.DocumentExplorerState.noDocumentSelected
); );
this.selectedConflictId = ko.observable<ConflictId>(); this.selectedConflictId = ko.observable<ConflictId>();
this.selectedConflictContent = editable.observable<string>(""); this.selectedConflictContent = editable.observable<any>("");
this.selectedConflictCurrent = editable.observable<string>(""); this.selectedConflictCurrent = editable.observable<any>("");
this.partitionKey = options.partitionKey || (this.collection && this.collection.partitionKey); this.partitionKey = options.partitionKey || (this.collection && this.collection.partitionKey);
this.conflictIds = options.conflictIds; this.conflictIds = options.conflictIds;
this.partitionKeyPropertyHeader = this.partitionKeyPropertyHeader =
(this.collection && this.collection.partitionKeyPropertyHeader) || this._getPartitionKeyPropertyHeader(); (this.collection && this.collection.partitionKeyPropertyHeader) || this._getPartitionKeyPropertyHeader();
this.partitionKeyProperty = this.partitionKeyPropertyHeader this.partitionKeyProperty = !!this.partitionKeyPropertyHeader
? this.partitionKeyPropertyHeader.replace(/[/]+/g, ".").substr(1).replace(/[']+/g, "") ? this.partitionKeyPropertyHeader.replace(/[/]+/g, ".").substr(1).replace(/[']+/g, "")
: null; : null;
@@ -189,7 +187,7 @@ export default class ConflictsTab extends TabsBase {
this.buildCommandBarOptions(); this.buildCommandBarOptions();
this.shouldShowDiffEditor = ko.pureComputed<boolean>(() => { this.shouldShowDiffEditor = ko.pureComputed<boolean>(() => {
const documentHasContent: boolean = const documentHasContent: boolean =
this.selectedConflictContent() !== null && this.selectedConflictContent().length > 0; this.selectedConflictContent() != null && this.selectedConflictContent().length > 0;
const operationIsReplace: boolean = this.conflictOperation() === Constants.ConflictOperationType.Replace; const operationIsReplace: boolean = this.conflictOperation() === Constants.ConflictOperationType.Replace;
const isLoadingData: boolean = this.loadingConflictData(); const isLoadingData: boolean = this.loadingConflictData();
return documentHasContent && operationIsReplace && !isLoadingData; return documentHasContent && operationIsReplace && !isLoadingData;
@@ -197,7 +195,7 @@ export default class ConflictsTab extends TabsBase {
this.shouldShowEditor = ko.pureComputed<boolean>(() => { this.shouldShowEditor = ko.pureComputed<boolean>(() => {
const documentHasContent: boolean = const documentHasContent: boolean =
this.selectedConflictContent() !== null && this.selectedConflictContent().length > 0; this.selectedConflictContent() != null && this.selectedConflictContent().length > 0;
const operationIsInsert: boolean = this.conflictOperation() === Constants.ConflictOperationType.Create; const operationIsInsert: boolean = this.conflictOperation() === Constants.ConflictOperationType.Create;
const operationIsDelete: boolean = this.conflictOperation() === Constants.ConflictOperationType.Delete; const operationIsDelete: boolean = this.conflictOperation() === Constants.ConflictOperationType.Delete;
const isLoadingData: boolean = this.loadingConflictData(); const isLoadingData: boolean = this.loadingConflictData();
@@ -244,7 +242,7 @@ export default class ConflictsTab extends TabsBase {
return true; return true;
}; };
public onConflictIdClick(): Q.Promise<unknown> { public onConflictIdClick(clickedDocumentId: ConflictId): Q.Promise<any> {
if (this.editorState() !== ViewModels.DocumentExplorerState.noDocumentSelected) { if (this.editorState() !== ViewModels.DocumentExplorerState.noDocumentSelected) {
return Q(); return Q();
} }
@@ -407,19 +405,19 @@ export default class ConflictsTab extends TabsBase {
} }
}; };
public onDiscardClick = (): Q.Promise<unknown> => { public onDiscardClick = (): Q.Promise<any> => {
this.selectedConflictContent(this.selectedConflictContent.getEditableOriginalValue()); this.selectedConflictContent(this.selectedConflictContent.getEditableOriginalValue());
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits); this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
return Q(); return Q();
}; };
public onValidDocumentEdit(): Q.Promise<unknown> { public onValidDocumentEdit(): Q.Promise<any> {
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid); this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid);
return Q(); return Q();
} }
public onInvalidDocumentEdit(): Q.Promise<unknown> { public onInvalidDocumentEdit(): Q.Promise<any> {
if ( if (
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentNoEdits || this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentNoEdits ||
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid
@@ -444,7 +442,7 @@ export default class ConflictsTab extends TabsBase {
this._documentsIterator = await this.createIterator(); this._documentsIterator = await this.createIterator();
await this.loadNextPage(); await this.loadNextPage();
} catch (error) { } catch (error) {
if (this.onLoadStartKey !== null && this.onLoadStartKey !== undefined) { if (this.onLoadStartKey != null && this.onLoadStartKey != undefined) {
TelemetryProcessor.traceFailure( TelemetryProcessor.traceFailure(
Action.Tab, Action.Tab,
{ {
@@ -473,7 +471,7 @@ export default class ConflictsTab extends TabsBase {
return queryConflicts(this.collection.databaseId, this.collection.id(), query, options as FeedOptions); return queryConflicts(this.collection.databaseId, this.collection.id(), query, options as FeedOptions);
} }
public loadNextPage(): Q.Promise<unknown> { public loadNextPage(): Q.Promise<any> {
this.isExecuting(true); this.isExecuting(true);
this.isExecutionError(false); this.isExecutionError(false);
return this._loadNextPageInternal() return this._loadNextPageInternal()
@@ -493,7 +491,7 @@ export default class ConflictsTab extends TabsBase {
const merged = currentConflicts.concat(nextConflictIds); const merged = currentConflicts.concat(nextConflictIds);
this.conflictIds(merged); this.conflictIds(merged);
if (this.onLoadStartKey !== null && this.onLoadStartKey !== undefined) { if (this.onLoadStartKey != null && this.onLoadStartKey != undefined) {
TelemetryProcessor.traceSuccess( TelemetryProcessor.traceSuccess(
Action.Tab, Action.Tab,
{ {
@@ -510,7 +508,7 @@ export default class ConflictsTab extends TabsBase {
}, },
(error) => { (error) => {
this.isExecutionError(true); this.isExecutionError(true);
if (this.onLoadStartKey !== null && this.onLoadStartKey !== undefined) { if (this.onLoadStartKey != null && this.onLoadStartKey != undefined) {
TelemetryProcessor.traceFailure( TelemetryProcessor.traceFailure(
Action.Tab, Action.Tab,
{ {
@@ -543,18 +541,18 @@ export default class ConflictsTab extends TabsBase {
return Q(this._documentsIterator.fetchNext().then((response) => response.resources)); return Q(this._documentsIterator.fetchNext().then((response) => response.resources));
} }
// eslint-disable-next-line @typescript-eslint/no-unused-vars protected _onEditorContentChange(newContent: string) {
protected _onEditorContentChange(_newContent: string) {
try { try {
const parsed: any = JSON.parse(newContent);
this.onValidDocumentEdit(); this.onValidDocumentEdit();
} catch (e) { } catch (e) {
this.onInvalidDocumentEdit(); this.onInvalidDocumentEdit();
} }
} }
public initDocumentEditorForCreate(documentId: ConflictId, documentToInsert: any): Q.Promise<unknown> { public initDocumentEditorForCreate(documentId: ConflictId, documentToInsert: any): Q.Promise<any> {
if (documentId) { if (documentId) {
const parsedConflictContent: any = JSON.parse(documentToInsert); let parsedConflictContent: any = JSON.parse(documentToInsert);
const renderedConflictContent: string = this.renderObjectForEditor(parsedConflictContent, null, 4); const renderedConflictContent: string = this.renderObjectForEditor(parsedConflictContent, null, 4);
this.selectedConflictContent.setBaseline(renderedConflictContent); this.selectedConflictContent.setBaseline(renderedConflictContent);
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits); this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
@@ -567,7 +565,7 @@ export default class ConflictsTab extends TabsBase {
documentId: ConflictId, documentId: ConflictId,
conflictContent: any, conflictContent: any,
currentContent: any currentContent: any
): Q.Promise<unknown> { ): Q.Promise<any> {
if (documentId) { if (documentId) {
currentContent = ConflictsTab.removeSystemProperties(currentContent); currentContent = ConflictsTab.removeSystemProperties(currentContent);
const renderedCurrentContent: string = this.renderObjectForEditor(currentContent, null, 4); const renderedCurrentContent: string = this.renderObjectForEditor(currentContent, null, 4);
@@ -584,7 +582,7 @@ export default class ConflictsTab extends TabsBase {
return Q(); return Q();
} }
public initDocumentEditorForDelete(documentId: ConflictId, documentToDelete: any): Q.Promise<unknown> { public initDocumentEditorForDelete(documentId: ConflictId, documentToDelete: any): Q.Promise<any> {
if (documentId) { if (documentId) {
let parsedDocumentToDelete: any = JSON.parse(documentToDelete); let parsedDocumentToDelete: any = JSON.parse(documentToDelete);
parsedDocumentToDelete = ConflictsTab.removeSystemProperties(parsedDocumentToDelete); parsedDocumentToDelete = ConflictsTab.removeSystemProperties(parsedDocumentToDelete);
@@ -596,8 +594,7 @@ export default class ConflictsTab extends TabsBase {
return Q(); return Q();
} }
// eslint-disable-next-line @typescript-eslint/no-unused-vars public initDocumentEditorForNoOp(documentId: ConflictId): Q.Promise<any> {
public initDocumentEditorForNoOp(_documentId: ConflictId): Q.Promise<unknown> {
this.selectedConflictContent(null); this.selectedConflictContent(null);
this.selectedConflictCurrent(null); this.selectedConflictCurrent(null);
this.editorState(ViewModels.DocumentExplorerState.noDocumentSelected); this.editorState(ViewModels.DocumentExplorerState.noDocumentSelected);

View File

@@ -54,7 +54,7 @@ export default class NotebookTabV2 extends NotebookTabBase {
}); });
} }
public onCloseTabButtonClick(): Q.Promise<any> { public onCloseTabButtonClick(): Q.Promise<void> {
const cleanup = () => { const cleanup = () => {
this.notebookComponentAdapter.notebookShutdown(); this.notebookComponentAdapter.notebookShutdown();
super.onCloseTabButtonClick(); super.onCloseTabButtonClick();
@@ -78,7 +78,7 @@ export default class NotebookTabV2 extends NotebookTabBase {
} }
} }
public async reconfigureServiceEndpoints() { public async reconfigureServiceEndpoints(): Promise<void> {
if (!this.notebookComponentAdapter) { if (!this.notebookComponentAdapter) {
return; return;
} }
@@ -136,7 +136,7 @@ export default class NotebookTabV2 extends NotebookTabBase {
ariaLabel: publishLabel, ariaLabel: publishLabel,
}); });
let buttons: CommandButtonComponentProps[] = [ const buttons: CommandButtonComponentProps[] = [
{ {
iconSrc: SaveIcon, iconSrc: SaveIcon,
iconAlt: saveLabel, iconAlt: saveLabel,
@@ -160,7 +160,7 @@ export default class NotebookTabV2 extends NotebookTabBase {
{ {
iconSrc: null, iconSrc: null,
iconAlt: kernelLabel, iconAlt: kernelLabel,
onCommandClick: () => {}, onCommandClick: () => undefined,
commandButtonLabel: null, commandButtonLabel: null,
hasPopup: false, hasPopup: false,
disabled: availableKernels.length < 1, disabled: availableKernels.length < 1,
@@ -271,7 +271,7 @@ export default class NotebookTabV2 extends NotebookTabBase {
{ {
iconSrc: null, iconSrc: null,
iconAlt: null, iconAlt: null,
onCommandClick: () => {}, onCommandClick: () => undefined,
commandButtonLabel: null, commandButtonLabel: null,
ariaLabel: cellTypeLabel, ariaLabel: cellTypeLabel,
hasPopup: false, hasPopup: false,
@@ -361,7 +361,7 @@ export default class NotebookTabV2 extends NotebookTabBase {
} }
private onKernelUpdate = async () => { private onKernelUpdate = async () => {
await this.configureServiceEndpoints(this.notebookComponentAdapter.getCurrentKernelName()).catch((reason) => { await this.configureServiceEndpoints(this.notebookComponentAdapter.getCurrentKernelName()).catch(() => {
/* Erroring is ok here */ /* Erroring is ok here */
}); });
this.updateNavbarWithTabsButtons(); this.updateNavbarWithTabsButtons();

View File

@@ -25,11 +25,12 @@ export default abstract class ScriptTabBase extends TabsBase implements ViewMode
public errors: ko.ObservableArray<ViewModels.QueryError>; public errors: ko.ObservableArray<ViewModels.QueryError>;
public statusMessge: ko.Observable<string>; public statusMessge: ko.Observable<string>;
public statusIcon: ko.Observable<string>; public statusIcon: ko.Observable<string>;
public formFields: ko.ObservableArray<ViewModels.Editable<any>>; public formFields: ko.ObservableArray<ViewModels.Editable<unknown>>;
public formIsValid: ko.Computed<boolean>; public formIsValid: ko.Computed<boolean>;
public formIsDirty: ko.Computed<boolean>; public formIsDirty: ko.Computed<boolean>;
public isNew: ko.Observable<boolean>; public isNew: ko.Observable<boolean>;
// TODO: Remove any. The SDK types for all the script.body are slightly incorrect which makes this REALLY hard to type correct. // TODO: Remove any. The SDK types for all the script.body are slightly incorrect which makes this REALLY hard to type correct.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public resource: ko.Observable<any>; public resource: ko.Observable<any>;
public isTemplateReady: ko.Observable<boolean>; public isTemplateReady: ko.Observable<boolean>;
protected _partitionKey: DataModels.PartitionKey; protected _partitionKey: DataModels.PartitionKey;
@@ -85,7 +86,6 @@ export default abstract class ScriptTabBase extends TabsBase implements ViewMode
this.editorState(ViewModels.ScriptEditorState.exisitingDirtyInvalid); this.editorState(ViewModels.ScriptEditorState.exisitingDirtyInvalid);
} }
break; break;
case ViewModels.ScriptEditorState.exisitingDirtyValid:
default: default:
break; break;
} }
@@ -182,7 +182,7 @@ export default abstract class ScriptTabBase extends TabsBase implements ViewMode
this.editorContent.setBaseline(resource.body); this.editorContent.setBaseline(resource.body);
} }
public setBaselines() { public setBaselines(): void {
this._setBaselines(); this._setBaselines();
} }
@@ -194,9 +194,9 @@ export default abstract class ScriptTabBase extends TabsBase implements ViewMode
} }
public abstract onSaveClick: () => void; public abstract onSaveClick: () => void;
public abstract onUpdateClick: () => Promise<any>; public abstract onUpdateClick: () => Promise<void>;
public onDiscard = (): Q.Promise<any> => { public onDiscard = (): Q.Promise<void> => {
this.setBaselines(); this.setBaselines();
const original = this.editorContent.getEditableOriginalValue(); const original = this.editorContent.getEditableOriginalValue();
const editorModel = this.editor() && this.editor().getModel(); const editorModel = this.editor() && this.editor().getModel();
@@ -289,7 +289,7 @@ export default abstract class ScriptTabBase extends TabsBase implements ViewMode
return !!value; return !!value;
} }
protected async _createBodyEditor() { protected async _createBodyEditor(): Promise<void> {
const id = this.editorId; const id = this.editorId;
const container = document.getElementById(id); const container = document.getElementById(id);
const options = { const options = {
@@ -308,7 +308,7 @@ export default abstract class ScriptTabBase extends TabsBase implements ViewMode
editorModel.onDidChangeContent(this._onBodyContentChange.bind(this)); editorModel.onDidChangeContent(this._onBodyContentChange.bind(this));
} }
private _onBodyContentChange(e: monaco.editor.IModelContentChangedEvent) { private _onBodyContentChange() {
const editorModel = this.editor().getModel(); const editorModel = this.editor().getModel();
this.editorContent(editorModel.getValue()); this.editorContent(editorModel.getValue());
} }