@ -206,6 +206,7 @@ import GeneratePassword from '../utils/GeneratePassword.js'
import Share from '../models/Share.js'
import SharesMixin from '../mixins/SharesMixin.js'
import ShareDetails from '../mixins/ShareDetails.js'
import { getLoggerBuilder } from '@nextcloud/logger'
export default {
name : 'SharingEntryLink' ,
@ -238,6 +239,7 @@ export default {
data ( ) {
return {
shareCreationComplete : false ,
showDropdown : false ,
copySuccess : true ,
copied : false ,
@ -247,6 +249,10 @@ export default {
ExternalLegacyLinkActions : OCA . Sharing . ExternalLinkActions . state ,
ExternalShareActions : OCA . Sharing . ExternalShareActions . state ,
logger : getLoggerBuilder ( )
. setApp ( 'files_sharing' )
. detectUser ( )
. build ( ) ,
}
} ,
@ -407,6 +413,32 @@ export default {
return this . config . isDefaultExpireDateEnforced && this . share && ! this . share . id
} ,
sharePolicyHasRequiredProperties ( ) {
return this . config . enforcePasswordForPublicLink || this . config . isDefaultExpireDateEnforced
} ,
requiredPropertiesMissing ( ) {
/ / E n s u r e s h a r e e x i s t a n d t h e s h a r e p o l i c y h a s r e q u i r e d p r o p e r t i e s
if ( ! this . sharePolicyHasRequiredProperties ) {
return false
}
if ( ! this . share ) {
/ / i f n o s h a r e , w e c a n ' t t e l l i f p r o p e r t i e s a r e m i s s i n g o r n o t s o w e a s s u m e p r o p e r t i e s a r e m i s s i n g
return true
}
/ / I f s h a r e h a s I D , t h e n t h i s i s a n i n c o m i n g l i n k s h a r e c r e a t e d f r o m t h e e x i s t i n g l i n k s h a r e
/ / H e n c e a s s u m e r e q u i r e d p r o p e r t i e s
if ( this . share . id ) {
return true
}
/ / C h e c k i f e i t h e r p a s s w o r d o r e x p i r a t i o n d a t e i s m i s s i n g a n d e n f o r c e d
const isPasswordMissing = this . config . enforcePasswordForPublicLink && ! this . share . password
const isExpireDateMissing = this . config . isDefaultExpireDateEnforced && ! this . share . expireDate
return isPasswordMissing || isExpireDateMissing
} ,
/ / i f n e w P a s s w o r d e x i s t s , b u t i s e m p t y , i t m e a n s
/ / t h e u s e r d e l e t e d t h e o r i g i n a l p a s s w o r d
hasUnsavedPassword ( ) {
@ -483,6 +515,7 @@ export default {
* Create a new share link and append it to the list
* /
async onNewLinkShare ( ) {
this . logger . debug ( 'onNewLinkShare called (with this.share)' , this . share )
/ / d o n o t r u n a g a i n i f a l r e a d y l o a d i n g
if ( this . loading ) {
return
@ -497,28 +530,13 @@ export default {
shareDefaults . expiration = this . formatDateToString ( this . config . defaultExpirationDate )
}
this . logger . debug ( 'Missing required properties?' , this . requiredPropertiesMissing )
/ / d o n o t p u s h y e t i f w e n e e d a p a s s w o r d o r a n e x p i r a t i o n d a t e : s h o w p e n d i n g m e n u
if ( this . config. enableLinkPasswordByDefault || this . config . enforcePasswordForPublicLink || this . config . isDefaultExpireDateEnforced ) {
if ( this . sharePolicyHasRequiredProperties && this . requiredPropertiesMissing ) {
this . pending = true
this . shareCreationComplete = false
/ / i f a s h a r e a l r e a d y e x i s t s , p u s h i n g i t
if ( this . share && ! this . share . id ) {
/ / i f t h e s h a r e i s v a l i d , c r e a t e i t o n t h e s e r v e r
if ( this . checkShare ( this . share ) ) {
try {
await this . pushNewLinkShare ( this . share , true )
} catch ( e ) {
this . pending = false
console . error ( e )
return false
}
return true
} else {
this . open = true
OC . Notification . showTemporary ( t ( 'files_sharing' , 'Error, please enter proper password and/or expiration date' ) )
return false
}
}
this . logger . info ( 'Share policy requires mandated properties (password)...' )
/ / E L S E , s h o w t h e p e n d i n g p o p o v e r m e n u
/ / i f p a s s w o r d d e f a u l t o r e n f o r c e d , p r e - f i l l w i t h r a n d o m o n e
@ -540,8 +558,32 @@ export default {
/ / N o t h i n g i s e n f o r c e d , c r e a t i n g s h a r e d i r e c t l y
} else {
/ / i f a s h a r e a l r e a d y e x i s t s , p u s h i n g i t
if ( this . share && ! this . share . id ) {
/ / i f t h e s h a r e i s v a l i d , c r e a t e i t o n t h e s e r v e r
if ( this . checkShare ( this . share ) ) {
try {
this . logger . info ( 'Sending existing share to server' , this . share )
await this . pushNewLinkShare ( this . share , true )
this . shareCreationComplete = true
this . logger . info ( 'Share created on server' , this . share )
} catch ( e ) {
this . pending = false
this . logger . error ( 'Error creating share' , e )
return false
}
return true
} else {
this . open = true
showError ( t ( 'files_sharing' , 'Error, please enter proper password and/or expiration date' ) )
return false
}
}
const share = new Share ( shareDefaults )
await this . pushNewLinkShare ( share )
this . shareCreationComplete = true
}
} ,
@ -581,8 +623,8 @@ export default {
const newShare = await this . createShare ( options )
this . open = false
this . shareCreationComplete = true
console . debug ( 'Link share created' , newShare )
/ / i f s h a r e a l r e a d y e x i s t s , c o p y l i n k d i r e c t l y o n n e x t t i c k
let component
if ( update ) {
@ -624,8 +666,10 @@ export default {
this . onSyncError ( 'pending' , message )
}
throw data
} finally {
this . loading = false
this . shareCreationComplete = true
}
} ,
async copyLink ( ) {
@ -728,7 +772,9 @@ export default {
/ / t h i s . s h a r e a l r e a d y e x i s t s a t t h i s p o i n t ,
/ / b u t i s i n c o m p l e t e a s n o t p u s h e d t o s e r v e r
/ / Y E T . W e c a n s a f e l y d e l e t e t h e s h a r e : )
this . $emit ( 'remove:share' , this . share )
if ( ! this . shareCreationComplete ) {
this . $emit ( 'remove:share' , this . share )
}
} ,
toggleQuickShareSelect ( ) {
@ -752,25 +798,22 @@ export default {
width : 80 % ;
min - width : 80 % ;
& _ _desc {
display : flex ;
flex - direction : column ;
line - height : 1.2 em ;
& _ _desc {
display : flex ;
flex - direction : column ;
line - height : 1.2 em ;
p {
color : var ( -- color - text - maxcontrast ) ;
}
p {
color : var ( -- color - text - maxcontrast ) ;
}
& _ _title {
text - overflow : ellipsis ;
overflow : hidden ;
white - space : nowrap ;
& _ _title {
text - overflow : ellipsis ;
overflow : hidden ;
white - space : nowrap ;
}
}
}
& _ _copy {
}
}
& : not ( . sharing - entry -- share ) & _ _actions {