Revert "Adds worker badge to .js files which have been registered as workers. Hovering badge shows popover with worker URL. File properties modal also shows clickable worker URL. (#2462)"

This reverts commit 50e2d275bc.
This commit is contained in:
jelveh
2026-02-11 15:13:56 -08:00
parent 81c88c1434
commit c2750f2ca1
5 changed files with 19 additions and 124 deletions
+14 -67
View File
@@ -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 += `<img class="item-badge item-is-worker long-hover"
style="background-color: #ffffff; padding: 2px; ${is_worker ? 'display:block;' : ''}"
src="${html_encode(window.icons['worker.svg'])}"
data-item-id="${item_id}"
>`;
h += '</div>';
// 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 = '<div class="allow-user-select worker-badge-popover-content">';
h += `<div class="worker-badge-popover-title">${i18n('worker')}</div>`;
h += `
<a class="worker-badge-popover-link" href="${worker_url}" style="font-size:13px;" target="_blank">${worker_url.replace('https://', '')}</a>
<br>`;
h += '</div>';
// 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 || {};
+3 -12
View File
@@ -42,7 +42,6 @@ async function UIWindowItemProperties (item_name, item_path, item_uid, left, top
h += `<tr><td class="item-prop-label">${i18n('modified')}</td><td class="item-prop-val item-prop-val-modified"></td></tr>`;
h += `<tr><td class="item-prop-label">${i18n('created')}</td><td class="item-prop-val item-prop-val-created"></td></tr>`;
h += `<tr><td class="item-prop-label">${i18n('versions')}</td><td class="item-prop-val item-prop-val-versions"></td></tr>`;
h += `<tr><td class="item-prop-label">${i18n('worker')}</td><td class="item-prop-val item-prop-val-worker">`;
h += `<tr><td class="item-prop-label">${i18n('associated_websites')}</td><td class="item-prop-val item-prop-val-websites">`;
h += '</td></tr>';
h += `<tr><td class="item-prop-label">${i18n('access_granted_to')}</td><td class="item-prop-val item-prop-val-permissions"></td></tr>`;
@@ -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(`<a target="_blank" href="${html_encode(worker_url)}">${html_encode(worker_url)}</a>`);
}
}
$(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);
}
});
});
});
},
});
-33
View File
@@ -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
@@ -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 += `<img class="item-badge item-is-worker long-hover"
style="background-color: #ffffff; padding: 2px; ${is_worker ? 'display:block;' : ''}"
src="${html_encode(window.icons['worker.svg'])}"
data-item-id="${item_id}"
>`;
h += '</div>';
// name
-1
View File
@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" color="#455a64" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-zap-icon lucide-zap"><path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/></svg>

Before

Width:  |  Height:  |  Size: 412 B