浏览代码

deprecate `UIWindowGetCopyLink` as it's not supported by the backend

Nariman Jelveh 1 年之前
父节点
当前提交
ab5fee1562
共有 4 个文件被更改,包括 10 次插入163 次删除
  1. 0 32
      src/UI/UIItem.js
  2. 0 121
      src/UI/UIWindowGetCopyLink.js
  3. 6 6
      src/UI/UIWindowItemProperties.js
  4. 4 4
      src/UI/UIWindowMyWebsites.js

+ 0 - 32
src/UI/UIItem.js

@@ -19,7 +19,6 @@
 
 import UIWindowPublishWebsite from './UIWindowPublishWebsite.js';
 import UIWindowItemProperties from './UIWindowItemProperties.js';
-import UIWindowGetCopyLink from './UIWindowGetCopyLink.js';
 import UIWindowSaveAccount from './UIWindowSaveAccount.js';
 import UIPopover from './UIPopover.js';
 import UIWindowEmailConfirmationRequired from './UIWindowEmailConfirmationRequired.js';
@@ -1131,37 +1130,6 @@ function UIItem(options){
                     }
                 });                
             }
-
-
-            // -------------------------------------------
-            // Get Copy Link
-            // -------------------------------------------
-            if(!is_trashed && !is_trash && (options.associated_app_name === null || options.associated_app_name === undefined)){
-                menu_items.push({
-                    html: i18n('get_copy_link'),
-                    onClick: async function(){
-                        if(window.user.is_temp && 
-                            !await UIWindowSaveAccount({
-                                message: i18n('save_account_to_get_copy_link'),
-                                send_confirmation_code: true,
-                                window_options: {
-                                    backdrop: true,
-                                    close_on_backdrop_click: false,
-                                }                                
-                            }))
-                            return;
-                        else if(!window.user.email_confirmed && !await UIWindowEmailConfirmationRequired())
-                            return;
-
-                        UIWindowGetCopyLink({
-                            name: $(el_item).attr('data-name'),
-                            uid: $(el_item).attr('data-uid'),
-                            path: $(el_item).attr('data-path'),
-                            is_dir: options.is_dir,
-                        });
-                    }
-                });
-            }
             // -------------------------------------------
             // Zip
             // -------------------------------------------

+ 0 - 121
src/UI/UIWindowGetCopyLink.js

