Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/DataEntry/DataEntryTable/RecentEntry.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -90,7 +90,12 @@ export function RecentEntry(props: RecentEntryProps): ReactElement {
<Grid2 size={4} sx={{ px: 1 }}>
<VernWithSuggestions
vernacular={vernacular}
isDisabled={props.disabled || props.entry.senses.length > 1}
isDisabled={
props.disabled ||
props.entry.senses.length > 1 ||
props.entry.accessibility === Status.Protected ||
sense.accessibility === Status.Protected
}
updateVernField={updateVernField}
onBlur={() => conditionallyUpdateVern()}
handleEnter={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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", () => {
Expand Down
Loading