-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
208 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ h1 { | |
} | ||
h2 { | ||
color: var(--Solid-Purple); | ||
color: var(--solid-purple); | ||
font-weight: 700; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<template> | ||
<fieldset> | ||
<input type="checkbox" :id="id" v-model="checked" | ||
@input="(event) => $emit('update:checked', event.target.checked)"> | ||
<label :for="id"> | ||
<slot></slot> | ||
</label> | ||
</fieldset> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, watchEffect } from 'vue'; | ||
const props = defineProps<{ id: string; defaultValue: boolean }>(); | ||
const checked = ref(props.defaultValue); | ||
watchEffect(() => checked.value = props.defaultValue); | ||
</script> | ||
|
||
<style scoped> | ||
fieldset { | ||
border: none; | ||
display: flex; | ||
align-content: center; | ||
gap: .7rem; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<template> | ||
<div> | ||
<component :is="isContainer ? PhFolder : PhFile" :size="40" /> | ||
<span> | ||
<slot></slot> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { PhFolder, PhFile } from '@phosphor-icons/vue'; | ||
defineProps<{ | ||
isContainer: boolean, | ||
}>() | ||
</script> | ||
|
||
<style scoped> | ||
div { | ||
display: flex; | ||
flex: 0 1 auto; | ||
flex-flow: row nowrap; | ||
align-items: center; | ||
gap: var(--base-unit); | ||
background-color: #0000; | ||
border: none; | ||
width: 100%; | ||
} | ||
span { | ||
font-size: calc(var(--base-unit)*3); | ||
font-style: normal; | ||
font-weight: 700; | ||
line-height: normal; | ||
flex-grow: 1; | ||
text-align: start; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<template> | ||
<div class="container"> | ||
<header> | ||
<ExplorerEntity :is-container="isContainer"> | ||
{{ name }} | ||
</ExplorerEntity> | ||
<PhXCircle :size="40" @click="$emit('close')" class="clickable" /> | ||
</header> | ||
<article> | ||
<label for="agents"> | ||
<h3>User</h3> | ||
</label> | ||
<select name="agents" id="agents" v-model="selectedAgent"> | ||
<option v-for="agent in Object.keys(agents)" :key="agent" :value="agent">{{ agent }}</option> | ||
</select> | ||
<form> | ||
<LoSwitch v-for="option in permissionOptions" :key="option.name" :id="option.name" | ||
:default-value="isByDefaultSelected(option.name)" | ||
@update:checked="updatePermissions(option.name, $event)"> | ||
{{ option.label }} | ||
</LoSwitch> | ||
</form> | ||
</article> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import ExplorerEntity from './ExplorerEntity.vue'; | ||
import { PhXCircle } from '@phosphor-icons/vue'; | ||
import { ref } from 'vue'; | ||
import LoSwitch from '../LoSwitch.vue'; | ||
import { type url, Permission } from 'loama-controller/dist/types'; | ||
import { editPermissions, getOrCreateIndex } from 'loama-controller'; | ||
import { store } from '@/store'; | ||
import type { Session } from '@inrupt/solid-client-authn-browser'; | ||
const props = defineProps<{ name: string; isContainer: boolean; agents: Record<url, Permission[]> }>(); | ||
const selectedAgent = ref(Object.keys(props.agents)[0]); | ||
const permissionOptions = ref([ | ||
{ name: 'Read', label: "Able to read data" }, | ||
{ name: 'Write', label: "Able to add new data" }, | ||
{ name: 'Append', label: 'Able to modify existing data' }, | ||
{ name: 'Control', label: 'Able to manage access & permissions' } | ||
]) | ||
// @ts-ignore If you cast the permission to a Permissions the comparison no longer works. | ||
const isByDefaultSelected = (permission: string) => props.agents[selectedAgent.value].includes(permission) | ||
const updatePermissions = async (type: string, newValue: boolean) => { | ||
const indexFile = await getOrCreateIndex(store.session as Session, store.usedPod); | ||
let permissions = props.agents[selectedAgent.value]; | ||
if (newValue) { | ||
permissions.push(type as Permission) | ||
} else { | ||
permissions = permissions.filter((p) => p !== type) | ||
} | ||
// TODO: Maybe map selectedAgent to the one from the index file | ||
await editPermissions(store.session as Session, indexFile, selectedAgent.value, permissions); | ||
// TODO: Make sure the changed index file is shown here | ||
// props.agents[selectedAgent.value] = permissions; | ||
// TODO: Some kind of notification? | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
form { | ||
margin-top: calc(var(--base-unit)*2) | ||
} | ||
article { | ||
background-color: var(--off-white); | ||
border-radius: var(--base-corner); | ||
height: 100%; | ||
padding: 2rem; | ||
} | ||
header { | ||
display: flex; | ||
color: var(--off-white); | ||
flex-grow: 1; | ||
padding: 2rem; | ||
} | ||
h3 { | ||
font-size: calc(var(--base-unit)*2); | ||
} | ||
.clickable { | ||
cursor: pointer; | ||
} | ||
.container { | ||
background-color: var(--solid-purple); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { FormattedThing } from 'loama-controller/dist/types' | ||
|
||
export type Entry = FormattedThing & { name: string; isContainer: boolean } |