diff --git a/src/gui/src/UI/UIItem.js b/src/gui/src/UI/UIItem.js index 99ef77224..e644edd09 100644 --- a/src/gui/src/UI/UIItem.js +++ b/src/gui/src/UI/UIItem.js @@ -35,12 +35,12 @@ import mime from '../lib/mime.js'; const AI_APP_NAME = 'ai'; const parseItemMetadataForAI = (metadata) => { - if ( ! metadata ) { + if (!metadata) { return undefined; } try { return JSON.parse(metadata); - } catch ( error ) { + } catch (error) { console.warn('Failed to parse item metadata for AI payload.', error); return undefined; } @@ -67,17 +67,17 @@ const buildAIPayloadFromItems = ($elements) => { const ensureAIAppIframe = async () => { let $aiWindow = $(`.window[data-app="${AI_APP_NAME}"]`); - if ( $aiWindow.length === 0 ) { + if ($aiWindow.length === 0) { try { await launch_app({ name: AI_APP_NAME }); - } catch ( error ) { + } catch (error) { console.error('Failed to launch AI app.', error); return null; } $aiWindow = $(`.window[data-app="${AI_APP_NAME}"]`); } - if ( $aiWindow.length === 0 ) { + if ($aiWindow.length === 0) { return null; } @@ -88,12 +88,12 @@ const ensureAIAppIframe = async () => { const sendSelectionToAIApp = async ($elements) => { const items = buildAIPayloadFromItems($elements); - if ( items.length === 0 ) { + if (items.length === 0) { return; } const aiIframe = await ensureAIAppIframe(); - if ( !aiIframe || !aiIframe.contentWindow ) { + if (!aiIframe || !aiIframe.contentWindow) { await UIAlert({ message: i18n('ai_app_unavailable'), }); @@ -107,7 +107,7 @@ const sendSelectionToAIApp = async ($elements) => { }, '*'); }; -async function UIItem (options) { +function UIItem(options){ const matching_appendto_count = $(options.appendTo).length; if ( matching_appendto_count > 1 ) { $(options.appendTo).each(function () { @@ -139,9 +139,7 @@ async function UIItem (options) { options.immutable = (options.immutable === false || options.immutable === 0 || options.immutable === undefined ? 0 : 1); options.sort_container_after_append = (options.sort_container_after_append !== undefined ? options.sort_container_after_append : false); const is_shared_with_me = (options.path !== `/${window.user.username}` && !options.path.startsWith(`/${window.user.username}/`)); - const workers = await puter.workers.list(); - const is_worker = workers.find(w => w.file_path === options.path); - const worker_url = is_worker?.url; + let website_url = window.determine_website_url(options.path); // do a quick check to see if the target parent has any file type restrictions @@ -167,8 +165,6 @@ async function UIItem (options) { data-website_url = "${website_url ? html_encode(website_url) : ''}" data-immutable="${options.immutable}" data-is_shortcut = "${options.is_shortcut}" - data-is_worker = "${is_worker !== undefined ? 1 : 0}" - data-worker_url = "${is_worker !== undefined ? worker_url : 0}" data-shortcut_to = "${html_encode(options.shortcut_to)}" data-shortcut_to_path = "${html_encode(options.shortcut_to_path)}" data-sortable = "${options.sortable ?? 'true'}" @@ -244,12 +240,7 @@ async function UIItem (options) { data-item-id="${item_id}" title="${i18n('item_shortcut')}" >`; - // worker badge - h += ``; + h += ''; // divider @@ -997,9 +988,9 @@ async function UIItem (options) { // ------------------------------------------- menu_items.push({ html: i18n('open_in_ai'), - onClick: async function () { + onClick: async function(){ await sendSelectionToAIApp($selected_items); - }, + } }); // ------------------------------------------- // - @@ -1341,9 +1332,9 @@ async function UIItem (options) { // ------------------------------------------- menu_items.push({ html: i18n('open_in_ai'), - onClick: async function () { + onClick: async function(){ await sendSelectionToAIApp($(el_item)); - }, + } }); } @@ -1889,50 +1880,6 @@ $(document).on('click', '.website-badge-popover-link', function (e) { $(e.target).closest('.popover').remove(); }); -$(document).on('long-hover', '.item-is-worker', function (e) { - const worker_url = e.target.parentNode.parentNode.getAttribute('data-worker_url'); - var box = e.target.getBoundingClientRect(); - - var body = document.body; - var docEl = document.documentElement; - - var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop; - var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft; - - var clientTop = docEl.clientTop || body.clientTop || 0; - var clientLeft = docEl.clientLeft || body.clientLeft || 0; - - var top = box.top + scrollTop - clientTop; - var left = box.left + scrollLeft - clientLeft; - - if ( worker_url ) { - let h = '
'; - h += `
${i18n('worker')}
`; - h += ` - ${worker_url.replace('https://', '')} -
`; - h += '
'; - - // close other worker popovers - $('.worker-badge-popover-content').closest('.popover').remove(); - - // show a UIPopover with the worker URL - UIPopover({ - target: e.target, - content: h, - snapToElement: e.target, - parent_element: e.target, - top: top - 30, - left: left + 20, - }); - } -}); - -$(document).on('click', '.worker-badge-popover-link', function (e) { - // remove the parent popover - $(e.target).closest('.popover').remove(); -}); - // removes item(s) $.fn.removeItems = async function (options) { options = options || {}; diff --git a/src/gui/src/UI/UIWindowItemProperties.js b/src/gui/src/UI/UIWindowItemProperties.js index d827faa32..fc92218f3 100644 --- a/src/gui/src/UI/UIWindowItemProperties.js +++ b/src/gui/src/UI/UIWindowItemProperties.js @@ -42,7 +42,6 @@ async function UIWindowItemProperties (item_name, item_path, item_uid, left, top h += `${i18n('modified')}`; h += `${i18n('created')}`; h += `${i18n('versions')}`; - h += `${i18n('worker')}`; h += `${i18n('associated_websites')}`; h += ''; h += `${i18n('access_granted_to')}`; @@ -110,7 +109,7 @@ async function UIWindowItemProperties (item_name, item_path, item_uid, left, top returnVersions: true, returnSize: true, consistency: 'eventual', - success: async function (fsentry) { + success: function (fsentry) { // hide versions tab if item is a directory if ( fsentry.is_dir ) { $(el_window).find('[data-tab="versions"]').hide(); @@ -169,15 +168,7 @@ async function UIWindowItemProperties (item_name, item_path, item_uid, left, top else { $(el_window).find('.item-props-version-list').append('-'); } - // worker - if ( fsentry.path.endsWith('.js') ) { - const workers = await puter.workers.list(); - const has_worker = workers.find(w => w.file_path === fsentry.path); - const worker_url = has_worker?.url; - if ( has_worker && worker_url ) { - $(el_window).find('.item-prop-val-worker').html(`${html_encode(worker_url)}`); - } - } + $(el_window).find('.disassociate-website-link').on('click', function (e) { puter.hosting.update($(e.target).attr('data-subdomain'), null).then(() => { @@ -187,7 +178,7 @@ async function UIWindowItemProperties (item_name, item_path, item_uid, left, top // remove the website badge from all instances of the dir $(`.item[data-uid="${item_uid}"]`).find('.item-has-website-badge').fadeOut(200); } - }); + }); }); }, }); diff --git a/src/gui/src/css/style.css b/src/gui/src/css/style.css index 70787430f..0c2758bb1 100644 --- a/src/gui/src/css/style.css +++ b/src/gui/src/css/style.css @@ -665,12 +665,6 @@ span.header-sort-icon img { filter: drop-shadow(0px 0px 1px rgba(0, 0, 0, 1)); } -.item-badge.item-is-worker { - border-radius: 50%; - background: white; - cursor: pointer; -} - .item-name, .item-name-editor, .item-name-shadow { font-size: 12px; color: white; @@ -3910,33 +3904,6 @@ fieldset[name=number-code] { text-decoration: underline; } -.worker-badge-popover-title { - font-size: 14px; - margin: -10px; - margin-bottom: 5px; - padding: 8px 10px; - background: #e5e5e5; - color: #4b5f6f; -} - -.worker-badge-popover-content { - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden; - width: 270px; - padding: 10px; -} - -.worker-badge-popover-link, .worker-badge-popover-link:visited { - color: #0073ed; - text-decoration: none; - width: 179px; -} - -.worker-badge-popover-link:hover { - text-decoration: underline; -} - /*! * animate.css - https://animate.style/ * Version - 4.1.1 diff --git a/src/gui/src/helpers/get_html_element_from_options.js b/src/gui/src/helpers/get_html_element_from_options.js index 3651ae2bc..be72a3b91 100644 --- a/src/gui/src/helpers/get_html_element_from_options.js +++ b/src/gui/src/helpers/get_html_element_from_options.js @@ -36,9 +36,7 @@ const get_html_element_from_options = async function (options) { options.immutable = (options.immutable === false || options.immutable === 0 || options.immutable === undefined ? 0 : 1); options.sort_container_after_append = (options.sort_container_after_append !== undefined ? options.sort_container_after_append : false); const is_shared_with_me = (options.path !== `/${window.user.username}` && !options.path.startsWith(`/${window.user.username}/`)); - const workers = await puter.workers.list(); - const is_worker = workers.find(w => w.file_path === options.path); - const worker_url = is_worker?.url; + let website_url = window.determine_website_url(options.path); // do a quick check to see if the target parent has any file type restrictions @@ -64,8 +62,6 @@ const get_html_element_from_options = async function (options) { data-website_url = "${website_url ? html_encode(website_url) : ''}" data-immutable="${options.immutable}" data-is_shortcut = "${options.is_shortcut}" - data-is_worker = "${is_worker !== undefined ? 1 : 0}" - data-worker_url = "${is_worker !== undefined ? worker_url : 0}" data-shortcut_to = "${html_encode(options.shortcut_to)}" data-shortcut_to_path = "${html_encode(options.shortcut_to_path)}" data-sortable = "${options.sortable ?? 'true'}" @@ -141,12 +137,7 @@ const get_html_element_from_options = async function (options) { data-item-id="${item_id}" title="Shortcut" >`; - // worker badge - h += ``; + h += ''; // name diff --git a/src/gui/src/icons/worker.svg b/src/gui/src/icons/worker.svg deleted file mode 100644 index 9dfe587ca..000000000 --- a/src/gui/src/icons/worker.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file