admin: avoid most of the console warnings when clicking async buttons

Massimo Melina committed Nov 6, 2024 at 19:25 UTC 5b2eb64db2b2de5479fafbd3a437cdba90ccf661
3 files changed +2 -3
admin/src/InstalledPlugins.ts
-1
@@ -100,7 +100,6 @@ export default function InstalledPlugins({ updates }: { updates?: true }) {
100 size,
101 disabled: !row.started && "Start plugin to access options"
102 || !row.config && "No options available for this plugin",
103 - progress: false,
103 async onClick() {
104 const { config: lastSaved } = await apiCall('get_plugin', { id })
105 const values = await formDialog({
admin/src/VfsMenuBar.ts
-1
@@ -23,7 +23,6 @@ export default function VfsMenuBar({ statusApi, add }: { add: ReactNode, statusA
23 h(Btn, {
24 icon: Storage,
25 title: "Disk spaces",
26 - progress: false,
26 onClick: () => apiCall<Awaited<ReturnType<typeof getDiskSpaces>>>('get_disk_spaces').then(res =>
27 alertDialog(h(List, { dense: true }, res.map(x => h(ListItem, { key: x.name },
28 h(ListItemIcon, {}, h(Storage)),
admin/src/mui.ts
+2 -1
@@ -144,7 +144,7 @@ export const Btn = forwardRef(({ icon, title, onClick, disabled, progress, link,
144 const [loadingState, setLoadingState] = useStateMounted(false)
145 if (typeof disabled === 'string')
146 title = disabled
147 - disabled = loadingState || progress || disabled ? true : undefined
147 + disabled = progress || disabled ? true : undefined
148 if (link)
149 onClick = () => window.open(link)
150 const showLabel = useBreakpoint(_.isString(labelIf) ? labelIf : 'xs') && (_.isBoolean(labelIf) ? labelIf : true)
@@ -156,6 +156,7 @@ export const Btn = forwardRef(({ icon, title, onClick, disabled, progress, link,
156 disabled,
157 'aria-hidden': disabled,
158 async onClick(...args: any[]) {
159 + if (loadingState) return
160 if (confirm && !await confirmDialog(confirm === true ? "Are you sure?" : confirm)) return
161 const ret = onClick?.apply(this, args as any)
162 if (ret && ret instanceof Promise) {