feat: when sharing, users can choose between 'viewer' and 'editor' for permissions

This commit is contained in:
jelveh
2024-11-14 14:08:49 -08:00
parent a6650ee2d8
commit 0cbe0139d7
5 changed files with 16 additions and 7 deletions
+1 -1
View File
@@ -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),
+2 -2
View File
@@ -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),
+11 -2
View File
@@ -79,9 +79,15 @@ async function UIWindowShare(items, recipient){
h += `<label style="font-size: 16px; font-weight: 600;">${i18n('share_with')}</label>`;
h += `<div style="display: flex;">`;
// Username/email
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"/>`;
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"/>`;
// type
h += `<select class="access-type" style="width: 170px; margin-bottom: 0; margin-right: 5px;">`;
h += `<option value="Viewer">Viewer</option>`;
h += `<option value="Editor">Editor</option>`;
h += `</select>`;
// Share
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>`
h += `<button class="give-access-btn button button-primary button-normal" style="" ${!recipient ? 'disabled' : ''}>${i18n('share')}</button>`
h += `</div>`;
h += `</div>`;
h += `</form>`;
@@ -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",
+1 -1
View File
@@ -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,
@@ -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),