Skip to content

Commit

Permalink
Merge branch 'master' into merge1
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec authored Jan 13, 2025
2 parents ec51d17 + 293e202 commit a7e2dd1
Show file tree
Hide file tree
Showing 22 changed files with 81 additions and 89 deletions.
2 changes: 1 addition & 1 deletion Backend.Tests/Models/ProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void TestClone()
LiftImported = true,
DefinitionsEnabled = true,
GrammaticalInfoEnabled = true,
AutocompleteSetting = AutocompleteSetting.On,
AutocompleteSetting = OffOnSetting.On,
SemDomWritingSystem = new("fr", "Français"),
VernacularWritingSystem = new("en", "English", "Calibri"),
AnalysisWritingSystems = new() { new("es", "Español") },
Expand Down
8 changes: 4 additions & 4 deletions Backend/Models/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class Project
[Required]
[BsonElement("autocompleteSetting")]
[BsonRepresentation(BsonType.String)]
public AutocompleteSetting AutocompleteSetting { get; set; }
public OffOnSetting AutocompleteSetting { get; set; }

[Required]
[BsonElement("semDomWritingSystem")]
Expand Down Expand Up @@ -92,7 +92,7 @@ public Project()
LiftImported = false;
DefinitionsEnabled = false;
GrammaticalInfoEnabled = false;
AutocompleteSetting = AutocompleteSetting.On;
AutocompleteSetting = OffOnSetting.On;
SemDomWritingSystem = new();
VernacularWritingSystem = new();
AnalysisWritingSystems = new();
Expand Down Expand Up @@ -186,10 +186,10 @@ public override int GetHashCode()
var hash = new HashCode();
hash.Add(Id);
hash.Add(Name);
hash.Add(IsActive);
hash.Add(LiftImported);
hash.Add(DefinitionsEnabled);
hash.Add(GrammaticalInfoEnabled);
hash.Add(IsActive);
hash.Add(AutocompleteSetting);
hash.Add(SemDomWritingSystem);
hash.Add(VernacularWritingSystem);
Expand Down Expand Up @@ -329,7 +329,7 @@ public UserCreatedProject()
}
}

