Skip to content

Commit 98c156e

Browse files
authored
Merge pull request #13 from code-kern-ai/release-updates
Release updates
2 parents ede8247 + dfef09a commit 98c156e

File tree

38 files changed

+252
-138
lines changed

38 files changed

+252
-138
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"focus-visible": "^5.2.0",
3333
"graphql": "^16.6.0",
3434
"lodash.debounce": "^4.0.8",
35-
"next": "13.4.8",
35+
"next": "13.5.6",
3636
"postcss-focus-visible": "^6.0.4",
3737
"react": "18.2.0",
3838
"react-chartjs-2": "^5.2.0",

src/components/config/Config.tsx

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { CacheEnum, selectCachedValue } from "@/src/reduxStore/states/cachedValues";
2-
import { selectOrganization } from "@/src/reduxStore/states/general";
2+
import { selectOrganization, setOrganization } from "@/src/reduxStore/states/general";
33
import { ConfigManager } from "@/src/services/base/config";
4+
import { GET_ORGANIZATION } from "@/src/services/gql/queries/organizations";
45
import { CHANGE_ORGANIZATION, UPDATE_CONFIG } from "@/src/services/gql/mutations/organizations";
56
import { Configuration, LocalConfig } from "@/src/types/components/config/config"
67
import { snakeCaseToCamelCase } from "@/submodules/javascript-functions/case-types-parser";
78
import Dropdown2 from "@/submodules/react-components/components/Dropdown2";
89
import { useMutation } from "@apollo/client";
910
import { IconPlus, IconTrash } from "@tabler/icons-react";
1011
import { useEffect, useState } from "react"
11-
import { useSelector } from "react-redux";
12+
import { useSelector, useDispatch } from "react-redux";
13+
import { useLazyQuery } from "@apollo/client";
1214

