From 821486d5e149651c977af14c5bca788a0b6a6cf5 Mon Sep 17 00:00:00 2001 From: SahilCs15 Date: Tue, 6 Oct 2026 17:39:07 +0530 Subject: [PATCH] feat(visual-builder): show fields disabled while the entry is locked by another session (DRFT-925) Adds the entryLocked restriction and its message, so the canvas blocks inline edits after a collaborator saves until the entry is reloaded. --- src/visualBuilder/utils/__test__/entryEditRestriction.test.ts | 4 ++++ src/visualBuilder/utils/fieldLockIndicator.ts | 2 ++ src/visualBuilder/utils/fieldLockStore.ts | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/visualBuilder/utils/__test__/entryEditRestriction.test.ts b/src/visualBuilder/utils/__test__/entryEditRestriction.test.ts index 45426191..6c220f34 100644 --- a/src/visualBuilder/utils/__test__/entryEditRestriction.test.ts +++ b/src/visualBuilder/utils/__test__/entryEditRestriction.test.ts @@ -55,6 +55,10 @@ describe("getEntryEditRestrictionForField", () => { expect(getEntryEditRestrictionForField(meta())).toBe( ENTRY_RESTRICTION_MESSAGES.unlocalized ); + setEntryEditRestriction(scope, "entryLocked"); + expect(getEntryEditRestrictionForField(meta())).toBe( + ENTRY_RESTRICTION_MESSAGES.entryLocked + ); setEntryEditRestriction(scope, "unsavedVariant"); expect(getEntryEditRestrictionForField(meta())).toBe( ENTRY_RESTRICTION_MESSAGES.unsavedVariant diff --git a/src/visualBuilder/utils/fieldLockIndicator.ts b/src/visualBuilder/utils/fieldLockIndicator.ts index bb435051..7f7aec22 100644 --- a/src/visualBuilder/utils/fieldLockIndicator.ts +++ b/src/visualBuilder/utils/fieldLockIndicator.ts @@ -66,6 +66,8 @@ export function getPeerLockForField( export const ENTRY_RESTRICTION_MESSAGES: Record = { olderVersion: "You're viewing an older version of this entry. Switch to the latest version to edit.", + entryLocked: + "This entry was updated by someone else. Reload the entry to keep editing.", unlocalized: "This entry isn't localized in this language yet. Save it from the form to localize it, then edit here.", unsavedVariant: diff --git a/src/visualBuilder/utils/fieldLockStore.ts b/src/visualBuilder/utils/fieldLockStore.ts index b5b97db4..9a011504 100644 --- a/src/visualBuilder/utils/fieldLockStore.ts +++ b/src/visualBuilder/utils/fieldLockStore.ts @@ -30,6 +30,7 @@ export type EntryFieldLockInfo = Record; /** Why the parent has turned editing off for a whole entry scope. */ export type EntryEditRestriction = | "olderVersion" + | "entryLocked" | "unlocalized" | "unsavedVariant"; @@ -122,6 +123,7 @@ export function getEntryEditRestrictionWriteSeq(): number { const RESTRICTIONS: ReadonlySet = new Set([ "olderVersion", + "entryLocked", "unlocalized", "unsavedVariant", ]);