@@ -8,7 +8,6 @@ import { isDefined } from '../../utils/utilities';
88import './CurrentTask.styl' ;
99import { reaction } from 'mobx' ;
1010
11-
1211export const CurrentTask = observer ( ( { store } ) => {
1312 const [ initialCommentLength , setInitialCommentLength ] = useState ( 0 ) ;
1413 const [ visibleComments , setVisibleComments ] = useState ( 0 ) ;
@@ -27,7 +26,7 @@ export const CurrentTask = observer(({ store }) => {
2726 } , [ ] ) ;
2827
2928 const currentIndex = useMemo ( ( ) => {
30- return store . taskHistory . findIndex ( ( x ) => x . taskId === store . task . id ) + 1 ;
29+ return store . taskHistory . findIndex ( x => x . taskId === store . task . id ) + 1 ;
3130 } , [ store . taskHistory ] ) ;
3231
3332 useEffect ( ( ) => {
@@ -36,43 +35,76 @@ export const CurrentTask = observer(({ store }) => {
3635 }
3736 } , [ store . commentStore . addedCommentThisSession ] ) ;
3837
39- const historyEnabled = store . hasInterface ( 'topbar:prevnext ' ) ;
38+ const historyBasedTaskList = store . hasInterface ( 'topbar:prev-next-history ' ) ;
4039 const showCounter = store . hasInterface ( 'topbar:task-counter' ) ;
4140
4241 // @todo some interface?
43- let canPostpone = isFF ( FF_DEV_3034 )
44- && ! isDefined ( store . annotationStore . selected . pk )
45- && ! store . canGoNextTask
46- && ! store . hasInterface ( 'review' )
47- && store . hasInterface ( 'postpone' ) ;
48-
42+ let canPostpone =
43+ isFF ( FF_DEV_3034 ) &&
44+ ! isDefined ( store . annotationStore . selected . pk ) &&
45+ ! store . canGoNextTask &&
46+ ! store . hasInterface ( 'review' ) &&
47+ store . hasInterface ( 'postpone' ) ;
4948
5049 if ( isFF ( FF_DEV_4174 ) ) {
51- canPostpone = canPostpone && store . commentStore . addedCommentThisSession && ( visibleComments >= initialCommentLength ) ;
50+ canPostpone = canPostpone && store . commentStore . addedCommentThisSession && visibleComments >= initialCommentLength ;
5251 }
53-
5452 return (
5553 < Elem name = "section" >
56- < Block name = "current-task" mod = { { 'with-history' : historyEnabled } } style = { {
57- padding :isFF ( FF_DEV_3873 ) && 0 ,
58- width :isFF ( FF_DEV_3873 ) && 'auto' ,
59- } } >
60- < Elem name = "task-id" style = { { fontSize :isFF ( FF_DEV_3873 ) ? 12 : 14 } } >
54+ < Block
55+ name = "current-task"
56+ mod = { { 'with-history' : historyBasedTaskList } }
57+ style = { {
58+ padding : isFF ( FF_DEV_3873 ) && 0 ,
59+ width : isFF ( FF_DEV_3873 ) && 'auto' ,
60+ } }
61+ >
62+ < Elem name = "task-id" style = { { fontSize : isFF ( FF_DEV_3873 ) ? 12 : 14 } } >
6163 { store . task . id ?? guidGenerator ( ) }
62- { historyEnabled && showCounter && (
64+ { historyBasedTaskList && showCounter && (
6365 < Elem name = "task-count" >
6466 { currentIndex } of { store . taskHistory . length }
6567 </ Elem >
6668 ) }
6769 </ Elem >
68- { historyEnabled && (
69- < Elem name = "history-controls" mod = { { newui : isFF ( FF_DEV_3873 ) } } >
70+ { historyBasedTaskList ? (
71+ < Elem name = "history-controls" mod = { { newui : isFF ( FF_DEV_3873 ) } } >
72+ < Elem
73+ tag = { Button }
74+ name = "prevnext"
75+ mod = { { prev : true , disabled : ! store . canGoPrevHistoryTask , newui : isFF ( FF_DEV_3873 ) } }
76+ type = "link"
77+ disabled = { ! historyBasedTaskList || ! store . canGoPrevHistoryTask }
78+ onClick = { store . prevTask }
79+ style = { { background : ! isFF ( FF_DEV_3873 ) && 'none' , backgroundColor : isFF ( FF_DEV_3873 ) && 'none' } }
80+ />
81+ < Elem
82+ tag = { Button }
83+ name = "prevnext"
84+ mod = { {
85+ next : true ,
86+ disabled : ! store . canGoNextHistoryTask && ! canPostpone ,
87+ postpone : ! store . canGoNextHistoryTask && canPostpone ,
88+ newui : isFF ( FF_DEV_3873 ) ,
89+ } }
90+ type = "link"
91+ disabled = { ! store . canGoNextHistoryTask && ! canPostpone }
92+ onClick = { store . canGoNextHistoryTask ? store . nextTask : store . postponeTask }
93+ style = { { background : ! isFF ( FF_DEV_3873 ) && 'none' , backgroundColor : isFF ( FF_DEV_3873 ) && 'none' } }
94+ />
95+ </ Elem >
96+ ) : (
97+ < Elem name = "history-controls" >
7098 < Elem
7199 tag = { Button }
72100 name = "prevnext"
73- mod = { { prev : true , disabled : ! store . canGoPrevTask , newui : isFF ( FF_DEV_3873 ) } }
101+ mod = { {
102+ prev : true ,
103+ disabled : ! store . adjacentTaskIds ?. prevTaskId ,
104+ newui : isFF ( FF_DEV_3873 ) ,
105+ } }
74106 type = "link"
75- disabled = { ! historyEnabled || ! store . canGoPrevTask }
107+ disabled = { ! store . adjacentTaskIds ?. prevTaskId }
76108 onClick = { store . prevTask }
77109 style = { { background : ! isFF ( FF_DEV_3873 ) && 'none' , backgroundColor : isFF ( FF_DEV_3873 ) && 'none' } }
78110 />
@@ -81,13 +113,12 @@ export const CurrentTask = observer(({ store }) => {
81113 name = "prevnext"
82114 mod = { {
83115 next : true ,
84- disabled : ! store . canGoNextTask && ! canPostpone ,
85- postpone : ! store . canGoNextTask && canPostpone ,
116+ disabled : ! store . adjacentTaskIds ?. nextTaskId ,
86117 newui : isFF ( FF_DEV_3873 ) ,
87118 } }
88119 type = "link"
89- disabled = { ! store . canGoNextTask && ! canPostpone }
90- onClick = { store . canGoNextTask ? store . nextTask : store . postponeTask }
120+ disabled = { ! store . adjacentTaskIds ?. nextTaskId }
121+ onClick = { store . nextTask }
91122 style = { { background : ! isFF ( FF_DEV_3873 ) && 'none' , backgroundColor : isFF ( FF_DEV_3873 ) && 'none' } }
92123 />
93124 </ Elem >
0 commit comments