fix(tabby-terminal): save icon/color/group/dynamic title/behavior on session end with 'Save As' Profile

This commit is contained in:
Clem 2023-07-07 15:03:57 +02:00
parent 4bbf86a7a7
commit 6709217a86

View File

@ -1,6 +1,6 @@
import { Injectable, Optional, Inject } from '@angular/core' import { Injectable, Optional, Inject } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { BaseTabComponent, TabContextMenuItemProvider, NotificationsService, MenuItemOptions, TranslateService, SplitTabComponent, PromptModalComponent, ConfigService, PartialProfile, Profile } from 'tabby-core' import { BaseTabComponent, TabContextMenuItemProvider, NotificationsService, MenuItemOptions, TranslateService, SplitTabComponent, PromptModalComponent, ConfigService, PartialProfile, Profile} from 'tabby-core'
import { BaseTerminalTabComponent } from './api/baseTerminalTab.component' import { BaseTerminalTabComponent } from './api/baseTerminalTab.component'
import { TerminalContextMenuItemProvider } from './api/contextMenuProvider' import { TerminalContextMenuItemProvider } from './api/contextMenuProvider'
import { MultifocusService } from './services/multifocus.service' import { MultifocusService } from './services/multifocus.service'
@ -174,27 +174,33 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider {
click: async () => { click: async () => {
const modal = this.ngbModal.open(PromptModalComponent) const modal = this.ngbModal.open(PromptModalComponent)
modal.componentInstance.prompt = this.translate.instant('New profile name') modal.componentInstance.prompt = this.translate.instant('New profile name')
modal.componentInstance.value = tab.profile.name
const name = (await modal.result)?.value const name = (await modal.result)?.value
if (!name) { if (!name) {
return return
} }
let options = {...tab.profile.options} let options = {
...tab.profile.options
}
const cwd = await tab.session?.getWorkingDirectory() ?? tab.profile.options.cwd const cwd = await tab.session?.getWorkingDirectory() ?? tab.profile.options.cwd
if (cwd) { if (cwd) {
options = { options.cwd = cwd
...options,
cwd
}
} }
const profile: PartialProfile<Profile> = { const profile: PartialProfile<Profile> = {
options,
name,
type: tab.profile.type, type: tab.profile.type,
name,
options
} }
profile.id = `${profile.type}:custom:${slugify(profile.name)}:${uuidv4()}` profile.id = `${profile.type}:custom:${slugify(name)}:${uuidv4()}`
profile.group = tab.profile.group
profile.icon = tab.profile.icon
profile.color = tab.profile.color
profile.disableDynamicTitle = tab.profile.disableDynamicTitle
profile.behaviorOnSessionEnd = tab.profile.behaviorOnSessionEnd
this.config.store.profiles = [ this.config.store.profiles = [
...this.config.store.profiles, ...this.config.store.profiles,