Skip to content

Commit

Permalink
Fix last todos
Browse files Browse the repository at this point in the history
  • Loading branch information
Zelzahn committed Jul 24, 2024
1 parent c0ea0b4 commit fe4d535
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 37 deletions.
19 changes: 18 additions & 1 deletion controller/src/index-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
const props = defineProps<{ type: 'success' | 'error', message: string }>();
defineProps<{ type: 'success' | 'error', message: string }>();
const visible = ref(true);
const timeoutDuration = 2000;
Expand Down
25 changes: 0 additions & 25 deletions loama/src/components/PodList.vue

This file was deleted.

7 changes: 5 additions & 2 deletions loama/src/components/explorer/ResourceExplorer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
</div>
</div>
<SelectedEntry v-else :name="selectedEntry.name" :isContainer="selectedEntry.isContainer"
:url="selectedEntry.url" :agents="selectedEntry.accessModes" @close="selectedEntry = null" />
:url="selectedEntry.url" :agents="selectedEntry.accessModes" @close="selectedEntry = null"
@update-permissions="updateAgent" />
</div>
</div>
</template>
Expand All @@ -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";
Expand All @@ -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 }
Expand Down
14 changes: 6 additions & 8 deletions loama/src/components/explorer/SelectedEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
@update:checked="updatePermissions(option.name, $event)">
{{ option.label }}
</LoSwitch>
<Notification
v-if="updateStatus"
:type="updateStatus.ok ? 'success' : 'error'"
:message="updateStatus.ok ? updateStatus.value : String(updateStatus.error) || 'No message available'"
/>
<Notification v-if="updateStatus" :type="updateStatus.ok ? 'success' : 'error'"
:message="updateStatus.ok ? updateStatus.value : String(updateStatus.error) || 'No message available'" />
</form>
</article>
</div>
Expand All @@ -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<string, Permission[]> }>();
const selectedAgent = ref(Object.keys(props.agents)[0]);
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit fe4d535

Please sign in to comment.