Add “node types” listing to plugin adapter (#464)

Summary:
This enables plugins to specify different semantic types of nodes, along
with human-readable names. This will be used, for instance, in the cred
explorer, where users may filter to one of these node types.

Paired with @decentralion.

Test Plan:
Flow passes.

wchargin-branch: plugin-node-types
This commit is contained in:
William Chargin 2018-06-29 23:28:29 -07:00 committed by GitHub
parent 728a3cdf37
commit 72be58a5c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -11,4 +11,8 @@ export interface PluginAdapter {
graph(): Graph;
renderer(): Renderer;
nodePrefix(): NodeAddressT;
nodeTypes(): Array<{|
+name: string,
+prefix: NodeAddressT,
|}>;
}

View File

@ -38,6 +38,14 @@ class PluginAdapter implements IPluginAdapter {
nodePrefix() {
return N._Prefix.base;
}
nodeTypes() {
return [
{name: "Blob", prefix: N._Prefix.blob},
{name: "Commit", prefix: N._Prefix.commit},
{name: "Tree", prefix: N._Prefix.tree},
{name: "Tree entry", prefix: N._Prefix.treeEntry},
];
}
}
class Renderer implements IRenderer {

View File

@ -43,6 +43,16 @@ class PluginAdapter implements IPluginAdapter {
nodePrefix() {
return N._Prefix.base;
}
nodeTypes() {
return [
{name: "Repository", prefix: N._Prefix.repo},
{name: "Issue", prefix: N._Prefix.issue},
{name: "Pull request", prefix: N._Prefix.pull},
{name: "Pull request review", prefix: N._Prefix.review},
{name: "Comment", prefix: N._Prefix.comment},
{name: "User", prefix: N._Prefix.userlike},
];
}
}
class Renderer implements IRenderer {