Skip to content

Commit

Permalink
Guest share enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
JanAckermann committed Apr 26, 2022
1 parent fc9075c commit 90da451
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
:userid="item.value.shareWith"
:user-name="item.label"
/>
<oc-avatar-guest
v-else-if="isGuest"
class="oc-mr-s"
:width="48"
:name="item.value.shareWith"
:accessible-label="$gettext('Guest')"
/>
<oc-icon
v-else-if="isGroup"
key="avatar-group"
Expand Down Expand Up @@ -71,6 +78,10 @@ export default {
return this.shareType === ShareTypes.space
},
isGuest() {
return this.shareType === ShareTypes.guest
},
isGroup() {
return this.shareType === ShareTypes.group
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,19 @@ export default {
this.configuration.options.sharingRecipientsPerPage
)
const shareType = this.resourceIsSpace ? ShareTypes.space.value : ShareTypes.user.value
const users = recipients.exact.users
.concat(recipients.users)
.filter((user) => user.value.shareWith !== this.user.id)
.map((result) => {
// Inject the correct share type here as the response has always type "user"
return { ...result, value: { ...result.value, shareType } }
// Inject the correct share type here if space
const shareType = this.resourceIsSpace ? ShareTypes.space.value : result.value.shareType
return {
...result,
value: {
...result.value,
shareType
}
}
})
let groups = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
:width="48"
class="files-collaborators-collaborator-indicator"
/>
<oc-avatar-guest
v-else-if="isGuest"
:name="share.collaborator.displayName"
:width="48"
:accessible-label="$gettext('Guest')"
/>
<oc-avatar-item
v-else
:width="48"
Expand Down Expand Up @@ -159,6 +165,10 @@ export default {
return this.shareType === ShareTypes.space
},
isGuest() {
return this.shareType === ShareTypes.guest
},
shareTypeText() {
return this.$gettext(this.shareType.label)
},
Expand Down
24 changes: 12 additions & 12 deletions packages/web-app-files/src/helpers/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,41 +279,41 @@ function addSharedWithToShares(shares) {
previousShare?.storage_id === share.storage_id &&
previousShare?.file_source === share.file_source
) {
if (ShareTypes.containsAnyValue(ShareTypes.authenticated, [share.share_type])) {
if (ShareTypes.containsAnyValue(ShareTypes.authenticated, [parseInt(share.share_type)])) {
previousShare.sharedWith.push({
username: share.share_with,
name: share.share_with_displayname,
displayName: share.share_with_displayname,
avatar: undefined,
shareType: share.share_type
shareType: parseInt(share.share_type)
})
} else if (share.share_type === ShareTypes.link.value) {
} else if (parseInt(share.share_type) === ShareTypes.link.value) {
previousShare.sharedWith.push({
name: share.name || share.token,
link: true,
shareType: share.share_type
shareType: parseInt(share.share_type)
})
}

continue
}

if (ShareTypes.containsAnyValue(ShareTypes.authenticated, [share.share_type])) {
if (ShareTypes.containsAnyValue(ShareTypes.authenticated, [parseInt(share.share_type)])) {
share.sharedWith = [
{
username: share.share_with,
displayName: share.share_with_displayname,
name: share.share_with_displayname,
avatar: undefined,
shareType: share.share_type
shareType: parseInt(share.share_type)
}
]
} else if (share.share_type === ShareTypes.link.value) {
} else if (parseInt(share.share_type) === ShareTypes.link.value) {
share.sharedWith = [
{
name: share.name || share.token,
link: true,
shareType: share.share_type
shareType: parseInt(share.share_type)
}
]
}
Expand All @@ -331,9 +331,9 @@ export function buildSharedResource(share, incomingShares = false, allowSharePer
fileId: share.item_source,
storageId: extractStorageId(share.item_source),
type: share.item_type,
mimeType: share.state === 0 ? share.mimetype : '',
mimeType: parseInt(share.state) === 0 ? share.mimetype : '',
isFolder,
sdate: DateTime.fromSeconds(share.stime).toRFC2822(),
sdate: DateTime.fromSeconds(parseInt(share.stime)).toRFC2822(),
indicators: [],
path: undefined,
webDavPath: undefined
Expand All @@ -353,7 +353,7 @@ export function buildSharedResource(share, incomingShares = false, allowSharePer
}
]
resource.sharedWith = share.sharedWith || []
resource.status = share.state
resource.status = parseInt(share.state)
resource.name = path.basename(share.file_target)
resource.path = share.file_target
resource.webDavPath = buildWebDavFilesPath(share.share_with, share.file_target)
Expand Down Expand Up @@ -471,7 +471,7 @@ export function buildCollaboratorShare(s, file, allowSharePermission): Share {
}
if (
ShareTypes.containsAnyValue(
[ShareTypes.user, ShareTypes.remote, ShareTypes.group],
[ShareTypes.user, ShareTypes.remote, ShareTypes.group, ShareTypes.guest],
[share.shareType]
)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ export class FolderLoaderSharedViaLink implements FolderLoader {
return useTask(function* (signal1, signal2) {
store.commit('Files/CLEAR_CURRENT_FILES_LIST')

let resources = yield client.requests.ocs({
service: 'apps/files_sharing',
action: '/api/v1/shares?format=json&share_types=3&include_tags=false',
method: 'GET'
let resources = yield client.shares.getShares('', {
share_types: '3',
include_tags: false
})

resources = yield resources.json()
resources = resources.ocs.data
resources = resources.map((r) => r.shareInfo)

if (resources.length) {
const configuration = store.getters.configuration
Expand Down
11 changes: 5 additions & 6 deletions packages/web-app-files/src/services/folder/loaderSharedWithMe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ export class FolderLoaderSharedWithMe implements FolderLoader {
return useTask(function* (signal1, signal2) {
store.commit('Files/CLEAR_CURRENT_FILES_LIST')

let resources = yield client.requests.ocs({
service: 'apps/files_sharing',
action: '/api/v1/shares?format=json&shared_with_me=true&state=all&include_tags=false',
method: 'GET'
let resources = yield client.shares.getShares('', {
state: 'all',
include_tags: false,
shared_with_me: true
})

resources = yield resources.json()
resources = resources.ocs.data
resources = resources.map((r) => r.shareInfo)

if (resources.length) {
const configuration = store.getters.configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ export class FolderLoaderSharedWithOthers implements FolderLoader {
.map((share) => share.value)
.join(',')

let resources = yield client.requests.ocs({
service: 'apps/files_sharing',
action: `/api/v1/shares?format=json&reshares=true&include_tags=false&share_types=${shareTypes}`,
method: 'GET'
let resources = yield client.shares.getShares('', {
share_types: shareTypes,
reshares: true,
include_tags: false
})

resources = yield resources.json()
resources = resources.ocs.data
resources = resources.map((r) => r.shareInfo)

if (resources.length) {
const configuration = store.getters.configuration
Expand All @@ -51,6 +50,9 @@ export class FolderLoaderSharedWithOthers implements FolderLoader {
)
}

const user = store.state.user
resources = resources.filter((r) => r.shareOwner === user.id)

store.commit('Files/LOAD_FILES', { currentFolder: null, files: resources })
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"marked": "^4.0.12",
"oidc-client": "1.11.5",
"owncloud-design-system": "^13.1.0-rc.5",
"owncloud-sdk": "~3.0.0-alpha.4",
"owncloud-sdk": "~3.0.0-alpha.6",
"p-queue": "^6.1.1",
"popper-max-size-modifier": "^0.2.0",
"portal-vue": "^2.1.7",
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9694,19 +9694,19 @@ __metadata:
languageName: node
linkType: hard

"owncloud-sdk@npm:~3.0.0-alpha.4":
version: 3.0.0-alpha.4
resolution: "owncloud-sdk@npm:3.0.0-alpha.4"
"owncloud-sdk@npm:~3.0.0-alpha.6":
version: 3.0.0-alpha.6
resolution: "owncloud-sdk@npm:3.0.0-alpha.6"
peerDependencies:
axios: ^0.26.0
cross-fetch: ^3.0.6
promise: ^8.0.3
qs: ^6.10.3
utf8: ^3.0.0
uuid: ^8.2.0
webdav: 4.8.0
webdav: 4.9.0
xml-js: ^1.6.11
checksum: de15ec2b3f5ed097eb73777192220f3e5df637d3aa2266d964c30d9fce904252ee9269f516e294fae8e8b41334508ef8e0212bda299c608d13a4e234536f9e27
checksum: 4f5d5e92f108ed2e1fa1145396cb29d2d6ff48737edb8de8e655e77d9960acccb1e5136451f681d9c731a95f94e37fd1b3abb0202d61e6724104bdece3052151
languageName: node
linkType: hard

Expand Down Expand Up @@ -13822,7 +13822,7 @@ __metadata:
marked: ^4.0.12
oidc-client: 1.11.5
owncloud-design-system: ^13.1.0-rc.5
owncloud-sdk: ~3.0.0-alpha.4
owncloud-sdk: ~3.0.0-alpha.6
p-queue: ^6.1.1
popper-max-size-modifier: ^0.2.0
portal-vue: ^2.1.7
Expand Down

0 comments on commit 90da451

Please sign in to comment.