1- import React , { useState } from 'react' ;
1+ import React , { useState , useEffect } from 'react' ;
22import { Link , useLocation , useNavigate , useParams } from 'react-router-dom' ;
33import { Typography , Grid , Tabs , Tab } from '@mui/material' ;
44import { CenteredFrame } from '../components/Common/CenteredFrame' ;
@@ -7,12 +7,32 @@ import { SnapshotsTab } from '../components/Snapshots/SnapshotsTab';
77import CollectionInfo from '../components/Collections/CollectionInfo' ;
88import PointsTabs from '../components/Points/PointsTabs' ;
99import SearchQuality from '../components/Collections/SearchQuality/SearchQuality' ;
10+ import { useClient } from '../context/client-context' ;
1011
1112function Collection ( ) {
1213 const { collectionName } = useParams ( ) ;
14+ const { client : qdrantClient } = useClient ( ) ;
1315 const navigate = useNavigate ( ) ;
1416 const location = useLocation ( ) ;
1517 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 ] ) ;
1636
1737 const handleTabChange = ( event , newValue ) => {
1838 if ( typeof newValue !== 'string' ) {
@@ -36,7 +56,12 @@ function Collection() {
3656 < Tab label = "Info" value = { 'info' } />
3757 < Tab label = "Search Quality" value = { 'quality' } />
3858 < 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+ />
4065 < Tab label = "Graph" component = { Link } to = { `${ location . pathname } /graph` } />
4166 </ Tabs >
4267 </ Box >
0 commit comments