Skip to content

Commit 09c9003

Browse files
treangenerall
andauthored
New points filers design (#344)
* audit fix * wip * add filters logic * autocomplete * fix * styles * autocomplete popper size and position * remove the current value from autocomplete options * fixes * changed filters field design * fixes * moved a file, theme colors * fix * add expanding of the similarity field * remove expanding field button, expand automatically * improve loading state * placeholders fix * refactoring * fix input with whitespace * do not loose focus on query * clear on empty * autocomplete from the first letter * autocomplete for values * sort + max autocomplete length * separate conditions and similarities * clear canvas * allow filter by id * audit fix * format --------- Co-authored-by: generall <andrey@vasnetsov.com>
1 parent 36d2ff8 commit 09c9003

File tree

10 files changed

+1420
-206
lines changed

10 files changed

+1420
-206
lines changed

package-lock.json

Lines changed: 237 additions & 78 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Points/PointCard.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { bigIntJSON } from '../../common/bigIntJSON';
1212
import { Divider } from '@mui/material';
1313

1414
const PointCard = (props) => {
15-
const { onConditionChange /* , conditions */ } = props;
15+
const { onFindSimilar } = props;
1616
const [point, setPoint] = React.useState(props.point);
1717
const [loading, setLoading] = React.useState(false);
1818
const [openDeleteDialog, setOpenDeleteDialog] = React.useState(false);
@@ -93,7 +93,7 @@ const PointCard = (props) => {
9393
)}
9494
<Divider />
9595
<CardContent sx={{ padding: '1rem' }}>
96-
{point?.vector && <Vectors point={point} onConditionChange={onConditionChange} />}
96+
{point?.vector && <Vectors point={point} onFindSimilar={onFindSimilar} />}
9797
</CardContent>
9898
</Card>
9999
<ConfirmationDialog
@@ -112,8 +112,7 @@ const PointCard = (props) => {
112112

113113
PointCard.propTypes = {
114114
point: PropTypes.object.isRequired,
115-
onConditionChange: PropTypes.func.isRequired,
116-
conditions: PropTypes.array.isRequired,
115+
onFindSimilar: PropTypes.func.isRequired,
117116
collectionName: PropTypes.string.isRequired, // use params instead?
118117
deletePoint: PropTypes.func.isRequired,
119118
payloadSchema: PropTypes.object.isRequired,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react';
2+
import { Card, CardContent, CardHeader, Divider, Skeleton, Box } from '@mui/material';
3+
4+
const PointCardSkeleton = () => {
5+
return (
6+
<Card
7+
elevation={0}
8+
sx={{
9+
display: 'flex',
10+
flexDirection: 'column',
11+
height: '100%',
12+
}}
13+
>
14+
<CardHeader
15+
title={<Skeleton variant="text" width="60%" height={24} />}
16+
action={
17+
<Box sx={{ display: 'flex', alignItems: 'center' }}>
18+
<Skeleton variant="circular" width={32} height={32} sx={{ mr: 1 }} />
19+
<Skeleton variant="circular" width={32} height={32} />
20+
</Box>
21+
}
22+
/>
23+
<CardContent sx={{ padding: '0.5rem 1rem' }}>
24+
<Skeleton variant="rounded" height={60} sx={{ mb: 1 }} />
25+
<Skeleton variant="rounded" height={40} />
26+
</CardContent>
27+
<Divider />
28+
<CardContent sx={{ padding: '1rem' }}>
29+
<Skeleton variant="rounded" height={100} />
30+
</CardContent>
31+
</Card>
32+
);
33+
};
34+
35+
export default PointCardSkeleton;

src/components/Points/PointVectors.jsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const StyledButton = styled(Button)({
2525
* @returns {JSX.Element|null}
2626
* @constructor
2727
*/
28-
const Vectors = memo(function Vectors({ point, onConditionChange }) {
28+
const Vectors = memo(function Vectors({ point, onFindSimilar }) {
2929
const { collectionName } = useParams();
3030
const navigate = useNavigate();
3131
if (!Object.getOwnPropertyDescriptor(point, 'vector')) {
@@ -116,13 +116,11 @@ const Vectors = memo(function Vectors({ point, onConditionChange }) {
116116
>
117117
Open graph
118118
</StyledButton>
119-
{typeof onConditionChange !== 'function' ? null : (
119+
{typeof onFindSimilar !== 'function' ? null : (
120120
<StyledButton
121121
variant="outlined"
122122
size="small"
123-
onClick={() =>
124-
onConditionChange([{ key: 'id', type: 'id', value: point.id }], key === '' ? null : key)
125-
}
123+
onClick={() => onFindSimilar(point.id, key === '' ? null : key)}
126124
sx={{
127125
width: { xs: '100%', md: 'auto' },
128126
}}
@@ -140,7 +138,7 @@ const Vectors = memo(function Vectors({ point, onConditionChange }) {
140138

141139
Vectors.propTypes = {
142140
point: PropTypes.object.isRequired,
143-
onConditionChange: PropTypes.func,
141+
onFindSimilar: PropTypes.func,
144142
};
145143

146144
export default Vectors;

0 commit comments

Comments
 (0)