@@ -6,6 +6,9 @@ import { isDefined } from "../../utils/utilities";
66import { IconBan } from "../../assets/icons" ;
77
88import "./Controls.styl" ;
9+ import { useCallback , useMemo , useState } from "react" ;
10+ import { Dropdown } from "../../common/Dropdown/DropdownComponent" ;
11+ import { FF_DEV_1593 , isFF } from "../../utils/feature-flags" ;
912
1013const TOOLTIP_DELAY = 0.8 ;
1114
@@ -28,6 +31,48 @@ const controlsInjector = inject(({ store }) => {
2831 } ;
2932} ) ;
3033
34+ const RejectDialog = ( { disabled, store } ) => {
35+ const [ show , setShow ] = useState ( false ) ;
36+ const [ comment , setComment ] = useState ( '' ) ;
37+ const onReject = useCallback ( ( ) => {
38+ store . rejectAnnotation ( { comment : comment . length ? comment : null } ) ;
39+ setShow ( false ) ;
40+ setComment ( '' ) ;
41+ } ) ;
42+
43+ return (
44+ < Dropdown . Trigger
45+ visible = { show }
46+ toggle = { ( ) => { } }
47+ onToggle = { ( visible ) => {
48+ setShow ( visible ) ;
49+ } }
50+ content = { (
51+ < Block name = "reject-dialog" >
52+ < Elem name = "input-title" >
53+ Reason of Rejection
54+ </ Elem >
55+ < Elem
56+ name = 'input'
57+ tag = { 'textarea' }
58+ type = "text"
59+ value = { comment }
60+ onChange = { ( event ) => { setComment ( event . target . value ) ; } }
61+ />
62+ < Elem name = 'footer' >
63+ < Button onClick = { ( ) => setShow ( false ) } > Cancel</ Button >
64+ < Button style = { { marginLeft : 8 } } look = "danger" onClick = { onReject } > Reject</ Button >
65+ </ Elem >
66+ </ Block >
67+ ) }
68+ >
69+ < Button aria-label = "reject-annotation" disabled = { disabled } look = "danger" >
70+ Reject
71+ </ Button >
72+ </ Dropdown . Trigger >
73+ ) ;
74+ } ;
75+
3176export const Controls = controlsInjector ( observer ( ( { store, history, annotation } ) => {
3277 const isReview = store . hasInterface ( "review" ) ;
3378 const historySelected = isDefined ( store . annotationStore . selectedHistory ) ;
@@ -37,14 +82,22 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
3782 const disabled = store . isSubmitting || historySelected ;
3883 const submitDisabled = store . hasInterface ( "annotations:deny-empty" ) && results . length === 0 ;
3984
85+ const RejectButton = useMemo ( ( ) => {
86+ if ( isFF ( FF_DEV_1593 ) ) {
87+ return < RejectDialog disabled = { disabled } store = { store } /> ;
88+ } else {
89+ return (
90+ < ButtonTooltip key = "reject" title = "Reject annotation: [ Ctrl+Space ]" >
91+ < Button aria-label = "reject-annotation" disabled = { disabled } look = "danger" onClick = { store . rejectAnnotation } >
92+ Reject
93+ </ Button >
94+ </ ButtonTooltip >
95+ ) ;
96+ }
97+ } , [ disabled , store ] ) ;
98+
4099 if ( isReview ) {
41- buttons . push (
42- < ButtonTooltip key = "reject" title = "Reject annotation: [ Ctrl+Space ]" >
43- < Button aria-label = "reject-annotation" disabled = { disabled } look = "danger" onClick = { store . rejectAnnotation } >
44- Reject
45- </ Button >
46- </ ButtonTooltip > ,
47- ) ;
100+ buttons . push ( RejectButton ) ;
48101
49102 buttons . push (
50103 < ButtonTooltip key = "accept" title = "Accept annotation: [ Ctrl+Enter ]" >
0 commit comments