fix: improve notes rename conflicts
This commit is contained in:
parent
f2e837a776
commit
10bc28cef7
|
|
@ -178,6 +178,7 @@
|
|||
var noteActions = [];
|
||||
var filterText = '';
|
||||
var sortMode = 'title-asc';
|
||||
var renameTarget = null;
|
||||
|
||||
function notesParent() {
|
||||
return workspaceRoot || '';
|
||||
|
|
@ -489,7 +490,7 @@
|
|||
if (disposed) return;
|
||||
data = data || {};
|
||||
if (data.conflict) {
|
||||
showConflictModal(title, data.path);
|
||||
showConflictModal(title, data.path, createInput);
|
||||
return;
|
||||
}
|
||||
hideCreate();
|
||||
|
|
@ -540,7 +541,7 @@
|
|||
if (disposed) return;
|
||||
data = data || {};
|
||||
if (data.conflict) {
|
||||
showConflictModal(newTitle, data.path);
|
||||
showConflictModal(newTitle, data.path, renameInput);
|
||||
return;
|
||||
}
|
||||
hideRename();
|
||||
|
|
@ -571,16 +572,17 @@
|
|||
|
||||
// ─── Conflict Modal ─────────────────────────────────────
|
||||
|
||||
function showConflictModal(title, existingPath) {
|
||||
function showConflictModal(title, existingPath, focusTarget) {
|
||||
var overlay = el('div', { className: 'notes-modal-overlay' });
|
||||
var modal = el('div', { className: 'notes-modal' }, [
|
||||
el('div', { className: 'notes-modal-title' }, ['Name Conflict']),
|
||||
el('div', { className: 'notes-modal-msg' }, [
|
||||
'A note with the title "' + title + '" already exists.',
|
||||
existingPath ? ' Existing file: ' + existingPath + '.' : '',
|
||||
' Please choose a different title.'
|
||||
].join('')),
|
||||
el('div', { className: 'notes-modal-actions' }, [
|
||||
el('button', { className: 'notes-modal-btn confirm', textContent: 'OK', onClick: function () { overlay.remove(); createInput.focus(); } })
|
||||
el('button', { className: 'notes-modal-btn confirm', textContent: 'OK', onClick: function () { overlay.remove(); (focusTarget || createInput).focus(); } })
|
||||
])
|
||||
]);
|
||||
overlay.appendChild(modal);
|
||||
|
|
|
|||
|
|
@ -288,6 +288,25 @@ async function mountNotes(api) {
|
|||
sortSelect.value = 'title-asc';
|
||||
sortSelect.dispatchEvent('change');
|
||||
|
||||
const renameButton = walk(container, (node) => node.getAttribute && node.getAttribute('data-note-action') === 'rename');
|
||||
if (!renameButton) throw new Error('rename note button not found');
|
||||
renameButton.click();
|
||||
const renameInput = walk(container, (node) => node.getAttribute && node.getAttribute('data-notes-rename-input') !== undefined);
|
||||
if (!renameInput) throw new Error('rename input not found');
|
||||
renameInput.value = 'Second Note';
|
||||
const renameConfirm = walk(container, (node) => node.tagName === 'BUTTON' && node.textContent === 'Rename');
|
||||
if (!renameConfirm) throw new Error('rename confirm button not found');
|
||||
renameConfirm.click();
|
||||
await flush();
|
||||
const conflictModal = walk(document.body, (node) => node.className === 'notes-modal-msg');
|
||||
if (!conflictModal || !conflictModal.textContent.includes('Project/Notes/Second_Note.md')) {
|
||||
throw new Error(`rename conflict modal should include existing path, got ${conflictModal && conflictModal.textContent}`);
|
||||
}
|
||||
const conflictOk = walk(document.body, (node) => node.tagName === 'BUTTON' && node.textContent === 'OK');
|
||||
if (!conflictOk) throw new Error('rename conflict OK button not found');
|
||||
conflictOk.click();
|
||||
await flush();
|
||||
|
||||
const providerAction = walk(container, (node) => node.getAttribute && node.getAttribute('data-note-contribution-action') === 'provider.note.action');
|
||||
if (!providerAction) throw new Error('provider note action button not found');
|
||||
providerAction.click();
|
||||
|
|
|
|||
Loading…
Reference in New Issue