Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 50602ef

Browse files
committed
Merge remote-tracking branch 'origin/master' into fb-leap-33/taxonomy-labels
2 parents 6953203 + 90c13cc commit 50602ef

File tree

4 files changed

+58
-17
lines changed

4 files changed

+58
-17
lines changed

src/components/BottomBar/CurrentTask.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import React, { useMemo } from 'react';
12
import { observer } from 'mobx-react';
2-
import { useMemo } from 'react';
33
import { Button } from '../../common/Button/Button';
44
import { Block, Elem } from '../../utils/bem';
55
import { guidGenerator } from '../../utils/unique';
66
import { isDefined } from '../../utils/utilities';
7+
import { FF_TASK_COUNT_FIX, isFF } from '../../common/Tooltip/Tooltip';
78
import './CurrentTask.styl';
89

910

@@ -18,16 +19,22 @@ export const CurrentTask = observer(({ store }) => {
1819
&& !store.canGoNextTask
1920
&& !store.hasInterface('review')
2021
&& store.hasInterface('postpone');
21-
22+
2223
return (
2324
<Elem name="section">
2425
<Block name="current-task" mod={{ 'with-history': historyEnabled }}>
2526
<Elem name="task-id">
2627
{store.task.id ?? guidGenerator()}
2728
{historyEnabled && (
28-
<Elem name="task-count">
29-
{currentIndex} of {store.taskHistory.length}
30-
</Elem>
29+
isFF(FF_TASK_COUNT_FIX) ? (
30+
<Elem name="task-count">
31+
{store.queuePosition} of {store.queueTotal}
32+
</Elem>
33+
) : (
34+
<Elem name="task-count">
35+
{currentIndex} of {store.taskHistory.length}
36+
</Elem>
37+
)
3138
)}
3239
</Elem>
3340
{historyEnabled && (

src/components/TopBar/CurrentTask.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
import React, { useMemo } from 'react';
12
import { observer } from 'mobx-react';
2-
import { useEffect, useMemo, useState } from 'react';
3+
import { useEffect, useState } from 'react';
34
import { Button } from '../../common/Button/Button';
45
import { Block, Elem } from '../../utils/bem';
5-
import { FF_DEV_3873, FF_DEV_4174, isFF } from '../../utils/feature-flags';
6+
import { FF_DEV_3873, FF_DEV_4174, FF_TASK_COUNT_FIX, isFF } from '../../utils/feature-flags';
67
import { guidGenerator } from '../../utils/unique';
78
import { isDefined } from '../../utils/utilities';
89
import './CurrentTask.styl';
910
import { reaction } from 'mobx';
1011

11-
1212
export const CurrentTask = observer(({ store }) => {
13+
const currentIndex = useMemo(() => {
14+
return store.taskHistory.findIndex((x) => x.taskId === store.task.id) + 1;
15+
}, [store.taskHistory]);
16+
1317
const [initialCommentLength, setInitialCommentLength] = useState(0);
1418
const [visibleComments, setVisibleComments] = useState(0);
1519

@@ -28,10 +32,6 @@ export const CurrentTask = observer(({ store }) => {
2832
};
2933
}, []);
3034

31-
const currentIndex = useMemo(() => {
32-
return store.taskHistory.findIndex((x) => x.taskId === store.task.id) + 1;
33-
}, [store.taskHistory]);
34-
3535
useEffect(() => {
3636
if (store.commentStore.addedCommentThisSession) {
3737
setInitialCommentLength(visibleComments);
@@ -61,9 +61,15 @@ export const CurrentTask = observer(({ store }) => {
6161
<Elem name="task-id" style={{ fontSize: isFF(FF_DEV_3873) ? 12 : 14 }}>
6262
{store.task.id ?? guidGenerator()}
6363
{historyEnabled && showCounter && (
64-
<Elem name="task-count">
65-
{currentIndex} of {store.taskHistory.length}
66-
</Elem>
64+
isFF(FF_TASK_COUNT_FIX) ? (
65+
<Elem name="task-count">
66+
{store.queuePosition} of {store.queueTotal}
67+
</Elem>
68+
) : (
69+
<Elem name="task-count">
70+
{currentIndex} of {store.taskHistory.length}
71+
</Elem>
72+
)
6773
)}
6874
</Elem>
6975
{historyEnabled && (

src/stores/AppStore.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Hotkey } from '../core/Hotkey';
1717
import ToolsManager from '../tools/Manager';
1818
import Utils from '../utils';
1919
import { guidGenerator } from '../utils/unique';
20-
import { delay, isDefined } from '../utils/utilities';
20+
import { clamp, delay, isDefined } from '../utils/utilities';
2121
import AnnotationStore from './Annotation/store';
2222
import Project from './ProjectStore';
2323
import Settings from './SettingsStore';
@@ -154,6 +154,10 @@ export default types
154154
users: types.optional(types.array(UserExtended), []),
155155

156156
userLabels: isFF(FF_DEV_1536) ? types.optional(UserLabels, { controls: {} }) : types.undefined,
157+
158+
queueTotal: types.optional(types.number, 0),
159+
160+
queuePosition: types.optional(types.number, 0),
157161
})
158162
.preProcessSnapshot((sn) => {
159163
// This should only be handled if the sn.user value is an object, and converted to a reference id for other
@@ -529,6 +533,9 @@ export default types
529533
})
530534
.then(() => self.setFlags({ isSubmitting: false }));
531535
}
536+
function incrementQueuePosition(number = 1) {
537+
self.queuePosition = clamp(self.queuePosition + number, 1, self.queueTotal);
538+
}
532539

533540
function submitAnnotation() {
534541
if (self.isSubmitting) return;
@@ -543,6 +550,7 @@ export default types
543550
entity.sendUserGenerate();
544551
handleSubmittingFlag(async () => {
545552
await getEnv(self).events.invoke(event, self, entity);
553+
self.incrementQueuePosition();
546554
});
547555
entity.dropDraft();
548556
}
@@ -558,6 +566,7 @@ export default types
558566

559567
handleSubmittingFlag(async () => {
560568
await getEnv(self).events.invoke('updateAnnotation', self, entity, extraData);
569+
self.incrementQueuePosition();
561570
});
562571
entity.dropDraft();
563572
!entity.sentUserGenerate && entity.sendUserGenerate();
@@ -567,6 +576,7 @@ export default types
567576
if (self.isSubmitting) return;
568577
handleSubmittingFlag(() => {
569578
getEnv(self).events.invoke('skipTask', self, extraData);
579+
self.incrementQueuePosition();
570580
}, 'Error during skip, try again');
571581
}
572582

@@ -590,6 +600,7 @@ export default types
590600

591601
entity.dropDraft();
592602
await getEnv(self).events.invoke('acceptAnnotation', self, { isDirty, entity });
603+
self.incrementQueuePosition();
593604
}, 'Error during accept, try again');
594605
}
595606

@@ -606,6 +617,8 @@ export default types
606617

607618
entity.dropDraft();
608619
await getEnv(self).events.invoke('rejectAnnotation', self, { isDirty, entity, comment });
620+
self.incrementQueuePosition(-1);
621+
609622
}, 'Error during reject, try again');
610623
}
611624

@@ -754,14 +767,20 @@ export default types
754767
// or annotation created from prediction
755768
await annotation.saveDraft({ was_postponed: true });
756769
await getEnv(self).events.invoke('nextTask');
770+
self.incrementQueuePosition();
771+
757772
}
758773

759774
function nextTask() {
775+
760776
if (self.canGoNextTask) {
761777
const { taskId, annotationId } = self.taskHistory[self.taskHistory.findIndex((x) => x.taskId === self.task.id) + 1];
762778

763779
getEnv(self).events.invoke('nextTask', taskId, annotationId);
780+
self.incrementQueuePosition();
781+
764782
}
783+
765784
}
766785

767786
function prevTask(e, shouldGoBack = false) {
@@ -771,6 +790,8 @@ export default types
771790
const { taskId, annotationId } = self.taskHistory[length];
772791

773792
getEnv(self).events.invoke('prevTask', taskId, annotationId);
793+
self.incrementQueuePosition(-1);
794+
774795
}
775796
}
776797

@@ -826,6 +847,7 @@ export default types
826847
nextTask,
827848
prevTask,
828849
postponeTask,
850+
incrementQueuePosition,
829851
beforeDestroy() {
830852
ToolsManager.removeAllTools();
831853
appControls = null;

src/utils/feature-flags.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,13 @@ export const FF_TAXONOMY_ASYNC = 'fflag_feat_front_lsdv_5451_async_taxonomy_1108
316316
export const FF_TAXONOMY_LABELING = 'fflag_feat_front_lsdv_5452_taxonomy_labeling_110823_short';
317317

318318
/**
319-
* Annotator workflow control for lead time calculation
319+
* Fix task count on projects with over 100 tasks (switch from task history to queue count)
320+
* @link https://app.launchdarkly.com/default/production/features/fflag_fix_all_optic_79_task_count_is_wrong_short/targeting
321+
*/
322+
323+
export const FF_TASK_COUNT_FIX = 'fflag_fix_all_optic_79_task_count_is_wrong_short';
324+
/**
325+
* Annotator workflow control for lead time calculation
320326
*/
321327
export const FF_PROD_E_111 = 'fflag_feat_front_prod_e_111_annotator_workflow_control_short';
322328

0 commit comments

Comments
 (0)