plugins: HFS.toast
Massimo Melina committed
Apr 1, 2024 at 17:29 UTC
ebf6234b83dcb938c90434e3191a26c6009f0409
3 files changed
+12
-6
dev-plugins.md
+8
-3
@@ -206,6 +206,9 @@ The HFS objects contains many properties:
206
- `h` shortcut for React.createElement
207
- `t` [translator function](https://github.com/rejetto/hfs/blob/main/frontend/src/i18n.ts)
208
- `_` [lodash library](https://lodash.com/docs/)
209
+- `toast: (message: string | ReactElement, type: ToastType='info')`
210
+ - show a brief message that doesn't steal focus
211
+ - `ToastType = 'error' | 'warning' | 'info' | 'success'`
212
- `dialogLib` this exposes all functions available in [dialog.ts](https://github.com/rejetto/hfs/blob/main/frontend/src/dialog.ts), for example alertDialog and newDialog. These are not documented yet, and subject to change without notification, but you can study the sources if you are interested in using them.
213
- `misc` many functions and constants available in [cross.ts](https://github.com/rejetto/hfs/blob/main/src/cross.ts). These are not documented, probably never will, and are subject to change without notifications, but you can study the sources if you are interested in using them.
214
- `navigate: (uri: string): void` use this if you have to change the page address without causing reload
@@ -393,9 +396,11 @@ Eg: `HFS.t('filter_count', {n:filteredVariable}, "{n} filtered")`
396
397
## API version history
398
396
-- 8.71 (v0.52.0)
397
- - exposed "misc" functions
398
- - new event: uriChanged
399
+- 8.72 (v0.52.0)
400
+ - HFS.toast
401
+ - HFS.misc functions
402
+ - HFS.state.uri
403
+ - ~~new event: uriChanged~~
404
- 8.65 (v0.51.0)
405
- plugin's own hfs-lang files
406
- HFS.state.props.can_overwrite
frontend/src/misc.ts
+3
-2
@@ -2,7 +2,7 @@
2
3
import React, { createElement as h } from 'react'
4
import { Spinner } from './components'
5
-import { newDialog } from './dialog'
5
+import { newDialog, toast } from './dialog'
6
import { Icon } from './icons'
7
import { Dict, getHFS, HTTP_MESSAGES, useBatch } from '@hfs/shared'
8
import * as misc from '../../src/cross'
@@ -56,7 +56,8 @@ export function hfsEvent(name: string, params?:Dict) {
56
return output
57
}
58
59
-const tools = { misc, h, React, state, t, _, dialogLib, apiCall, useApi, reloadList, logout, Icon, hIcon, useBatch, fileShow,
59
+const tools = {
60
+ misc, h, React, state, t, _, dialogLib, apiCall, useApi, reloadList, logout, Icon, hIcon, useBatch, fileShow, toast,
61
watchState(k: string, cb: (v: any) => void) {
62
const up = k.split('upload.')[1]
63
return subscribeKey(up ? uploadState : state as any, up || k, cb, true)
src/const.ts
+1
-1
@@ -7,7 +7,7 @@ import { mkdirSync } from 'fs'
7
import { basename, dirname, join } from 'path'
8
export * from './cross-const'
9
10
-export const API_VERSION = 8.71
10
+export const API_VERSION = 8.72
11
export const COMPATIBLE_API_VERSION = 1 // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
12
export const HFS_REPO = 'rejetto/hfs'
13