@samitouri / QOSami-HFS / commits / 4845e56d

plugins: new event 'entry'

Massimo Melina committed Sep 22, 2023 at 00:18 UTC 4845e56d5452025e4bef0541634d3d570a568b1a
2 files changed +32 -25
dev-plugins.md
+5
@@ -257,6 +257,10 @@ This is a list of available frontend-events, with respective object parameter an
257 - `getNextFiltered/getPreviousFiltered: ()=>Entry` as above, but considers the filtered-list instead
258 - `getDefaultIcon: ()=>ReactElement` produces the default icon for this entry
259 - output `Html`
260 +- `entry`
261 + - you receive each entry of the list, and optionally produce HTML code that will completely replace the entry row/slot.
262 + - parameter `{ entry: Entry }` (refer above for Entry object)
263 + - output `Html`
264 - `afterEntryName`
265 - you receive each entry of the list, and optionally produce HTML code that will be added after the name of the entry.
266 - parameter `{ entry: Entry }` (refer above for Entry object)
@@ -360,6 +364,7 @@ Where `h` is just `import { createElement as h } from 'react'`.
364 ## API version history
365
366 - 8.5 (v0.49.0)
367 + - new event: entry
368 - exports.onDirEntry: entry.icon
369 - 8.4 (v0.48.2)
370 - HFS.fileShow
frontend/src/BrowseFiles.ts
+27 -25
@@ -193,31 +193,33 @@ const Entry = memo(({ entry, midnight, separator }: EntryProps) => {
193 const small = useWindowSize().width < 800
194 const showingButton = !menuOnLink || isFolder && small
195 return h('li', { className, label: separator },
196 - showFilter && h(Checkbox, {
197 - value: selected[uri],
198 - onChange(v){
199 - if (v)
200 - return state.selected[uri] = true
201 - delete state.selected[uri]
202 - },
203 - }),
204 - h('span', { className: 'link-wrapper' }, // container to handle mouse over for both children
205 - isFolder ? h(Fragment, {},
206 - h(Link, { to: uri }, ico, entry.n.slice(0,-1)),
207 - menuOnLink && !showingButton && h('button', { className: 'popup-menu-button', onClick: fileMenu }, hIcon('menu'), t`Menu`)
208 - )
209 - : containerDir ? h(Fragment, {},
210 - h('a', { href: uri, onClick, tabIndex: -1 }, ico),
211 - h(Link, { to: containerDir, className:'container-folder', tabIndex: -1 }, containerName),
212 - h('a', { href: uri, onClick }, entry.name)
213 - ) : h('a', { href: uri, onClick }, ico, entry.name),
214 - ),
215 - h(CustomCode, { name: 'afterEntryName', props: { entry } }),
216 - h('div', { className: 'entry-panel' },
217 - h(EntryDetails, { entry, midnight }),
218 - showingButton && h('button', { className: 'file-menu-button', onClick: fileMenu }, hIcon('menu')),
219 - ),
220 - h('div'),
196 + h(CustomCode, { name: 'entry', props: { entry }, ifEmpty: () => h(Fragment, {},
197 + showFilter && h(Checkbox, {
198 + value: selected[uri],
199 + onChange(v){
200 + if (v)
201 + return state.selected[uri] = true
202 + delete state.selected[uri]
203 + },
204 + }),
205 + h('span', { className: 'link-wrapper' }, // container to handle mouse over for both children
206 + isFolder ? h(Fragment, {},
207 + h(Link, { to: uri }, ico, entry.n.slice(0,-1)),
208 + menuOnLink && !showingButton && h('button', { className: 'popup-menu-button', onClick: fileMenu }, hIcon('menu'), t`Menu`)
209 + )
210 + : containerDir ? h(Fragment, {},
211 + h('a', { href: uri, onClick, tabIndex: -1 }, ico),
212 + h(Link, { to: containerDir, className:'container-folder', tabIndex: -1 }, containerName),
213 + h('a', { href: uri, onClick }, entry.name)
214 + ) : h('a', { href: uri, onClick }, ico, entry.name),
215 + ),
216 + h(CustomCode, { name: 'afterEntryName', props: { entry } }),
217 + h('div', { className: 'entry-panel' },
218 + h(EntryDetails, { entry, midnight }),
219 + showingButton && h('button', { className: 'file-menu-button', onClick: fileMenu }, hIcon('menu')),
220 + ),
221 + h('div'),
222 + ) }),
223 )
224
225 function fileMenu(ev: MouseEvent) {