Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(snapshot-tab): fix loading issue and disable take snapshot if a process in already running #259

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 22 additions & 6 deletions src/components/Snapshots/SnapshotsTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const SnapshotsTab = ({ collectionName }) => {
const { client: qdrantClient } = useClient();
const [snapshots, setSnapshots] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const [isSnapshotLoading, setIsSnapshotLoading] = useState(false);
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
const errorSnackbarOptions = getSnackbarOptions('error', closeSnackbar);
const [localShards, setLocalShards] = useState([]);
Expand Down Expand Up @@ -50,7 +51,7 @@ export const SnapshotsTab = ({ collectionName }) => {
}, [qdrantClient, collectionName]);

const createSnapshot = () => {
setIsLoading(true);
setIsSnapshotLoading(true);
qdrantClient
.createSnapshot(collectionName)
.then((res) => {
Expand All @@ -60,7 +61,7 @@ export const SnapshotsTab = ({ collectionName }) => {
enqueueSnackbar(err.message, errorSnackbarOptions);
})
.finally(() => {
setIsLoading(false);
setIsSnapshotLoading(false);
});
};

Expand Down Expand Up @@ -136,7 +137,12 @@ export const SnapshotsTab = ({ collectionName }) => {
<h1>Snapshots</h1>
</Grid>
<Grid item xs={12} md={4} sx={{ display: 'flex', justifyContent: 'end' }}>
<Button variant={'contained'} onClick={createSnapshot} startIcon={<PhotoCamera fontSize={'small'} />}>
<Button
variant={'contained'}
onClick={createSnapshot}
startIcon={<PhotoCamera fontSize={'small'} />}
disabled={isSnapshotLoading}
>
Take snapshot
</Button>
</Grid>
Expand Down Expand Up @@ -178,7 +184,7 @@ export const SnapshotsTab = ({ collectionName }) => {
</InfoBanner>
)}
{isLoading && <div>Loading...</div>}
{!isLoading && snapshots?.length > 0 && (
{(snapshots?.length > 0 || isSnapshotLoading) && (
<Grid item xs={12}>
<TableContainer>
<TableWithGaps aria-label="simple table">
Expand All @@ -196,12 +202,22 @@ export const SnapshotsTab = ({ collectionName }) => {
</TableCell>
</TableRow>
</TableHeadWithGaps>
<TableBodyWithGaps>{tableRows}</TableBodyWithGaps>
<TableBodyWithGaps>
{tableRows}

{isSnapshotLoading && (
<TableRow>
<TableCell colSpan={4} align="center">
Loading...
</TableCell>
</TableRow>
)}
</TableBodyWithGaps>
</TableWithGaps>
</TableContainer>
</Grid>
)}
{!isLoading && !snapshots?.length && (
{!isLoading && !snapshots?.length && !isSnapshotLoading && (
<Grid item xs={12} textAlign={'center'}>
<Typography>No snapshots yet, take one! 📸</Typography>
</Grid>
Expand Down
Loading