11import React , { useState , useEffect , Fragment , useRef } from "react"
22import { WOQLClientObj } from '../init-woql-client'
33import { timeConverter , } from "../pages/utils"
4- import { Button , Alert } from "react-bootstrap"
4+ import { Button , Alert , ButtonGroup , ToggleButton } from "react-bootstrap"
55import { DATA_PRODUCT_HEALTHY } from "../pages/constants"
66import { HealthModal } from "./HealthModal"
77import { localSettings } from "../../localSettings"
@@ -20,9 +20,9 @@ export const AboutDataProduct = ({dataProductDetails, setShowDeleteModal, setSho
2020 const { dataProduct, organization} = useParams ( )
2121 const [ showHealth , setShowHealth ] = useState ( false )
2222 const [ branchCount , setBranchCount ] = useState ( 0 )
23- const { woqlClient, accessControlDashboard} = WOQLClientObj ( )
23+ const { woqlClient, accessControlDashboard, updateChangeRequestStatus , useChangeRequest , clientUser } = WOQLClientObj ( )
2424 const { documentClasses, getDocumentClasses} = useTDBDocuments ( woqlClient )
25-
25+ const [ radioValue , setRadioValue ] = useState ( useChangeRequest === false ? "Inactive" : "Active" ) ;
2626
2727 const { cloneDatabase, loading :loadingClone , error :errorClone , setError :setCloneError } = ManageDatabase ( )
2828
@@ -90,9 +90,43 @@ export const AboutDataProduct = ({dataProductDetails, setShowDeleteModal, setSho
9090 const showUpdateHandler = ( ) => {
9191 setShowUpdate ( dataProductDetails )
9292 }
93+
94+ const radios = [
95+ { name : 'Change Request Mode Active' , value : 'Active' , title :'manage your documents using the change request mode' } ,
96+ { name : 'Change Request Mode Inactive' , value : 'Inactive' , title :'manage your documents directly in the current branch' } ,
97+ ] ;
98+
99+
100+ const updateChangeRequestStatusHandler = function ( value ) {
101+ setRadioValue ( value )
102+ updateChangeRequestStatus ( value )
103+ }
93104
94105 return < React . Fragment >
95106 < HealthModal dataProduct = { dataProduct } showHealth = { showHealth } setShowHealth = { setShowHealth } />
107+ { clientUser . serverType !== "TerminusDB" &&
108+ < Card className = "bg-transparent p-1 mb-5 tdb__align__container" border = "muted" >
109+ < Card . Body >
110+ < ButtonGroup >
111+ { radios . map ( ( radio , idx ) => (
112+ < ToggleButton
113+ key = { idx }
114+ id = { `radio-${ idx } ` }
115+ type = "radio"
116+ title = { radio . title }
117+ variant = { idx === 0 ? 'outline-success' : 'outline-warning' }
118+ name = "radio"
119+ value = { radio . value }
120+ checked = { radioValue === radio . value }
121+ onChange = { ( e ) => updateChangeRequestStatusHandler ( e . currentTarget . value ) }
122+ >
123+ { radio . name }
124+ </ ToggleButton >
125+ ) ) }
126+ </ ButtonGroup >
127+ </ Card . Body >
128+ </ Card >
129+ }
96130 < Card className = "bg-transparent p-1 mb-5 tdb__align__container" border = "muted" >
97131 < Card . Body >
98132 < h4 className = "text-light mb-3 fw-bold" > About</ h4 >
0 commit comments