diff --git a/src/components/DataEntry/DataEntryTable/RecentEntry.tsx b/src/components/DataEntry/DataEntryTable/RecentEntry.tsx index b6f0e68aa5..31ff99e20b 100644 --- a/src/components/DataEntry/DataEntryTable/RecentEntry.tsx +++ b/src/components/DataEntry/DataEntryTable/RecentEntry.tsx @@ -1,7 +1,7 @@ import { Grid2 } from "@mui/material"; import { ReactElement, memo, useState } from "react"; -import { Pronunciation, Word, WritingSystem } from "api/models"; +import { Pronunciation, Status, Word, WritingSystem } from "api/models"; import NoteButton from "components/Buttons/NoteButton"; import { DeleteEntry, @@ -90,7 +90,12 @@ export function RecentEntry(props: RecentEntryProps): ReactElement { 1} + isDisabled={ + props.disabled || + props.entry.senses.length > 1 || + props.entry.accessibility === Status.Protected || + sense.accessibility === Status.Protected + } updateVernField={updateVernField} onBlur={() => conditionallyUpdateVern()} handleEnter={() => { diff --git a/src/components/DataEntry/DataEntryTable/tests/RecentEntry.test.tsx b/src/components/DataEntry/DataEntryTable/tests/RecentEntry.test.tsx index 81e77d24e2..9318d91554 100644 --- a/src/components/DataEntry/DataEntryTable/tests/RecentEntry.test.tsx +++ b/src/components/DataEntry/DataEntryTable/tests/RecentEntry.test.tsx @@ -5,7 +5,7 @@ import userEvent, { UserEvent } from "@testing-library/user-event"; import { Provider } from "react-redux"; import configureMockStore from "redux-mock-store"; -import { Word } from "api/models"; +import { Status, Word } from "api/models"; import RecentEntry, { RecentEntryIdPrefix, } from "components/DataEntry/DataEntryTable/RecentEntry"; @@ -132,6 +132,26 @@ describe("ExistingEntry", () => { await agent.click(glossField); expect(mockUpdateVern).toHaveBeenCalledWith(0, mockText); }); + + it("disables vernacular if word is protected", async () => { + const protectedWord: Word = { + ...mockWord, + accessibility: Status.Protected, + }; + await renderWithWord(protectedWord); + const { vernField } = getVernAndGlossFields(); + expect(vernField).toBeDisabled(); + }); + + it("disables vernacular if sense is protected", async () => { + const protectedSenseWord: Word = { + ...mockWord, + senses: [{ ...mockWord.senses[0], accessibility: Status.Protected }], + }; + await renderWithWord(protectedSenseWord); + const { vernField } = getVernAndGlossFields(); + expect(vernField).toBeDisabled(); + }); }); describe("gloss", () => {