@@ -1,121 +0,0 @@
-/**
- * Copyright (C) 2024 Puter Technologies Inc.
- *
- * This file is part of Puter.
- *
- * Puter is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- * 
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-import UIWindow from './UIWindow.js'
-import UIPopover from './UIPopover.js'
-
-async function UIWindowGetCopyLink(options){
-    let h = '';
-    let copy_btn_text = 'Copy Link';
-    let copied_btn_text = 'Copied!';
-    const signature = await puter.fs.sign(null, {uid: options.uid, action: 'read'})
-    const url = `${gui_origin}/?name=${encodeURIComponent(options.name)}&is_dir=${encodeURIComponent(options.is_dir)}&download=${encodeURIComponent(signature.items.read_url)}`;
-
-    h += `<div>`;
-        h += `<p style="font-size: 15px; font-weight: 400; -webkit-font-smoothing: antialiased; color: #474a57;">Share the following link with anyone and they will be able to receive a copy of <strong>${html_encode(options.name)}</strong></p>`;
-        h += `<input type="text" style="margin-bottom:10px;" class="downloadable-link" readonly />`;
-        h += `<button class="button button-primary copy-downloadable-link" style="width:130px;">${copy_btn_text}</button>`
-        h += `<img class="share-copy-link-on-social" src="${window.icons['share-outline.svg']}">`;
-    h += `</div>`;
-
-    const el_window = await UIWindow({
-        title: `Get Copy Link`,
-        icon: null,
-        uid: null,
-        is_dir: false,
-        body_content: h,
-        has_head: true,
-        selectable_body: false,
-        draggable_body: false,
-        allow_context_menu: false,
-        is_resizable: false,
-        is_droppable: false,
-        init_center: true,
-        allow_native_ctxmenu: true,
-        allow_user_select: true,
-        onAppend: function(el_window){
-        },
-        width: 500,
-        dominant: true,
-        window_css: {
-            height: 'initial',
-        },
-        body_css: {
-            width: 'initial',
-            'max-height': 'calc(100vh - 200px)',
-            'background-color': 'rgb(241 246 251)',
-            'backdrop-filter': 'blur(3px)',
-            'padding': '10px 20px 20px 20px',
-            'height': 'initial',
-        }    
-    });
-
-    $(el_window).find('.window-body .downloadable-link').val(url);
-
-    $(el_window).find('.window-body .share-copy-link-on-social').on('click', function(e){    
-        const social_links = socialLink({
-            url: url, 
-            title: i18n('get_a_copy_of_on_puter', options.name, false), 
-            description: i18n('get_a_copy_of_on_puter', options.name, false),
-        });
-
-        let social_links_html = ``;
-        social_links_html += `<div style="padding: 10px;">`;
-            social_links_html += `<p style="margin: 0; text-align: center; margin-bottom: 6px; color: #484a57; font-weight: bold; font-size: 14px;">Share to</p>`
-            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.twitter}" style=""><svg viewBox="0 0 24 24" aria-hidden="true" style="opacity: 0.7;"><g><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path></g></svg></a>`
-            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.whatsapp}" style=""><img src="${window.icons['logo-whatsapp.svg']}"></a>`
-            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.facebook}" style=""><img src="${window.icons['logo-facebook.svg']}"></a>`
-            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.linkedin}" style=""><img src="${window.icons['logo-linkedin.svg']}"></a>`
-            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.reddit}" style=""><img src="${window.icons['logo-reddit.svg']}"></a>`
-            social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links['telegram.me']}" style=""><img src="${window.icons['logo-telegram.svg']}"></a>`
-        social_links_html += '</div>';
-
-        UIPopover({
-            content: social_links_html,
-            snapToElement: this,
-            parent_element: this,
-            // width: 300,
-            height: 100,
-            position: 'bottom',
-        });    
-    })
-
-    $(el_window).find('.window-body .copy-downloadable-link').on('click', async function(e){
-        var copy_btn = this;
-        if (navigator.clipboard) {
-            // Get link text
-            const selected_text = $(el_window).find('.window-body .downloadable-link').val();
-            // copy selected text to clipboard
-            await navigator.clipboard.writeText(selected_text);
-        }
-        else{
-            // Get the text field
-            $(el_window).find('.window-body .downloadable-link').select();
-            // Copy the text inside the text field
-            document.execCommand('copy');
-        }
-
-        $(this).html(copied_btn_text);
-        setTimeout(function(){
-            $(copy_btn).html(copy_btn_text);
-        }, 1000);
-    });
-}
-
-export default UIWindowGetCopyLink

+ 6 - 6
src/UI/UIWindowItemProperties.js

@@ -117,19 +117,19 @@ async function UIWindowItemProperties(item_name, item_path, item_uid, left, top,
                 $(el_window).find('[data-tab="versions"]').hide();
             }
             // name
-            $(el_window).find('.item-prop-val-name').html(fsentry.name);
+            $(el_window).find('.item-prop-val-name').text(fsentry.name);
             // path
-            $(el_window).find('.item-prop-val-path').html(item_path);
+            $(el_window).find('.item-prop-val-path').text(item_path);
             // original name & path
             if(fsentry.metadata){
                 try{
                     let metadata = JSON.parse(fsentry.metadata);
                     if(metadata.original_name){
-                        $(el_window).find('.item-prop-val-original-name').html(metadata.original_name);
+                        $(el_window).find('.item-prop-val-original-name').text(metadata.original_name);
                         $(el_window).find('.item-prop-original-name').show();
                     }
                     if(metadata.original_path){
-                        $(el_window).find('.item-prop-val-original-path').html(metadata.original_path);
+                        $(el_window).find('.item-prop-val-original-path').text(metadata.original_path);
                         $(el_window).find('.item-prop-original-path').show();
                     }
                 }catch(e){}
@@ -137,7 +137,7 @@ async function UIWindowItemProperties(item_name, item_path, item_uid, left, top,
 
             // shortcut to
             if(fsentry.shortcut_to && fsentry.shortcut_to_path){
-                $(el_window).find('.item-prop-val-shortcut-to').html(fsentry.shortcut_to_path);
+                $(el_window).find('.item-prop-val-shortcut-to').text(fsentry.shortcut_to_path);
             }
             // uid
             $(el_window).find('.item-prop-val-uid').html(fsentry.id);
@@ -152,7 +152,7 @@ async function UIWindowItemProperties(item_name, item_path, item_uid, left, top,
             // subdomains
             if(fsentry.subdomains && fsentry.subdomains.length > 0 ){
                 fsentry.subdomains.forEach(subdomain => {
-                    $(el_window).find('.item-prop-val-websites').append(`<p class="item-prop-website-entry" data-uuid="${subdomain.uuid}" style="margin-bottom:5px; margin-top:5px;"><a target="_blank" href="${subdomain.address}">${subdomain.address}</a> (<span class="disassociate-website-link" data-uuid="${subdomain.uuid}" data-subdomain="${extractSubdomain(subdomain.address)}">disassociate</span>)</p>`);
+                    $(el_window).find('.item-prop-val-websites').append(`<p class="item-prop-website-entry" data-uuid="${html_encode(subdomain.uuid)}" style="margin-bottom:5px; margin-top:5px;"><a target="_blank" href="${html_encode(subdomain.address)}">${html_encode(subdomain.address)}</a> (<span class="disassociate-website-link" data-uuid="${html_encode(subdomain.uuid)}" data-subdomain="${extractSubdomain(subdomain.address)}">disassociate</span>)</p>`);
                 });
             }
             else{

+ 4 - 4
src/UI/UIWindowMyWebsites.js

@@ -84,16 +84,16 @@ async function UIWindowMyWebsites(options){
                         h += `<img class="mywebsites-site-setting" data-site-uuid="${sites[i].uid}" src="${html_encode(window.icons['cog.svg'])}">`;
                         // there is a directory associated with this site
                         if(sites[i].root_dir){
-                            h += `<p class="mywebsites-dir-path" data-path="${html_encode(sites[i].root_dir.path)}" data-name="${sites[i].root_dir.name}" data-uuid="${sites[i].root_dir.id}">`;
+                            h += `<p class="mywebsites-dir-path" data-path="${html_encode(sites[i].root_dir.path)}" data-name="${html_encode(sites[i].root_dir.name)}" data-uuid="${sites[i].root_dir.id}">`;
                                 h+= `<img src="${html_encode(window.icons['folder.svg'])}">`;
-                                h+= `${sites[i].root_dir.path}`;
+                                h+= `${html_encode(sites[i].root_dir.path)}`;
                             h += `</p>`;
                             h += `<p style="margin-bottom:0; margin-top: 20px; font-size: 13px;">`;
-                                h += `<span class="mywebsites-dis-dir" data-dir-uuid="${sites[i].root_dir.id}" data-site-uuid="${sites[i].uid}">`;
+                                h += `<span class="mywebsites-dis-dir" data-dir-uuid="${html_encode(sites[i].root_dir.id)}" data-site-uuid="${html_encode(sites[i].uid)}">`;
                                 h += `<img style="width: 16px; margin-bottom: -2px; margin-right: 4px;" src="${html_encode(window.icons['plug.svg'])}">${i18n('disassociate_dir')}</span>`;
                             h += `</p>`;
                         }
-                        h += `<p class="mywebsites-no-dir-notice" data-site-uuid="${sites[i].uid}" style="${sites[i].root_dir ? `display:none;` : `display:block;`}">${i18n('no_dir_associated_with_site')}</p>`;
+                        h += `<p class="mywebsites-no-dir-notice" data-site-uuid="${html_encode(sites[i].uid)}" style="${sites[i].root_dir ? `display:none;` : `display:block;`}">${i18n('no_dir_associated_with_site')}</p>`;
                     h += `</div>`;
                 }
                 $(el_window).find('.window-body').html(h);