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

Function selectEntityView

ui/src/selectors.js:400–425  ·  view source on GitHub ↗
(state, entityId, mode, isPreview)

Source from the content-addressed store, hash-verified

398}
399
400export function selectEntityView(state, entityId, mode, isPreview) {
401 if (mode) {
402 return mode;
403 }
404 const { schema } = selectEntity(state, entityId);
405 if (
406 schema &&
407 schema.isAny(['Email', 'HyperText', 'Image', 'Pages', 'Table'])
408 ) {
409 return 'view';
410 }
411 if (schema && schema.isA('Folder')) {
412 return 'browse';
413 }
414 if (schema && schema.isDocument()) {
415 return 'view';
416 }
417 if (isPreview) {
418 return 'info';
419 }
420 const references = selectEntityReferences(state, entityId);
421 if (references?.results?.length) {
422 return references.results[0].property.qname;
423 }
424 return 'similar';
425}
426
427export function selectProfileView(state, profileId, mode) {
428 return mode ? mode : 'items';

Callers 2

mapStateToPropsFunction · 0.90
mapStateToPropsFunction · 0.90

Calls 2

selectEntityFunction · 0.85
selectEntityReferencesFunction · 0.85

Tested by

no test coverage detected