diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-07 10:35:09 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-07 10:35:09 +0200 |
| commit | 2c0903c648e24b4e2adf20492398e8b67d033b49 (patch) | |
| tree | 0435f298010f0f946362f28baebbe88337ca8768 /packages/meshbay-hub/src/meshbay_hub/static/music-app-settings.js | |
| parent | 0ed078c92cabab1dab0f70f321562032ea549ce6 (diff) | |
| parent | eeda274d751c537f4ecef3087994a16a9517478f (diff) | |
| download | meshbay-2c0903c648e24b4e2adf20492398e8b67d033b49.tar.gz | |
Merge branch 'refactor/groups-phase1'
Groups refactor, phases 1-3.
The root model replaces the old `upload` flag and group-wide `member_upload`
with per-root `writable`/`removable`/`ejected`, carried by a `RootSet` that
both front doors — the loopback API and signed MNP — reach through the same
`ops` functions. MNP goes to 1.1, additively: the roots table now rides on
`index_delta`, so a root added, removed, ejected or plugged reaches every
connected client instead of only whoever reloaded.
The group UI becomes a plugin architecture: an application is a registry
entry in `apps.js` plus its own files, with directories stored generically
by `ops.set_app_directories` under whatever the app is called. A reference
application, hidden behind `?dev=1`, is what makes that claim testable —
adding it is what found the two places still naming apps by hand.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011pvMdvLBG92jyhvD5pD6us
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/music-app-settings.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/music-app-settings.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/music-app-settings.js b/packages/meshbay-hub/src/meshbay_hub/static/music-app-settings.js new file mode 100644 index 0000000..8ce2ab6 --- /dev/null +++ b/packages/meshbay-hub/src/meshbay_hub/static/music-app-settings.js @@ -0,0 +1,60 @@ +import { html, useState, useEffect } from './vendor/htm-preact.js'; +import { t } from './i18n.js'; +import { ToggleSwitch, useSaver } from './settings-ui.js'; +import { FolderPickerField } from './folder-tree.js'; + +/** + * The Music app's operator settings. + * + * Same shape as Videos, minus a credential: MusicBrainz's read endpoints need + * no API key, only a descriptive User-Agent, and that is one operator identity + * held node-wide rather than a per-group setting (docs/musicbay.md §3.2). + * + * Several folders, for the same reason Videos has several: a music library + * that lives on two drives had no way to say so. + */ +function MusicSettings({ roots, dirs, settings, saveDirectories, transport, signFn }) { + const { busy, msg, run } = useSaver(); + const [directories, setDirectories] = useState(settings.musicDirectories || []); + const [mbEnabled, setMbEnabled] = useState(settings.musicbrainzEnabled !== false); + + useEffect(() => { + setDirectories(settings.musicDirectories || []); + }, [settings.musicDirectories]); + useEffect(() => { + setMbEnabled(settings.musicbrainzEnabled !== false); + }, [settings.musicbrainzEnabled]); + + const current = settings.musicDirectories || []; + const dirsDirty = directories.length !== current.length + || directories.some((d, i) => d !== current[i]); + + return html` + <div class="app-settings"> + <${FolderPickerField} + label=${t('settings_app.music_directories_label')} + hint=${t('settings_app.music_directories_hint')} + roots=${roots} dirs=${dirs} mode="multi" + value=${directories} disabled=${busy} + onChange=${setDirectories} /> + + <button class="app-save" disabled=${busy || !dirsDirty} + onClick=${() => run(() => saveDirectories(directories))}> + ${busy ? t('settings_app.saving') : t('settings_app.save')} + </button> + + <h4 class="app-settings-sub">${t('settings_node.musicbrainz_title')}</h4> + <p class="settings-hint">${t('settings_node.musicbrainz_hint')}</p> + <div class="settings-row"> + <${ToggleSwitch} checked=${mbEnabled} disabled=${busy} + onChange=${(v) => { setMbEnabled(v); + run(() => transport.setMusicbrainzEnabled(v, signFn)); }} + label=${mbEnabled ? t('settings_node.musicbrainz_enabled') + : t('settings_node.musicbrainz_disabled')} /> + </div> + ${msg && html`<p class="settings-hint">${msg}</p>`} + </div> + `; +} + +export { MusicSettings }; |