aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src/mixins/ShareDetails.js
blob: 3884d22dae6fb89504b0d91f1e8ab2642498fd25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Share from '../models/Share.js'

export default {
	methods: {
		async openSharingDetails(shareRequestObject) {
			let share = {}
			// handle externalResults from OCA.Sharing.ShareSearch
			// TODO : Better name/interface for handler required
			// For example `externalAppCreateShareHook` with proper documentation
			if (shareRequestObject.handler) {
				if (this.suggestions) {
					shareRequestObject.suggestions = this.suggestions
					shareRequestObject.fileInfo = this.fileInfo
					shareRequestObject.query = this.query
				}
				share = await shareRequestObject.handler(shareRequestObject)
				share = new Share(share)
			} else {
				share = this.mapShareRequestToShareObject(shareRequestObject)
			}

			const shareDetails = {
				fileInfo: this.fileInfo,
				share,
			}

			this.$emit('open-sharing-details', shareDetails)
		},
		openShareDetailsForCustomSettings(share) {
			share.setCustomPermissions = true
			this.openSharingDetails(share)
		},
		mapShareRequestToShareObject(shareRequestObject) {

			if (shareRequestObject.id) {
				return shareRequestObject
			}

			const share = {
				attributes: [
					{
						enabled: true,
						key: 'download',
						scope: 'permissions',
					},
				],
				share_type: shareRequestObject.shareType,
				share_with: shareRequestObject.shareWith,
				is_no_user: shareRequestObject.isNoUser,
				user: shareRequestObject.shareWith,
				share_with_displayname: shareRequestObject.displayName,
				subtitle: shareRequestObject.subtitle,
				permissions: shareRequestObject.permissions,
				expiration: '',
			}

			return new Share(share)
		},
	},
}