1315
export default function Config() {
16+
const dispatch = useDispatch();
1417
const organization = useSelector(selectOrganization);
1518
const tokenizerValues = useSelector(selectCachedValue(CacheEnum.TOKENIZER_VALUES));
1619

@@ -19,6 +22,7 @@ export default function Config() {
1922
const [prepareTokenizedValues, setPrepareTokenizedValues] = useState<any[]>([]);
2023
const [preparedOptions, setPreparedOptions] = useState<any[]>([]);
2124

25+
const [refetchOrganization] = useLazyQuery(GET_ORGANIZATION, { fetchPolicy: 'no-cache' });
2226
const [changeOrganizationMut] = useMutation(CHANGE_ORGANIZATION);
2327
const [updateConfigMut] = useMutation(UPDATE_CONFIG);
2428

@@ -55,6 +59,12 @@ export default function Config() {
5559
setPreparedOptions(removeDuplicates);
5660
}, [tokenizerValues, localConfig]);
5761

62+
useEffect(() => {
63+
return () => {
64+
ConfigManager.refreshConfig();
65+
}
66+
}, []);
67+
5868
function checkAndSaveValue(value: any, key: string, subkey: string = null) {
5969
if (key == "limit_checks") {
6070
if (Number(value) == organization[snakeCaseToCamelCase(subkey)]) return;
@@ -72,6 +82,12 @@ export default function Config() {
7282
changeOrganizationMut({ variables: { orgId: organization.id, changes: JSON.stringify(updateDict.limit_checks) } }).then((res) => {
7383
if (!res?.data?.changeOrganization) {
7484
window.alert('something went wrong with the update');
85+
} else {
86+
refetchOrganization().then((res) => {
87+
if (res.data["userOrganization"]) {
88+
dispatch(setOrganization(res.data["userOrganization"]));
89+
}
90+
});
7591
}
7692
});
7793
} else {
@@ -172,6 +188,7 @@ export default function Config() {
172188
dropdownItemsClasses="max-h-80 overflow-y-auto"
173189
buttonClasses="whitespace-nowrap"
174190
dropdownWidth="w-72"
191+
disabled={index < 2}
175192
/>
176193
{index > 1 && <button className="px-1 inline-flex items-center">
177194
<IconTrash onClick={() => removeSpacyTokenizer(myConfig)} className="h-6 w-6 text-red-700" />

src/components/models-download/ModelsDownload.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useDispatch, useSelector } from "react-redux";
1010
import LoadingIcon from "../shared/loading/LoadingIcon";
1111
import { openModal, setModalStates } from "@/src/reduxStore/states/modal";
1212
import { ModalEnum } from "@/src/types/shared/modal";
13-
import { selectIsManaged } from "@/src/reduxStore/states/general";
13+
import { selectIsAdmin, selectIsManaged } from "@/src/reduxStore/states/general";
1414
import { CurrentPage } from "@/src/types/shared/general";
1515
import { timer } from "rxjs";
1616
import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants";
@@ -23,6 +23,7 @@ export default function ModelsDownload() {
2323
const dispatch = useDispatch();
2424

2525
const isManaged = useSelector(selectIsManaged);
26+
const isAdmin = useSelector(selectIsAdmin);
2627
const modelsDownloaded = useSelector(selectModelsDownloaded);
2728

2829
const [refetchModelsDownload] = useLazyQuery(GET_MODEL_PROVIDER_INFO, { fetchPolicy: 'network-only', nextFetchPolicy: 'cache-first' });
@@ -139,8 +140,8 @@ export default function ModelsDownload() {
139140
</div>
140141
</td>
141142
<td className="whitespace-nowrap text-center px-3 py-2 text-sm text-gray-500">
142-
<IconTrash onClick={() => dispatch(setModalStates(ModalEnum.DELETE_MODEL_DOWNLOAD, { modelName: model.name, open: true }))}
143-
className="h-6 w-6 text-red-700 cursor-pointer" />
143+
{isAdmin && <IconTrash onClick={() => dispatch(setModalStates(ModalEnum.DELETE_MODEL_DOWNLOAD, { modelName: model.name, open: true }))}
144+
className="h-6 w-6 text-red-700 cursor-pointer" />}
144145
</td>
145146
</tr>
146147
))}

src/components/projects/projectId/admin/NewPersonalTokenModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default function NewPersonalToken(props: PersonalTokenModalProps) {
8282
</Tooltip>
8383
<div className="flex flex-row flex-nowrap justify-between items-center gap-x-2">
8484
<span style={{ width: '22.5rem', minHeight: '2.25rem' }}
85-
className="text-xs block px-4 py-2 text-gray-900 break-all border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">{newToken}</span>
85+
className="text-xs block px-4 py-2 text-gray-900 break-all border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500">{newToken}</span>
8686

8787
<Tooltip content={tokenCopied ? TOOLTIPS_DICT.ADMIN_PAGE.TOKEN_COPIED : ''} color="invert" placement="right">
8888
<div className="flex items-center">

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

+6-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import DataBrowserSidebar from "./DataBrowserSidebar";
44
import { useLazyQuery } from "@apollo/client";
55
import { DATA_SLICES, GET_RECORD_COMMENTS, GET_UNIQUE_VALUES_BY_ATTRIBUTES, SEARCH_RECORDS_EXTENDED } from "@/src/services/gql/queries/data-browser";
66
import { useCallback, useEffect, useState } from "react";
7-
import { expandRecordList, setActiveDataSlice, setDataSlices, setRecordComments, setSearchRecordsExtended, setUniqueValuesDict, setUsersMapCount, updateAdditionalDataState } from "@/src/reduxStore/states/pages/data-browser";
7+
import { expandRecordList, selectRecords, setActiveDataSlice, setDataSlices, setRecordComments, setSearchRecordsExtended, setUniqueValuesDict, setUsersMapCount, updateAdditionalDataState } from "@/src/reduxStore/states/pages/data-browser";
88
import { postProcessRecordsExtended, postProcessUniqueValues, postProcessUsersCount } from "@/src/util/components/projects/projectId/data-browser/data-browser-helper";
99
import { GET_ATTRIBUTES_BY_PROJECT_ID, GET_EMBEDDING_SCHEMA_BY_PROJECT_ID, GET_LABELING_TASKS_BY_PROJECT_ID } from "@/src/services/gql/queries/project-setting";
1010
import { selectAttributes, selectLabelingTasksAll, setAllAttributes, setAllEmbeddings, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings";
@@ -29,6 +29,8 @@ export default function DataBrowser() {
2929
const labelingTasks = useSelector(selectLabelingTasksAll);
3030
const attributes = useSelector(selectAttributes);
3131
const user = useSelector(selectUser);
32+
const recordList = useSelector(selectRecords).recordList;
33+
3234

3335
const [searchRequest, setSearchRequest] = useState(SEARCH_REQUEST);
3436

@@ -54,10 +56,9 @@ export default function DataBrowser() {
5456
}, [projectId, users, user]);
5557

5658
useEffect(() => {
57-
if (!projectId) return;
58-
if (!labelingTasks) return;
59-
refetchExtendedSearchAndProcess();
60-
}, [projectId, labelingTasks]);
59+
if (!projectId || !labelingTasks || !recordList) return;
60+
refetchRecordCommentsAndProcess(recordList);
61+
}, [projectId, labelingTasks, recordList]);
6162

6263
useEffect(() => {
6364
if (!projectId) return;
@@ -122,14 +123,6 @@ export default function DataBrowser() {
122123
});
123124
}
124125

125-
function refetchExtendedSearchAndProcess() {
126-
refetchExtendedRecord({ variables: { projectId: projectId, filterData: JSON.stringify({}), offset: searchRequest.offset, limit: searchRequest.limit } }).then((res) => {
127-
const parsedRecordData = postProcessRecordsExtended(res.data['searchRecordsExtended'], labelingTasks);
128-
dispatch(setSearchRecordsExtended(parsedRecordData));
129-
refetchRecordCommentsAndProcess(parsedRecordData.recordList);
130-
});
131-
}
132-
133126
function refetchEmbeddingsAndPostProcess() {
134127
refetchEmbeddings({ variables: { projectId: projectId } }).then((res) => {
135128
const embeddings = postProcessingEmbeddings(res.data['projectByProjectId']['embeddings']['edges'].map((e) => e['node']), []);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export default function DataBrowserRecords(props: DataBrowserRecordsProps) {
150150
</Fragment>))}
151151
</div>}
152152

153-
<div className="mb-3 mt-4 grow overflow-y-auto" style={{ maxHeight: 'calc(100vh - 160px)' }} onScroll={(e: any) => refetchMoreRecords(e)}>
153+
<div className={`mb-3 mt-4 grow ${additionalData.loading ? '' : 'overflow-y-auto'}`} style={{ maxHeight: 'calc(100vh - 160px)' }} onScroll={(e: any) => refetchMoreRecords(e)}>
154154
{additionalData.loading && <div className="h-full flex justify-center items-center"><LoadingIcon size="lg" /></div>}
155155
{extendedRecords && attributes && !additionalData.loading && <div className="mr-2">
156156
{extendedRecords.fullCount == 0 && <div>Your search criteria didn&apos;t match any record.</div>}

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

+47-21
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,31 @@ export default function SearchGroups() {
113113
}, [searchGroupsStore, attributesSortOrder]);
114114

115115
useEffect(() => {
116-
if (!user || !activeSearchParams || !labelingTasks || !attributes) return;
116+
if (!user || !activeSearchParams || !labelingTasks || !attributes || !projectId) return;
117+
if (!fullSearchStore || fullSearchStore[SearchGroup.DRILL_DOWN] == undefined) return;
118+
if (recordsInDisplay) return;
119+
refreshTextHighlightNeeded();
120+
setHighlightingToRecords();
121+
if (!(activeSlice && activeSlice.static)) {
122+
dispatch(updateAdditionalDataState('loading', true));
123+
const refetchTimer = setTimeout(() => {
124+
refetchExtendedRecord({
125+
variables: {
126+
projectId: projectId,
127+
filterData: parseFilterToExtended(activeSearchParams, attributes, configuration, labelingTasks, user, fullSearchStore[SearchGroup.DRILL_DOWN]),
128+
offset: 0, limit: 20
129+
}
130+
}).then((res) => {
131+
dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res.data['searchRecordsExtended'], labelingTasks)));
132+
dispatch(updateAdditionalDataState('loading', false));
133+
});
134+
}, 500);
135+
return () => clearTimeout(refetchTimer);
136+
}
137+
}, [activeSearchParams, user, projectId, attributes, labelingTasks, configuration]);
138+
139+
useEffect(() => {
140+
if (!user || !activeSearchParams || !labelingTasks || !attributes || !projectId) return;
117141
if (!fullSearchStore || fullSearchStore[SearchGroup.DRILL_DOWN] == undefined) return;
118142
if (recordsInDisplay) return;
119143
refreshTextHighlightNeeded();
@@ -136,23 +160,8 @@ export default function SearchGroups() {
136160
dispatch(updateAdditionalDataState('staticDataSliceCurrentCount', res['data']['staticDataSlicesCurrentCount']));
137161
});
138162
});
139-
} else {
140-
dispatch(updateAdditionalDataState('loading', true));
141-
const refetchTimer = setTimeout(() => {
142-
refetchExtendedRecord({
143-
variables: {
144-
projectId: projectId,
145-
filterData: parseFilterToExtended(activeSearchParams, attributes, configuration, labelingTasks, user, fullSearchStore[SearchGroup.DRILL_DOWN]),
146-
offset: 0, limit: 20
147-
}
148-
}).then((res) => {
149-
dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res.data['searchRecordsExtended'], labelingTasks)));
150-
dispatch(updateAdditionalDataState('loading', false));
151-
});
152-
}, 500);
153-
return () => clearTimeout(refetchTimer);
154163
}
155-
}, [activeSearchParams, user, projectId, attributes, labelingTasks, configuration, activeSlice]);
164+
}, [activeSlice, activeSearchParams, user, projectId, attributes, labelingTasks,]);
156165

