-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from bcgov/public-toggle-inside-permissions
Add public toggle to permissions modal
- Loading branch information
Showing
7 changed files
with
127 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
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,53 @@ | ||
<script setup lang="ts"> | ||
import { ref, watch } from 'vue'; | ||
import { InputSwitch } from '@/lib/primevue'; | ||
import { useObjectStore, usePermissionStore } from '@/store'; | ||
import { Permissions } from '@/utils/constants'; | ||
import type { Ref } from 'vue'; | ||
// Props | ||
type Props = { | ||
bucketId: string; | ||
objectId: string; | ||
objectPublic: boolean; | ||
userId: string; | ||
}; | ||
const props = withDefaults(defineProps<Props>(), {}); | ||
// Store | ||
const objectStore = useObjectStore(); | ||
const permissionStore = usePermissionStore(); | ||
// State | ||
const isPublic: Ref<boolean> = ref(props.objectPublic); | ||
// Actions | ||
const togglePublic = async (isPublic: boolean) => { | ||
await objectStore.togglePublic(props.objectId, isPublic); | ||
}; | ||
watch(props, () => { | ||
isPublic.value = props.objectPublic; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<InputSwitch | ||
v-model="isPublic" | ||
:disabled=" | ||
!( | ||
usePermissionStore().isUserElevatedRights() && | ||
permissionStore.isObjectActionAllowed( | ||
props.objectId, | ||
props.userId, | ||
Permissions.MANAGE, | ||
props.bucketId as string | ||
) | ||
) | ||
" | ||
@change="togglePublic(isPublic)" | ||
/> | ||
</template> |
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