support entry.icon
Massimo Melina committed
Sep 20, 2023 at 22:09 UTC
9054a7a3193c64fee5bd3910287202e9d9dee180
2 files changed
+9
-6
dev-plugins.md
+7
-5
@@ -92,8 +92,9 @@ used must be strictly JSON (thus, no single quotes, only double quotes for strin
92
If you want to execute something in the "upstream" of middlewares, return a function.
93
94
- `unload: function` called when unloading a plugin. This is a good place for example to clearInterval().
95
-- `onDirEntry: ({ entry: DirEntry, listUri: string }) => Promisable<void | false>` by providing this callback you can manipulate the record
96
- that is sent to the frontend (`entry`), or you can return false to exclude this entry from the results.
95
+- `onDirEntry: ({ entry: DirEntry, listUri: string }) => Promisable<void | false>` by providing this callback you can manipulate
96
+ the record that is sent to the frontend (`entry`), or you can return false to exclude this entry from the results.
97
+ Refer to source `frontend/src/stats.ts`.
98
- `config: { [key]: FieldDescriptor }` declare a set of admin-configurable values owned by the plugin
99
that will be displayed inside Admin-panel for change. Each property is identified by its key,
100
and the descriptor is another object with options about the field.
@@ -358,9 +359,10 @@ Where `h` is just `import { createElement as h } from 'react'`.
359
360
## API version history
361
361
-- 8.4 (v0.49.0)
362
- - exports.onDirEntry: support async
363
- - HFS.fileShow
362
+- 8.5 (v0.49.0)
363
+ - exports.onDirEntry: entry.icon
364
+- 8.4 (v0.48.2)
365
+ - HFS.fileShow
366
- api.Const (api.const is now deprecated)
367
- 8.3 (v0.47.0)
368
- HFS.useBatch
frontend/src/state.ts
+2
-1
@@ -86,6 +86,7 @@ export class DirEntry {
86
public readonly m?: string
87
public readonly c?: string
88
public readonly p?: string
89
+ public readonly icon?: string
90
// we memoize these value for speed
91
public readonly name: string
92
public readonly uri: string
@@ -128,7 +129,7 @@ export class DirEntry {
129
}
130
131
getDefaultIcon() {
131
- return hIcon(this.isFolder ? 'folder' : ext2type(this.ext) || 'file')
132
+ return hIcon(this.icon ?? (this.isFolder ? 'folder' : ext2type(this.ext) || 'file'))
133
}
134
}
135
export type DirList = DirEntry[]