157166
useEffect(() => {
158167
if (!recordList) return;
@@ -477,6 +486,11 @@ export default function SearchGroups() {
477486
const fullSearchCopy = jsonCopy(fullSearchStore);
478487
const formControlsIdx = fullSearchCopy[group.key].groupElements['orderBy'][index];
479488
const findActive = fullSearchCopy[group.key].groupElements['orderBy'].find((el) => el['active'] == true);
489+
const findRandom = fullSearchCopy[group.key].groupElements['orderBy'].find((el) => el['orderByKey'] == StaticOrderByKeys.RANDOM);
490+
if (findRandom) {
491+
findRandom['active'] = false;
492+
findRandom['color'] = getActiveNegateGroupColor(findRandom);
493+
}
480494
if (findActive && findActive != formControlsIdx) findActive['active'] = false;
481495
if (formControlsIdx['active'] && formControlsIdx['direction'] == -1) {
482496
formControlsIdx['direction'] = 1;
@@ -490,6 +504,18 @@ export default function SearchGroups() {
490504
updateSearchParams(fullSearchCopy);
491505
}
492506

507+
function updateRandomSeed() {
508+
const fullSearchCopy = jsonCopy(fullSearchStore);
509+
const formControlsIdx = fullSearchCopy[SearchGroup.ORDER_STATEMENTS].groupElements['orderBy'].find((el) => el['orderByKey'] == StaticOrderByKeys.RANDOM);
510+
fullSearchCopy[SearchGroup.ORDER_STATEMENTS].groupElements['orderBy'].forEach((el) => {
511+
if (el['orderByKey'] != StaticOrderByKeys.RANDOM) el['active'] = false;
512+
});
513+
formControlsIdx['active'] = !formControlsIdx['active'];
514+
formControlsIdx['color'] = getActiveNegateGroupColor(formControlsIdx);
515+
dispatch(setFullSearchStore(fullSearchCopy));
516+
updateSearchParams(fullSearchCopy);
517+
}
518+
493519
function setRandomSeedGroup(value?: string) {
494520
const fullSearchCopy = jsonCopy(fullSearchStore);
495521
const formControlsIdx = fullSearchCopy[SearchGroup.ORDER_STATEMENTS].groupElements['orderBy'].find((el) => el['orderByKey'] == StaticOrderByKeys.RANDOM);
@@ -676,7 +702,7 @@ export default function SearchGroups() {
676702
{fullSearchStore[group.key] && <div className="flex-grow flex flex-col">
677703
<div>Manually labeled</div>
678704
{fullSearchStore[group.key].groupElements['manualLabels'] && fullSearchStore[group.key].groupElements['manualLabels'].length == 0 ? (<ButtonLabelsDisabled />) : (
679-
<Dropdown2 options={fullSearchStore[group.key].groupElements['manualLabels'] ?? []} buttonName={manualLabels.length == 0 ? 'None selected' : manualLabels.join(',')} hasCheckboxesThreeStates={true} keepDrownOpen={true}
705+
<Dropdown2 options={fullSearchStore[group.key].groupElements['manualLabels'] ?? []} buttonName={manualLabels.length == 0 ? 'None selected' : manualLabels.join(', ')} hasCheckboxesThreeStates={true} keepDrownOpen={true}
680706
selectedOption={(option: any) => {
681707
const labels = [...manualLabels, option.name]
682708
setManualLabels(labels);
@@ -686,7 +712,7 @@ export default function SearchGroups() {
686712

687713
<div className="mt-2">Weakly supervised</div>
688714
{fullSearchStore[group.key].groupElements['weakSupervisionLabels'] && fullSearchStore[group.key].groupElements['weakSupervisionLabels'].length == 0 ? (<ButtonLabelsDisabled />) : (
689-
<Dropdown2 options={fullSearchStore[group.key].groupElements['weakSupervisionLabels'] ?? []} buttonName={weakSupervisionLabels.length == 0 ? 'None selected' : weakSupervisionLabels.join(',')} hasCheckboxesThreeStates={true}
715+
<Dropdown2 options={fullSearchStore[group.key].groupElements['weakSupervisionLabels'] ?? []} buttonName={weakSupervisionLabels.length == 0 ? 'None selected' : weakSupervisionLabels.join(', ')} hasCheckboxesThreeStates={true}
690716
selectedOption={(option: any) => {
691717
const labels = [...weakSupervisionLabels, option.name]
692718
setWeakSupervisionLabels(labels);
@@ -714,7 +740,7 @@ export default function SearchGroups() {
714740

715741
<div className="mt-2">Model callback</div>
716742
{fullSearchStore[group.key].groupElements['modelCallbackLabels'] && fullSearchStore[group.key].groupElements['modelCallbackLabels'].length == 0 ? (<ButtonLabelsDisabled />) : (
717-
<Dropdown2 options={fullSearchStore[group.key].groupElements['modelCallbackLabels'] ?? []} buttonName={modelCallBacksLabels.length == 0 ? 'None selected' : modelCallBacksLabels.join(',')} hasCheckboxesThreeStates={true}
743+
<Dropdown2 options={fullSearchStore[group.key].groupElements['modelCallbackLabels'] ?? []} buttonName={modelCallBacksLabels.length == 0 ? 'None selected' : modelCallBacksLabels.join(', ')} hasCheckboxesThreeStates={true}
718744
selectedOption={(option: any) => {
719745
const labels = [...modelCallBacksLabels, option.name]
720746
setModelCallBacksLabels(labels);
@@ -772,7 +798,7 @@ export default function SearchGroups() {
772798
<span className="ml-2 text-sm truncate w-full">{groupItem['displayName']}</span>
773799
</div>
774800
</div>) : (<div className="flex flex-row items-center mr-2">
775-
<div className="flex flex-row items-center cursor-pointer" onClick={() => setActiveNegateGroup(groupItem, index, group)}>
801+
<div className="flex flex-row items-center cursor-pointer" onClick={updateRandomSeed}>
776802
<div style={{ backgroundColor: groupItem.color, borderColor: groupItem.color }}
777803
className="ml-2 mr-2 h-4 w-4 border-gray-300 border rounded cursor-pointer hover:bg-gray-200">
778804
</div>

0 commit comments

Comments
 (0)