11import React , { useState , useEffect , Fragment , useRef } from "react"
22import { WOQLClientObj } from '../init-woql-client'
33import { timeConverter , } from "../pages/utils"
4- import { Col , Button , Alert } from "react-bootstrap"
4+ import { Button , Alert } from "react-bootstrap"
55import { DATA_PRODUCT_HEALTHY } from "../pages/constants"
66import { HealthModal } from "./HealthModal"
77import { localSettings } from "../../localSettings"
88import InputGroup from 'react-bootstrap/InputGroup'
99import Card from "react-bootstrap/Card"
1010import Form from 'react-bootstrap/Form' ;
1111import { CopyButton } from "./utils"
12- import { RiDeleteBin7Line } from "react-icons/ri"
1312import { ManageDatabase } from "../hooks/ManageDatabase"
14- import { useNavigate } from "react-router-dom"
13+ import { useParams } from "react-router-dom"
1514import { Loading } from "./Loading"
1615
1716export const AboutDataProduct = ( { dataProductDetails, setShowDeleteModal, healthColor , branches} ) => {
17+ const { dataProduct, organization} = useParams ( )
1818 const [ showHealth , setShowHealth ] = useState ( false )
19+ const [ branchCount , setBranchCount ] = useState ( 0 )
20+
1921 const {
2022 woqlClient,
2123 documentClasses,
2224 accessControlDashboard
2325 } = WOQLClientObj ( )
24-
2526 const { cloneDatabase, loading :loadingClone , error :errorClone , setError :setCloneError } = ManageDatabase ( )
2627
2728 const cloneInTeam = useRef ( null ) ;
2829 const cloneDBName = useRef ( null ) ;
2930
30- if ( ! woqlClient ) return ""
31- const dataProduct = woqlClient . db ( )
32- const organization = woqlClient . organization ( )
33-
31+ if ( ! woqlClient ) return ""
3432
3533 const [ color , setColor ] = useState ( "text-muted" )
3634 const [ healthText , setHealthText ] = useState ( false )
@@ -44,14 +42,17 @@ export const AboutDataProduct = ({dataProductDetails, setShowDeleteModal, health
4442 if ( healthColor == DATA_PRODUCT_HEALTHY ) setColor ( "text-success" )
4543 } , [ healthColor ] )
4644
47- const [ branchCount , setBranchCount ] = useState ( 0 )
45+ useEffect ( ( ) => {
46+ if ( cloneDBName ) {
47+ cloneDBName . current . value = dataProduct
48+ }
49+ } , [ dataProduct ] )
4850
4951 useEffect ( ( ) => {
50- let count = 0
51- for ( var key in branches ) {
52- count += 1
52+ if ( branches && typeof branches === "object" ) {
53+ const keys = Object . keys ( branches )
54+ setBranchCount ( keys . length )
5355 }
54- setBranchCount ( count )
5556 } , [ branches ] )
5657
5758 let cloneURL = getCloneUrl ( )
@@ -76,7 +77,6 @@ export const AboutDataProduct = ({dataProductDetails, setShowDeleteModal, health
7677 }
7778
7879 return < React . Fragment >
79-
8080 < HealthModal dataProduct = { dataProduct } showHealth = { showHealth } setShowHealth = { setShowHealth } />
8181 < Card className = "bg-transparent p-1 mb-5 tdb__align__container" border = "muted" >
8282 < Card . Body >
@@ -151,7 +151,7 @@ export const AboutDataProduct = ({dataProductDetails, setShowDeleteModal, health
151151 placeholder = "New Data Product name"
152152 aria-label = "New Data Product name"
153153 defaultValue = { dataProduct }
154- />
154+ />
155155 </ InputGroup >
156156 < InputGroup className = "mb-3" >
157157 < Form . Select aria-label = "Clone Selects" className = "mt-4" ref = { cloneInTeam } >
0 commit comments