diff --git a/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx b/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx index 760c3f26..2b36e105 100644 --- a/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx +++ b/src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx @@ -1,6 +1,6 @@ import Statuses from "@/src/components/shared/statuses/Statuses"; import { selectAllLookupLists, setAllLookupLists } from "@/src/reduxStore/states/pages/lookup-lists"; -import { selectAttributes, selectVisibleAttributeAC, setAllAttributes, setLabelingTasksAll, updateAttributeById } from "@/src/reduxStore/states/pages/settings"; +import { selectAttributes, selectVisibleAttributeAC, selectVisibleAttributesWithoutPermissions, setAllAttributes, setLabelingTasksAll, updateAttributeById } from "@/src/reduxStore/states/pages/settings"; import { selectProjectId } from "@/src/reduxStore/states/project" import { Attribute, AttributeState, AttributeVisibility, AttributeWithOnClick, LLMConfig } from "@/src/types/components/projects/projectId/settings/data-schema"; import { DataTypeEnum } from "@/src/types/shared/general"; @@ -52,7 +52,7 @@ export default function AttributeCalculation() { const projectId = useSelector(selectProjectId); const attributes = useSelector(selectAttributes); - const usableAttributes = useSelector(selectVisibleAttributeAC) + const usableAttributes = useSelector(selectVisibleAttributesWithoutPermissions); const lookupLists = useSelector(selectAllLookupLists); const allUsers = useSelector(selectAllUsers); diff --git a/src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx b/src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx index f1795545..70c461c6 100644 --- a/src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx +++ b/src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx @@ -74,10 +74,12 @@ export default function ExecutionContainer(props: ExecutionContainerProps) { const sampleRecordsFinal = useMemo(() => { if (sampleRecords && sampleRecords.calculatedAttributesDisplay) { - return sampleRecords.calculatedAttributesDisplay.map((record: any) => { + return sampleRecords.calculatedAttributesDisplay.map((record: any, index) => { + const calculatedValue = currentAttributesRef.current.dataType != DataTypeEnum.EMBEDDING_LIST ? record : { id: record.id, value: JSON.parse(record.value) } return { ...record, - onClick: viewRecordDetails(record.id) + onClick: viewRecordDetails(index), + calculatedValue: calculatedValue } } ); @@ -130,7 +132,7 @@ export default function ExecutionContainer(props: ExecutionContainerProps) {
- {sampleRecordsFinal.map((record: any, index: number) => ( + {sampleRecordsFinal.map((record: any) => (
@@ -151,7 +153,7 @@ export default function ExecutionContainer(props: ExecutionContainerProps) {
} - +
) } \ No newline at end of file diff --git a/src/components/projects/projectId/attributes/attributeId/ViewRecordDetailsModal.tsx b/src/components/projects/projectId/attributes/attributeId/ViewRecordDetailsModal.tsx index b47ce748..007be4cd 100644 --- a/src/components/projects/projectId/attributes/attributeId/ViewRecordDetailsModal.tsx +++ b/src/components/projects/projectId/attributes/attributeId/ViewRecordDetailsModal.tsx @@ -24,10 +24,10 @@ export default function ViewRecordDetailsModal(props: ViewRecordDetailsModalProp
Calculated value
{props.currentAttribute.dataType != DataTypeEnum.EMBEDDING_LIST ? - {props.sampleRecords.calculatedAttributes[modalViewRecordDetails.recordIdx]} + {props.sampleRecords[modalViewRecordDetails.recordIdx].calculatedValue.value} :
- {props.sampleRecords.calculatedAttributesListDisplay[modalViewRecordDetails.recordIdx].map((item: any) => - {props.sampleRecords.calculatedAttributesList[modalViewRecordDetails.recordIdx]} + {props.sampleRecords[modalViewRecordDetails.recordIdx].calculatedValue.value.map((item: any) => + {item} )}
}
diff --git a/src/components/projects/projectId/data-browser/SearchGroups.tsx b/src/components/projects/projectId/data-browser/SearchGroups.tsx index 42b94e38..9c5a1b55 100644 --- a/src/components/projects/projectId/data-browser/SearchGroups.tsx +++ b/src/components/projects/projectId/data-browser/SearchGroups.tsx @@ -85,6 +85,7 @@ export default function SearchGroups() { }); colors.push('gray'); visibleAttributes.forEach((att) => { + if (att.dataType == DataTypeEnum.PERMISSION) return; attributesSort.push({ name: att.name, key: att.id, diff --git a/src/components/projects/projectId/heuristics/heuristicId/labeling-function/LabelingFunction.tsx b/src/components/projects/projectId/heuristics/heuristicId/labeling-function/LabelingFunction.tsx index f4daf388..1979a907 100644 --- a/src/components/projects/projectId/heuristics/heuristicId/labeling-function/LabelingFunction.tsx +++ b/src/components/projects/projectId/heuristics/heuristicId/labeling-function/LabelingFunction.tsx @@ -8,7 +8,7 @@ import { postProcessCurrentHeuristic, postProcessLastTaskLogs } from "@/src/util import { Tooltip } from "@nextui-org/react"; import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants"; import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper"; -import { selectVisibleAttributesHeuristics, selectLabelingTasksAll, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings"; +import { selectVisibleAttributesHeuristics, selectLabelingTasksAll, setLabelingTasksAll, selectVisibleAttributesWithoutPermissions } from "@/src/reduxStore/states/pages/settings"; import HeuristicsEditor from "../shared/HeuristicsEditor"; import DangerZone from "@/src/components/shared/danger-zone/DangerZone"; import HeuristicRunButtons from "../shared/HeuristicRunButtons"; @@ -46,7 +46,7 @@ export default function LabelingFunction() { const projectId = useSelector(selectProjectId); const currentHeuristic = useSelector(selectHeuristic); const labelingTasks = useSelector(selectLabelingTasksAll); - const attributes = useSelector(selectVisibleAttributesHeuristics); + const attributes = useSelector(selectVisibleAttributesWithoutPermissions); const allUsers = useSelector(selectAllUsers); const [lastTaskLogs, setLastTaskLogs] = useState([]); diff --git a/src/components/projects/projectId/heuristics/heuristicId/shared/HeuristicsLayout.tsx b/src/components/projects/projectId/heuristics/heuristicId/shared/HeuristicsLayout.tsx index ac8d2c89..de54a508 100644 --- a/src/components/projects/projectId/heuristics/heuristicId/shared/HeuristicsLayout.tsx +++ b/src/components/projects/projectId/heuristics/heuristicId/shared/HeuristicsLayout.tsx @@ -1,7 +1,7 @@ import Statuses from "@/src/components/shared/statuses/Statuses"; import { selectHeuristic, setActiveHeuristics, updateHeuristicsState } from "@/src/reduxStore/states/pages/heuristics"; import { selectAllLookupLists, setAllLookupLists } from "@/src/reduxStore/states/pages/lookup-lists"; -import { selectVisibleAttributesHeuristics, setAllAttributes } from "@/src/reduxStore/states/pages/settings"; +import { selectVisibleAttributesHeuristics, selectVisibleAttributesWithoutPermissions, setAllAttributes } from "@/src/reduxStore/states/pages/settings"; import { selectProjectId } from "@/src/reduxStore/states/project" import { HeuristicsProperty } from "@/src/types/components/projects/projectId/heuristics/heuristicId/heuristics-details"; import { Attribute } from "@/src/types/components/projects/projectId/settings/data-schema"; @@ -26,7 +26,7 @@ export default function HeuristicsLayout(props: any) { const projectId = useSelector(selectProjectId); const currentHeuristic = useSelector(selectHeuristic); - const usableAttributes = useSelector(selectVisibleAttributesHeuristics); + const usableAttributes = useSelector(selectVisibleAttributesWithoutPermissions); const lookupLists = useSelector(selectAllLookupLists); const [isHeaderNormal, setIsHeaderNormal] = useState(true); diff --git a/src/components/projects/projectId/playground/CreateEvaluationSetModal.tsx b/src/components/projects/projectId/playground/CreateEvaluationSetModal.tsx index 47a111ad..45d2489e 100644 --- a/src/components/projects/projectId/playground/CreateEvaluationSetModal.tsx +++ b/src/components/projects/projectId/playground/CreateEvaluationSetModal.tsx @@ -15,6 +15,7 @@ import { useCallback, useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import QuestionHistory from "./QuestionHistory"; import { MemoIconPlus, MemoIconWand } from "@/submodules/react-components/components/kern-icons/icons"; +import { postProcessUpdateAndSortRecords } from "@/submodules/javascript-functions/post-process-functions"; const ACCEPT_BUTTON = { buttonCaption: 'Create', useButton: true }; const SEARCH_REQUEST = { offset: 0, limit: 20 }; @@ -129,16 +130,7 @@ export default function CreateEvaluationSetModal(props: CreateEvaluationSetsModa } function updateAndSortRecordList(newRecords = []) { - setRecordList((prev) => { - const merged = [...prev, ...newRecords]; - const uniqueRecords = Array.from( - new Map(merged.map((item) => [item.data?.running_id, item])).values() - ); - uniqueRecords.sort( - (a, b) => (a.data?.running_id || 0) - (b.data?.running_id || 0) - ); - return uniqueRecords; - }); + setRecordList((prev) => postProcessUpdateAndSortRecords(prev, newRecords)); } function resetState() { diff --git a/src/components/shared/record-display/RecordDisplay.tsx b/src/components/shared/record-display/RecordDisplay.tsx index 80bd4da0..6af65606 100644 --- a/src/components/shared/record-display/RecordDisplay.tsx +++ b/src/components/shared/record-display/RecordDisplay.tsx @@ -3,11 +3,11 @@ import { selectAttributesDict } from "@/src/reduxStore/states/pages/settings"; import { LineBreaksType } from "@/src/types/components/projects/projectId/data-browser/data-browser"; import { Attribute } from "@/src/types/components/projects/projectId/settings/data-schema"; import { DataTypeEnum } from "@/src/types/shared/general"; -import { postProcessAttributes, postProcessRecord } from "@/src/util/shared/record-display-helper"; import { useEffect, useState } from "react"; import { useSelector } from "react-redux"; import Highlight from "../highlight/Highlight"; import { MemoIconAlertCircle } from "@/submodules/react-components/components/kern-icons/icons"; +import { postProcessAttributes, postProcessRecord } from "@/submodules/javascript-functions/post-process-functions"; export function RecordDisplay(props: any) { const attributesDict = useSelector(selectAttributesDict); @@ -33,8 +33,8 @@ export function RecordDisplay(props: any) {
{attributesDict[attribute.id] &&
- {attribute.dataType == DataTypeEnum.EMBEDDING_LIST ? (
- {preparedRecord.data[attributesDict[attribute.key].name] && preparedRecord.data[attributesDict[attribute.key].name].map((item, indexJ) => (
+ {attribute.dataType === DataTypeEnum.EMBEDDING_LIST || attribute.dataType === DataTypeEnum.PERMISSION ? (
+ {preparedRecord.data[attributesDict[attribute.key].name] ? preparedRecord.data[attributesDict[attribute.key].name].map((item, indexJ) => (
{(configuration.highlightText && isTextHighlightNeeded[attribute.key]) ? () : ( @@ -42,7 +42,7 @@ export function RecordDisplay(props: any) { {item != null && item !== '' ? item : } )} -
))} +
)) : }
) : (<> {(configuration.highlightText && isTextHighlightNeeded[attribute.key]) ? ( { + if (res.role == UserRole.ANNOTATOR || res.role == UserRole.EXPERT) { + window.location.href = '/cognition'; + return; + } const userInfo = { ...res }; userInfo.avatarUri = getUserAvatarUri(res); dispatch(setUser(userInfo)); @@ -106,6 +112,6 @@ export function GlobalStoreDataComponent(props: React.PropsWithChildren) { }) }, [ConfigManager.isInit()]); - if (!dataLoaded) return <>; + if (!dataLoaded || userRole !== UserRole.ENGINEER) return <>; return
{props.children}
; } diff --git a/src/reduxStore/states/pages/settings.ts b/src/reduxStore/states/pages/settings.ts index bf601170..fb802ad1 100644 --- a/src/reduxStore/states/pages/settings.ts +++ b/src/reduxStore/states/pages/settings.ts @@ -148,6 +148,7 @@ export const selectVisibleAttributesDataBrowser = createSelector([selectUsableAt export const selectVisibleAttributeAC = createSelector([selectUsableAttributesFiltered], (a): any => a ? a.filter((a) => a.visibility != AttributeVisibility.HIDE) : null); export const selectVisibleAttributesHeuristics = createSelector([selectUsableAttributesFiltered], (a): any => a ? a.filter((a) => a.visibility != AttributeVisibility.HIDE) : null); export const selectOnAttributeEmbeddings = createSelector([selectEmbeddings], (a): any => a ? a.filter((embedding) => embedding.type == EmbeddingType.ON_ATTRIBUTE && embedding.state == Status.FINISHED) : null); +export const selectVisibleAttributesWithoutPermissions = createSelector([selectUsableAttributesFiltered], (a): any => a ? a.filter((a) => a.dataType != DataTypeEnum.PERMISSION) : null); export const { setAllAttributes, extendAllAttributes, removeFromAllAttributesById, updateAttributeById, setAllEmbeddings, setFilteredEmbeddings, removeFromAllEmbeddingsById, setAllRecommendedEncodersDict, setRecommendedEncodersAll, setLabelingTasksAll, removeFromAllLabelingTasksById, removeLabelFromLabelingTask } = settingsSlice.actions; export const settingsReducer = settingsSlice.reducer; \ No newline at end of file diff --git a/src/types/components/projects/projectId/settings/attribute-calculation.ts b/src/types/components/projects/projectId/settings/attribute-calculation.ts index 0258b96a..e7af548d 100644 --- a/src/types/components/projects/projectId/settings/attribute-calculation.ts +++ b/src/types/components/projects/projectId/settings/attribute-calculation.ts @@ -15,6 +15,7 @@ export type SampleRecord = { calculatedAttributesList: any[]; calculatedAttributesDisplay: any[]; calculatedAttributesListDisplay: any[]; + id: number; }; export type ContainerLogsProps = { @@ -31,7 +32,7 @@ export type Record = { export type ViewRecordDetailsModalProps = { currentAttribute: Attribute; - sampleRecords: SampleRecord; + sampleRecords: any; } export type ConfirmExecutionModalProps = { diff --git a/src/types/shared/general.ts b/src/types/shared/general.ts index 4cee791c..75ae07ee 100644 --- a/src/types/shared/general.ts +++ b/src/types/shared/general.ts @@ -20,5 +20,6 @@ export enum DataTypeEnum { FLOAT = "FLOAT", BOOLEAN = "BOOLEAN", EMBEDDING_LIST = "EMBEDDING_LIST", - LLM_RESPONSE = "LLM_RESPONSE" + LLM_RESPONSE = "LLM_RESPONSE", + PERMISSION = "PERMISSION", } \ No newline at end of file diff --git a/src/util/components/projects/projectId/settings/data-schema-helper.ts b/src/util/components/projects/projectId/settings/data-schema-helper.ts index 421c46e8..def7053a 100644 --- a/src/util/components/projects/projectId/settings/data-schema-helper.ts +++ b/src/util/components/projects/projectId/settings/data-schema-helper.ts @@ -10,6 +10,7 @@ export const DATA_TYPES = [ { name: 'Boolean', value: 'BOOLEAN' }, { name: 'Embedding List', value: 'EMBEDDING_LIST' }, { name: 'LLM Response', value: 'LLM_RESPONSE' }, + { name: 'Permission', value: 'PERMISSION' }, ]; export const ATTRIBUTES_VISIBILITY_STATES = [ diff --git a/src/util/shared/record-display-helper.ts b/src/util/shared/record-display-helper.ts deleted file mode 100644 index 45c925ca..00000000 --- a/src/util/shared/record-display-helper.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Attribute } from "@/src/types/components/projects/projectId/settings/data-schema"; -import { jsonCopy } from "@/submodules/javascript-functions/general"; - -export function postProcessRecord(record: any, attributes: Attribute[]) { - const prepareRecord = jsonCopy(record); - if (!prepareRecord.hasOwnProperty('data')) { - if (prepareRecord.hasOwnProperty('fullRecordData')) { - prepareRecord.data = prepareRecord.fullRecordData; - } - else if (prepareRecord.hasOwnProperty('recordData')) { - prepareRecord.data = prepareRecord.recordData; - } else { - throw new Error("Cant find record data in record object"); - } - } - attributes.forEach((attribute, index) => { - if (typeof prepareRecord.data[attribute.name] === 'boolean') { - prepareRecord.data[attribute.name] = prepareRecord.data[attribute.name].toString(); - } - }); - return prepareRecord; -} - -export function postProcessAttributes(attributes: Attribute[]) { - const prepareAttributes = jsonCopy(attributes); - if (attributes && attributes.length > 0) { - if (!attributes[0].hasOwnProperty('key')) { - prepareAttributes.forEach((attribute, index) => { - if (attribute.id !== null) { - attribute.key = attribute.id; - } else { - throw new Error("Cant find attribute id in attribute object"); - } - }); - } - } - return prepareAttributes; -} \ No newline at end of file diff --git a/submodules/javascript-functions b/submodules/javascript-functions index 5a070394..be97756c 160000 --- a/submodules/javascript-functions +++ b/submodules/javascript-functions @@ -1 +1 @@ -Subproject commit 5a070394a45b5ed5a86efd0fc42370331e0ab101 +Subproject commit be97756ca607b1f479b246913a6df9cab71510fb diff --git a/submodules/react-components b/submodules/react-components index 1af9f210..0464f210 160000 --- a/submodules/react-components +++ b/submodules/react-components @@ -1 +1 @@ -Subproject commit 1af9f210f292f5e6ea23a2cbb3f9f8619650eec8 +Subproject commit 0464f210a6d3a85624a6c78445568c45e0a9fca4