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

feat: Add Separate Panel for Points View to Mirror Graph Layout #222

Merged
merged 5 commits into from
Sep 19, 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
29 changes: 14 additions & 15 deletions package-lock.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const PointPreview = ({ point }) => {
const [loading] = React.useState(false);
const conditions = [];
const payloadSchema = {};
const onConditionChange = () => {};

if (!point) {
return null;
Expand Down Expand Up @@ -48,7 +47,6 @@ const PointPreview = ({ point }) => {
<Grid item xs={12} my={1}>
<DataGridList
data={{ id: point.id, ...point.payload }}
onConditionChange={onConditionChange}
conditions={conditions}
payloadSchema={payloadSchema}
/>
Expand All @@ -67,7 +65,7 @@ const PointPreview = ({ point }) => {
}}
/>
<CardContent>
<Vectors point={point} onConditionChange={onConditionChange} />
<Vectors point={point} />
</CardContent>
</>
)}
Expand Down
165 changes: 0 additions & 165 deletions src/components/FilterEditorWindow/config/RequestFromCode.js

This file was deleted.

16 changes: 15 additions & 1 deletion src/components/FilterEditorWindow/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useClient } from '../../context/client-context';
import { useTheme } from '@mui/material/styles';
import { autocomplete } from './config/Autocomplete';
import { useSnackbar } from 'notistack';
import { codeParse } from './config/RequestFromCode';
import { bigIntJSON } from '../../common/bigIntJSON';
import './editor.css';
import EditorCommon from '../EditorCommon';

Expand All @@ -30,6 +30,20 @@ const CodeEditorWindow = ({ onChange, code, onChangeResult, customRequestSchema,
[]
);

function codeParse(codeText) {
// Parse JSON
if (codeText) {
try {
return bigIntJSON.parse(codeText);
} catch (e) {
return {
reqBody: codeText,
error: 'Fix the position brackets to run & check the json',
};
}
}
}

function onRun(codeText) {
const data = codeParse(codeText);
if (data.error) {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Points/DataGridList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ export const DataGridList = function ({ data = {}, specialCases = {}, onConditio
if (conditions.find((c) => c.key === filter.key && c.value === filter.value)) {
return;
}
onConditionChange([...conditions, filter]);
if (typeof onConditionChange === 'function') {
onConditionChange([...conditions, filter]);
}
}}
>
<FilterAltIcon />
Expand Down
21 changes: 13 additions & 8 deletions src/components/Points/PointVectors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const Vectors = memo(function Vectors({ point, onConditionChange }) {

return (
<Box pt={2}>
Vectors:
{Object.keys(vectors).map((key) => {
return (
<Grid key={key} container spacing={2}>
Expand Down Expand Up @@ -81,13 +82,17 @@ const Vectors = memo(function Vectors({ point, onConditionChange }) {
<Button variant="outlined" size="small" onClick={() => handleNavigate(key)}>
Open graph
</Button>
<Button
variant="outlined"
size="small"
onClick={() => onConditionChange([{ key: 'id', type: 'id', value: point.id }], key === '' ? null : key)}
>
Find Similar
</Button>
{typeof onConditionChange !== 'function' ? null : (
<Button
variant="outlined"
size="small"
onClick={() =>
onConditionChange([{ key: 'id', type: 'id', value: point.id }], key === '' ? null : key)
}
>
Find Similar
</Button>
)}
</Grid>
</Grid>
);
Expand All @@ -98,7 +103,7 @@ const Vectors = memo(function Vectors({ point, onConditionChange }) {

Vectors.propTypes = {
point: PropTypes.object.isRequired,
onConditionChange: PropTypes.func.isRequired,
onConditionChange: PropTypes.func,
};

export default Vectors;
Loading
Loading