Skip to content

Commit

Permalink
update license also in parent component
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Apr 19, 2024
1 parent 28b34ec commit 9396a0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 6 additions & 8 deletions frontend/src/components/VaultDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@
<ArrowPathIcon class="h-5 w-5" aria-hidden="true" />
</button>
</div>
<p v-if="licenseViolated" class="text-sm text-red-900 mt-1">
{{ t('vaultDetails.error.licenseViolated') }}
</p>
<!-- editMetadata button -->
<button v-if="vaultRole == 'OWNER'" type="button" class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary" @click="showEditVaultMetadataDialog()">
{{ t('vaultDetails.actions.editVaultMetadata') }}
Expand Down Expand Up @@ -228,6 +225,7 @@ const props = defineProps<{
const emit = defineEmits<{
vaultUpdated: [updatedVault: VaultDto]
licenseStatusUpdated: [license: LicenseUserInfoDto]
}>();
const onFetchError = ref<Error | null>();
Expand Down Expand Up @@ -295,8 +293,9 @@ async function fetchOwnerData() {
if (error instanceof ForbiddenError) {
vaultRecoveryRequired.value = true;
} else if (error instanceof PaymentRequiredError) {
//do nuthin
//or refetch license
//refetch license
license.value = await backend.license.getUserInfo();
emit('licenseStatusUpdated', license.value);
} else {
console.error('Retrieving ownership failed.', error);
onFetchError.value = error instanceof Error ? error : new Error('Unknown Error');
Expand Down Expand Up @@ -490,9 +489,8 @@ async function removeMember(memberId: string) {
if (!licenseViolated.value) {
usersRequiringAccessGrant.value = await backend.vaults.getUsersRequiringAccessGrant(props.vaultId);
} else {
// reload, maybe removing memberId fixed the license issue
//TODO is license.value = await backend.license.getUserInfo(); enough?
await fetchData();
license.value = await backend.license.getUserInfo();
emit('licenseStatusUpdated', license.value);
}
} catch (error) {
console.error('Removing member access failed.', error);
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/VaultList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</div>

<SlideOver v-if="selectedVault != null" ref="vaultDetailsSlideOver" :title="selectedVault.name" @close="selectedVault = null">
<VaultDetails :vault-id="selectedVault.id" :vault-role="roleOfSelectedVault" @vault-updated="v => onSelectedVaultUpdate(v)"></VaultDetails>
<VaultDetails :vault-id="selectedVault.id" :vault-role="roleOfSelectedVault" @vault-updated="v => onSelectedVaultUpdate(v)" @license-status-updated="l => licenseUpdated(l)"></VaultDetails>
</SlideOver>
</template>

Expand Down Expand Up @@ -221,4 +221,8 @@ async function onSelectedVaultUpdate(vault: VaultDto) {
selectedVault.value = vault;
}
}
async function licenseUpdated(license: LicenseUserInfoDto) {
licenseStatus.value = license;
}
</script>

0 comments on commit 9396a0e

Please sign in to comment.