/
sidebar.ts
48 lines (43 loc) · 1.37 KB
/
sidebar.ts
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { IModuleConfig } from '../types'
import { createSidebar } from '../../../Sidebar/SidebarElement'
import { SettingsWindow } from '/@/components/Windows/Settings/SettingsWindow'
import { Component } from 'vue'
import { SidebarContent } from '/@/components/Sidebar/Content/SidebarContent'
import { SidebarAction } from '/@/components/Sidebar/Content/SidebarAction'
import { SelectableSidebarAction } from '/@/components/Sidebar/Content/SelectableSidebarAction'
export const SidebarModule = ({ disposables, extensionId }: IModuleConfig) => ({
SidebarContent,
SidebarAction,
SelectableSidebarAction,
create(config: {
id?: string
displayName: string
component: Component
icon: string
}) {
if (!config.id) {
console.warn('SidebarModule: config.id is required')
config.id = `${extensionId}//${config.displayName}`
}
const sidebar = createSidebar(config)
if (config.id) {
SettingsWindow.loadedSettings.once((settingsState) => {
sidebar.isVisibleSetting =
(<any>settingsState)?.sidebar?.sidebarElements?.[
config.id!
] ?? true
})
}
disposables.push(sidebar)
return sidebar
},
getSelected() {
throw new Error(`This function no longer works with bridge. v2`)
},
onChange() {
throw new Error(`This function no longer works with bridge. v2`)
},
select() {
throw new Error(`This function no longer works with bridge. v2`)
},
})