Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/services/i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@
"restartApp": "Restart massCode",
"updateAvailable": "Update Available",
"hide": "Hide",
"show": "Show"
"show": "Show",
"collapse-all": "Collapse All",
"expand-all": "Expand All"
}
4 changes: 3 additions & 1 deletion src/main/services/i18n/locales/ru/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@
"restartApp": "Перезагрузить massCode",
"updateAvailable": "Доступно обновление",
"hide": "Hide",
"show": "Show"
"show": "Show",
"collapse-all": "Закрыть все",
"expand-all": "Открыть все"
}
21 changes: 21 additions & 0 deletions src/main/services/ipc/context-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,27 @@ export const subscribeToContextMenu = () => {
}
},
{ type: 'separator' },
{
label: i18n.t('collapse-all'),
click: () => {
resolve({
action: 'collapse-all',
type,
data: undefined
})
}
},
{
label: i18n.t('expand-all'),
click: () => {
resolve({
action: 'expand-all',
type,
data: undefined
})
}
},
{ type: 'separator' },
{
label: i18n.t('defaultLanguage'),
submenu: createLanguageMenu()
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/components/sidebar/SidebarListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ const onClickContextMenu = async () => {
await folderStore.patchFoldersById(props.id!, { defaultLanguage: data })
track('folders/set-language', data)
}

if (action === 'collapse-all') {
folderStore.openFolders('close')
}

if (action === 'expand-all') {
folderStore.openFolders('open')
}
}

if (props.alias) {
Expand Down
15 changes: 15 additions & 0 deletions src/renderer/store/folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ export const useFolderStore = defineStore('folders', {
await this.getFolders()
await snippetStore.getSnippets()
snippetStore.setSnippetsByAlias('trash')
},
openFolders (action: 'open' | 'close') {
if (action === 'open') {
this.folders.forEach(async i => {
this.patchFoldersById(i.id, {
isOpen: true
})
})
} else {
this.folders.forEach(i => {
this.patchFoldersById(i.id, {
isOpen: false
})
})
}
}
}
})
2 changes: 2 additions & 0 deletions src/shared/types/main/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type ContextMenuAction =
| 'favorites'
| 'new'
| 'update:language'
| 'collapse-all'
| 'expand-all'
| 'none'

export type ContextMenuType =
Expand Down