fix: hide explorer action for inbox links

This commit is contained in:
mirivlad 2026-06-05 08:07:39 +08:00
parent 91b5629e01
commit a8df9d118c
2 changed files with 22 additions and 1 deletions

View File

@ -902,6 +902,11 @@
return item?.sourceKind || item?.captureKind || item?.type || '' return item?.sourceKind || item?.captureKind || item?.type || ''
} }
function canShowInboxArtifactInFolder(item) {
const kind = inboxArtifactKind(item)
return kind !== 'url' && item?.type !== 'link'
}
function fileRecordToPreviewItem(item, record) { function fileRecordToPreviewItem(item, record) {
return { return {
id: item.id, id: item.id,
@ -2584,7 +2589,9 @@
{/if} {/if}
<button class="btn btn-sm btn-primary" on:click|stopPropagation={() => openAssignInbox(item)}>{t('inbox.assign')}</button> <button class="btn btn-sm btn-primary" on:click|stopPropagation={() => openAssignInbox(item)}>{t('inbox.assign')}</button>
<button class="btn btn-sm" on:click|stopPropagation={() => openInboxArtifact(item)}>{t('common.open')}</button> <button class="btn btn-sm" on:click|stopPropagation={() => openInboxArtifact(item)}>{t('common.open')}</button>
<button class="btn btn-sm" on:click|stopPropagation={() => openNodeFolder(item)}>{t('file.showInExplorer')}</button> {#if canShowInboxArtifactInFolder(item)}
<button class="btn btn-sm" on:click|stopPropagation={() => openNodeFolder(item)}>{t('file.showInExplorer')}</button>
{/if}
<button class="btn btn-sm btn-danger" on:click|stopPropagation={() => confirmDeleteInbox(item)}>{t('common.delete')}</button> <button class="btn btn-sm btn-danger" on:click|stopPropagation={() => confirmDeleteInbox(item)}>{t('common.delete')}</button>
</div> </div>
</div> </div>

View File

@ -144,6 +144,7 @@ async function runReadyScenario(cdp, url) {
await clickText(cdp, '.inbox-header .btn', 'Вставить из буфера') await clickText(cdp, '.inbox-header .btn', 'Вставить из буфера')
await assertText(cdp, 'example.test', 'inbox: clipboard URL captured') await assertText(cdp, 'example.test', 'inbox: clipboard URL captured')
await assertText(cdp, 'Ссылка', 'inbox: clipboard URL kind visible') await assertText(cdp, 'Ссылка', 'inbox: clipboard URL kind visible')
await assertInboxItemButtonAbsent(cdp, 'example.test', 'Показать в проводнике', 'inbox: link has no explorer action')
await clickInboxItemButton(cdp, 'example.test', 'Открыть') await clickInboxItemButton(cdp, 'example.test', 'Открыть')
await assertEval(cdp, `window.__VERSTAK_GUI_SMOKE__.state.openedUrls.includes('https://example.test/from-clipboard')`, 'inbox: open URL launches external URL') await assertEval(cdp, `window.__VERSTAK_GUI_SMOKE__.state.openedUrls.includes('https://example.test/from-clipboard')`, 'inbox: open URL launches external URL')
await clickInboxItemButton(cdp, 'example.test', 'Разложить') await clickInboxItemButton(cdp, 'example.test', 'Разложить')
@ -485,6 +486,19 @@ async function clickInboxItemButton(cdp, title, buttonText) {
await sleep(250) await sleep(250)
} }
async function assertInboxItemButtonAbsent(cdp, title, buttonText, label) {
await assertEval(cdp, `
(() => {
const norm = (value) => (value || '').replace(/\\s+/g, ' ').trim();
const row = [...document.querySelectorAll('.inbox-item')]
.find((node) => norm(node.innerText || node.textContent).includes(${JSON.stringify(title)}));
if (!row) return false;
return ![...row.querySelectorAll('button')]
.some((node) => norm(node.innerText || node.textContent).includes(${JSON.stringify(buttonText)}));
})()
`, label)
}
async function evalValue(cdp, expression) { async function evalValue(cdp, expression) {
const result = await cdp.send('Runtime.evaluate', { const result = await cdp.send('Runtime.evaluate', {
expression, expression,