1
- import React , { useState } from 'react' ;
1
+ import React , { useState , useEffect } from 'react' ;
2
2
import { Link , useLocation , useNavigate , useParams } from 'react-router-dom' ;
3
3
import { Typography , Grid , Tabs , Tab } from '@mui/material' ;
4
4
import { CenteredFrame } from '../components/Common/CenteredFrame' ;
@@ -7,12 +7,32 @@ import { SnapshotsTab } from '../components/Snapshots/SnapshotsTab';
7
7
import CollectionInfo from '../components/Collections/CollectionInfo' ;
8
8
import PointsTabs from '../components/Points/PointsTabs' ;
9
9
import SearchQuality from '../components/Collections/SearchQuality/SearchQuality' ;
10
+ import { useClient } from '../context/client-context' ;
10
11
11
12
function Collection ( ) {
12
13
const { collectionName } = useParams ( ) ;
14
+ const { client : qdrantClient } = useClient ( ) ;
13
15
const navigate = useNavigate ( ) ;
14
16
const location = useLocation ( ) ;
15
17
const [ currentTab , setCurrentTab ] = useState ( location . hash . slice ( 1 ) || 'points' ) ;
18
+ const [ isDense , setIsDense ] = useState ( false ) ;
19
+
20
+ useEffect ( ( ) => {
21
+ const checkDenseView = async ( ) => {
22
+ const collectionData = await qdrantClient . getCollection ( collectionName ) ;
23
+ const vectors = collectionData . config . params . vectors ;
24
+ if ( vectors && vectors . size && vectors . distance && ! vectors . multivector_config ) {
25
+ setIsDense ( true ) ;
26
+ return ;
27
+ }
28
+ const vectorNames = Object . keys ( vectors ) ;
29
+ const dense = vectorNames . some ( ( vectorName ) => {
30
+ return vectors [ vectorName ] . size && vectors [ vectorName ] . distance && ! vectors [ vectorName ] . multivector_config ;
31
+ } ) ;
32
+ setIsDense ( dense ) ;
33
+ } ;
34
+ checkDenseView ( ) ;
35
+ } , [ collectionName , qdrantClient ] ) ;
16
36
17
37
const handleTabChange = ( event , newValue ) => {
18
38
if ( typeof newValue !== 'string' ) {
@@ -36,7 +56,12 @@ function Collection() {
36
56
< Tab label = "Info" value = { 'info' } />
37
57
< Tab label = "Search Quality" value = { 'quality' } />
38
58
< Tab label = "Snapshots" value = { 'snapshots' } />
39
- < Tab label = "Visualize" component = { Link } to = { `${ location . pathname } /visualize` } />
59
+ < Tab
60
+ label = "Visualize"
61
+ component = { Link }
62
+ to = { `${ location . pathname } /visualize` }
63
+ disabled = { ! isDense }
64
+ />
40
65
< Tab label = "Graph" component = { Link } to = { `${ location . pathname } /graph` } />
41
66
</ Tabs >
42
67
</ Box >
0 commit comments