Skip to content
Open
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
26 changes: 17 additions & 9 deletions app/lib/class/ContainerDataset.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { DatasetWrapper } from "@rdfjs/wrapper"
import { Container } from "@/app/lib/class/Container"
import { LDP } from "@/app/lib/class/Vocabulary"
import { DatasetWrapper } from "@rdfjs/wrapper";
import { Container } from "@/app/lib/class/Container";
import { LDP } from "@/app/lib/class/Vocabulary";

export class ContainerDataset extends DatasetWrapper {
// TODO: Consider that this might be undefined if there are no contained resources. We might need different matching.
get container(): Container | undefined {
// Return the first container in the dataset
for (const s of this.subjectsOf(LDP.contains, Container)) {
return s;
}
get container(): Container | undefined {
// Non-empty containers advertise children via ldp:contains.
for (const s of this.subjectsOf(LDP.contains, Container)) {
return s;
}

// Empty containers have no ldp:contains; resolve via rdf:type instead.
for (const s of this.instancesOf(LDP.Container, Container)) {
return s;
}

for (const s of this.instancesOf(LDP.BasicContainer, Container)) {
return s;
}
}
}
2 changes: 2 additions & 0 deletions app/lib/class/Vocabulary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const FOAF = {

export const LDP = {
contains: "http://www.w3.org/ns/ldp#contains",
Container: "http://www.w3.org/ns/ldp#Container",
BasicContainer: "http://www.w3.org/ns/ldp#BasicContainer",
} as const

export const PIM = {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/hooks/useBrowseStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function useBrowseStorage(containerUrl: string | null, refreshKey?: numbe
.container

if (container === undefined) {
throw new Error() // TODO: Handle properly
throw new Error("Could not identify the storage container in the listing response")
}

const fileItems: FileItemData[] = [];
Expand Down
26 changes: 21 additions & 5 deletions package-lock.json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated lockfile updates should not be introduced in this PR.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.