diff --git a/frontend/src/components/common/InviteButton.vue b/frontend/src/components/common/InviteButton.vue index ca5b1c05..f6259937 100644 --- a/frontend/src/components/common/InviteButton.vue +++ b/frontend/src/components/common/InviteButton.vue @@ -4,7 +4,17 @@ import { computed, ref, onMounted } from 'vue'; import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; import ShareLinkContent from '@/components/object/share/ShareLinkContent.vue'; -import { Button, Dialog, TabView, TabPanel, RadioButton, InputText, useToast, InputSwitch } from '@/lib/primevue'; +import { + Button, + Dialog, + TabView, + TabPanel, + RadioButton, + Checkbox, + InputText, + useToast, + InputSwitch +} from '@/lib/primevue'; import { Permissions } from '@/utils/constants'; import { inviteService } from '@/services'; import { useAuthStore, useConfigStore, useObjectStore, usePermissionStore, useBucketStore } from '@/store'; @@ -24,6 +34,7 @@ export type InviteFormData = { bucketId?: string; expiresAt?: number; objectId?: string; + permCodes?: Array; }; const props = withDefaults(defineProps(), { @@ -47,10 +58,10 @@ const obj: Ref = ref(undefined); const bucket: Ref = ref(undefined); const isRestricted: Ref = ref(props.restricted); const showInviteLink: Ref = ref(false); -const hasManagePermission: Ref = computed(() => { - return (props.objectId) ? - permissionStore.isObjectActionAllowed(props.objectId, getUserId.value, Permissions.MANAGE) : - permissionStore.isBucketActionAllowed(props.bucketId, getUserId.value, Permissions.MANAGE); +const hasManagePermission: Ref = computed(() => { + return props.objectId + ? permissionStore.isObjectActionAllowed(props.objectId, getUserId.value, Permissions.MANAGE) + : permissionStore.isBucketActionAllowed(props.bucketId, getUserId.value, Permissions.MANAGE); }); // Share link @@ -62,11 +73,27 @@ const timeFrames: Record = { '1 Day (Default)': 86400, '1 Week': 604800 }; -const formData: Ref = ref({ expiresAt: 86400 }); + +const bucketPermCodes: Record = { + READ: 'READ', + CREATE: 'UPLOAD', + UPDATE: 'UPDATE' +}; + +const objectPermCodes: Record = { + READ: 'READ', + UPDATE: 'UPDATE' +}; + +const formData: Ref = ref({ expiresAt: 86400, permCodes: ['READ'] }); // Dialog const displayInviteDialog = ref(false); +// Permissions selection +const selectedOptions = computed(() => { + return props.labelText === 'Bucket' ? bucketPermCodes : objectPermCodes; +}); // Share link const bcBoxLink = computed(() => { const path = props.objectId ? `detail/objects?objectId=${props.objectId}` : `list/objects?bucketId=${props.bucketId}`; @@ -76,6 +103,11 @@ const comsUrl = computed(() => { return `${getConfig.value.coms?.apiPath}/object/${props.objectId}`; }); +const isOptionUnselectable = (optionName: string) => { + // Make default permission disabled + return optionName === 'READ'; +}; + //Action async function sendInvite() { try { @@ -87,7 +119,8 @@ async function sendInvite() { props.bucketId, formData.value.email, expiresAt, - props.objectId + props.objectId, + formData.value.permCodes ); inviteLink.value = `${window.location.origin}/invite/${permissionToken.data}`; toast.success('', 'Invite link is created.'); @@ -159,7 +192,7 @@ onMounted(() => { :disabled="!hasManagePermission" >

{{ props.labelText }} Invite

-

Make invite available for:

+

Make invite available for

{
+

Access options

+
+
+ + +
+

Restrict to user's email

) { return comsAxios().post(`${PATH}`, { bucketId: bucketId || undefined, email: email || undefined, expiresAt: expiresAt || undefined, - objectId: objectId || undefined + objectId: objectId || undefined, + permCodes: permCodes || undefined }); },