Skip to content

Commit 7440f47

Browse files
authored
Merge pull request #74 from code-kern-ai/cognition-integration-provider
Added warning message for integration projects
2 parents 7ad256b + f5f0d75 commit 7440f47

File tree

20 files changed

+51
-73
lines changed

20 files changed

+51
-73
lines changed

src/components/projects/ProjectCard.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ export default function ProjectCard(props: ProjectCardProps) {
6565
<span className="text-sm text-gray-900 ">{props.project.time}</span>
6666
</>}
6767
</div>}
68+
{props.project.is_integration_project && <div className="absolute bottom-0 left-2/4 flex flex-row flex-nowrap gap-x-1 bg-gray-100 px-1 rounded-br rounded-bl" style={{ 'transform': 'translate(-50%' }}>
69+
<span className="text-sm text-red-500">This is an integration project, please do not delete it unless the integration is deleted</span>
70+
</div>}
6871
{(isAdmin && props.project.status !== ProjectStatus.INIT_SAMPLE_PROJECT) &&
6972
<div className="absolute top-0 left-0 cursor-pointer" onClick={adminOpenOrDeleteProjectFunc}>
7073
<Tooltip content={TOOLTIPS_DICT.PROJECTS.QUICK_DELETE} color="invert" offset={2} placement="right">

src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Statuses from "@/src/components/shared/statuses/Statuses";
22
import { selectAllLookupLists, setAllLookupLists } from "@/src/reduxStore/states/pages/lookup-lists";
3-
import { selectAttributes, selectVisibleAttributeAC, setAllAttributes, setLabelingTasksAll, updateAttributeById } from "@/src/reduxStore/states/pages/settings";
3+
import { selectAttributes, selectVisibleAttributeAC, selectVisibleAttributesWithoutPermissions, setAllAttributes, setLabelingTasksAll, updateAttributeById } from "@/src/reduxStore/states/pages/settings";
44
import { selectProjectId } from "@/src/reduxStore/states/project"
55
import { Attribute, AttributeState, AttributeVisibility, AttributeWithOnClick, LLMConfig } from "@/src/types/components/projects/projectId/settings/data-schema";
66
import { DataTypeEnum } from "@/src/types/shared/general";
@@ -52,7 +52,7 @@ export default function AttributeCalculation() {
5252

5353
const projectId = useSelector(selectProjectId);
5454
const attributes = useSelector(selectAttributes);
55-
const usableAttributes = useSelector(selectVisibleAttributeAC)
55+
const usableAttributes = useSelector(selectVisibleAttributesWithoutPermissions);
5656
const lookupLists = useSelector(selectAllLookupLists);
5757
const allUsers = useSelector(selectAllUsers);
5858

src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ export default function ExecutionContainer(props: ExecutionContainerProps) {
7474

7575
const sampleRecordsFinal = useMemo(() => {
7676
if (sampleRecords && sampleRecords.calculatedAttributesDisplay) {
77-
return sampleRecords.calculatedAttributesDisplay.map((record: any) => {
77+
return sampleRecords.calculatedAttributesDisplay.map((record: any, index) => {
78+
const calculatedValue = currentAttributesRef.current.dataType != DataTypeEnum.EMBEDDING_LIST ? record : { id: record.id, value: JSON.parse(record.value) }
7879
return {
7980
...record,
80-
onClick: viewRecordDetails(record.id)
81+
onClick: viewRecordDetails(index),
82+
calculatedValue: calculatedValue
8183
}
8284
}
8385
);
@@ -130,7 +132,7 @@ export default function ExecutionContainer(props: ExecutionContainerProps) {
130132
<div className="inline-block min-w-full align-middle">
131133
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
132134
<div className="min-w-full border divide-y divide-gray-300">
133-
{sampleRecordsFinal.map((record: any, index: number) => (
135+
{sampleRecordsFinal.map((record: any) => (
134136
<div key={record.id} className="divide-y divide-gray-200 bg-white">
135137
<div className="flex-shrink-0 border-b border-gray-200 shadow-sm flex justify-between items-center">
136138
<div className="flex items-center text-xs leading-5 text-gray-500 font-normal mx-4 my-3 text-justify">
@@ -151,7 +153,7 @@ export default function ExecutionContainer(props: ExecutionContainerProps) {
151153
</div>
152154
</div >}
153155

154-
<ViewRecordDetailsModal currentAttribute={props.currentAttribute} sampleRecords={sampleRecords} />
156+
<ViewRecordDetailsModal currentAttribute={props.currentAttribute} sampleRecords={sampleRecordsFinal} />
155157
<ConfirmExecutionModal currentAttributeId={props.currentAttribute.id} />
156158
</div >)
157159
}

src/components/projects/projectId/attributes/attributeId/ViewRecordDetailsModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export default function ViewRecordDetailsModal(props: ViewRecordDetailsModalProp
2424
<div className="text-sm leading-5 text-left text-gray-900 font-medium">Calculated value</div>
2525
<div className="text-sm leading-5 text-left text-gray-500 font-normal whitespace-pre-line">
2626
{props.currentAttribute.dataType != DataTypeEnum.EMBEDDING_LIST ? <span>
27-
{props.sampleRecords.calculatedAttributes[modalViewRecordDetails.recordIdx]}
27+
{props.sampleRecords[modalViewRecordDetails.recordIdx].calculatedValue.value}
2828
</span> : <div className="flex flex-col gap-y-2 divide-y">
29-
{props.sampleRecords.calculatedAttributesListDisplay[modalViewRecordDetails.recordIdx].map((item: any) => <span key={item.id} className="mt-1">
30-
{props.sampleRecords.calculatedAttributesList[modalViewRecordDetails.recordIdx]}
29+
{props.sampleRecords[modalViewRecordDetails.recordIdx].calculatedValue.value.map((item: any) => <span key={item} className="mt-1">
30+
{item}
3131
</span>)}
3232
</div>}
3333
</div>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export default function SearchGroups() {
8585
});
8686
colors.push('gray');
8787
visibleAttributes.forEach((att) => {
88+
if (att.dataType == DataTypeEnum.PERMISSION) return;
8889
attributesSort.push({
8990
name: att.name,
9091
key: att.id,

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

Lines changed: 2 additions & 2 deletions
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 } from "@/src/reduxStore/states/pages/settings";
11+
import { selectVisibleAttributesHeuristics, 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";
@@ -46,7 +46,7 @@ export default function LabelingFunction() {
4646
const projectId = useSelector(selectProjectId);
4747
const currentHeuristic = useSelector(selectHeuristic);
4848
const labelingTasks = useSelector(selectLabelingTasksAll);
49-
const attributes = useSelector(selectVisibleAttributesHeuristics);
49+
const attributes = useSelector(selectVisibleAttributesWithoutPermissions);
5050
const allUsers = useSelector(selectAllUsers);
5151

5252
const [lastTaskLogs, setLastTaskLogs] = useState<string[]>([]);

src/components/projects/projectId/heuristics/heuristicId/shared/HeuristicsLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Statuses from "@/src/components/shared/statuses/Statuses";
22
import { selectHeuristic, setActiveHeuristics, updateHeuristicsState } from "@/src/reduxStore/states/pages/heuristics";
33
import { selectAllLookupLists, setAllLookupLists } from "@/src/reduxStore/states/pages/lookup-lists";
4-
import { selectVisibleAttributesHeuristics, setAllAttributes } from "@/src/reduxStore/states/pages/settings";
4+
import { selectVisibleAttributesHeuristics, selectVisibleAttributesWithoutPermissions, setAllAttributes } from "@/src/reduxStore/states/pages/settings";
55
import { selectProjectId } from "@/src/reduxStore/states/project"
66
import { HeuristicsProperty } from "@/src/types/components/projects/projectId/heuristics/heuristicId/heuristics-details";
77
import { Attribute } from "@/src/types/components/projects/projectId/settings/data-schema";
@@ -26,7 +26,7 @@ export default function HeuristicsLayout(props: any) {
2626

2727
const projectId = useSelector(selectProjectId);
2828
const currentHeuristic = useSelector(selectHeuristic);
29-
const usableAttributes = useSelector(selectVisibleAttributesHeuristics);
29+
const usableAttributes = useSelector(selectVisibleAttributesWithoutPermissions);
3030
const lookupLists = useSelector(selectAllLookupLists);
3131

3232
const [isHeaderNormal, setIsHeaderNormal] = useState(true);

src/components/projects/projectId/playground/CreateEvaluationSetModal.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useCallback, useEffect, useState } from "react";
1515
import { useDispatch, useSelector } from "react-redux";
1616
import QuestionHistory from "./QuestionHistory";
1717
import { MemoIconPlus, MemoIconWand } from "@/submodules/react-components/components/kern-icons/icons";
18+
import { postProcessUpdateAndSortRecords } from "@/submodules/javascript-functions/post-process-functions";
1819

1920
const ACCEPT_BUTTON = { buttonCaption: 'Create', useButton: true };
2021
const SEARCH_REQUEST = { offset: 0, limit: 20 };
@@ -129,16 +130,7 @@ export default function CreateEvaluationSetModal(props: CreateEvaluationSetsModa
129130
}
130131

131132
function updateAndSortRecordList(newRecords = []) {
132-
setRecordList((prev) => {
133-
const merged = [...prev, ...newRecords];
134-
const uniqueRecords = Array.from(
135-
new Map(merged.map((item) => [item.data?.running_id, item])).values()
136-
);
137-
uniqueRecords.sort(
138-
(a, b) => (a.data?.running_id || 0) - (b.data?.running_id || 0)
139-
);
140-
return uniqueRecords;
141-
});
133+
setRecordList((prev) => postProcessUpdateAndSortRecords(prev, newRecords));
142134
}
143135

144136
function resetState() {

src/components/projects/projectId/settings/CreateNewAttributeModal.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { toPythonFunctionName } from "@/submodules/javascript-functions/python-f
1212
import KernDropdown from "@/submodules/react-components/components/KernDropdown";
1313
import { Tooltip } from "@nextui-org/react";
1414
import { useRouter } from "next/router";
15-
import { useCallback, useEffect, useState } from "react";
15+
import { useCallback, useEffect, useMemo, useState } from "react";
1616
import { useDispatch, useSelector } from "react-redux";
1717

1818
const ACCEPT_BUTTON = { buttonCaption: "Accept", useButton: true, disabled: true }
@@ -58,6 +58,10 @@ export default function CreateNewAttributeModal() {
5858
setDuplicateNameExists(checkName);
5959
}
6060

61+
const filteredDataTypes = useMemo(() => {
62+
return DATA_TYPES.filter(type => type.value !== 'PERMISSION');
63+
}, []);
64+
6165
return (<Modal modalName={ModalEnum.CREATE_NEW_ATTRIBUTE} acceptButton={acceptButton}>
6266
<div className="flex flex-grow justify-center text-lg leading-6 text-gray-900 font-medium">
6367
Add new attribute </div>
@@ -73,7 +77,7 @@ export default function CreateNewAttributeModal() {
7377
<Tooltip content={TOOLTIPS_DICT.PROJECT_SETTINGS.SELECT_ATTRIBUTE_TYPE} color="invert" placement="right">
7478
<span className="cursor-help card-title mb-0 label-text font-normal"><span className="underline filtersUnderline">Attribute type</span></span>
7579
</Tooltip>
76-
<KernDropdown buttonName={attributeType ? attributeType.name : 'Select type'} options={DATA_TYPES} selectedOption={(option: any) => setAttributeType(option)} />
80+
<KernDropdown buttonName={attributeType ? attributeType.name : 'Select type'} options={filteredDataTypes} selectedOption={(option: any) => setAttributeType(option)} />
7781
</div>
7882
{duplicateNameExists && <div className="text-red-700 text-xs mt-2">Attribute name exists</div>}
7983
{attributeType.name == 'Embedding List' && <div className="border border-gray-300 text-xs text-gray-500 p-2.5 rounded-lg text-justify mt-2 max-w-2xl">

src/components/projects/projectId/settings/ProjectMetaData.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ export default function ProjectMetaData() {
8585
<div className="text-gray-900 text-lg leading-6 font-medium">Danger zone</div>
8686
<div className="text-sm leading-5 font-normal mt-2 text-gray-500 inline-block">This action can not be reversed.
8787
Are you sure you want to delete this project?</div>
88+
{project.is_integration_project && <div className="text-sm text-red-500 italic">
89+
This is an integration project, please do not delete it unless the integration is deleted
90+
</div>}
8891
<div className="form-control">
8992
<div className="flex space-x-2 items-center">
9093
<input className="h-9 w-full text-sm border-gray-300 rounded-md placeholder-italic border text-gray-900 pl-4 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-300 focus:ring-offset-2 focus:ring-offset-gray-100"

0 commit comments

Comments
 (0)