MCPcopy Create free account
hub / github.com/error311/FileRise / startInlineRenameInTree

Function startInlineRenameInTree

public/js/folderManager.js:3596–3721  ·  view source on GitHub ↗
(folderPath, targetOpt)

Source from the content-addressed store, hash-verified

3594}
3595
3596export async function startInlineRenameInTree(folderPath, targetOpt) {
3597 const selectedFolder = folderPath || window.currentFolder || 'root';
3598 if (!selectedFolder || selectedFolder === 'root') {
3599 showToast(t('select_folder_rename'), 'warning');
3600 return false;
3601 }
3602
3603 clearInlineTreeRenameState();
3604
3605 let opt = targetOpt || null;
3606 if (!opt) {
3607 try {
3608 opt = document.querySelector(`.folder-option[data-folder="${CSS.escape(selectedFolder)}"]`);
3609 } catch (e) {
3610 opt = null;
3611 }
3612 }
3613
3614 if (!opt) {
3615 try {
3616 await expandTreePathAsync(selectedFolder, { force: true, includeLeaf: true, persist: true });
3617 opt = document.querySelector(`.folder-option[data-folder="${CSS.escape(selectedFolder)}"]`);
3618 } catch (e) {
3619 opt = null;
3620 }
3621 }
3622
3623 if (!opt) {
3624 showToast(t('select_folder_rename'), 'warning');
3625 return false;
3626 }
3627
3628 if (opt.classList.contains('locked')) {
3629 showToast(t('no_access') || "You do not have access to this resource.", 'error');
3630 return false;
3631 }
3632
3633 const labelEl = opt.querySelector('.folder-label');
3634 if (!labelEl) return false;
3635
3636 const oldName = labelEl.textContent || (String(selectedFolder).split('/').pop() || '');
3637
3638 const input = document.createElement('input');
3639 input.type = 'text';
3640 input.value = oldName;
3641 input.className = 'inline-rename-input form-control';
3642 input.setAttribute('aria-label', t('rename_folder') || 'Rename folder');
3643 input.style.width = '100%';
3644 input.style.maxWidth = '100%';
3645 input.style.fontSize = 'inherit';
3646 input.style.padding = '2px 6px';
3647 input.style.height = 'auto';
3648 input.style.boxSizing = 'border-box';
3649
3650 labelEl.style.display = 'none';
3651 opt.insertBefore(input, labelEl);
3652
3653 const state = {

Callers 3

fileListView.jsFile · 0.85
openFolderActionsMenuFunction · 0.85
folderManager.jsFile · 0.85

Calls 8

tFunction · 0.85
expandTreePathAsyncFunction · 0.85
focusTreeRenameInputFunction · 0.85
splitMethod · 0.80
showToastFunction · 0.70
commitFunction · 0.70
cancelFunction · 0.70

Tested by

no test coverage detected