Skip to content

Commit c14fd88

Browse files
fix[visualize-tab] : disable visalize tab for sparse and multi vector on collections and view-point page
1 parent 497e1f5 commit c14fd88

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

src/components/Collections/CollectionsList.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ const StyledLink = styled(Link)`
2020
const CollectionTableRow = ({ collection, getCollectionsCall }) => {
2121
const [openDeleteDialog, setOpenDeleteDialog] = useState(false);
2222
const theme = useTheme();
23+
const isDenseView = (vectors) => {
24+
if (vectors && vectors.size && vectors.distance && !vectors.multivector_config) {
25+
return true;
26+
}
27+
const vectorNames = Object.keys(vectors);
28+
return vectorNames.some((vectorName) => {
29+
return vectors[vectorName].size && vectors[vectorName].distance && !vectors[vectorName].multivector_config;
30+
});
31+
};
2332

2433
return (
2534
<TableRow>
@@ -57,9 +66,11 @@ const CollectionTableRow = ({ collection, getCollectionsCall }) => {
5766
<MenuItem component={Link} to={`/collections/${collection.name}#snapshots`}>
5867
Take Snapshot
5968
</MenuItem>
60-
<MenuItem component={Link} to={`/collections/${collection.name}/visualize`}>
61-
Visualize
62-
</MenuItem>
69+
{isDenseView(collection.config.params.vectors) ? (
70+
<MenuItem component={Link} to={`/collections/${collection.name}/visualize`}>
71+
Visualize
72+
</MenuItem>
73+
) : null}
6374
<MenuItem component={Link} to={`/collections/${collection.name}/graph`}>
6475
Graph
6576
</MenuItem>

src/pages/Collection.jsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import React, { useState, useEffect } from 'react';
22
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
33
import { Typography, Grid, Tabs, Tab } from '@mui/material';
44
import { CenteredFrame } from '../components/Common/CenteredFrame';
@@ -7,12 +7,32 @@ import { SnapshotsTab } from '../components/Snapshots/SnapshotsTab';
77
import CollectionInfo from '../components/Collections/CollectionInfo';
88
import PointsTabs from '../components/Points/PointsTabs';
99
import SearchQuality from '../components/Collections/SearchQuality/SearchQuality';
10+
import { useClient } from '../context/client-context';
1011

1112
function 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

Comments
 (0)