@@ -22,6 +22,7 @@ OCA.Sharing.App = {
2222 _inFileList : null ,
2323 _outFileList : null ,
2424 _overviewFileList : null ,
25+ _pendingFileList : null ,
2526
2627 initSharingIn : function ( $el ) {
2728 if ( this . _inFileList ) {
@@ -129,6 +130,33 @@ OCA.Sharing.App = {
129130 return this . _deletedFileList
130131 } ,
131132
133+ initSharingPening : function ( $el ) {
134+ if ( this . _pendingFileList ) {
135+ return this . _pendingFileList
136+ }
137+ this . _pendingFileList = new OCA . Sharing . FileList (
138+ $el ,
139+ {
140+ id : 'shares.pending' ,
141+ showPending : true ,
142+ sharedWithUser : true ,
143+ fileActions : this . _acceptShareAction ( ) ,
144+ config : OCA . Files . App . getFilesConfig ( ) ,
145+ // The file list is created when a "show" event is handled, so
146+ // it should be marked as "shown" like it would have been done
147+ // if handling the event with the file list already created.
148+ shown : true ,
149+ }
150+ )
151+
152+ this . _extendFileList ( this . _pendingFileList )
153+ this . _pendingFileList . appName = t ( 'files_sharing' , 'Pending shares' )
154+ this . _pendingFileList . $el . find ( '#emptycontent' ) . html ( '<div class="icon-share"></div>'
155+ + '<h2>' + t ( 'files_sharing' , 'No pending shares' ) + '</h2>'
156+ + '<p>' + t ( 'files_sharing' , 'Shares you have received but not confirmed will show up here' ) + '</p>' )
157+ return this . _pendingFileList
158+ } ,
159+
132160 initShareingOverview : function ( $el ) {
133161 if ( this . _overviewFileList ) {
134162 return this . _overviewFileList
@@ -178,6 +206,12 @@ OCA.Sharing.App = {
178206 }
179207 } ,
180208
209+ removeSharingPending : function ( ) {
210+ if ( this . _pendingFileList ) {
211+ this . _pendingFileList . $fileList . empty ( )
212+ }
213+ } ,
214+
181215 removeSharingOverview : function ( ) {
182216 if ( this . _overviewFileList ) {
183217 this . _overviewFileList . $fileList . empty ( )
@@ -249,6 +283,47 @@ OCA.Sharing.App = {
249283 return fileActions
250284 } ,
251285
286+ _acceptShareAction : function ( ) {
287+ const fileActions = new OCA . Files . FileActions ( )
288+ fileActions . registerAction ( {
289+ name : 'Accept share' ,
290+ displayName : t ( 'files_sharing' , 'Accept share' ) ,
291+ mime : 'all' ,
292+ permissions : OC . PERMISSION_ALL ,
293+ iconClass : 'icon-checkmark' ,
294+ type : OCA . Files . FileActions . TYPE_INLINE ,
295+ actionHandler : function ( fileName , context ) {
296+ const shareId = context . $file . data ( 'shareId' )
297+ $ . post ( OC . linkToOCS ( 'apps/files_sharing/api/v1/shares/pending' , 2 ) + shareId )
298+ . success ( function ( result ) {
299+ context . fileList . remove ( context . fileInfoModel . attributes . name )
300+ } ) . fail ( function ( ) {
301+ OC . Notification . showTemporary ( t ( 'files_sharing' , 'Something happened. Unable to accept the share.' ) )
302+ } )
303+ } ,
304+ } )
305+ fileActions . registerAction ( {
306+ name : 'Reject share' ,
307+ displayName : t ( 'files_sharing' , 'Reject share' ) ,
308+ mime : 'all' ,
309+ permissions : OC . PERMISSION_ALL ,
310+ iconClass : 'icon-close' ,
311+ type : OCA . Files . FileActions . TYPE_INLINE ,
312+ actionHandler : function ( fileName , context ) {
313+ const shareId = context . $file . data ( 'shareId' )
314+ $ . ajax ( {
315+ url : OC . linkToOCS ( 'apps/files_sharing/api/v1/shares' , 2 ) + shareId ,
316+ type : 'DELETE' ,
317+ } ) . success ( function ( result ) {
318+ context . fileList . remove ( context . fileInfoModel . attributes . name )
319+ } ) . fail ( function ( ) {
320+ OC . Notification . showTemporary ( t ( 'files_sharing' , 'Something happened. Unable to reject the share.' ) )
321+ } )
322+ } ,
323+ } )
324+ return fileActions
325+ } ,
326+
252327 _onActionsUpdated : function ( ev ) {
253328 _ . each ( [ this . _inFileList , this . _outFileList , this . _linkFileList ] , function ( list ) {
254329 if ( ! list ) {
@@ -297,6 +372,12 @@ $(document).ready(function() {
297372 $ ( '#app-content-deletedshares' ) . on ( 'hide' , function ( ) {
298373 OCA . Sharing . App . removeSharingDeleted ( )
299374 } )
375+ $ ( '#app-content-pendingshares' ) . on ( 'show' , function ( e ) {
376+ OCA . Sharing . App . initSharingPening ( $ ( e . target ) )
377+ } )
378+ $ ( '#app-content-pendingshares' ) . on ( 'hide' , function ( ) {
379+ OCA . Sharing . App . removeSharingPending ( )
380+ } )
300381 $ ( '#app-content-shareoverview' ) . on ( 'show' , function ( e ) {
301382 OCA . Sharing . App . initShareingOverview ( $ ( e . target ) )
302383 } )
0 commit comments