Skip to content

Commit 0cbe013

Browse files
committed
feat: when sharing, users can choose between 'viewer' and 'editor' for permissions
1 parent a6650ee commit 0cbe013

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

src/gui/src/IPC.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ const ipc_listener = async (event, handled) => {
13161316
// now add new items
13171317
UIItem({
13181318
appendTo: $(`.item-container[data-path="${html_encode(path.dirname(target_path))}" i]`),
1319-
immutable: res.immutable,
1319+
immutable: res.immutable || res.writable === false,
13201320
associated_app_name: res.associated_app?.name,
13211321
path: target_path,
13221322
icon: await item_icon(res),

src/gui/src/UI/UIDesktop.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ async function UIDesktop(options){
351351
// create new item on matching containers
352352
UIItem({
353353
appendTo: $(`.item-container[data-path='${html_encode(dest_path)}' i]`),
354-
immutable: fsentry.immutable,
354+
immutable: fsentry.immutable || fsentry.writable === false,
355355
uid: fsentry.uid,
356356
path: fsentry.path,
357357
icon: await item_icon(fsentry),
@@ -526,7 +526,7 @@ async function UIDesktop(options){
526526
UIItem({
527527
appendTo: $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`),
528528
uid: item.uid,
529-
immutable: item.immutable,
529+
immutable: item.immutable || item.writable === false,
530530
associated_app_name: item.associated_app?.name,
531531
path: item.path,
532532
icon: await item_icon(item),

src/gui/src/UI/UIWindowShare.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,15 @@ async function UIWindowShare(items, recipient){
7979
h += `<label style="font-size: 16px; font-weight: 600;">${i18n('share_with')}</label>`;
8080
h += `<div style="display: flex;">`;
8181
// Username/email
82-
h += `<input placeholder="username" class="access-recipient" value="${html_encode(recipient ?? '')}" style="border-right: none; margin-bottom: 10px; border-top-right-radius: 0; border-bottom-right-radius: 0;" type="text" autocomplete="recipient_email_username" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`;
82+
h += `<input placeholder="username" class="access-recipient" value="${html_encode(recipient ?? '')}" style="margin-bottom: 0; margin-right: 5px;" type="text" autocomplete="recipient_email_username" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`;
83+
// type
84+
h += `<select class="access-type" style="width: 170px; margin-bottom: 0; margin-right: 5px;">`;
85+
h += `<option value="Viewer">Viewer</option>`;
86+
h += `<option value="Editor">Editor</option>`;
87+
h += `</select>`;
88+
8389
// Share
84-
h += `<button class="give-access-btn button button-primary button-normal" style="border-top-left-radius: 0; border-bottom-left-radius: 0;" ${!recipient ? 'disabled' : ''}>${i18n('share')}</button>`
90+
h += `<button class="give-access-btn button button-primary button-normal" style="" ${!recipient ? 'disabled' : ''}>${i18n('share')}</button>`
8591
h += `</div>`;
8692
h += `</div>`;
8793
h += `</form>`;
@@ -245,6 +251,9 @@ async function UIWindowShare(items, recipient){
245251
let share_result;
246252
let access_level = 'write';
247253

254+
if($(el_window).find('.access-type').val() === 'Viewer')
255+
access_level = 'read';
256+
248257
$.ajax({
249258
url: puter.APIOrigin + "/share",
250259
type: "POST",

src/gui/src/helpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ window.move_items = async function(el_items, dest_path, is_undo = false){
14851485
// create new item on matching containers
14861486
const options = {
14871487
appendTo: $(`.item-container[data-path="${html_encode(dest_path)}" i]`),
1488-
immutable: fsentry.immutable,
1488+
immutable: fsentry.immutable || (fsentry.writable === false),
14891489
associated_app_name: fsentry.associated_app?.name,
14901490
uid: fsentry.uid,
14911491
path: fsentry.path,

src/gui/src/helpers/refresh_item_container.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ const refresh_item_container = function(el_item_container, options){
175175
UIItem({
176176
appendTo: el_item_container,
177177
uid: fsentry.uid,
178-
immutable: fsentry.immutable,
178+
immutable: fsentry.immutable || fsentry.writable === false,
179179
associated_app_name: fsentry.associated_app?.name,
180180
path: item_path,
181181
icon: await item_icon(fsentry),

0 commit comments

Comments
 (0)