@@ -29,6 +29,8 @@ import { queryClient } from '@/common/queryClient';
2929import { API_HISTORY } from '@/api/history' ;
3030import { HistoryList } from '@/components2/HistoryList' ;
3131import { HistoryDashboardLabel } from '@/components2/HistoryDashboardLabel' ;
32+ import { ConfirmButton } from '@/components/UI/ConfirmButton' ;
33+ import { useStateBoolean } from '@/hooks' ;
3234
3335const METRIC_TYPE_KEYS : MetricType [ ] = Object . values ( METRIC_TYPE ) as MetricType [ ] ;
3436const PATH_VERSION_PARAM = '?mv' ;
@@ -180,6 +182,26 @@ export function EditForm(props: { isReadonly: boolean; adminMode: boolean; isHis
180182 return false ;
181183 } , [ values . resolution ] ) ;
182184
185+ const [ confirmRaw , setConfirmRaw ] = useStateBoolean ( false ) ;
186+
187+ const confirm = useMemo ( ( ) => {
188+ if ( confirmRaw ) {
189+ return (
190+ < div >
191+ < div > Enabling the Raw option for a tag can make your previous data for this tag uninterpretable.</ div >
192+ < div > Please ensure that you have not sent data for this tag before.</ div >
193+ </ div >
194+ ) ;
195+ }
196+ return undefined ;
197+ } , [ confirmRaw ] ) ;
198+
199+ useEffect ( ( ) => {
200+ if ( success ) {
201+ setConfirmRaw . off ( ) ;
202+ }
203+ } , [ setConfirmRaw , setConfirmRaw . off , success ] ) ;
204+
183205 return (
184206 < form key = { values . version } >
185207 < div className = "row mb-3" >
@@ -374,7 +396,12 @@ export function EditForm(props: { isReadonly: boolean; adminMode: boolean; isHis
374396 key = { ind }
375397 tagNumber = { ind }
376398 value = { tag }
377- onChange = { ( v ) => dispatch ( { type : 'alias' , pos : ind , tag : v } ) }
399+ onChange = { ( v ) => {
400+ dispatch ( { type : 'alias' , pos : ind , tag : v } ) ;
401+ if ( v . isRaw != null || v . raw_kind != null ) {
402+ setConfirmRaw . on ( ) ;
403+ }
404+ } }
378405 onChangeCustomMapping = { ( pos , from , to ) => dispatch ( { type : 'customMapping' , tag : ind , pos, from, to } ) }
379406 disabled = { isReadonly }
380407 />
@@ -648,9 +675,19 @@ export function EditForm(props: { isReadonly: boolean; adminMode: boolean; isHis
648675 </ div >
649676
650677 < div >
651- < button type = "button" disabled = { isRunning || isReadonly } className = "btn btn-primary me-3" onClick = { onSubmit } >
678+ { /*<button type="button" disabled={isRunning || isReadonly} className="btn btn-primary me-3" onClick={onSubmit}>*/ }
679+ { /* Save*/ }
680+ { /*</button>*/ }
681+ < ConfirmButton
682+ type = "button"
683+ disabled = { isRunning || isReadonly }
684+ className = "btn btn-primary me-3"
685+ confirmHeader = { < div className = "fw-bold" > Warning!</ div > }
686+ confirm = { confirm }
687+ onClick = { onSubmit }
688+ >
652689 Save
653- </ button >
690+ </ ConfirmButton >
654691 { isRunning ? (
655692 < div className = "spinner-border spinner-border-sm" role = "status" >
656693 < span className = "visually-hidden" > Loading...</ span >
0 commit comments