Skip to content
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

Bugfix/514 🐛 Fix explorer incomplete #518

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const LinkedStandards = ({ creCode, linkedTo, applyHighlight, filter }) =
*/
function isExternalLink(x: LinkedTreeDocument, linkedTo: any) {
if (!x.document.hyperlink) {
console.log(x.document);
return false;
}
const siblingCount = linkedTo.reduce((count, obj) => {
Expand Down
6 changes: 6 additions & 0 deletions application/frontend/src/pages/Explorer/explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { TYPE_CONTAINS, TYPE_LINKED_TO } from '../../const';
import { useDataStore } from '../../providers/DataProvider';
import { LinkedTreeDocument, TreeDocument } from '../../types';
import { LinkedStandards } from './LinkedStandards';
import { getDocumentDisplayName } from '../../utils';
import { getInternalUrl } from '../../utils/document';

export const Explorer = () => {
const { dataLoading, dataTree } = useDataStore();
Expand Down Expand Up @@ -80,6 +82,10 @@ export const Explorer = () => {
if (!item) {
return <></>;
}
item.displayName = item.displayName ?? getDocumentDisplayName(item);
item.url = item.url ?? getInternalUrl(item);
item.links = item.links ?? [];

const contains = item.links.filter((x) => x.ltype === TYPE_CONTAINS);
const linkedTo = item.links.filter((x) => x.ltype === TYPE_LINKED_TO);

Expand Down
4 changes: 3 additions & 1 deletion application/frontend/src/providers/DataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export const DataProvider = ({ children }: { children: React.ReactNode }) => {
);

if (!creLinks.length) {
storedDoc.links = [];
// leaves of the tree can be links that are included in the keyPath.
// If we don't add this here, the leaves are filtered out above (see ticket #514 on OpenCRE)
storedDoc.links = initialLinks.filter((x) => x.ltype === 'Contains' && !!x.document);
return storedDoc;
}

Expand Down
Loading