ui: harden workspace and secrets rendering

This commit is contained in:
a.tolmachev
2026-04-12 02:05:05 +03:00
parent f30c63146b
commit c69c327123
14 changed files with 219 additions and 62 deletions
+51 -15
View File
@@ -110,23 +110,59 @@ function renderWorkspaceList() {
var list = document.getElementById('ws-dropdown-list');
if (!list) return;
window.CrankDom.clear(list);
list.innerHTML = WS_LIST.map(function(workspace) {
WS_LIST.forEach(function(workspace) {
var active = current && workspace.id === current.id;
return '<div class="ws-dropdown-item' + (active ? ' active' : '') + '" onclick="switchWorkspace(\'' + workspace.id + '\')">' +
'<div class="ws-item-dot" style="background:' + workspace.color + '">' + workspace.letter + '</div>' +
'<div class="ws-item-info">' +
'<div class="ws-item-name">' + workspace.name + '</div>' +
'<div class="ws-item-role">' + workspace.role + '</div>' +
'</div>' +
(active ? '<svg width="12" height="12"><use href="' + (window.APP_BASE || '') + 'icons/general/check.svg#icon"/></svg>' : '') +
'</div>';
}).join('') +
'<div class="ws-dropdown-divider"></div>' +
'<a class="ws-dropdown-mgmt-link" href="' + ((window.CrankRoutes && window.CrankRoutes.workspaceSetup) || '/workspace-setup') + '" onclick="var dd=document.getElementById(\'ws-dropdown\');if(dd)dd.style.display=\'none\'">' +
'<svg width="14" height="14"><use href="' + (window.APP_BASE || '') + 'icons/general/settings.svg#icon"/></svg>' +
tKey('settings.ws.title') +
'</a>';
var item = document.createElement('div');
item.className = 'ws-dropdown-item' + (active ? ' active' : '');
item.addEventListener('click', function() {
switchWorkspace(workspace.id);
});
var dot = document.createElement('div');
dot.className = 'ws-item-dot';
dot.style.background = workspace.color;
dot.textContent = workspace.letter;
item.appendChild(dot);
var info = document.createElement('div');
info.className = 'ws-item-info';
var name = document.createElement('div');
name.className = 'ws-item-name';
name.textContent = workspace.name;
var role = document.createElement('div');
role.className = 'ws-item-role';
role.textContent = workspace.role;
info.appendChild(name);
info.appendChild(role);
item.appendChild(info);
if (active) {
var check = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
check.setAttribute('width', '12');
check.setAttribute('height', '12');
check.innerHTML = '<use href="' + (window.APP_BASE || '') + 'icons/general/check.svg#icon"></use>';
item.appendChild(check);
}
list.appendChild(item);
});
var divider = document.createElement('div');
divider.className = 'ws-dropdown-divider';
list.appendChild(divider);
var manageLink = document.createElement('a');
manageLink.className = 'ws-dropdown-mgmt-link';
manageLink.href = (window.CrankRoutes && window.CrankRoutes.workspaceSetup) || '/workspace-setup';
manageLink.addEventListener('click', function() {
var dd = document.getElementById('ws-dropdown');
if (dd) dd.style.display = 'none';
});
manageLink.innerHTML = '<svg width="14" height="14"><use href="' + (window.APP_BASE || '') + 'icons/general/settings.svg#icon"/></svg>';
manageLink.appendChild(document.createTextNode(tKey('settings.ws.title')));
list.appendChild(manageLink);
}
async function loadWorkspaces() {