Skip to content

Commit

Permalink
[#41] Added route link from terms to vocabularies
Browse files Browse the repository at this point in the history
  • Loading branch information
filip-kopecky committed Oct 14, 2021
1 parent 7f3b148 commit dba668a
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/TermHeader.tsx
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@ import React from "react";
import AltLabel from "./AltLabel";
import IriLabel from "./IriLabel";
import DetailPageHeader from "./DetailPageHeader";
import RouteLink from "./RouteLink";
import { generateVocabularyRoute } from "../utils/Utils";

export interface DetailHeaderProps {
data: {
@@ -17,9 +19,11 @@ const TermHeader: React.FC<DetailHeaderProps> = (props) => {
const altLabels = props.data.altLabels;
const iri = props.data.uri;
const vocabulary = props.data.vocabulary;

const vocabularyRoute = generateVocabularyRoute(vocabulary);
const above = (
<IriLabel iri={vocabulary} variant="h5" color="textSecondary" />
<RouteLink to={vocabularyRoute} color="textSecondary">
<IriLabel iri={vocabulary} variant="h5" color="textSecondary" />
</RouteLink>
);
const below = <AltLabel altLabels={altLabels} />;

6 changes: 6 additions & 0 deletions src/utils/Utils.ts
Original file line number Diff line number Diff line change
@@ -40,3 +40,9 @@ export const generateTermRoute = (term: TermBase) => {
return "/error";
}
};

export const generateVocabularyRoute = (vocabularyUri: string) => {
const name = getNameFromUri(vocabularyUri);
const namespace = getNamespaceUri(vocabularyUri);
return `/vocabularies/${name}?namespace=${namespace}/`
};

0 comments on commit dba668a

Please sign in to comment.