diff --git a/src/UI/UIWindowShare.js b/src/UI/UIWindowShare.js index 6c9bc75c..894409b4 100644 --- a/src/UI/UIWindowShare.js +++ b/src/UI/UIWindowShare.js @@ -12,35 +12,24 @@ async function UIWindowShare(items){ // name h += `
Shared with
`; - h+= `People with access
`; h += ` `; h += ``; @@ -137,13 +126,24 @@ async function UIWindowShare(items){ let recipient_id = $(el_window).find('.access-recipient').val(); // todo do some basic validation client-side - if(recipient_id === null) + if(recipient_id === '' || recipient_id === null || recipient_id === undefined) return; if(is_email(recipient_id)) recipient_email = recipient_id; else recipient_username = recipient_id; + // can't share with self + if(recipient_username === window.user.username){ + $(el_window).find('.error').html('You can\'t share with yourself'); + $(el_window).find('.error').fadeIn(); + return; + } + else if(recipient_email && recipient_email === window.user.email){ + $(el_window).find('.error').html('You can\'t share with yourself'); + $(el_window).find('.error').fadeIn(); + return; + } // disable 'Give Access' button $(el_window).find('.give-access-btn').prop('disabled', true); @@ -166,14 +166,13 @@ async function UIWindowShare(items){ paths: [ { path: items[0].path, - access_level: access_level, + access: access_level, } ] }), success: function(response) { // show success message $(el_window).find('.access-recipient-print').html(recipient_id); - $(el_window).find('.window-give-item-access-success').show(100); let perm_id = `fs:${items[0].uid}:${access_level}`; // append recipient to list @@ -185,9 +184,6 @@ async function UIWindowShare(items){ // append recipient to list $(el_window).find('.share-recipients').append(`${perm_list}`); - - // add this user to the list of printed users - // printed_users.push(perm.user.username); }, error: function(err) { // at this point 'username_not_found' and 'shared_with_self' are the only @@ -213,8 +209,13 @@ async function UIWindowShare(items){ return false; }) - $(el_window).find('.hide-sharing-success-alert').on('click', function(){ - $(el_window).find('.window-give-item-access-success').hide(200); + $(el_window).find('.access-recipient').on('input keypress keyup keydown paste', function(){ + if($(this).val() === ''){ + $(el_window).find('.give-access-btn').prop('disabled', true); + } + else{ + $(el_window).find('.give-access-btn').prop('disabled', false); + } }) }) diff --git a/src/css/style.css b/src/css/style.css index d7c4ecbb..9288a627 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -2078,7 +2078,6 @@ label { } .share-recipients { - margin-top: 10px; max-height: 200px; overflow: scroll; }