From 0cbe0139d7f306ce62992f1eda94d99e09b32df8 Mon Sep 17 00:00:00 2001 From: jelveh Date: Thu, 14 Nov 2024 14:08:49 -0800 Subject: [PATCH] feat: when sharing, users can choose between 'viewer' and 'editor' for permissions --- src/gui/src/IPC.js | 2 +- src/gui/src/UI/UIDesktop.js | 4 ++-- src/gui/src/UI/UIWindowShare.js | 13 +++++++++++-- src/gui/src/helpers.js | 2 +- src/gui/src/helpers/refresh_item_container.js | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/gui/src/IPC.js b/src/gui/src/IPC.js index 18580da0f..bd8132dad 100644 --- a/src/gui/src/IPC.js +++ b/src/gui/src/IPC.js @@ -1316,7 +1316,7 @@ const ipc_listener = async (event, handled) => { // now add new items UIItem({ appendTo: $(`.item-container[data-path="${html_encode(path.dirname(target_path))}" i]`), - immutable: res.immutable, + immutable: res.immutable || res.writable === false, associated_app_name: res.associated_app?.name, path: target_path, icon: await item_icon(res), diff --git a/src/gui/src/UI/UIDesktop.js b/src/gui/src/UI/UIDesktop.js index 86c97f354..d62b104fe 100644 --- a/src/gui/src/UI/UIDesktop.js +++ b/src/gui/src/UI/UIDesktop.js @@ -351,7 +351,7 @@ async function UIDesktop(options){ // create new item on matching containers UIItem({ appendTo: $(`.item-container[data-path='${html_encode(dest_path)}' i]`), - immutable: fsentry.immutable, + immutable: fsentry.immutable || fsentry.writable === false, uid: fsentry.uid, path: fsentry.path, icon: await item_icon(fsentry), @@ -526,7 +526,7 @@ async function UIDesktop(options){ UIItem({ appendTo: $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`), uid: item.uid, - immutable: item.immutable, + immutable: item.immutable || item.writable === false, associated_app_name: item.associated_app?.name, path: item.path, icon: await item_icon(item), diff --git a/src/gui/src/UI/UIWindowShare.js b/src/gui/src/UI/UIWindowShare.js index e40636265..506e9477e 100644 --- a/src/gui/src/UI/UIWindowShare.js +++ b/src/gui/src/UI/UIWindowShare.js @@ -79,9 +79,15 @@ async function UIWindowShare(items, recipient){ h += ``; h += `
`; // Username/email - h += ``; + h += ``; + // type + h += ``; + // Share - h += `` + h += `` h += `
`; h += ``; h += ``; @@ -245,6 +251,9 @@ async function UIWindowShare(items, recipient){ let share_result; let access_level = 'write'; + if($(el_window).find('.access-type').val() === 'Viewer') + access_level = 'read'; + $.ajax({ url: puter.APIOrigin + "/share", type: "POST", diff --git a/src/gui/src/helpers.js b/src/gui/src/helpers.js index 7c6a010fb..2657bcef5 100644 --- a/src/gui/src/helpers.js +++ b/src/gui/src/helpers.js @@ -1485,7 +1485,7 @@ window.move_items = async function(el_items, dest_path, is_undo = false){ // create new item on matching containers const options = { appendTo: $(`.item-container[data-path="${html_encode(dest_path)}" i]`), - immutable: fsentry.immutable, + immutable: fsentry.immutable || (fsentry.writable === false), associated_app_name: fsentry.associated_app?.name, uid: fsentry.uid, path: fsentry.path, diff --git a/src/gui/src/helpers/refresh_item_container.js b/src/gui/src/helpers/refresh_item_container.js index 3de003295..a4cdc6f8e 100644 --- a/src/gui/src/helpers/refresh_item_container.js +++ b/src/gui/src/helpers/refresh_item_container.js @@ -175,7 +175,7 @@ const refresh_item_container = function(el_item_container, options){ UIItem({ appendTo: el_item_container, uid: fsentry.uid, - immutable: fsentry.immutable, + immutable: fsentry.immutable || fsentry.writable === false, associated_app_name: fsentry.associated_app?.name, path: item_path, icon: await item_icon(fsentry),