Skip to content

Commit

Permalink
Show onwed vaults filter for users as well
Browse files Browse the repository at this point in the history
This is also required to fix #225 so that non-admins can unarchive their vaults as well
  • Loading branch information
SailReal committed Oct 27, 2023
1 parent d9803cf commit c399d9d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions frontend/src/components/VaultList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="pb-5 mt-3 border-b border-gray-200 flex flex-wrap sm:flex-nowrap gap-3 items-center whitespace-nowrap">
<input id="vaultSearch" v-model="query" :placeholder="t('vaultList.search.placeholder')" type="text" class="focus:ring-primary focus:border-primary block w-full shadow-sm text-sm border-gray-300 rounded-md disabled:bg-gray-200"/>

<Listbox v-if="isAdmin" v-model="selectedFilter" as="div">
<Listbox v-model="selectedFilter" as="div">
<div class="relative w-44">
<ListboxButton class="relative w-full rounded-md border border-gray-300 bg-white py-2 pl-3 pr-10 text-left shadow-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary text-sm">
<span class="block truncate">{{ filterOptions[selectedFilter] }}</span>
Expand Down Expand Up @@ -138,11 +138,7 @@ const ownsSelectedVault = computed(() => {
const isAdmin = ref<boolean>();
const filterOptions = {
accessibleVaults: t('vaultList.filter.entry.accessibleVaults'),
ownedVaults: t('vaultList.filter.entry.ownedVaults'),
allVaults: t('vaultList.filter.entry.allVaults'),
};
const filterOptions = ref< {[key: string]: string} >({accessibleVaults: t('vaultList.filter.entry.accessibleVaults'), ownedVaults: t('vaultList.filter.entry.ownedVaults')});
const selectedFilter = ref<'accessibleVaults' | 'ownedVaults' | 'allVaults'>('accessibleVaults');
watch(selectedFilter, fetchData);
const query = ref('');
Expand All @@ -159,6 +155,11 @@ onMounted(fetchData);
async function fetchData() {
onFetchError.value = null;
try {
isAdmin.value = (await auth).isAdmin();
if (isAdmin.value) {
filterOptions.value['allVaults'] = t('vaultList.filter.entry.allVaults')
}
ownedVaults.value = (await backend.vaults.listAccessible('OWNER')).sort((a, b) => a.name.localeCompare(b.name));
switch (selectedFilter.value) {
case 'accessibleVaults':
Expand All @@ -173,7 +174,7 @@ async function fetchData() {
default:
throw new Error('Unknown filter');
}
isAdmin.value = (await auth).isAdmin();
} catch (error) {
console.error('Retrieving vault list failed.', error);
onFetchError.value = error instanceof Error ? error : new Error('Unknown Error');
Expand Down

0 comments on commit c399d9d

Please sign in to comment.