Skip to content

Commit

Permalink
feat: optional menu entry to config panel in sidebar
Browse files Browse the repository at this point in the history
(resolves #174)
  • Loading branch information
mbnuqw committed Mar 5, 2024
1 parent 309ca95 commit 470656c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/_locales/dict.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,13 @@ export const commonTranslations: Translations = {
zh_CN: '配置面板\nAlt: 基本面板配置',
zh_TW: '設定面板\nAlt: 基本面板設定',
},
'menu.common.conf_in_sidebar': {
en: 'Configure panel in sidebar',
ru: 'Быстрые настройки панели',
de: 'Panel in der Seitenleiste konfigurieren',
zh_CN: '在侧边栏中配置面板',
zh_TW: '在側邊欄中配置面板',
},
'menu.panels.unload': {
en: 'Unload',
ru: 'Выгрузить',
Expand Down
2 changes: 2 additions & 0 deletions src/page.setup/components/menu-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ const TABS_PANEL_MENU_OPTS: Record<string, string> = {
collapseInactiveBranches: 'menu.tabs_panel.collapse_inact_branches',
closeTabs: 'menu.tabs_panel.close',
openPanelConfig: 'menu.common.conf',
openPanelConfigInSidebar: 'menu.common.conf_in_sidebar',
hidePanel: 'menu.panels.hide_panel',
removePanel: 'menu.tabs_panel.remove_panel',
bookmarkTabsPanel: 'menu.tabs_panel.bookmark',
Expand Down Expand Up @@ -255,6 +256,7 @@ const BOOKMARKS_PANEL_MENU_OPTS: Record<string, string> = {
switchViewMode: 'menu.bookmark.switch_view',
unloadPanelType: 'menu.panels.unload',
openPanelConfig: 'menu.common.conf',
openPanelConfigInSidebar: 'menu.common.conf_in_sidebar',
convertToTabsPanel: 'menu.bookmark.convert_to_tabs_panel',
hidePanel: 'menu.panels.hide_panel',
removePanel: 'menu.tabs_panel.remove_panel',
Expand Down
17 changes: 17 additions & 0 deletions src/services/menu.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ export const menuOptions: Record<string, () => MenuOption | MenuOption[] | undef
return option
},

openPanelConfigInSidebar: () => {
const panel = Sidebar.panelsById[Selection.getFirst()]
if (!panel) return

const inSidebar = Utils.isTabsPanel(panel) || Utils.isBookmarksPanel(panel)
const option: MenuOption = {
label: translate('menu.common.conf_in_sidebar'),
icon: 'icon_panel_config',
onClick: () => {
if (inSidebar) Popups.openPanelPopup({ id: panel.id })
else SetupPage.open(`settings_nav.${panel.id}`)
},
}
if (!Settings.state.ctxMenuRenderInact && option.inactive) return
return option
},

unloadPanelType: () => {
const panel = Sidebar.panelsById[Selection.getFirst()]
if (!panel) return
Expand Down

0 comments on commit 470656c

Please sign in to comment.