Skip to content

Commit

Permalink
remove deprecated sharing endpoints and event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
jelveh committed Mar 30, 2024
1 parent fe0cd89 commit b4be6aa
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 107 deletions.
56 changes: 1 addition & 55 deletions src/UI/UIWindowItemProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,24 +169,6 @@ async function UIWindowItemProperties(item_name, item_path, item_uid, left, top,
$(el_window).find('.item-props-version-list').append('-');
}

// owner
$(el_window).find('.item-prop-val-permissions').append(`<p class="item-prop-perm-entry" style="margin-bottom:5px; margin-top:5px;">${(fsentry.owner.email === undefined || fsentry.owner.email === null) ? fsentry.owner.username : fsentry.owner.email} (owner)</p>`);

// other users with access
if(fsentry.permissions && fsentry.permissions.length > 0 ){
fsentry.permissions.forEach(perm => {
let h = ``;
// username/email
h += `<p class="item-prop-perm-entry" data-perm-uid="${perm.uid}" style="margin-bottom:5px; margin-top:5px;">${perm.email ?? perm.username} `;
// remove
h += `(<span class="remove-permission-link" data-perm-uid="${perm.uid}">remove</span>)`;
$(el_window).find('.item-prop-val-permissions').append(h);
});
}
else{
$(el_window).find('.item-prop-val-permissions').append('-');
}

$(el_window).find(`.disassociate-website-link`).on('click', function(e){
puter.hosting.update(
$(e.target).attr('data-subdomain'),
Expand All @@ -199,43 +181,7 @@ async function UIWindowItemProperties(item_name, item_path, item_uid, left, top,
}
}
)
})

$(el_window).find('.remove-permission-link').on('click', function(e){
const el_remove_perm_link= this;
const perm_uid = $(el_remove_perm_link).attr('data-perm-uid');
$.ajax({
url: api_origin + "/remove-perm",
type: 'POST',
async: true,
contentType: "application/json",
data: JSON.stringify({
uid: perm_uid,
}),
headers: {
"Authorization": "Bearer "+auth_token
},
statusCode: {
401: function () {
logout();
},
},
success: async function (res){
$(el_window).find(`.item-prop-perm-entry[data-perm-uid="${perm_uid}"]`).remove();

if($(el_window).find(`.item-prop-perm-entry`).length === 0){
$(el_window).find(`.item-prop-val-permissions`).html('-');
// todo is it better to combine the following two queriesinto one css selector?
$(`.item[data-uid="${item_uid}"]`).find(`.item-is-shared`).fadeOut(200);
// todo optim do this only if item is a directory
// todo this has to be case-insensitive but the `i` selector doesn't work on ^=
$(`.item[data-path^="${item_path}/"]`).find(`.item-is-shared`).fadeOut(200);
}
},
complete: function(){
}
})
})
})
}
})
}
Expand Down
23 changes: 0 additions & 23 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2476,29 +2476,6 @@ window.move_items = async function(el_items, dest_path, is_undo = false){
success: function (){
}
})
// remove all associated permissions
// todo, some client-side check to see if this dir has an FR associated with it before sending a whole ajax req
$.ajax({
url: api_origin + "/remove-item-perms",
type: 'POST',
data: JSON.stringify({
uid: $(el_item).attr('data-uid'),
}),
async: true,
contentType: "application/json",
headers: {
"Authorization": "Bearer "+auth_token
},
statusCode: {
401: function () {
logout();
},
},
success: function (){
}
})
$(`.item[data-uid="${$(el_item).attr('data-uid')}"]`).find('.item-is-shared').fadeOut(300);

// if trashing dir...
if($(el_item).attr('data-is_dir') === '1'){
// disassociate all its websites
Expand Down
29 changes: 0 additions & 29 deletions src/initgui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1697,35 +1697,6 @@ window.initgui = async function(){
}
});

$(document).on('click', '.remove-permission-link', async function(e){
const el_remove_perm_link= this;
const perm_uid = $(el_remove_perm_link).attr('data-perm-uid');
$.ajax({
url: api_origin + "/remove-perm",
type: 'POST',
async: true,
contentType: "application/json",
data: JSON.stringify({
uid: perm_uid,
}),
headers: {
"Authorization": "Bearer "+auth_token
},
statusCode: {
401: function () {
logout();
},
},
success: async function (res){
$(`[data-perm-uid="${perm_uid}"]`).hide("slide", { direction: "right" }, 300, function(e){
$(this).remove();
});
},
complete: function(){
}
})
})

// update mouse position coordinates
$(document).mousemove(function(event){
mouseX = event.clientX;
Expand Down

0 comments on commit b4be6aa

Please sign in to comment.