Skip to content

Commit abcf1e4

Browse files
authored
Merge pull request #51580 from nextcloud/backport/51250/stable29
[stable29] fix: pass hide download attribute while creating the share to fix github issue 50788
2 parents 1245912 + 4676b75 commit abcf1e4

14 files changed

Lines changed: 54 additions & 19 deletions

apps/files_sharing/src/components/SharingInput.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
<template>
2424
<div class="sharing-search">
25-
<label for="sharing-search-input">{{ t('files_sharing', 'Search for share recipients') }}</label>
25+
<label :for="shareInputId">{{ t('files_sharing', 'Search for share recipients') }}</label>
2626
<NcSelect ref="select"
2727
v-model="value"
28-
input-id="sharing-search-input"
28+
:input-id="shareInputId"
2929
class="sharing-search__input"
3030
:disabled="!canReshare"
3131
:loading="loading"
@@ -93,6 +93,12 @@ export default {
9393
},
9494
},
9595
96+
setup() {
97+
return {
98+
shareInputId: `share-input-${Math.random().toString(36).slice(2, 7)}`,
99+
}
100+
},
101+
96102
data() {
97103
return {
98104
config: new Config(),

apps/files_sharing/src/mixins/ShareDetails.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default {
4646
scope: 'permissions',
4747
},
4848
],
49+
hideDownload: false,
4950
share_type: shareRequestObject.shareType,
5051
share_with: shareRequestObject.shareWith,
5152
is_no_user: shareRequestObject.isNoUser,

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,16 @@ export default {
299299
// force value to string because that is what our
300300
// share api controller accepts
301301
propertyNames.forEach(name => {
302-
if ((typeof this.share[name]) === 'object') {
302+
if (this.share[name] === null || this.share[name] === undefined) {
303+
properties[name] = ''
304+
} else if ((typeof this.share[name]) === 'object') {
303305
properties[name] = JSON.stringify(this.share[name])
304306
} else {
305307
properties[name] = this.share[name].toString()
306308
}
307309
})
308310

309-
this.updateQueue.add(async () => {
311+
return this.updateQueue.add(async () => {
310312
this.saving = true
311313
this.errors = {}
312314
try {
@@ -338,7 +340,6 @@ export default {
338340
this.saving = false
339341
}
340342
})
341-
return
342343
}
343344

344345
// This share does not exists on the server yet

apps/files_sharing/src/models/Share.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export default class Share {
3939
ocsData = ocsData.ocs.data[0]
4040
}
4141

42+
// string to int
43+
if (typeof ocsData.id === 'string') {
44+
ocsData.id = Number.parseInt(ocsData.id)
45+
}
4246
// convert int into boolean
4347
ocsData.hide_download = !!ocsData.hide_download
4448
ocsData.mail_send = !!ocsData.mail_send
@@ -113,7 +117,7 @@ export default class Share {
113117
* @memberof Share
114118
*/
115119
get attributes() {
116-
return this._share.attributes
120+
return this._share.attributes || []
117121
}
118122

119123
/**

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,10 +901,24 @@ export default {
901901
902902
this.creating = true
903903
const share = await this.addShare(incomingShare)
904-
this.creating = false
904+
// ugly hack to make code work - we need the id to be set but at the same time we need to keep values we want to update
905+
this.share._share.id = share.id
906+
await this.queueUpdate(...permissionsAndAttributes)
907+
// Also a ugly hack to update the updated permissions
908+
for (const prop of permissionsAndAttributes) {
909+
if (prop in share && prop in this.share) {
910+
try {
911+
share[prop] = this.share[prop]
912+
} catch {
913+
share._share[prop] = this.share[prop]
914+
}
915+
}
916+
}
905917
this.share = share
918+
this.creating = false
906919
this.$emit('add:share', this.share)
907920
} else {
921+
// Let's update after creation as some attrs are only available after creation
908922
this.$emit('update:share', this.share)
909923
emit('update:share', this.share)
910924
this.queueUpdate(...permissionsAndAttributes)

cypress/e2e/files_sharing/filesSharingUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export function createShare(fileName: string, username: string, shareSettings: P
3737
openSharingPanel(fileName)
3838

3939
cy.get('#app-sidebar-vue').within(() => {
40-
cy.get('#sharing-search-input').clear()
4140
cy.intercept({ times: 1, method: 'GET', url: '**/apps/files_sharing/api/v1/sharees?*' }).as('userSearch')
42-
cy.get('#sharing-search-input').type(username)
41+
cy.findByRole('combobox', { name: /Search for share recipients/i })
42+
.type(`{selectAll}${username}`)
4343
cy.wait('@userSearch')
4444
})
4545

cypress/e2e/files_sharing/public-share/setup-public-share.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,24 @@ export function createShare(context: ShareContext, shareName: string, options: S
118118
}
119119

120120
/**
121-
* Adjust share permissions to be editable
121+
* open link share details for specific index
122+
*
123+
* @param index
122124
*/
123-
function adjustSharePermission(): void {
125+
export function openLinkShareDetails(index: number) {
124126
cy.findByRole('list', { name: 'Link shares' })
125127
.findAllByRole('listitem')
126-
.first()
128+
.eq(index)
127129
.findByRole('button', { name: /Actions/i })
128130
.click()
129131
cy.findByRole('menuitem', { name: /Customize link/i }).click()
132+
}
133+
134+
/**
135+
* Adjust share permissions to be editable
136+
*/
137+
function adjustSharePermission(): void {
138+
openLinkShareDetails(0)
130139

131140
cy.get('[data-cy-files-sharing-share-permissions-bundle]').should('be.visible')
132141
cy.get('[data-cy-files-sharing-share-permissions-bundle="upload-edit"]').click()

dist/5956-5956.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/5956-5956.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)