public enum AutocompleteSetting
public enum OffOnSetting
{
Off,
On
Expand Down
4 changes: 2 additions & 2 deletions Backend/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class User
[Required]
[BsonElement("glossSuggestion")]
[BsonRepresentation(BsonType.String)]
public AutocompleteSetting GlossSuggestion { get; set; }
public OffOnSetting GlossSuggestion { get; set; }

[Required]
[BsonElement("token")]
Expand All @@ -98,7 +98,7 @@ public User()
Password = "";
Username = "";
UILang = "";
GlossSuggestion = AutocompleteSetting.On;
GlossSuggestion = OffOnSetting.On;
Token = "";
IsAdmin = false;
WorkedProjects = new();
Expand Down
2 changes: 1 addition & 1 deletion src/api/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ common.ts
configuration.ts
git_push.sh
index.ts
models/autocomplete-setting.ts
models/banner-type.ts
models/chart-root-data.ts
models/consent-type.ts
Expand All @@ -42,6 +41,7 @@ models/merge-source-word.ts
models/merge-undo-ids.ts
models/merge-words.ts
models/note.ts
models/off-on-setting.ts
models/password-reset-data.ts
models/password-reset-request-data.ts
models/permission.ts
Expand Down
2 changes: 1 addition & 1 deletion src/api/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./autocomplete-setting";
export * from "./banner-type";
export * from "./chart-root-data";
export * from "./consent-type";
Expand All @@ -18,6 +17,7 @@ export * from "./merge-source-word";
export * from "./merge-undo-ids";
export * from "./merge-words";
export * from "./note";
export * from "./off-on-setting";
export * from "./password-reset-data";
export * from "./password-reset-request-data";
export * from "./permission";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @export
* @enum {string}
*/
export enum AutocompleteSetting {
export enum OffOnSetting {
Off = "Off",
On = "On",
}
6 changes: 3 additions & 3 deletions src/api/models/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
* Do not edit the class manually.
*/

import { AutocompleteSetting } from "./autocomplete-setting";
import { CustomField } from "./custom-field";
import { EmailInvite } from "./email-invite";
import { OffOnSetting } from "./off-on-setting";
import { SemanticDomainFull } from "./semantic-domain-full";
import { WritingSystem } from "./writing-system";

Expand Down Expand Up @@ -62,10 +62,10 @@ export interface Project {
grammaticalInfoEnabled: boolean;
/**
*
* @type {AutocompleteSetting}
* @type {OffOnSetting}
* @memberof Project
*/
autocompleteSetting: AutocompleteSetting;
autocompleteSetting: OffOnSetting;
/**
*
* @type {WritingSystem}
Expand Down
14 changes: 7 additions & 7 deletions src/api/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Do not edit the class manually.
*/

import { AutocompleteSetting } from "./autocomplete-setting";
import { OffOnSetting } from "./off-on-setting";

/**
*
Expand Down Expand Up @@ -100,20 +100,20 @@ export interface User {
uiLang?: string | null;
/**
*
* @type {string}
* @type {OffOnSetting}
* @memberof User
*/
token: string;
glossSuggestion: OffOnSetting;
/**
*
* @type {boolean}
* @type {string}
* @memberof User
*/
isAdmin: boolean;
token: string;
/**
*
* @type {AutocompleteSetting}
* @type {boolean}
* @memberof User
*/
glossSuggestion: AutocompleteSetting;
isAdmin: boolean;
}
7 changes: 3 additions & 4 deletions src/components/DataEntry/DataEntryTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { useTranslation } from "react-i18next";
import { v4 } from "uuid";

import {
AutocompleteSetting,
Note,
OffOnSetting,
Pronunciation,
SemanticDomain,
SemanticDomainTreeNode,
Expand Down Expand Up @@ -250,8 +250,7 @@ export default function DataEntryTable(
);
const suggestVerns = useAppSelector(
(state: StoreState) =>
state.currentProjectState.project.autocompleteSetting ===
AutocompleteSetting.On
state.currentProjectState.project.autocompleteSetting === OffOnSetting.On
);
const vernacularLang = useAppSelector(
(state: StoreState) =>
Expand All @@ -272,7 +271,7 @@ export default function DataEntryTable(
const spellChecker = useContext(SpellCheckerContext);
useEffect(() => {
spellChecker.updateLang(
getCurrentUser()?.glossSuggestion === AutocompleteSetting.Off
getCurrentUser()?.glossSuggestion === OffOnSetting.Off
? undefined
: analysisLang.bcp47
);
Expand Down
10 changes: 5 additions & 5 deletions src/components/ProjectSettings/ProjectAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Grid, MenuItem, Select, Tooltip } from "@mui/material";
import { type ReactElement } from "react";
import { useTranslation } from "react-i18next";

import { AutocompleteSetting } from "api/models";
import { OffOnSetting } from "api/models";
import { type ProjectSettingProps } from "components/ProjectSettings/ProjectSettingsTypes";

export default function ProjectAutocomplete(
Expand All @@ -12,7 +12,7 @@ export default function ProjectAutocomplete(
const { t } = useTranslation();

const updateAutocompleteSetting = async (
autocompleteSetting: AutocompleteSetting
autocompleteSetting: OffOnSetting
): Promise<void> => {
await props.setProject({ ...props.project, autocompleteSetting });
};
Expand All @@ -24,13 +24,13 @@ export default function ProjectAutocomplete(
variant="standard"
value={props.project.autocompleteSetting}
onChange={(e) =>
updateAutocompleteSetting(e.target.value as AutocompleteSetting)
updateAutocompleteSetting(e.target.value as OffOnSetting)
}
>
<MenuItem value={AutocompleteSetting.Off}>
<MenuItem value={OffOnSetting.Off}>
{t("projectSettings.autocomplete.off")}
</MenuItem>
<MenuItem value={AutocompleteSetting.On}>
<MenuItem value={OffOnSetting.On}>
{t("projectSettings.autocomplete.on")}
</MenuItem>
</Select>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Select } from "@mui/material";
import renderer from "react-test-renderer";

import { AutocompleteSetting } from "api/models";
import { OffOnSetting } from "api/models";
import ProjectAutocomplete from "components/ProjectSettings/ProjectAutocomplete";
import { randomProject } from "types/project";

Expand All @@ -26,12 +26,12 @@ describe("ProjectAutocomplete", () => {
await renderer.act(async () => selectChange({ target: { value: "Off" } }));
expect(mockSetProject).toHaveBeenCalledWith({
...mockProject,
autocompleteSetting: AutocompleteSetting.Off,
autocompleteSetting: OffOnSetting.Off,
});
await renderer.act(async () => selectChange({ target: { value: "On" } }));
expect(mockSetProject).toHaveBeenCalledWith({
...mockProject,
autocompleteSetting: AutocompleteSetting.On,
autocompleteSetting: OffOnSetting.On,
});
});
});
8 changes: 4 additions & 4 deletions src/components/UserSettings/UserSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { FormEvent, Fragment, ReactElement, useState } from "react";
import { useTranslation } from "react-i18next";
import { show } from "vanilla-cookieconsent";

import { AutocompleteSetting, User } from "api/models";
import { OffOnSetting, User } from "api/models";
import { isEmailTaken, updateUser } from "backend";
import { getAvatar, getCurrentUser } from "backend/localStorage";
import { asyncLoadSemanticDomains } from "components/Project/ProjectActions";
Expand Down Expand Up @@ -252,15 +252,15 @@ export function UserSettings(props: {
data-testid={UserSettingsIds.SelectGlossSuggestion}
id={UserSettingsIds.SelectGlossSuggestion}
onChange={(e) =>
setGlossSuggestion(e.target.value as AutocompleteSetting)
setGlossSuggestion(e.target.value as OffOnSetting)
}
value={glossSuggestion}
variant="standard"
>
<MenuItem value={AutocompleteSetting.Off}>
<MenuItem value={OffOnSetting.Off}>
{t("projectSettings.autocomplete.off")}
</MenuItem>
<MenuItem value={AutocompleteSetting.On}>
<MenuItem value={OffOnSetting.On}>
{t("projectSettings.autocomplete.on")}
</MenuItem>
</Select>
Expand Down
35 changes: 14 additions & 21 deletions src/goals/MergeDuplicates/MergeDupsStep/MergeDragDrop/DragSense.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import { Card } from "@mui/material";
import { ReactElement, useCallback, useEffect, useState } from "react";
import { type ReactElement, useCallback, useEffect, useState } from "react";
import { Draggable } from "react-beautiful-dnd";

import { trashId } from "goals/MergeDuplicates/MergeDupsStep/MergeDragDrop";
import SenseCardContent from "goals/MergeDuplicates/MergeDupsStep/SenseCardContent";
import { MergeTreeSense } from "goals/MergeDuplicates/MergeDupsTreeTypes";
import {
type MergeTreeReference,
type MergeTreeSense,
} from "goals/MergeDuplicates/MergeDupsTreeTypes";
import { setSidebar } from "goals/MergeDuplicates/Redux/MergeDupsActions";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import theme from "types/theme";

interface DragSenseProps {
index: number;
wordId: string;
mergeSenseId: string;
mergeSenses: MergeTreeSense[];
isOnlySenseInProtectedWord: boolean;
isProtectedSense: boolean;
mergeSenses: MergeTreeSense[];
senseRef: MergeTreeReference;
}

function arraysEqual<T>(arr1: T[], arr2: T[]): boolean {
Expand Down Expand Up @@ -45,17 +46,13 @@ export default function DragSense(props: DragSenseProps): ReactElement {
(state: StoreState) => state.mergeDuplicateGoal.tree.sidebar
);
const isInSidebar =
sidebar.wordId === props.wordId &&
sidebar.mergeSenseId === props.mergeSenseId &&
sidebar.senseRef.wordId === props.senseRef.wordId &&
sidebar.senseRef.mergeSenseId === props.senseRef.mergeSenseId &&
sidebar.mergeSenses.length > 1;

const updateSidebar = useCallback(() => {
dispatch(
setSidebar({
mergeSenses: props.mergeSenses,
wordId: props.wordId,
mergeSenseId: props.mergeSenseId,
})
setSidebar({ mergeSenses: props.mergeSenses, senseRef: props.senseRef })
);
}, [dispatch, props]);

Expand Down Expand Up @@ -88,12 +85,8 @@ export default function DragSense(props: DragSenseProps): ReactElement {

return (
<Draggable
key={props.mergeSenseId}
draggableId={JSON.stringify({
wordId: props.wordId,
mergeSenseId: props.mergeSenseId,
isSenseProtected: props.isProtectedSense,
})}
key={props.senseRef.mergeSenseId}
draggableId={JSON.stringify(props.senseRef)}
index={props.index}
isDragDisabled={props.isOnlySenseInProtectedWord}
>
Expand All @@ -109,13 +102,13 @@ export default function DragSense(props: DragSenseProps): ReactElement {
minWidth: 150,
maxWidth: 300,
opacity:
!props.isProtectedSense &&
!props.senseRef.isSenseProtected &&
(snapshot.draggingOver === trashId || snapshot.combineWith)
? 0.7
: 1,
background: isInSidebar
? "lightblue"
: props.isProtectedSense
: props.senseRef.isSenseProtected
? "lightyellow"
: snapshot.draggingOver === trashId
? "red"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ export default function DropWord(props: DropWordProps): ReactElement {
<DragSense
key={id}
index={index}
wordId={props.wordId}
mergeSenseId={id}
mergeSenses={senses}
senseRef={{
isSenseProtected: senses[0].protected,
mergeSenseId: id,
wordId: props.wordId,
}}
isOnlySenseInProtectedWord={protectedWithOneChild}
isProtectedSense={senses[0].protected}
/>
);
})}
Expand Down
Loading

0 comments on commit a7e2dd1

Please sign in to comment.