diff --git a/controller/src/index-file.ts b/controller/src/index-file.ts
index 78bc395..80519a1 100644
--- a/controller/src/index-file.ts
+++ b/controller/src/index-file.ts
@@ -137,7 +137,24 @@ export async function editPermissions(
return index;
}
-export function getItemId(index: Index, resource: url, user: url) {
+export function getItemId(index: Index, resource: url, user: string) {
+ console.log(user);
+ console.log(user === "public");
+ if (user === "public") {
+ console.log(
+ index.items.find(
+ (indexItem) =>
+ indexItem.resources.includes(resource) &&
+ indexItem.userType === undefined
+ )
+ );
+ return index.items.find(
+ (indexItem) =>
+ indexItem.resources.includes(resource) &&
+ indexItem.userType === undefined
+ )?.id;
+ }
+
return index.items.find(
(indexItem) =>
indexItem.resources.includes(resource) &&
diff --git a/loama/src/components/explorer/LoNotification.vue b/loama/src/components/LoNotification.vue
similarity index 90%
rename from loama/src/components/explorer/LoNotification.vue
rename to loama/src/components/LoNotification.vue
index 469359b..9741bfc 100644
--- a/loama/src/components/explorer/LoNotification.vue
+++ b/loama/src/components/LoNotification.vue
@@ -7,7 +7,7 @@
diff --git a/loama/src/components/explorer/ResourceExplorer.vue b/loama/src/components/explorer/ResourceExplorer.vue
index 4965b9e..de7a329 100644
--- a/loama/src/components/explorer/ResourceExplorer.vue
+++ b/loama/src/components/explorer/ResourceExplorer.vue
@@ -17,7 +17,8 @@
+ :url="selectedEntry.url" :agents="selectedEntry.accessModes" @close="selectedEntry = null"
+ @update-permissions="updateAgent" />
@@ -30,7 +31,7 @@ import { getPod } from "loama-controller";
import { ref, watch } from "vue";
import { PhLock, PhLockOpen } from "@phosphor-icons/vue";
import ExplorerEntry from "./ExplorerEntry.vue";
-import type { FormattedThing } from "loama-controller/dist/types";
+import type { FormattedThing, Permission } from "loama-controller/dist/types";
import { useRoute } from "vue-router";
import ExplorerBreadcrumbs from "./ExplorerBreadcrumbs.vue";
import SelectedEntry from "./SelectedEntry.vue";
@@ -51,6 +52,8 @@ const uriToName = (uri: string, isContainer: boolean) => {
return isContainer ? splitted[splitted.length - 2] : splitted[splitted.length - 1];
}
+const updateAgent = (selectedAgent: string, newPermissions: Permission[]) => selectedEntry.value!.accessModes[selectedAgent] = newPermissions;
+
watch(() => route.params.filePath, async (path) => {
selectedEntry.value = null;
data.value = await getThingsAtLevel(fileUrl(path)), { immediate: true }
diff --git a/loama/src/components/explorer/SelectedEntry.vue b/loama/src/components/explorer/SelectedEntry.vue
index eacc5c6..e95aa4a 100644
--- a/loama/src/components/explorer/SelectedEntry.vue
+++ b/loama/src/components/explorer/SelectedEntry.vue
@@ -19,11 +19,8 @@
@update:checked="updatePermissions(option.name, $event)">
{{ option.label }}
-
+
@@ -40,8 +37,9 @@ import { editPermissions, getOrCreateIndex, addPermissions, getItemId } from 'lo
import { store } from '@/store';
import type { Session } from '@inrupt/solid-client-authn-browser';
import type { Result } from '@/utils/types';
-import Notification from './LoNotification.vue';
+import Notification from '../LoNotification.vue';
+const emits = defineEmits<{ updatePermissions: [selectedAgent: string, newPermissions: Permission[]], close: [] }>()
const props = defineProps<{ name: string; url: string; isContainer: boolean; agents: Record }>();
const selectedAgent = ref(Object.keys(props.agents)[0]);
@@ -73,7 +71,7 @@ const refetchData = async () => {
if (itemId) {
const updatedPermissions = indexFile.items.find(item => item.id === itemId)?.permissions || [];
- props.agents[selectedAgent.value] = updatedPermissions;
+ emits('updatePermissions', selectedAgent.value, updatedPermissions);
} else {
console.warn('Item ID is not available for refetching permissions');
}
@@ -101,7 +99,7 @@ const updatePermissions = async (type: string, newValue: boolean) => {
await editPermissions(store.session as Session, indexFile, itemId, permissions);
} else {
// NOTE: This should be more fleshed out, e.g. username support
- const userType = { type: Type.WebID, url: selectedAgent.value };
+ const userType = selectedAgent.value === "public" ? undefined : { type: Type.WebID, url: selectedAgent.value };
await addPermissions(store.session as Session, indexFile, [props.url], userType, permissions);
}