This commit is contained in:
Laurent Nguyen 2024-05-29 18:20:07 +02:00 committed by GitHub
parent f669a99228
commit cebf044803
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 77 additions and 77 deletions

View File

@ -324,9 +324,9 @@ export enum DocumentExplorerState {
noDocumentSelected,
newDocumentValid,
newDocumentInvalid,
exisitingDocumentNoEdits,
exisitingDocumentDirtyValid,
exisitingDocumentDirtyInvalid,
existingDocumentNoEdits,
existingDocumentDirtyValid,
existingDocumentDirtyInvalid,
}
export enum IndexingPolicyEditorState {
@ -339,9 +339,9 @@ export enum IndexingPolicyEditorState {
export enum ScriptEditorState {
newInvalid,
newValid,
exisitingNoEdits,
exisitingDirtyValid,
exisitingDirtyInvalid,
existingNoEdits,
existingDirtyValid,
existingDirtyInvalid,
}
export enum CollectionTabKind {

View File

@ -6,16 +6,16 @@ import DiscardIcon from "../../../images/discard.svg";
import SaveIcon from "../../../images/save-cosmos.svg";
import * as Constants from "../../Common/Constants";
import { DocumentsGridMetrics, KeyCodes } from "../../Common/Constants";
import { createDocument } from "../../Common/dataAccess/createDocument";
import { deleteConflict } from "../../Common/dataAccess/deleteConflict";
import { deleteDocument } from "../../Common/dataAccess/deleteDocument";
import { queryConflicts } from "../../Common/dataAccess/queryConflicts";
import { updateDocument } from "../../Common/dataAccess/updateDocument";
import editable from "../../Common/EditableUtility";
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
import * as HeadersUtility from "../../Common/HeadersUtility";
import { MinimalQueryIterator } from "../../Common/IteratorUtilities";
import { Splitter, SplitterBounds, SplitterDirection } from "../../Common/Splitter";
import { createDocument } from "../../Common/dataAccess/createDocument";
import { deleteConflict } from "../../Common/dataAccess/deleteConflict";
import { deleteDocument } from "../../Common/dataAccess/deleteDocument";
import { queryConflicts } from "../../Common/dataAccess/queryConflicts";
import { updateDocument } from "../../Common/dataAccess/updateDocument";
import * as DataModels from "../../Contracts/DataModels";
import * as ViewModels from "../../Contracts/ViewModels";
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
@ -117,15 +117,15 @@ export default class ConflictsTab extends TabsBase {
this.isEditorDirty = ko.computed<boolean>(() => {
switch (this.editorState()) {
case ViewModels.DocumentExplorerState.noDocumentSelected:
case ViewModels.DocumentExplorerState.exisitingDocumentNoEdits:
case ViewModels.DocumentExplorerState.existingDocumentNoEdits:
return false;
case ViewModels.DocumentExplorerState.newDocumentValid:
case ViewModels.DocumentExplorerState.newDocumentInvalid:
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid:
case ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid:
return true;
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.existingDocumentDirtyValid:
return (
this.selectedConflictCurrent.getEditableOriginalValue() !==
this.selectedConflictCurrent.getEditableCurrentValue()
@ -139,8 +139,8 @@ export default class ConflictsTab extends TabsBase {
this.acceptChangesButton = {
enabled: ko.computed<boolean>(() => {
switch (this.editorState()) {
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.exisitingDocumentNoEdits:
case ViewModels.DocumentExplorerState.existingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.existingDocumentNoEdits:
return true;
}
@ -155,8 +155,8 @@ export default class ConflictsTab extends TabsBase {
this.discardButton = {
enabled: ko.computed<boolean>(() => {
switch (this.editorState()) {
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid:
case ViewModels.DocumentExplorerState.existingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid:
return true;
}
@ -171,8 +171,8 @@ export default class ConflictsTab extends TabsBase {
this.deleteButton = {
enabled: ko.computed<boolean>(() => {
switch (this.editorState()) {
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.exisitingDocumentNoEdits:
case ViewModels.DocumentExplorerState.existingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.existingDocumentNoEdits:
return true;
}
@ -247,7 +247,7 @@ export default class ConflictsTab extends TabsBase {
return Q();
}
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
this.editorState(ViewModels.DocumentExplorerState.existingDocumentNoEdits);
return Q();
}
@ -407,22 +407,22 @@ export default class ConflictsTab extends TabsBase {
public onDiscardClick = (): Q.Promise<any> => {
this.selectedConflictContent(this.selectedConflictContent.getEditableOriginalValue());
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
this.editorState(ViewModels.DocumentExplorerState.existingDocumentNoEdits);
return Q();
};
public onValidDocumentEdit(): Q.Promise<any> {
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid);
this.editorState(ViewModels.DocumentExplorerState.existingDocumentDirtyValid);
return Q();
}
public onInvalidDocumentEdit(): Q.Promise<any> {
if (
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentNoEdits ||
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid
this.editorState() === ViewModels.DocumentExplorerState.existingDocumentNoEdits ||
this.editorState() === ViewModels.DocumentExplorerState.existingDocumentDirtyValid
) {
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid);
this.editorState(ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid);
return Q();
}
@ -555,7 +555,7 @@ export default class ConflictsTab extends TabsBase {
let parsedConflictContent: any = JSON.parse(documentToInsert);
const renderedConflictContent: string = this.renderObjectForEditor(parsedConflictContent, null, 4);
this.selectedConflictContent.setBaseline(renderedConflictContent);
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
this.editorState(ViewModels.DocumentExplorerState.existingDocumentNoEdits);
}
return Q();
@ -576,7 +576,7 @@ export default class ConflictsTab extends TabsBase {
const renderedConflictContent: string = this.renderObjectForEditor(parsedConflictContent, null, 4);
this.selectedConflictContent.setBaseline(renderedConflictContent);
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
this.editorState(ViewModels.DocumentExplorerState.existingDocumentNoEdits);
}
return Q();
@ -588,7 +588,7 @@ export default class ConflictsTab extends TabsBase {
parsedDocumentToDelete = ConflictsTab.removeSystemProperties(parsedDocumentToDelete);
const renderedDocumentToDelete: string = this.renderObjectForEditor(parsedDocumentToDelete, null, 4);
this.selectedConflictContent.setBaseline(renderedDocumentToDelete);
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
this.editorState(ViewModels.DocumentExplorerState.existingDocumentNoEdits);
}
return Q();

View File

@ -179,17 +179,17 @@ describe("Documents tab (noSql API)", () => {
testCases.add({ state: ViewModels.DocumentExplorerState.newDocumentValid, enabled: true, visible: true });
testCases.add({ state: ViewModels.DocumentExplorerState.newDocumentInvalid, enabled: false, visible: true });
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentNoEdits,
state: ViewModels.DocumentExplorerState.existingDocumentNoEdits,
enabled: false,
visible: false,
});
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid,
state: ViewModels.DocumentExplorerState.existingDocumentDirtyValid,
enabled: false,
visible: false,
});
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid,
state: ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid,
enabled: false,
visible: false,
});
@ -211,17 +211,17 @@ describe("Documents tab (noSql API)", () => {
testCases.add({ state: ViewModels.DocumentExplorerState.newDocumentValid, enabled: true, visible: true });
testCases.add({ state: ViewModels.DocumentExplorerState.newDocumentInvalid, enabled: true, visible: true });
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentNoEdits,
state: ViewModels.DocumentExplorerState.existingDocumentNoEdits,
enabled: false,
visible: false,
});
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid,
state: ViewModels.DocumentExplorerState.existingDocumentDirtyValid,
enabled: false,
visible: false,
});
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid,
state: ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid,
enabled: false,
visible: false,
});
@ -243,17 +243,17 @@ describe("Documents tab (noSql API)", () => {
testCases.add({ state: ViewModels.DocumentExplorerState.newDocumentValid, enabled: false, visible: false });
testCases.add({ state: ViewModels.DocumentExplorerState.newDocumentInvalid, enabled: false, visible: false });
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentNoEdits,
state: ViewModels.DocumentExplorerState.existingDocumentNoEdits,
enabled: false,
visible: true,
});
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid,
state: ViewModels.DocumentExplorerState.existingDocumentDirtyValid,
enabled: true,
visible: true,
});
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid,
state: ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid,
enabled: false,
visible: true,
});
@ -275,17 +275,17 @@ describe("Documents tab (noSql API)", () => {
testCases.add({ state: ViewModels.DocumentExplorerState.newDocumentValid, enabled: false, visible: false });
testCases.add({ state: ViewModels.DocumentExplorerState.newDocumentInvalid, enabled: false, visible: false });
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentNoEdits,
state: ViewModels.DocumentExplorerState.existingDocumentNoEdits,
enabled: false,
visible: true,
});
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid,
state: ViewModels.DocumentExplorerState.existingDocumentDirtyValid,
enabled: true,
visible: true,
});
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid,
state: ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid,
enabled: true,
visible: true,
});
@ -306,14 +306,14 @@ describe("Documents tab (noSql API)", () => {
testCases.add({ state: ViewModels.DocumentExplorerState.noDocumentSelected, enabled: false, visible: false });
testCases.add({ state: ViewModels.DocumentExplorerState.newDocumentValid, enabled: false, visible: false });
testCases.add({ state: ViewModels.DocumentExplorerState.newDocumentInvalid, enabled: false, visible: false });
testCases.add({ state: ViewModels.DocumentExplorerState.exisitingDocumentNoEdits, enabled: true, visible: true });
testCases.add({ state: ViewModels.DocumentExplorerState.existingDocumentNoEdits, enabled: true, visible: true });
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid,
state: ViewModels.DocumentExplorerState.existingDocumentDirtyValid,
enabled: true,
visible: true,
});
testCases.add({
state: ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid,
state: ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid,
enabled: true,
visible: true,
});

View File

@ -146,7 +146,7 @@ export const getDiscardNewDocumentChangesButtonState = (editorState: ViewModels.
export const getSaveExistingDocumentButtonState = (editorState: ViewModels.DocumentExplorerState) => ({
enabled: (() => {
switch (editorState) {
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.existingDocumentDirtyValid:
return true;
default:
return false;
@ -155,9 +155,9 @@ export const getSaveExistingDocumentButtonState = (editorState: ViewModels.Docum
visible: (() => {
switch (editorState) {
case ViewModels.DocumentExplorerState.exisitingDocumentNoEdits:
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid:
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.existingDocumentNoEdits:
case ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid:
case ViewModels.DocumentExplorerState.existingDocumentDirtyValid:
return true;
default:
return false;
@ -169,8 +169,8 @@ export const getSaveExistingDocumentButtonState = (editorState: ViewModels.Docum
export const getDiscardExistingDocumentChangesButtonState = (editorState: ViewModels.DocumentExplorerState) => ({
enabled: (() => {
switch (editorState) {
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid:
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid:
case ViewModels.DocumentExplorerState.existingDocumentDirtyValid:
return true;
default:
return false;
@ -179,9 +179,9 @@ export const getDiscardExistingDocumentChangesButtonState = (editorState: ViewMo
visible: (() => {
switch (editorState) {
case ViewModels.DocumentExplorerState.exisitingDocumentNoEdits:
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid:
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.existingDocumentNoEdits:
case ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid:
case ViewModels.DocumentExplorerState.existingDocumentDirtyValid:
return true;
default:
return false;
@ -368,7 +368,7 @@ const getNewDocumentButtonState = (editorState: ViewModels.DocumentExplorerState
enabled: (() => {
switch (editorState) {
case ViewModels.DocumentExplorerState.noDocumentSelected:
case ViewModels.DocumentExplorerState.exisitingDocumentNoEdits:
case ViewModels.DocumentExplorerState.existingDocumentNoEdits:
return true;
default:
return false;
@ -588,15 +588,15 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
const isEditorDirty = useCallback((): boolean => {
switch (editorState) {
case ViewModels.DocumentExplorerState.noDocumentSelected:
case ViewModels.DocumentExplorerState.exisitingDocumentNoEdits:
case ViewModels.DocumentExplorerState.existingDocumentNoEdits:
return false;
case ViewModels.DocumentExplorerState.newDocumentValid:
case ViewModels.DocumentExplorerState.newDocumentInvalid:
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid:
case ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid:
return true;
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid:
case ViewModels.DocumentExplorerState.existingDocumentDirtyValid:
return true;
default:
@ -685,7 +685,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
ids.push(id);
setDocumentIds(ids);
setEditorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
setEditorState(ViewModels.DocumentExplorerState.existingDocumentNoEdits);
TelemetryProcessor.traceSuccess(
Action.CreateDocument,
{
@ -759,7 +759,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
documentId.id(updatedDocument.id);
}
});
setEditorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
setEditorState(ViewModels.DocumentExplorerState.existingDocumentNoEdits);
TelemetryProcessor.traceSuccess(
Action.UpdateDocument,
{
@ -1179,7 +1179,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
setInitialDocumentContent(content);
const newState = documentId
? ViewModels.DocumentExplorerState.exisitingDocumentNoEdits
? ViewModels.DocumentExplorerState.existingDocumentNoEdits
: ViewModels.DocumentExplorerState.newDocumentValid;
setEditorState(newState);
}
@ -1193,7 +1193,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
newContent === initialDocumentContent &&
editorState !== ViewModels.DocumentExplorerState.newDocumentValid
) {
setEditorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
setEditorState(ViewModels.DocumentExplorerState.existingDocumentNoEdits);
return;
}
@ -1221,7 +1221,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
return;
}
setEditorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid);
setEditorState(ViewModels.DocumentExplorerState.existingDocumentDirtyValid);
};
const onInvalidDocumentEdit = (): void => {
@ -1234,10 +1234,10 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
}
if (
editorState === ViewModels.DocumentExplorerState.exisitingDocumentNoEdits ||
editorState === ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid
editorState === ViewModels.DocumentExplorerState.existingDocumentNoEdits ||
editorState === ViewModels.DocumentExplorerState.existingDocumentDirtyValid
) {
setEditorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid);
setEditorState(ViewModels.DocumentExplorerState.existingDocumentDirtyInvalid);
return;
}
};
@ -1280,7 +1280,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
// If only one selection, we consider as a click
if (selectedRows.size === 1) {
setEditorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
setEditorState(ViewModels.DocumentExplorerState.existingDocumentNoEdits);
}
setSelectedRows(selectedRows);
@ -1443,7 +1443,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
setSelectedDocumentContentBaseline(value);
setDocumentIds(ids);
setEditorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
setEditorState(ViewModels.DocumentExplorerState.existingDocumentNoEdits);
TelemetryProcessor.traceSuccess(
Action.CreateDocument,
{
@ -1514,7 +1514,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
documentId.id(id.id());
}
});
setEditorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
setEditorState(ViewModels.DocumentExplorerState.existingDocumentNoEdits);
TelemetryProcessor.traceSuccess(
Action.UpdateDocument,
{

View File

@ -53,7 +53,7 @@ export default abstract class ScriptTabBase extends TabsBase implements ViewMode
if (this.isNew()) {
this.editorState = ko.observable(ViewModels.ScriptEditorState.newInvalid);
} else {
this.editorState = ko.observable(ViewModels.ScriptEditorState.exisitingNoEdits);
this.editorState = ko.observable(ViewModels.ScriptEditorState.existingNoEdits);
}
this.id = editable.observable<string>();
@ -77,15 +77,15 @@ export default abstract class ScriptTabBase extends TabsBase implements ViewMode
this.editorState(ViewModels.ScriptEditorState.newInvalid);
}
break;
case ViewModels.ScriptEditorState.exisitingDirtyInvalid:
case ViewModels.ScriptEditorState.exisitingDirtyValid:
case ViewModels.ScriptEditorState.existingDirtyInvalid:
case ViewModels.ScriptEditorState.existingDirtyValid:
if (isValid) {
this.editorState(ViewModels.ScriptEditorState.exisitingDirtyValid);
this.editorState(ViewModels.ScriptEditorState.existingDirtyValid);
} else {
this.editorState(ViewModels.ScriptEditorState.exisitingDirtyInvalid);
this.editorState(ViewModels.ScriptEditorState.existingDirtyInvalid);
}
break;
case ViewModels.ScriptEditorState.exisitingDirtyValid:
case ViewModels.ScriptEditorState.existingDirtyValid:
default:
break;
}

View File

@ -404,7 +404,7 @@ export default class StoredProcedureTabComponent extends React.Component<
this.node = this.collection.createStoredProcedureNode(createdResource);
this.props.scriptTabBaseInstance.node = this.node;
useTabs.getState().updateTab(this.props.scriptTabBaseInstance);
this.props.scriptTabBaseInstance.editorState(ViewModels.ScriptEditorState.exisitingNoEdits);
this.props.scriptTabBaseInstance.editorState(ViewModels.ScriptEditorState.existingNoEdits);
this.setState({
executeButton: {

View File

@ -114,7 +114,7 @@ export class TriggerTabContent extends Component<TriggerTab, ITriggerTabContentS
},
startKey,
);
this.props.editorState(ViewModels.ScriptEditorState.exisitingNoEdits);
this.props.editorState(ViewModels.ScriptEditorState.existingNoEdits);
this.props.isExecuting(false);
}
} catch (createError) {

View File

@ -161,7 +161,7 @@ export default class UserDefinedFunctionTabContent extends Component<
},
startKey,
);
this.props.editorState(ViewModels.ScriptEditorState.exisitingNoEdits);
this.props.editorState(ViewModels.ScriptEditorState.existingNoEdits);
}
} catch (createError) {
this.props.isExecutionError(true);