diff --git a/src/components/projects/ProjectCard.tsx b/src/components/projects/ProjectCard.tsx index 41870b71..c0f4097c 100644 --- a/src/components/projects/ProjectCard.tsx +++ b/src/components/projects/ProjectCard.tsx @@ -65,6 +65,9 @@ export default function ProjectCard(props: ProjectCardProps) { {props.project.time} } } + {props.project.is_integration_project &&
+ This is an integration project, please do not delete it unless the integration is deleted +
} {(isAdmin && props.project.status !== ProjectStatus.INIT_SAMPLE_PROJECT) &&
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/projects/projectId/settings/CreateNewAttributeModal.tsx b/src/components/projects/projectId/settings/CreateNewAttributeModal.tsx index 4e34be4c..8edec2ac 100644 --- a/src/components/projects/projectId/settings/CreateNewAttributeModal.tsx +++ b/src/components/projects/projectId/settings/CreateNewAttributeModal.tsx @@ -12,7 +12,7 @@ import { toPythonFunctionName } from "@/submodules/javascript-functions/python-f import KernDropdown from "@/submodules/react-components/components/KernDropdown"; import { Tooltip } from "@nextui-org/react"; import { useRouter } from "next/router"; -import { useCallback, useEffect, useState } from "react"; +import { useCallback, useEffect, useMemo, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; const ACCEPT_BUTTON = { buttonCaption: "Accept", useButton: true, disabled: true } @@ -58,6 +58,10 @@ export default function CreateNewAttributeModal() { setDuplicateNameExists(checkName); } + const filteredDataTypes = useMemo(() => { + return DATA_TYPES.filter(type => type.value !== 'PERMISSION'); + }, []); + return (
Add new attribute
@@ -73,7 +77,7 @@ export default function CreateNewAttributeModal() { Attribute type - setAttributeType(option)} /> + setAttributeType(option)} />
{duplicateNameExists &&
Attribute name exists
} {attributeType.name == 'Embedding List' &&
diff --git a/src/components/projects/projectId/settings/ProjectMetaData.tsx b/src/components/projects/projectId/settings/ProjectMetaData.tsx index 455a35ed..68eaf679 100644 --- a/src/components/projects/projectId/settings/ProjectMetaData.tsx +++ b/src/components/projects/projectId/settings/ProjectMetaData.tsx @@ -85,6 +85,9 @@ export default function ProjectMetaData() {
Danger zone
This action can not be reversed. Are you sure you want to delete this project?
+ {project.is_integration_project &&
+ This is an integration project, please do not delete it unless the integration is deleted +
}
{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/components/projects/projects-list.ts b/src/types/components/projects/projects-list.ts index ed82c159..8be362f8 100644 --- a/src/types/components/projects/projects-list.ts +++ b/src/types/components/projects/projects-list.ts @@ -14,6 +14,7 @@ export type Project = { timeStamp: string; date: string; time: string + is_integration_project: boolean; } export enum ProjectStatus { 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 31880f7e..dcbd2e81 160000 --- a/submodules/javascript-functions +++ b/submodules/javascript-functions @@ -1 +1 @@ -Subproject commit 31880f7ee0dcc7c559aea03dca064f1f338daa3f +Subproject commit dcbd2e811fdf0f3f950ec0a612371fd38f6152b7 diff --git a/submodules/react-components b/submodules/react-components index 660d4ef6..94c030a7 160000 --- a/submodules/react-components +++ b/submodules/react-components @@ -1 +1 @@ -Subproject commit 660d4ef6c3a1046a257ce2e1d0158ff7364b5dd2 +Subproject commit 94c030a73b3d191adac3a679edf6c084301a69a1