Skip to content

Commit 2bfc0ac

Browse files
UI bug fixes (#20)
* UI bug fixes * PR comments * Submodules merged
1 parent 7158bfb commit 2bfc0ac

File tree

9 files changed

+39
-21
lines changed

9 files changed

+39
-21
lines changed

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

Lines changed: 18 additions & 7 deletions
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, selectRecords, setActiveDataSlice, setDataSlices, setRecordComments, setSearchRecordsExtended, setUniqueValuesDict, setUsersMapCount, updateAdditionalDataState } from "@/src/reduxStore/states/pages/data-browser";
7+
import { expandRecordList, selectActiveSearchParams, selectConfiguration, selectFullSearchStore, 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";
@@ -18,6 +18,8 @@ import { CommentType } from "@/src/types/shared/comments";
1818
import { CommentDataManager } from "@/src/util/classes/comments";
1919
import { REQUEST_COMMENTS } from "@/src/services/gql/queries/projects";
2020
import { useWebsocket } from "@/src/services/base/web-sockets/useWebsocket";
21+
import { parseFilterToExtended } from "@/src/util/components/projects/projectId/data-browser/filter-parser-helper";
22+
import { SearchGroup } from "@/submodules/javascript-functions/enums/enums";
2123

2224
const SEARCH_REQUEST = { offset: 0, limit: 20 };
2325

@@ -30,7 +32,10 @@ export default function DataBrowser() {
3032
const attributes = useSelector(selectAttributes);
3133
const user = useSelector(selectUser);
3234
const recordList = useSelector(selectRecords).recordList;
33-
35+
const activeSearchParams = useSelector(selectActiveSearchParams);
36+
const configuration = useSelector(selectConfiguration);
37+
const fullSearchStore = useSelector(selectFullSearchStore);
38+
const fullCount = useSelector(selectRecords).fullCount;
3439

3540
const [searchRequest, setSearchRequest] = useState(SEARCH_REQUEST);
3641

@@ -61,15 +66,16 @@ export default function DataBrowser() {
6166
}, [projectId, labelingTasks, recordList]);
6267

6368
useEffect(() => {
64-
if (!projectId) return;
69+
if (!projectId || !labelingTasks || !attributes) return;
6570
if (!searchRequest) return;
66-
if (searchRequest.offset == 0) return;
67-
refetchExtendedRecord({ variables: { projectId: projectId, filterData: JSON.stringify({}), offset: searchRequest.offset, limit: searchRequest.limit } }).then((res) => {
71+
if (searchRequest.offset == 0 || searchRequest.offset > fullCount) return;
72+
const filterData = parseFilterToExtended(activeSearchParams, attributes, configuration, labelingTasks, user, fullSearchStore[SearchGroup.DRILL_DOWN])
73+
refetchExtendedRecord({ variables: { projectId: projectId, filterData: filterData, offset: searchRequest.offset, limit: searchRequest.limit } }).then((res) => {
6874
const parsedRecordData = postProcessRecordsExtended(res.data['searchRecordsExtended'], labelingTasks);
6975
dispatch(expandRecordList(parsedRecordData));
7076
refetchRecordCommentsAndProcess(parsedRecordData.recordList);
7177
});
72-
}, [searchRequest]);
78+
}, [searchRequest, activeSearchParams, projectId, attributes, configuration, labelingTasks, user, fullSearchStore]);
7379

7480
useEffect(() => {
7581
if (!projectId || users.length == 0) return;
@@ -139,6 +145,7 @@ export default function DataBrowser() {
139145
}
140146

141147
function getNextRecords() {
148+
console.log('getNextRecords?')
142149
setSearchRequest({ offset: searchRequest.offset + searchRequest.limit, limit: searchRequest.limit });
143150
}
144151

@@ -148,6 +155,10 @@ export default function DataBrowser() {
148155
});
149156
}
150157

158+
const setSearchRequestToInit = useCallback(() => {
159+
setSearchRequest(SEARCH_REQUEST);
160+
}, []);
161+
151162
const handleWebsocketNotification = useCallback((msgParts: string[]) => {
152163
if (['data_slice_created', 'data_slice_updated', 'data_slice_deleted'].includes(msgParts[1])) {
153164
refetchDataSlicesAndProcess(msgParts[2]);
@@ -169,7 +180,7 @@ export default function DataBrowser() {
169180
return (<>
170181
{projectId && <div className="flex flex-row h-full">
171182
<DataBrowserSidebar />
172-
<DataBrowserRecords refetchNextRecords={getNextRecords} />
183+
<DataBrowserRecords refetchNextRecords={getNextRecords} clearSearchRequest={setSearchRequestToInit} />
173184
</div>}
174185
</>)
175186
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default function DataBrowserRecords(props: DataBrowserRecordsProps) {
4848
dispatch(updateAdditionalDataState('clearFullSearch', true));
4949
dispatch(updateAdditionalDataState('displayOutdatedWarning', false));
5050
dispatch(updateAdditionalDataState('canUpdateDynamicSlice', false));
51+
props.clearSearchRequest();
5152
}
5253

5354
function storePreliminaryRecordIds(index: number, forEdit: boolean = false) {

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,20 @@ export default function DataBrowserSidebar() {
9494

9595
{dataSlices && <div className="mt-2 mb-4">
9696
{dataSlices.length > 0 && <div className="w-full grid grid-cols-2 gap-y-1 items-center justify-center" style={{ gridColumnGap: '26px' }}>
97-
{filteredSlices.map((slice: DataSlice, index: number) => (<Tooltip content={!slice.static ? slice.name : ''} color="invert" placement={index % 2 == 0 ? 'right' : 'left'} key={slice.id}>
97+
{filteredSlices.map((slice: DataSlice, index: number) => (<Tooltip content={!slice.static ? <div className="w-24 break-words">{slice.name}</div> : null} color="invert" placement={index % 2 == 0 ? 'right' : 'left'} key={slice.id}>
9898
<button onClick={() => toggleSlice(slice)} style={{ width: '170px' }}
9999
className={`cursor-pointer inline-flex border items-center justify-between px-2.5 py-1.5 shadow-sm text-sm font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none ${activeSlice?.id == slice.id ? 'ring-blue-500 ring-2' : ' border-gray-200'}`}>
100100
<label className="cursor-pointer mr-2" onClick={(e) => { updateSliceInfo(slice); e.stopPropagation(); }}>
101101
<IconInfoCircle className={`w-6 h-6 ${slice.color.textColor} ${slice.color.fillColor}`} />
102102
</label>
103-
<label className={`text-gray-700 truncate label-max-width cursor-pointer ${slice.sliceType == Slice.STATIC_OUTLIER ? 'text-xs whitespace-pre' : 'text-sm'}`}>
103+
<label className={`text-gray-700 truncate cursor-pointer ${slice.sliceType == Slice.STATIC_OUTLIER ? 'text-xs whitespace-pre' : 'text-sm'}`}>
104104
{slice.displayName}</label>
105-
<IconTrash className="text-red-700 h-6 w-6 ml-2 cursor-pointer" onClick={(e) => {
105+
<label className="cursor-pointer mr-2" onClick={(e) => {
106106
dispatch(setModalStates(ModalEnum.DELETE_SLICE, { sliceId: slice.id, open: true }));
107107
e.stopPropagation();
108-
}} />
108+
}}>
109+
<IconTrash className="text-red-700 h-5 w-5 ml-2 cursor-pointer" />
110+
</label>
109111
</button>
110112
</Tooltip>))}
111113
</div>}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,11 +606,11 @@ export default function SearchGroups() {
606606
<ChevronDownIcon className="text-gray-700" />
607607
</div>
608608
<div className="flex flex-col">
609-
<div className="font-bold truncate" style={{ maxWidth: '21rem' }}>
609+
<div className="font-bold truncate" style={{ maxWidth: '20rem' }}>
610610
{searchGroupsStore[group.key].name}
611611
{searchGroupsStore[group.key].nameAdd != '' && <label className="font-normal ml-2">{searchGroupsStore[group.key].nameAdd}</label>}
612612
</div>
613-
<div className="text-xs text-gray-400 truncate" style={{ maxWidth: '21rem' }}>
613+
<div className="text-xs text-gray-400 truncate" style={{ maxWidth: '20rem' }}>
614614
{searchGroupsStore[group.key].subText}
615615
{searchGroupsStore[group.key].nameAdd != '' && <label className="font-normal ml-1">{searchGroupsStore[group.key].nameAdd}</label>}
616616
</div>
@@ -703,7 +703,7 @@ export default function SearchGroups() {
703703
<div>Manually labeled</div>
704704
{fullSearchStore[group.key].groupElements['manualLabels'] && fullSearchStore[group.key].groupElements['manualLabels'].length == 0 ? (<ButtonLabelsDisabled />) : (
705705
<Dropdown2 options={fullSearchStore[group.key].groupElements['manualLabels'] ?? []} buttonName={manualLabels.length == 0 ? 'None selected' : manualLabels.join(', ')} hasCheckboxesThreeStates={true} keepDrownOpen={true}
706-
selectedOption={(option: any) => {
706+
dropdownWidth="w-80" selectedOption={(option: any) => {
707707
const labels = [...manualLabels, option.name]
708708
setManualLabels(labels);
709709
updateLabelsFullSearch(option, group.key, 'manualLabels');
@@ -713,7 +713,7 @@ export default function SearchGroups() {
713713
<div className="mt-2">Weakly supervised</div>
714714
{fullSearchStore[group.key].groupElements['weakSupervisionLabels'] && fullSearchStore[group.key].groupElements['weakSupervisionLabels'].length == 0 ? (<ButtonLabelsDisabled />) : (
715715
<Dropdown2 options={fullSearchStore[group.key].groupElements['weakSupervisionLabels'] ?? []} buttonName={weakSupervisionLabels.length == 0 ? 'None selected' : weakSupervisionLabels.join(', ')} hasCheckboxesThreeStates={true}
716-
selectedOption={(option: any) => {
716+
dropdownWidth="w-80" selectedOption={(option: any) => {
717717
const labels = [...weakSupervisionLabels, option.name]
718718
setWeakSupervisionLabels(labels);
719719
updateLabelsFullSearch(option, group.key, 'weakSupervisionLabels');
@@ -741,7 +741,7 @@ export default function SearchGroups() {
741741
<div className="mt-2">Model callback</div>
742742
{fullSearchStore[group.key].groupElements['modelCallbackLabels'] && fullSearchStore[group.key].groupElements['modelCallbackLabels'].length == 0 ? (<ButtonLabelsDisabled />) : (
743743
<Dropdown2 options={fullSearchStore[group.key].groupElements['modelCallbackLabels'] ?? []} buttonName={modelCallBacksLabels.length == 0 ? 'None selected' : modelCallBacksLabels.join(', ')} hasCheckboxesThreeStates={true}
744-
selectedOption={(option: any) => {
744+
dropdownWidth="w-80" selectedOption={(option: any) => {
745745
const labels = [...modelCallBacksLabels, option.name]
746746
setModelCallBacksLabels(labels);
747747
updateLabelsFullSearch(option, group.key, 'modelCallbackLabels');

src/components/shared/grid-cards/GridCards.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ export default function GridCards(props: GridCardsProps) {
5454
<div className="flex-1 min-w-0 text-sm leading-5">
5555
<div className="flow-root font-medium">
5656
<div className="text-gray-900 float-left"> {heuristic.name}</div>
57-
<a className="text-green-800 float-right cursor-pointer" href={`/refinery${heuristic.routerLink}`} onClick={(e) => {
57+
{heuristic.routerLink && <a className="text-green-800 float-right cursor-pointer" href={`/refinery${heuristic.routerLink}`} onClick={(e) => {
5858
e.preventDefault();
5959
router.push(`${heuristic.routerLink}`);
6060
}}> Details
6161
<IconArrowRight className="h-5 w-5 inline-block text-green-800" />
62-
</a>
62+
</a>}
6363
</div>
6464
<div className="flow-root font-normal">
6565
<div className="text-gray-500 float-left line-clamp-3" style={{ maxWidth: '250px' }}>

src/types/components/projects/projectId/data-browser/data-browser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ export enum LineBreaksType {
5454

5555
export type DataBrowserRecordsProps = {
5656
refetchNextRecords: () => void;
57+
clearSearchRequest: () => void;
5758
};

src/util/components/projects/projectId/model-callbacks-helper.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LabelSource } from "@/submodules/javascript-functions/enums/enums";
2-
import { mapInformationSourceStatsGlobal } from "./heuristics/shared-helper";
2+
import { getColorStruct, mapInformationSourceStatsGlobal } from "./heuristics/shared-helper";
33

44
export const ACTIONS_DROPDOWN_OPTIONS = ['Select all', 'Deselect all', 'Delete selected'];
55

@@ -8,6 +8,9 @@ export function postProcessModelCallbacks(modelCallBack: string) {
88
return JSON.parse(modelCallBack).map((source) => {
99
source.labelSource = LabelSource.INFORMATION_SOURCE;
1010
source.stats = mapInformationSourceStatsGlobal(source.stat_data);
11+
source.stats.forEach((stat) => {
12+
stat.color = getColorStruct(stat.color);
13+
});
1114
return source;
1215
});
1316
}

src/util/components/projects/projectId/settings/data-schema-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function getColorForDataType(dataType): string {
4949
case 'BOOLEAN': return 'cyan';
5050
case 'INTEGER': return 'indigo';
5151
case 'FLOAT': return 'purple';
52-
case 'EMBEDDING_LIST': return 'gray';
52+
case 'EMBEDDING_LIST': return 'rose';
5353
default: return 'gray';
5454
}
5555
}

submodules/react-components

0 commit comments

Comments
 (0)