mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-27 12:10:09 +00:00
fixed eslint of ConflictsTab
This commit is contained in:
parent
55837db65b
commit
bd1009c849
@ -87,7 +87,6 @@ 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
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* 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";
|
||||||
@ -69,13 +71,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<any>("");
|
this.selectedConflictContent = editable.observable<string>("");
|
||||||
this.selectedConflictCurrent = editable.observable<any>("");
|
this.selectedConflictCurrent = editable.observable<string>("");
|
||||||
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;
|
||||||
|
|
||||||
@ -187,7 +189,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;
|
||||||
@ -195,7 +197,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();
|
||||||
@ -242,7 +244,7 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
public onConflictIdClick(clickedDocumentId: ConflictId): Q.Promise<any> {
|
public onConflictIdClick(): Q.Promise<unknown> {
|
||||||
if (this.editorState() !== ViewModels.DocumentExplorerState.noDocumentSelected) {
|
if (this.editorState() !== ViewModels.DocumentExplorerState.noDocumentSelected) {
|
||||||
return Q();
|
return Q();
|
||||||
}
|
}
|
||||||
@ -405,19 +407,19 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public onDiscardClick = (): Q.Promise<any> => {
|
public onDiscardClick = (): Q.Promise<unknown> => {
|
||||||
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<any> {
|
public onValidDocumentEdit(): Q.Promise<unknown> {
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid);
|
||||||
return Q();
|
return Q();
|
||||||
}
|
}
|
||||||
|
|
||||||
public onInvalidDocumentEdit(): Q.Promise<any> {
|
public onInvalidDocumentEdit(): Q.Promise<unknown> {
|
||||||
if (
|
if (
|
||||||
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentNoEdits ||
|
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentNoEdits ||
|
||||||
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid
|
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid
|
||||||
@ -442,7 +444,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,
|
||||||
{
|
{
|
||||||
@ -471,7 +473,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<any> {
|
public loadNextPage(): Q.Promise<unknown> {
|
||||||
this.isExecuting(true);
|
this.isExecuting(true);
|
||||||
this.isExecutionError(false);
|
this.isExecutionError(false);
|
||||||
return this._loadNextPageInternal()
|
return this._loadNextPageInternal()
|
||||||
@ -491,7 +493,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,
|
||||||
{
|
{
|
||||||
@ -508,7 +510,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,
|
||||||
{
|
{
|
||||||
@ -541,18 +543,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));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _onEditorContentChange(newContent: string) {
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
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<any> {
|
public initDocumentEditorForCreate(documentId: ConflictId, documentToInsert: any): Q.Promise<unknown> {
|
||||||
if (documentId) {
|
if (documentId) {
|
||||||
let parsedConflictContent: any = JSON.parse(documentToInsert);
|
const 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);
|
||||||
@ -565,7 +567,7 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
documentId: ConflictId,
|
documentId: ConflictId,
|
||||||
conflictContent: any,
|
conflictContent: any,
|
||||||
currentContent: any
|
currentContent: any
|
||||||
): Q.Promise<any> {
|
): Q.Promise<unknown> {
|
||||||
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);
|
||||||
@ -582,7 +584,7 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
return Q();
|
return Q();
|
||||||
}
|
}
|
||||||
|
|
||||||
public initDocumentEditorForDelete(documentId: ConflictId, documentToDelete: any): Q.Promise<any> {
|
public initDocumentEditorForDelete(documentId: ConflictId, documentToDelete: any): Q.Promise<unknown> {
|
||||||
if (documentId) {
|
if (documentId) {
|
||||||
let parsedDocumentToDelete: any = JSON.parse(documentToDelete);
|
let parsedDocumentToDelete: any = JSON.parse(documentToDelete);
|
||||||
parsedDocumentToDelete = ConflictsTab.removeSystemProperties(parsedDocumentToDelete);
|
parsedDocumentToDelete = ConflictsTab.removeSystemProperties(parsedDocumentToDelete);
|
||||||
@ -594,7 +596,8 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
return Q();
|
return Q();
|
||||||
}
|
}
|
||||||
|
|
||||||
public initDocumentEditorForNoOp(documentId: ConflictId): Q.Promise<any> {
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user