Skip to content

Commit 8554b34

Browse files
Fixed the rectified issues and cleaned up the code
Signed-off-by: Yogesh Shejwadkar <yogesh.shejwadkar@t-systems.com>
1 parent afe3d16 commit 8554b34

File tree

8 files changed

+90
-337
lines changed

8 files changed

+90
-337
lines changed

apps/files_sharing/lib/Controller/ShareAPIController.php

+28-1
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ public function deleteShare(string $id): DataResponse {
430430
* @param string $sendPasswordByTalk
431431
* @param string $expireDate
432432
* @param string $label
433+
* @param string $hideDownload
433434
*
434435
* @return DataResponse
435436
* @throws NotFoundException
@@ -449,7 +450,8 @@ public function createShare(
449450
string $password = '',
450451
string $sendPasswordByTalk = null,
451452
string $expireDate = '',
452-
string $label = ''
453+
string $label = '',
454+
string $hideDownload = null
453455
): DataResponse {
454456
$share = $this->shareManager->newShare();
455457

@@ -506,6 +508,15 @@ public function createShare(
506508
}
507509
$share->setSharedWith($shareWith);
508510
$share->setPermissions($permissions);
511+
512+
if ($expireDate !== '') {
513+
try {
514+
$expireDate = $this->parseDate($expireDate);
515+
$share->setExpirationDate($expireDate);
516+
} catch (\Exception $e) {
517+
throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
518+
}
519+
}
509520
} elseif ($shareType === IShare::TYPE_GROUP) {
510521
if (!$this->shareManager->allowGroupSharing()) {
511522
throw new OCSNotFoundException($this->l->t('Group sharing is disabled by the administrator'));
@@ -517,6 +528,15 @@ public function createShare(
517528
}
518529
$share->setSharedWith($shareWith);
519530
$share->setPermissions($permissions);
531+
532+
if ($expireDate !== '') {
533+
try {
534+
$expireDate = $this->parseDate($expireDate);
535+
$share->setExpirationDate($expireDate);
536+
} catch (\Exception $e) {
537+
throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
538+
}
539+
}
520540
} elseif ($shareType === IShare::TYPE_LINK
521541
|| $shareType === IShare::TYPE_EMAIL) {
522542

@@ -544,6 +564,13 @@ public function createShare(
544564
$permissions = Constants::PERMISSION_READ;
545565
}
546566

567+
// Update hide download state
568+
if ($hideDownload === 'true') {
569+
$share->setHideDownload(true);
570+
} elseif ($hideDownload === 'false') {
571+
$share->setHideDownload(false);
572+
}
573+
547574
// TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones
548575
if (($permissions & Constants::PERMISSION_READ) && $this->shareManager->outgoingServer2ServerSharesAllowed()) {
549576
$permissions |= Constants::PERMISSION_SHARE;

apps/files_sharing/src/components/SharingEntry.vue

-79
Original file line numberDiff line numberDiff line change
@@ -166,63 +166,11 @@ export default {
166166
return null
167167
},
168168

169-
canHaveNote() {
170-
return !this.isRemote
171-
},
172-
173169
isRemote() {
174170
return this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE
175171
|| this.share.type === this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP
176172
},
177173

178-
/**
179-
* Can the sharer set whether the sharee can edit the file ?
180-
*
181-
* @returns {boolean}
182-
*/
183-
canSetEdit() {
184-
// If the owner revoked the permission after the resharer granted it
185-
// the share still has the permission, and the resharer is still
186-
// allowed to revoke it too (but not to grant it again).
187-
return (this.fileInfo.sharePermissions & OC.PERMISSION_UPDATE) || this.canEdit
188-
},
189-
190-
/**
191-
* Can the sharer set whether the sharee can create the file ?
192-
*
193-
* @returns {boolean}
194-
*/
195-
canSetCreate() {
196-
// If the owner revoked the permission after the resharer granted it
197-
// the share still has the permission, and the resharer is still
198-
// allowed to revoke it too (but not to grant it again).
199-
return (this.fileInfo.sharePermissions & OC.PERMISSION_CREATE) || this.canCreate
200-
},
201-
202-
/**
203-
* Can the sharer set whether the sharee can delete the file ?
204-
*
205-
* @returns {boolean}
206-
*/
207-
canSetDelete() {
208-
// If the owner revoked the permission after the resharer granted it
209-
// the share still has the permission, and the resharer is still
210-
// allowed to revoke it too (but not to grant it again).
211-
return (this.fileInfo.sharePermissions & OC.PERMISSION_DELETE) || this.canDelete
212-
},
213-
214-
/**
215-
* Can the sharer set whether the sharee can reshare the file ?
216-
*
217-
* @returns {boolean}
218-
*/
219-
canSetReshare() {
220-
// If the owner revoked the permission after the resharer granted it
221-
// the share still has the permission, and the resharer is still
222-
// allowed to revoke it too (but not to grant it again).
223-
return (this.fileInfo.sharePermissions & OC.PERMISSION_SHARE) || this.canReshare
224-
},
225-
226174
/**
227175
* Can the sharee edit the shared file ?
228176
*/
@@ -289,33 +237,6 @@ export default {
289237
return this.fileInfo.type === 'dir'
290238
},
291239

292-
/**
293-
* Does the current share have an expiration date
294-
* @returns {boolean}
295-
*/
296-
// hasExpirationDate: {
297-
// get() {
298-
// return this.config.isDefaultInternalExpireDateEnforced || !!this.share.expireDate
299-
// },
300-
// set(enabled) {
301-
// this.share.expireDate = enabled
302-
// ? this.config.defaultInternalExpirationDateString !== ''
303-
// ? this.config.defaultInternalExpirationDateString
304-
// : moment().format('YYYY-MM-DD')
305-
// : ''
306-
// },
307-
// },
308-
309-
// dateMaxEnforced() {
310-
// if (!this.isRemote) {
311-
// return this.config.isDefaultInternalExpireDateEnforced
312-
// && moment().add(1 + this.config.defaultInternalExpireDate, 'days')
313-
// } else {
314-
// return this.config.isDefaultRemoteExpireDateEnforced
315-
// && moment().add(1 + this.config.defaultRemoteExpireDate, 'days')
316-
// }
317-
// },
318-
319240
/**
320241
* @returns {bool}
321242
*/

apps/files_sharing/src/components/SharingEntryLink.vue

-134
Original file line numberDiff line numberDiff line change
@@ -309,32 +309,6 @@ export default {
309309
return null
310310
},
311311

312-
/**
313-
* Does the current share have an expiration date
314-
* @returns {boolean}
315-
*/
316-
hasExpirationDate: {
317-
get() {
318-
return this.config.isDefaultExpireDateEnforced
319-
|| !!this.share.expireDate
320-
},
321-
set(enabled) {
322-
let dateString = moment(this.config.defaultExpirationDateString)
323-
if (!dateString.isValid()) {
324-
dateString = moment()
325-
}
326-
this.share.state.expiration = enabled
327-
? dateString.format('YYYY-MM-DD')
328-
: ''
329-
console.debug('Expiration date status', enabled, this.share.expireDate)
330-
},
331-
},
332-
333-
dateMaxEnforced() {
334-
return this.config.isDefaultExpireDateEnforced
335-
&& moment().add(1 + this.config.defaultExpireDate, 'days')
336-
},
337-
338312
/**
339313
* Is the current share password protected ?
340314
* @returns {boolean}
@@ -351,35 +325,6 @@ export default {
351325
},
352326
},
353327

354-
/**
355-
* Is Talk enabled?
356-
* @returns {boolean}
357-
*/
358-
isTalkEnabled() {
359-
return OC.appswebroots.spreed !== undefined
360-
},
361-
362-
/**
363-
* Is it possible to protect the password by Talk?
364-
* @returns {boolean}
365-
*/
366-
isPasswordProtectedByTalkAvailable() {
367-
return this.isPasswordProtected && this.isTalkEnabled
368-
},
369-
370-
/**
371-
* Is the current share password protected by Talk?
372-
* @returns {boolean}
373-
*/
374-
isPasswordProtectedByTalk: {
375-
get() {
376-
return this.share.sendPasswordByTalk
377-
},
378-
async set(enabled) {
379-
this.share.sendPasswordByTalk = enabled
380-
},
381-
},
382-
383328
/**
384329
* Is the current share an email share ?
385330
* @returns {boolean}
@@ -390,20 +335,6 @@ export default {
390335
: false
391336
},
392337

393-
canTogglePasswordProtectedByTalkAvailable() {
394-
if (!this.isPasswordProtected) {
395-
// Makes no sense
396-
return false
397-
} else if (this.isEmailShareType && !this.hasUnsavedPassword) {
398-
// For email shares we need a new password in order to enable or
399-
// disable
400-
return false
401-
}
402-
403-
// Anything else should be fine
404-
return true
405-
},
406-
407338
/**
408339
* Pending data.
409340
* If the share still doesn't have an id, it is not synced
@@ -417,21 +348,6 @@ export default {
417348
return this.config.isDefaultExpireDateEnforced && this.share && !this.share.id
418349
},
419350

420-
/**
421-
* Can the recipient edit the file ?
422-
* @returns {boolean}
423-
*/
424-
canUpdate: {
425-
get() {
426-
return this.share.hasUpdatePermission
427-
},
428-
set(enabled) {
429-
this.share.permissions = enabled
430-
? OC.PERMISSION_READ | OC.PERMISSION_UPDATE
431-
: OC.PERMISSION_READ
432-
},
433-
},
434-
435351
// if newPassword exists, but is empty, it means
436352
// the user deleted the original password
437353
hasUnsavedPassword() {
@@ -649,24 +565,6 @@ export default {
649565
this.queueUpdate('permissions')
650566
},
651567

652-
/**
653-
* Label changed, let's save it to a different key
654-
* @param {String} label the share label
655-
*/
656-
onLabelChange(label) {
657-
this.$set(this.share, 'newLabel', label.trim())
658-
},
659-
660-
/**
661-
* When the note change, we trim, save and dispatch
662-
*/
663-
onLabelSubmit() {
664-
if (typeof this.share.newLabel === 'string') {
665-
this.share.label = this.share.newLabel
666-
this.$delete(this.share, 'newLabel')
667-
this.queueUpdate('label')
668-
}
669-
},
670568
async copyLink() {
671569
try {
672570
await this.$copyText(this.shareLink)
@@ -686,19 +584,6 @@ export default {
686584
}
687585
},
688586

689-
/**
690-
* Update newPassword values
691-
* of share. If password is set but not newPassword
692-
* then the user did not changed the password
693-
* If both co-exists, the password have changed and
694-
* we show it in plain text.
695-
* Then on submit (or menu close), we sync it.
696-
* @param {string} password the changed password
697-
*/
698-
onPasswordChange(password) {
699-
this.$set(this.share, 'newPassword', password)
700-
},
701-
702587
/**
703588
* Uncheck password protection
704589
* We need this method because @update:checked
@@ -733,22 +618,6 @@ export default {
733618
}
734619
},
735620

736-
/**
737-
* Update the password along with "sendPasswordByTalk".
738-
*
739-
* If the password was modified the new password is sent; otherwise
740-
* updating a mail share would fail, as in that case it is required that
741-
* a new password is set when enabling or disabling
742-
* "sendPasswordByTalk".
743-
*/
744-
onPasswordProtectedByTalkChange() {
745-
if (this.hasUnsavedPassword) {
746-
this.share.password = this.share.newPassword.trim()
747-
}
748-
749-
this.queueUpdate('sendPasswordByTalk', 'password')
750-
},
751-
752621
/**
753622
* Save potential changed data on menu close
754623
*/
@@ -762,9 +631,6 @@ export default {
762631
* Used in the pending popover
763632
*/
764633
onCancel() {
765-
// this.share already exists at this point,
766-
// but is incomplete as not pushed to server
767-
// YET. We can safely delete the share :)
768634
this.$emit('remove:share', this.share)
769635
},
770636

apps/files_sharing/src/components/SharingInput.vue

+2
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ export default {
443443
this.$store.commit('addFromInput', true)
444444
const newShare = new Share({})
445445
newShare.permissions = OC.PERMISSION_READ
446+
newShare.expireDate = ''
447+
newShare.password = ''
446448
this.$store.commit('addShare', newShare)
447449
this.$store.commit('addCurrentTab', 'permissions')
448450
},

0 commit comments

Comments
 (0)