Skip to content

Commit 9fdd153

Browse files
Smaller fixed for annotators and locked links
1 parent bf2b533 commit 9fdd153

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

src/components/projects/projectId/labeling/sessionId/main-component/LabelingMainComponent.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default function LabelingMainComponent() {
6464
useEffect(unsubscribeWSOnDestroy(router, [CurrentPage.LABELING]), []);
6565

6666
useEffect(() => {
67-
if (!projectId) return;
67+
if (!projectId || !router.query) return;
6868
let tmp = localStorage.getItem(SETTINGS_KEY);
6969
if (tmp) {
7070
dispatch(setSettings(JSON.parse(tmp)));
@@ -87,7 +87,7 @@ export default function LabelingMainComponent() {
8787
whitelist: ['attributes_updated', 'calculate_attribute', 'payload_finished', 'weak_supervision_finished', 'record_deleted', 'rla_created', 'rla_deleted', 'access_link_changed', 'access_link_removed', 'label_created', 'label_deleted', 'labeling_task_deleted', 'labeling_task_updated', 'labeling_task_created'],
8888
func: handleWebsocketNotification
8989
});
90-
}, [projectId]);
90+
}, [projectId, router.query]);
9191

9292
//destructor
9393
useEffect(() => () => {
@@ -104,7 +104,10 @@ export default function LabelingMainComponent() {
104104
refetchLinkLocked({ variables: { projectId: projectId, linkRoute: router.asPath } }).then((result) => {
105105
const lockedLink = result['data']['linkLocked'];
106106
if (lockedLink) {
107-
setAbsoluteWarning(user?.role !== UserRole.ENGINEER ? 'This link is locked, contact your supervisor to request access' : null)
107+
setAbsoluteWarning('This link is locked, contact your supervisor to request access');
108+
if (router.query.type == LabelingLinkType.HEURISTIC) {
109+
dispatch(setDisplayUserRole(UserRole.ANNOTATOR));
110+
}
108111
} else {
109112
if (router.query.type == LabelingLinkType.HEURISTIC) {
110113
dispatch(setDisplayUserRole(UserRole.ANNOTATOR));
@@ -300,7 +303,8 @@ export default function LabelingMainComponent() {
300303

301304
function prepareTasksForRole(taskData: LabelingTask[], userDisplayRole): LabelingTask[] {
302305
if (user?.role != UserRole.ANNOTATOR && userDisplayRole != UserRole.ANNOTATOR) return taskData;
303-
const taskId = JSON.parse(localStorage.getItem('huddleData'))?.allowedTask;
306+
if (!JSON.parse(localStorage.getItem('huddleData'))) return null;
307+
const taskId = JSON.parse(localStorage.getItem('huddleData')).allowedTask;
304308
if (!taskId) return null;
305309
else return taskData.filter(t => t.id == taskId);
306310
}

src/components/projects/projectId/labeling/sessionId/main-component/NavigationBarTop.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default function NavigationBarTop(props: NavigationBarTopProps) {
6767
{user && <div className="w-full px-4 border-gray-200 border-b h-16">
6868
<div className="relative flex-shrink-0 bg-white shadow-sm flex justify-between items-center h-full">
6969
<div className="flex flex-row flex-nowrap items-center">
70-
{user.role == UserRole.ENGINEER ? (<>
70+
{user.role == UserRole.ENGINEER && userDisplayRole == UserRole.ENGINEER ? (<>
7171
<div className="flex justify-center overflow-visible">
7272
<Tooltip content={TOOLTIPS_DICT.LABELING.NAVIGATE_TO_DATA_BROWSER} placement="bottom" color="invert">
7373
<button onClick={() => router.push(`/projects/${projectId}/data-browser`)}

src/components/projects/projectId/labeling/sessionId/sub-components/LabelingSuiteLabeling.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import LoadingIcon from "@/src/components/shared/loading/LoadingIcon"
22
import { selectUser } from "@/src/reduxStore/states/general"
33
import { removeFromRlaById, selectDisplayUserRole, selectHoverGroupDict, selectRecordRequests, selectRecordRequestsRecord, selectSettings, selectTmpHighlightIds, selectUserDisplayId, setHoverGroupDict, tmpAddHighlightIds } from "@/src/reduxStore/states/pages/labeling"
4-
import { selectAttributes, selectLabelingTasksAll, selectVisibleAttributesLabeling } from "@/src/reduxStore/states/pages/settings"
4+
import { selectLabelingTasksAll, selectVisibleAttributesLabeling } from "@/src/reduxStore/states/pages/settings"
55
import { selectProjectId } from "@/src/reduxStore/states/project"
66
import { HotkeyLookup, LabelSourceHover, LabelingVars, TokenLookup } from "@/src/types/components/projects/projectId/labeling/labeling"
77
import { LabelingTaskTaskType } from "@/src/types/components/projects/projectId/settings/labeling-tasks"
88
import { UserRole } from "@/src/types/shared/sidebar"
99
import { DEFAULT_LABEL_COLOR, FULL_RECORD_ID, SWIM_LANE_SIZE_PX, buildLabelingRlaData, checkCanEditLabels, collectSelectionData, filterRlaDataForLabeling, findOrderPosItem, getDefaultLabelingVars, getFirstFitPos, getGoldInfoForTask, getOrderLookupItem, getOrderLookupSort, getTaskTypeOrder, getTokenData, parseSelectionData } from "@/src/util/components/projects/projectId/labeling/labeling-helper"
1010
import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants"
1111
import { Tooltip } from "@nextui-org/react"
12-
import { IconAlertCircle, IconAssembly, IconBolt, IconCode, IconSparkles, IconStar, IconStarFilled, IconUsers } from "@tabler/icons-react"
12+
import { IconAlertCircle, IconAssembly, IconBolt, IconCode, IconSparkles, IconStar, IconUsers } from "@tabler/icons-react"
1313
import { Fragment, useRef, useEffect, useState } from "react"
1414
import { useDispatch, useSelector } from "react-redux"
1515
import ExtractionDisplay from "./ExtractionDisplay"
@@ -20,7 +20,7 @@ import { LabelingSuiteManager } from "@/src/util/classes/labeling/manager";
2020
import { useMutation } from "@apollo/client"
2121
import { ADD_CLASSIFICATION_LABELS_TO_RECORD, ADD_EXTRACTION_LABEL_TO_RECORD, CREATE_LABEL, DELETE_RECORD_LABEL_ASSOCIATION_BY_ID, REMOVE_GOLD_STAR_ANNOTATION_FOR_TASK, SET_GOLD_STAR_ANNOTATION_FOR_TASK } from "@/src/services/gql/mutations/labeling"
2222
import { SessionManager } from "@/src/util/classes/labeling/session-manager"
23-
import { ALL_USERS_USER_ID, GOLD_STAR_USER_ID } from "@/src/util/components/projects/projectId/labeling/labeling-main-component-helper"
23+
import { GOLD_STAR_USER_ID } from "@/src/util/components/projects/projectId/labeling/labeling-main-component-helper"
2424
import { useRouter } from "next/router"
2525
import LabelSelectionBox from "./LabelSelectionBox"
2626
import { filterRlaDataForUser } from "@/src/util/components/projects/projectId/labeling/overview-table-helper"
@@ -71,11 +71,11 @@ export default function LabelingSuiteLabeling() {
7171
const [removeGoldStarMut] = useMutation(REMOVE_GOLD_STAR_ANNOTATION_FOR_TASK);
7272

7373
useEffect(() => {
74-
if (!projectId || !attributes || !recordRequests || !user || !settings || !userDisplayRole) return;
74+
if (!projectId || !attributes || !recordRequests || !user || !settings || !userDisplayRole || !labelingTasks) return;
7575
attributesChanged();
7676
prepareRlaData();
7777
rebuildGoldInfo();
78-
}, [projectId, attributes, recordRequests, user, settings, userDisplayRole]);
78+
}, [projectId, attributes, recordRequests, user, settings, userDisplayRole, labelingTasks]);
7979

8080
useEffect(() => {
8181
if (!labelingTasks || !lVars) return;
@@ -136,10 +136,10 @@ export default function LabelingSuiteLabeling() {
136136
}, [tokenLookup]);
137137

138138
useEffect(() => {
139-
if (!settings) return;
139+
if (!settings || !lVars || !labelingTasks) return;
140140
rebuildTaskLookup(lVars);
141141
filterRlaDataForCurrent();
142-
}, [settings]);
142+
}, [settings, lVars, labelingTasks]);
143143

144144
useEffect(() => {
145145
if (!user || !displayUserId || !userDisplayRole) return;

src/reduxStore/StoreManagerComponent.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { checkWhitelistTokenizer } from "../util/components/projects/new-project
1919
import { ConfigManager } from "../services/base/config";
2020
import postprocessVersionOverview from "../util/shared/sidebar-helper";
2121
import { postProcessingEmbeddingPlatforms } from "../util/components/projects/projectId/settings/embeddings-helper";
22+
import { setDisplayUserRole } from "./states/pages/labeling";
2223

2324
export function GlobalStoreDataComponent(props: React.PropsWithChildren) {
2425
const router = useRouter();
@@ -56,6 +57,7 @@ export function GlobalStoreDataComponent(props: React.PropsWithChildren) {
5657
const userInfo = { ...res.data["userInfo"] };
5758
userInfo.avatarUri = getUserAvatarUri(res.data["userInfo"]);
5859
dispatch(setUser(userInfo));
60+
dispatch(setDisplayUserRole(res.data["userInfo"].role));
5961
});
6062
refetchOrganization().then((res) => {
6163
if (res.data["userOrganization"]) {

0 commit comments

Comments
 (0)