Skip to content

Commit 3147176

Browse files
committed
Improve labels for errored properties
1 parent 4f51de7 commit 3147176

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

data-browser/src/components/forms/ResourceField.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ import { AtomicLink } from '../AtomicLink';
99
import { useState } from 'react';
1010
import { Button } from '../Button';
1111

12+
function generateErrorPropName(prop: Property): string {
13+
if (prop.error) {
14+
const endOfPath = prop.subject.split('/').pop();
15+
16+
return endOfPath || 'error';
17+
} else return prop.shortname;
18+
}
19+
1220
/** An input field for a single Property, rendered with a Label. Has a loading state. */
1321
function ResourceField({
1422
handleDelete,
@@ -32,7 +40,10 @@ function ResourceField({
3240
);
3341
}
3442

35-
const label = labelProp || property.shortname;
43+
const label =
44+
labelProp || property.error
45+
? generateErrorPropName(property)
46+
: property.shortname;
3647

3748
if (property.isDynamic && collapsedDynamic) {
3849
return (
@@ -88,7 +99,7 @@ function HelperText({ text, link }: HelperTextProps) {
8899
return (
89100
<HelperTextWraper>
90101
<Markdown text={text} />
91-
<AtomicLink subject={link}>Go to Property</AtomicLink>
102+
<AtomicLink subject={link}>{link}</AtomicLink>
92103
</HelperTextWraper>
93104
);
94105
}

data-browser/src/components/forms/ResourceForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ export function ResourceForm({
173173
<form about={resource.getSubject()} onSubmit={save}>
174174
{classSubject && klass.error && (
175175
<ErrMessage>
176-
Error in class. {klass.error.message}. You can still edit the
177-
resource, though.
176+
Error in class, so this form could miss properties. You can still edit
177+
the resource, though. Error message: `{klass.error.message}`
178178
</ErrMessage>
179179
)}
180180
{canWriteErr && <ErrMessage>Cannot save edits: {canWriteErr}</ErrMessage>}

0 commit comments

Comments
 (0)