-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't raise errors for missing labels #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small question about whether to provide empty string or "None", but other than that, lgtm 👍🏼
@@ -54,7 +54,11 @@ export const getItemLabel = ( | |||
): Label => { | |||
const labels = (item as WithLabels).labels ?? (item as WithValues).values; | |||
if (!labels.length) { | |||
throw new Error(); | |||
return { | |||
value: "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -17,6 +17,11 @@ function asLabel(valuetype_id: string, language_id: string): Label { | |||
} | |||
|
|||
const systemLanguageCode = "en-ZA"; // arbitrary | |||
const emptyLabel = { | |||
value: "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elsewhere in Arches, we have "None" as a placeholder for no data (e.g. resource report page). What do you think of returning that instead of empty string to maintain the pattern and signal the absence of data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea, but the problem is that we'd need to localize it, and we don't currently have a way to use gettext in js/ts files. The recommendation is to expose the result of createGettext
in its own file, but we create it dynamically after making a call to the backend to get available languages.
We might want to make the languages a little more static following the lead of archesproject/arches#11571. I'll open a core issue to discuss it with @chrabyrd.
(If we leave it as is, the caller can check if the result is truthy and then replace it with a localized placeholder.) |
Discovered in archesproject/arches-lingo#135 that if you have incomplete data, like using the resource editor to create an incomplete scheme, the concept tree would break. The backend is hardened against this in lingo, but to harden the frontend, we need to update this util to not throw.