* A single Property / Value renderer that shows a label on the left, and the * value on the right. The value is editable.
({
propertyURL,
resource,
editable,
columns,
}: Props)
| 41 | * value on the right. The value is editable. |
| 42 | */ |
| 43 | function PropVal({ |
| 44 | propertyURL, |
| 45 | resource, |
| 46 | editable, |
| 47 | columns, |
| 48 | }: Props): JSX.Element { |
| 49 | const property = useProperty(propertyURL); |
| 50 | const truncated = truncateUrl(propertyURL, 10, true); |
| 51 | |
| 52 | if (property.loading) { |
| 53 | return ( |
| 54 | <PropValRow columns={columns}> |
| 55 | <PropertyLabel title={propertyURL + ' is loading'}> |
| 56 | loading... |
| 57 | </PropertyLabel> |
| 58 | </PropValRow> |
| 59 | ); |
| 60 | } |
| 61 | |
| 62 | if (property.error) { |
| 63 | return ( |
| 64 | <PropValRow columns={columns}> |
| 65 | <PropertyLabel title={propertyURL + ' could not be loaded'}> |
| 66 | <AtomicLink subject={propertyURL}> |
| 67 | <ErrorLook>{truncated}</ErrorLook> |
| 68 | </AtomicLink> |
| 69 | </PropertyLabel> |
| 70 | <code>{JSON.stringify(resource.get(propertyURL))}</code> |
| 71 | </PropValRow> |
| 72 | ); |
| 73 | } |
| 74 | |
| 75 | return ( |
| 76 | <PropValRow columns={columns}> |
| 77 | <AtomicLink subject={propertyURL}> |
| 78 | <PropertyLabel title={property.description}> |
| 79 | {property.error ? ( |
| 80 | <ErrorLook>{truncated}</ErrorLook> |
| 81 | ) : ( |
| 82 | property.shortname || truncated |
| 83 | )} |
| 84 | : |
| 85 | </PropertyLabel> |
| 86 | </AtomicLink> |
| 87 | {editable ? ( |
| 88 | <ValueForm resource={resource} propertyURL={propertyURL} noMargin /> |
| 89 | ) : ( |
| 90 | <ValueComp |
| 91 | datatype={property.datatype} |
| 92 | value={resource.get(propertyURL)} |
| 93 | /> |
| 94 | )} |
| 95 | </PropValRow> |
| 96 | ); |
| 97 | } |
| 98 | |
| 99 | export default PropVal; |
nothing calls this directly
no test coverage detected