aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static/apps.js
blob: 0db713c6d5d7efaba0a127774284712752905364 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { ChatPanel } from './chat-app.js';
import { FilesPanel } from './files-app.js';

/**
 * Every group "application", in tab order.
 *
 * Adding one (Videos, Music, Photos — none of them need an MNP change, see
 * the node's indexer classifying video/audio/image already) means a new file
 * exporting a component and one entry here. Nothing in group-page.js changes:
 * every registered component receives the same shared context (see its
 * `commonProps`) and renders itself into the active tab.
 *
 * `key` doubles as the identifier the node's `apps_enabled` setting uses, so
 * it must match `ALLOWED_APPS` in the node's webrtc_server.py.
 */
const APPS = [
  { key: 'chat', icon: 'chat', labelKey: 'group.tab_chat', Component: ChatPanel },
  { key: 'files', icon: 'folder', labelKey: 'group.tab_files', Component: FilesPanel },
];

/** The registry filtered to what this group has enabled, in registry order. */
function visibleApps(enabledKeys) {
  const enabled = new Set(
    enabledKeys && enabledKeys.length ? enabledKeys : APPS.map(a => a.key));
  return APPS.filter(a => enabled.has(a.key));
}

export { APPS, visibleApps };