Skip to content

Commit 65664e9

Browse files
Text list attribute changes on data browser, heuristivcs and settings
1 parent f5974aa commit 65664e9

File tree

9 files changed

+36
-18
lines changed

9 files changed

+36
-18
lines changed

src/components/projects/projectId/data-browser/DataBrowser.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function DataBrowser() {
4343
const [clearRequest, setClearRequest] = useState(false);
4444

4545
useEffect(() => {
46-
if (!projectId) return;
46+
if (!projectId || !attributes) return;
4747
if (!users || !user) return;
4848
refetchDataSlicesAndProcess();
4949
refetchAttributesAndProcess();
@@ -52,11 +52,11 @@ export default function DataBrowser() {
5252
}, [projectId, users, user]);
5353

5454
useEffect(() => {
55-
if (!attributes || attributes.length == 0 || !projectId) return;
55+
if (!projectId || !attributes) return;
5656
getUniqueValuesByAttributes(projectId, (res) => {
5757
dispatch(setUniqueValuesDict(postProcessUniqueValues(res, attributes)));
5858
});
59-
}, [attributes, projectId]);
59+
}, [projectId, attributes]);
6060

6161
useEffect(() => {
6262
if (!projectId || !labelingTasks || !recordList) return;

src/components/projects/projectId/data-browser/RecordList.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import SimilaritySearchModal from "./modals/SimilaritySeachModal";
1515
import RecordCommentsModal from "./modals/RecordCommentsModal";
1616
import ButtonAsText from "@/submodules/react-components/components/kern-button/ButtonAsText";
1717
import { MemoIconAngle, MemoIconArrowRight, MemoIconEdit, MemoIconNotes } from "@/submodules/react-components/components/kern-icons/icons";
18+
import { useEffect, useMemo } from "react";
19+
import { selectAllProjects, selectProject, setAllProjects } from "@/src/reduxStore/states/project";
20+
import { getAllProjects } from "@/src/services/base/project";
1821

1922
export default function RecordList(props: RecordListProps) {
2023
const dispatch = useDispatch();
@@ -25,6 +28,16 @@ export default function RecordList(props: RecordListProps) {
2528
const embeddings = useSelector(selectEmbeddings);
2629
const recordComments = useSelector(selectRecordComments);
2730
const attributes = useSelector(selectVisibleAttributesDataBrowser);
31+
const project = useSelector(selectProject);
32+
const allProjects = useSelector(selectAllProjects);
33+
34+
useEffect(() => {
35+
getAllProjects((projects) => dispatch(setAllProjects(projects)));
36+
}, []);
37+
38+
const isIntegrationProject = useMemo(() => {
39+
return allProjects && allProjects.find(p => p.id === project.id)?.isIntegrationProject;
40+
}, [allProjects, project.id]);
2841

2942
return (<>
3043
{recordList && recordList.map((record, index) => (<div key={record.id} className="bg-white overflow-hidden shadow rounded-lg border mb-4 pb-4 relative">
@@ -71,7 +84,7 @@ export default function RecordList(props: RecordListProps) {
7184
</div>
7285
</div>
7386
</div>
74-
{user?.role == UserRole.ENGINEER && <div className="p-2 cursor-pointer absolute right-2 top-2">
87+
{(user?.role == UserRole.ENGINEER && !isIntegrationProject) && <div className="p-2 cursor-pointer absolute right-2 top-2">
7588
<Tooltip content={TOOLTIPS_DICT.DATA_BROWSER.EDIT_RECORD} color="invert">
7689
<MemoIconEdit className="h-4 w-4" onClick={() => props.editRecord(index)} />
7790
</Tooltip></div>}

src/components/projects/projectId/data-browser/SearchGroups.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ export default function SearchGroups(props: SearchGroupsProps) {
339339
}
340340
if (attributeType == DataTypeEnum.TEXT_LIST) {
341341
operatorsCopy.push({
342-
value: SearchOperator.EQUAL.split("_").join(" "),
342+
value: SearchOperator.CONTAINS.split("_").join(" "),
343343
});
344-
tooltipsCopy.push(getSearchOperatorTooltip(SearchOperator.EQUAL));
345-
formControlsIdx['operator'] = SearchOperator.EQUAL;
344+
tooltipsCopy.push(getSearchOperatorTooltip(SearchOperator.CONTAINS));
345+
formControlsIdx['operator'] = SearchOperator.CONTAINS;
346346

347347
} else if (attributeType !== DataTypeEnum.BOOLEAN) {
348348
for (let t of Object.values(SearchOperator)) {

src/components/projects/projectId/heuristics/heuristicId/labeling-function/LabelingFunction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { postProcessCurrentHeuristic, postProcessLastTaskLogs } from "@/src/util
88
import { Tooltip } from "@nextui-org/react";
99
import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants";
1010
import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper";
11-
import { selectVisibleAttributesHeuristics, selectLabelingTasksAll, setLabelingTasksAll, selectVisibleAttributesWithoutPermissions } from "@/src/reduxStore/states/pages/settings";
11+
import { selectLabelingTasksAll, setLabelingTasksAll, selectVisibleAttributesWithoutPermissions } from "@/src/reduxStore/states/pages/settings";
1212
import HeuristicsEditor from "../shared/HeuristicsEditor";
1313
import DangerZone from "@/src/components/shared/danger-zone/DangerZone";
1414
import HeuristicRunButtons from "../shared/HeuristicRunButtons";

src/components/projects/projectId/heuristics/heuristicId/labeling-function/SampleRecords.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function SampleRecords(props: SampleRecordProps) {
1616
<div className="divide-y divide-gray-200 bg-white" key={record.id}>
1717
<div className="flex-shrink-0 border-b border-gray-200 shadow-sm flex justify-between items-center">
1818
<div className="flex items-center text-xs leading-5 text-gray-500 font-normal mx-4 my-3 text-justify">
19-
{record.fullRecordData[props.selectedAttribute]}
19+
{Array.isArray(record.fullRecordData[props.selectedAttribute]) ? JSON.stringify(record.fullRecordData[props.selectedAttribute]) : record.fullRecordData[props.selectedAttribute]}
2020
</div>
2121
<div className="flex items-center justify-center mr-5 ml-auto">
2222
{Object.entries(record.calculatedLabelsResult).map(([key, value]: any) => (

src/components/projects/projectId/settings/labeling-tasks/LabelingTasks.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { openModal, setModalStates } from "@/src/reduxStore/states/modal";
2-
import { selectLabelingTasksAll, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings";
2+
import { selectAttributes, selectLabelingTasksAll, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings";
33
import { selectProjectId } from "@/src/reduxStore/states/project";
44
import { LabelType, LabelTypeWithOnClick, LabelingTask, LabelingTaskTaskType, LabelingTaskWithOnClick } from "@/src/types/components/projects/projectId/settings/labeling-tasks";
55
import { ModalEnum } from "@/src/types/shared/modal";
@@ -20,12 +20,15 @@ import { updateLabelingTask } from "@/src/services/base/labeling-tasks";
2020
import IconButton from "@/submodules/react-components/components/kern-button/IconButton";
2121
import KernButton from "@/submodules/react-components/components/kern-button/KernButton";
2222
import { MemoIconColorPicker, MemoIconPlus, MemoIconTrash } from "@/submodules/react-components/components/kern-icons/icons";
23+
import { DataTypeEnum } from "@/src/types/shared/general";
2324

2425
export default function LabelingTasks() {
2526
const dispatch = useDispatch();
2627

2728
const projectId = useSelector(selectProjectId);
2829
const labelingTasksSchema = useSelector(selectLabelingTasksAll);
30+
const attributes = useSelector(selectAttributes);
31+
2932

3033
const [labelingTasksDropdownArray, setLabelingTasksDropdownArray] = useState<{ name: string, value: string }[]>([]);
3134

@@ -102,9 +105,10 @@ export default function LabelingTasks() {
102105
...labelingTask,
103106
onDelete: () => dispatch(setModalStates(ModalEnum.DELETE_LABELING_TASK, { taskId: labelingTask.id, open: true })),
104107
labels: labelingTask.labels.map((label) => ({ ...label, onDelete: deleteLabel(labelingTask, label), onChangeColor: changeColorLabel(labelingTask, label) })),
108+
attributeType: attributes.find(att => att.name == labelingTask.targetName)?.dataType
105109
}
106110
))
107-
}, [labelingTasksSchema]);
111+
}, [labelingTasksSchema, attributes]);
108112

109113

110114
return (<div className="mt-8">
@@ -152,7 +156,7 @@ export default function LabelingTasks() {
152156
</td>
153157
<td className="whitespace-nowrap text-center px-3 py-2 text-sm text-gray-500">
154158
<KernDropdown options={labelingTasksDropdownArray} buttonName={labelingTaskToString(task.taskType)}
155-
disabledOptions={[false, task.targetName === 'Full Record', false]} dropdownWidth="w-60" dropdownItemsClasses="w-60"
159+
disabledOptions={[false, task.targetName === 'Full Record' || task.attributeType == DataTypeEnum.TEXT_LIST, false]} dropdownWidth="w-60" dropdownItemsClasses="w-60"
156160
selectedOption={(option: any) => updateLabelingTaskType(task, index, labelingTaskFromString(option.name))} />
157161
</td>
158162
<td className="flex flex-wrap justify-center items-center px-3 py-2 text-sm text-gray-500">

src/types/components/projects/projectId/settings/labeling-tasks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { DataTypeEnum } from "@/src/types/shared/general";
12
import { Attribute } from "./data-schema";
23

34
export type LabelingTask = {
@@ -16,6 +17,7 @@ export type LabelingTask = {
1617

1718
export type LabelingTaskWithOnClick = LabelingTask & {
1819
onDelete: () => void;
20+
attributeType: DataTypeEnum;
1921
}
2022

2123
export type LabelType = {

src/util/components/projects/projectId/data-browser/data-browser-helper.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,11 @@ export function postProcessUniqueValues(uniqueValues: any, attributesSortOrder:
179179
if (attributeType == DataTypeEnum.TEXT || attributeType == DataTypeEnum.LLM_RESPONSE) {
180180
delete uniqueValuesDict[key];
181181
} else if (attributeType == DataTypeEnum.TEXT_LIST) {
182-
uniqueValuesDict[key] = uniqueValuesDict[key].map((value: string) => {
183-
return JSON.parse(value);
184-
})[0];
182+
const uniqueSet = new Set<string>();
183+
for (const item of uniqueValuesDict[key]) {
184+
JSON.parse(item).forEach(str => uniqueSet.add(str));
185+
}
186+
uniqueValuesDict[key] = Array.from(uniqueSet);
185187
}
186188
}
187189
return uniqueValuesDict;

src/util/components/projects/projectId/data-browser/search-operators-helper.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,6 @@ export function prepareOperator(searchElement: any, attributeType: string): stri
135135
if (attributeType == "BOOLEAN") {
136136
return SearchOperator.EQUAL;
137137
} else {
138-
if (attributeType == DataTypeEnum.TEXT_LIST && searchElement.values.operator == SearchOperator.EQUAL) {
139-
return SearchOperator.CONTAINS;
140-
}
141138
return searchElement.values.operator;
142139
}
143140
}

0 commit comments

Comments
 (0)