-
Notifications
You must be signed in to change notification settings - Fork 62
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: fix empty props in template import #415
Conversation
app/pages/Console/ExportModal.tsx
Outdated
? tables.reduce((acc, cur) => { | ||
if (cur.type === 'vertex') { | ||
acc.push(cur.vid); | ||
} else { | ||
vertexIds.forEach(id => { | ||
acc.push(cur[id].toString()); | ||
}); | ||
} | ||
return acc; | ||
}, []).filter(vertexId => vertexId !== '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tables.reduce((acc, cur) => {
if (cur.type === 'vertex') {
cur.vid && acc.push(cur.vid);
} else {
vertexIds.forEach(id => {
acc.push(cur[id].toString());
});
}
return acc;
}, [])
const [data, setData] = useState<{ | ||
list: { | ||
Type: string, | ||
Name: string, | ||
Count: number, | ||
}[], | ||
total: { | ||
vertices: number, | ||
edges: number, | ||
} | null | ||
} | null>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [data, setData] = useState<{
list: { Type: string; Name: string; Count: number }[];
total?: { vertices: number; edges: number };
}>({ list: [], total: undefined });
const _data = data.tables.reduce((prev, cur) => { | ||
if (cur.Type === 'Space') { | ||
if(!prev.total) { | ||
prev.total = { | ||
vertex: 0, | ||
edge: 0, | ||
}; | ||
} | ||
prev.total[cur.Name] = cur.Count; | ||
} else { | ||
prev.list.push(cur); | ||
} | ||
return prev; | ||
}, { list: [], total: null }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const nextData = data.tables.reduce((prev, cur) => {
if (cur.Type === 'Space') {
prev.total ||= { vertex: 0, edge: 0 };
prev.total[cur.Name] = cur.Count;
} else {
prev.list.push(cur);
}
return prev;
}, { list: [], total: undefined } as typeof data });
// empty props in yaml will converted to null, but its required in nebula-importer | ||
parseContent.files.forEach(file => { | ||
if(file.schema.edge) { | ||
file.schema.edge.props = file.schema.edge?.props || []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file.schema.edge.props ||= [];
} | ||
if(file.schema.vertex) { | ||
file.schema.vertex?.tags.forEach(tag => { | ||
tag.props = tag.props || []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tag.props ||= [];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What type of PR is this?
What problem(s) does this PR solve?
Issue(s) number:
Description:
How do you solve it?
Special notes for your reviewer, ex. impact of this fix, design document, etc: