plugins: HFS.iconBtn

Massimo Melina committed Jun 9, 2024 at 17:36 UTC a6ec9962302fe7f01942d2b923bae5c9998f35d1
3 files changed +6 -4
dev-plugins.md
+3 -1
@@ -238,6 +238,7 @@ The HFS objects contains many properties:
238 - `emit(name: string, params?: object): any[]` use this to emit a custom event. Prefix name with your plugin name to avoid conflicts.
239 - `Icon: ReactComponent` Properties:
240 - `name: string` refer to file `icons.ts` for names, but you can also enter an emoji instead.
241 +- `iconBtn(icon: string, onClick: function, props?: any)` render a React Icon Button. For icons, refer to `Icon` component.
242 - `useBatch(worker, job): any`
243 - `getNotifications(channel: string, cb: (eventName: string, data:any) => void)`
244 receive messages when the backend uses `notifyClient` on the same channel.
@@ -586,7 +587,7 @@ If you want to override a text regardless of the language, use the special langu
587
588 ## API version history
589
589 -- 8.85 (v0.53.0)
590 +- 8.87 (v0.53.0)
591 - api.openDb
592 - frontend event: menuZip
593 - config.type:username
@@ -598,6 +599,7 @@ If you want to override a text regardless of the language, use the special langu
599 - HFS.useSnapState
600 - HFS.debounceAsync
601 - HFS.loadScript
602 + - HFS.iconBtn
603 - middleware: ctx.stop()
604 - the old way of returning true is now deprecated
605 - exports.customHtml
frontend/src/misc.ts
+2 -2
@@ -1,7 +1,7 @@
1 // This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
2
3 import React, { createElement as h } from 'react'
4 -import { Spinner } from './components'
4 +import { iconBtn, Spinner } from './components'
5 import { newDialog, toast } from './dialog'
6 import { Icon } from './icons'
7 import { Dict, getHFS, Html, HTTP_MESSAGES, useBatch } from '@hfs/shared'
@@ -59,7 +59,7 @@ export function hfsEvent(name: string, params?:Dict) {
59 }
60
61 const tools = {
62 - h, React, state, t, _, dialogLib, apiCall, useApi, reloadList, logout, Icon, hIcon, useBatch, fileShow, toast,
62 + h, React, state, t, _, dialogLib, apiCall, useApi, reloadList, logout, Icon, hIcon, iconBtn, useBatch, fileShow, toast,
63 misc: { ...cross, ...shared },
64 watchState(k: string, cb: (v: any) => void) {
65 const up = k.split('upload.')[1]
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.86
10 +export const API_VERSION = 8.87
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