-
- {
- linkTypes ? (
-
- ) :
+ return (
+
+
+ {linkTypes && !fetchState ? (
+
+ ) : (
+
+
+
+ )}
+ {error ?
{error} : null}
+
+ );
+}
+
+function LinkTypeOptions(props: {
+ link: ExtendedLink;
+ linkTypes: readonly DirectedLinkType[];
+}) {
+ const {link, linkTypes} = props;
+ const {model, translation: t} = useWorkspace();
+
+ const language = useObservedProperty(model.events, 'changeLanguage', () => model.language);
+ useKeyedSyncStore(subscribeLinkTypes, linkTypes.map(type => type.iri), model);
+ const sortedLinkTypes = [...linkTypes].sort(
+ makeLinkTypeComparatorByLabelAndDirection(model, t, language)
+ );
+
+ return (
+ <>
+ {sortedLinkTypes.map(({key, iri, direction}: DirectedLinkType) => {
+ const data = model.getLinkType(iri);
+ const label = t.formatLabel(data?.data?.label, iri, model.language);
+ let [sourceLabel, targetLabel] = [link.source, link.target].map(element =>
+ model.locale.formatEntityLabel(element, model.language)
+ );
+ if (direction === 'in') {
+ [sourceLabel, targetLabel] = [targetLabel, sourceLabel];
}
- {error ?
{error} : null}
-
- );
- }
+ return (
+