ux: admin/home: clearer "auto check" option

Massimo Melina committed Jul 20, 2024 at 23:00 UTC 03d4e69f51983227f4bf8eaf0ac75e2e76b97f4d
1 file changed +26 -31
admin/src/HomePage.ts
+26 -31
@@ -87,42 +87,37 @@ export default function HomePage() {
87 !updates && with_(status.autoCheckUpdateResult, x => x?.isNewer && h(Update, { info: x, bodyCollapsed: true, title: "An update has been found" })),
88 pluginUpdates.length > 0 && entry('success', "Updates available for plugin(s): " + pluginUpdates.map(p => p.id).join(', ')),
89 h(ConfigForm, {
90 - gridProps: { sx: { columns: '13em 2', gap: 0, display: 'block', mt: 0, '&>div.MuiGrid-item': { pt: 0 }, '.MuiCheckbox-root': { pl: '2px' } } },
90 + gridProps: { sx: { columns: '13em 3', gap: 0, display: 'block', mt: 0, '&>div.MuiGrid-item': { pt: 0 }, '.MuiCheckbox-root': { pl: '2px' } } },
91 saveOnChange: true,
92 form: { fields: [
93 - { k: 'auto_check_update', comp: CheckboxField, label: "Check updates daily" },
93 + status.updatePossible === 'local' ? h(Btn, { icon: UpdateIcon, onClick: () => update() }, "Update from local file")
94 + : !updates && h(Btn, {
95 + variant: 'outlined',
96 + icon: UpdateIcon,
97 + onClick() {
98 + apiCall('wait_project_info').then(reloadStatus)
99 + setCheckPlugins(true) // this only happens once, actually (until you change page)
100 + return apiCall<typeof adminApis.check_update>('check_update').then(x => setUpdates(x.options), alertDialog)
101 + },
102 + async onContextMenu(ev) {
103 + ev.preventDefault()
104 + if (!status.updatePossible)
105 + return alertDialog("Automatic update is only for binary versions", 'warning')
106 + const res = await promptDialog("Enter a link to the zip to install")
107 + if (res)
108 + await update(res)
109 + },
110 + title: status.updatePossible && "Right-click if you want to install a zip",
111 + }, "Check for updates"),
112 + { k: 'auto_check_update', comp: CheckboxField, label: "Auto check updates daily" },
113 { k: 'update_to_beta', comp: CheckboxField, label: "Include beta versions" },
114 ] }
115 }),
97 - status.updatePossible === 'local' ? h(Btn, {
98 - icon: UpdateIcon,
99 - onClick: () => update()
100 - }, "Update from local file")
101 - : !updates ? h(Flex, { flexWrap: 'wrap' },
102 - h(Btn, {
103 - variant: 'outlined',
104 - icon: UpdateIcon,
105 - onClick() {
106 - apiCall('wait_project_info').then(reloadStatus)
107 - setCheckPlugins(true) // this only happens once, actually (until you change page)
108 - return apiCall<typeof adminApis.check_update>('check_update').then(x => setUpdates(x.options), alertDialog)
109 - },
110 - async onContextMenu(ev) {
111 - ev.preventDefault()
112 - if (!status.updatePossible)
113 - return alertDialog("Automatic update is only for binary versions", 'warning')
114 - const res = await promptDialog("Enter a link to the zip to install")
115 - if (res)
116 - await update(res)
117 - },
118 - title: status.updatePossible && "Right-click if you want to install a zip",
119 - }, "Check for updates"),
120 - )
121 - : with_(_.find(updates, 'isNewer'), newer =>
122 - !updates.length || !status.updatePossible && !newer ? entry('', "No update available")
123 - : newer && !status.updatePossible ? entry('success', `Version ${newer.name} available`)
124 - : h(Flex, { vert: true },
125 - updates.map((x: any) => h(Update, { info: x })) )),
116 + updates && with_(_.find(updates, 'isNewer'), newer =>
117 + !updates.length || !status.updatePossible && !newer ? entry('', "No update available")
118 + : newer && !status.updatePossible ? entry('success', `Version ${newer.name} available`)
119 + : h(Flex, { vert: true },
120 + updates.map((x: any) => h(Update, { info: x })) )),
121 h(SwitchThemeBtn, { variant: 'outlined' }),
122 )
123 }