MCPcopy Create free account
hub / github.com/alephdata/aleph / getLabelFromId

Method getLabelFromId

ui/src/components/MappingEditor/MappingList.js:58–74  ·  view source on GitHub ↗
(id, schema)

Source from the content-addressed store, hash-verified

56
57 // for pre-existing mappings, generate display label from schema id
58 getLabelFromId(id, schema) {
59 const schemaName = schema?.name;
60 if (!schemaName) {
61 return;
62 }
63
64 const re = new RegExp(`^${schemaName}(?<index>([0-9]*))$`);
65 const match = id.match(re)?.groups;
66 if (!match) {
67 return;
68 }
69
70 const label = `${schema.label} ${match.index}`.trim();
71 if (label !== id) {
72 return label;
73 }
74 }
75
76 changeId(oldId, newId) {
77 const mapping = this.getMapping(oldId);

Callers 1

constructorMethod · 0.95

Calls 1

matchMethod · 0.45

Tested by

no test coverage detected