mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-09 14:00:03 +00:00
better new profile name handling - fixes #4325
This commit is contained in:
parent
c1a1f53707
commit
ab8061ab39
@ -46,6 +46,10 @@ export abstract class ProfileProvider<P extends Profile> {
|
|||||||
|
|
||||||
abstract getNewTabParameters (profile: PartialProfile<P>): Promise<NewTabParameters<BaseTabComponent>>
|
abstract getNewTabParameters (profile: PartialProfile<P>): Promise<NewTabParameters<BaseTabComponent>>
|
||||||
|
|
||||||
|
getSuggestedName (profile: PartialProfile<P>): string|null {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
abstract getDescription (profile: PartialProfile<P>): string
|
abstract getDescription (profile: PartialProfile<P>): string
|
||||||
|
|
||||||
quickConnect (query: string): PartialProfile<P>|null {
|
quickConnect (query: string): PartialProfile<P>|null {
|
||||||
|
@ -84,6 +84,10 @@ export class LocalProfilesService extends ProfileProvider<LocalProfile> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSuggestedName (profile: LocalProfile): string {
|
||||||
|
return this.getDescription(profile)
|
||||||
|
}
|
||||||
|
|
||||||
getDescription (profile: PartialProfile<LocalProfile>): string {
|
getDescription (profile: PartialProfile<LocalProfile>): string {
|
||||||
return profile.options?.command ?? ''
|
return profile.options?.command ?? ''
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import { SerialProfileSettingsComponent } from './components/serialProfileSettin
|
|||||||
import { SerialTabComponent } from './components/serialTab.component'
|
import { SerialTabComponent } from './components/serialTab.component'
|
||||||
import { SerialService } from './services/serial.service'
|
import { SerialService } from './services/serial.service'
|
||||||
import { BAUD_RATES, SerialProfile } from './api'
|
import { BAUD_RATES, SerialProfile } from './api'
|
||||||
|
import { profileEnd } from 'console'
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class SerialProfilesService extends ProfileProvider<SerialProfile> {
|
export class SerialProfilesService extends ProfileProvider<SerialProfile> {
|
||||||
@ -92,6 +93,10 @@ export class SerialProfilesService extends ProfileProvider<SerialProfile> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSuggestedName (profile: SerialProfile): string {
|
||||||
|
return this.getDescription(profile)
|
||||||
|
}
|
||||||
|
|
||||||
getDescription (profile: SerialProfile): string {
|
getDescription (profile: SerialProfile): string {
|
||||||
return profile.options.port
|
return profile.options.port
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,20 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
|||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const profile = deepClone(base)
|
const profile: PartialProfile<Profile> = deepClone(base)
|
||||||
profile.id = null
|
delete profile.id
|
||||||
profile.name = `${profile.name} copy`
|
if (base.isTemplate) {
|
||||||
|
profile.name = ''
|
||||||
|
} else if (!base.isBuiltin) {
|
||||||
|
profile.name = `${base.name} copy`
|
||||||
|
}
|
||||||
profile.isBuiltin = false
|
profile.isBuiltin = false
|
||||||
profile.isTemplate = false
|
profile.isTemplate = false
|
||||||
await this.editProfile(profile)
|
await this.editProfile(profile)
|
||||||
|
if (!profile.name) {
|
||||||
|
const cfgProxy = this.profilesService.getConfigProxyForProfile(profile)
|
||||||
|
profile.name = this.profilesService.providerForProfile(profile)?.getSuggestedName(cfgProxy) ?? `${base.name} copy`
|
||||||
|
}
|
||||||
profile.id = `${profile.type}:custom:${slugify(profile.name)}:${uuidv4()}`
|
profile.id = `${profile.type}:custom:${slugify(profile.name)}:${uuidv4()}`
|
||||||
this.config.store.profiles = [profile, ...this.config.store.profiles]
|
this.config.store.profiles = [profile, ...this.config.store.profiles]
|
||||||
await this.config.save()
|
await this.config.save()
|
||||||
|
@ -81,6 +81,10 @@ export class SSHProfilesService extends ProfileProvider<SSHProfile> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSuggestedName (profile: SSHProfile): string {
|
||||||
|
return `${profile.options.user}@${profile.options.host}:${profile.options.port}`
|
||||||
|
}
|
||||||
|
|
||||||
getDescription (profile: PartialProfile<SSHProfile>): string {
|
getDescription (profile: PartialProfile<SSHProfile>): string {
|
||||||
return profile.options?.host ?? ''
|
return profile.options?.host ?? ''
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,10 @@ export class TelnetProfilesService extends ProfileProvider<TelnetProfile> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSuggestedName (profile: TelnetProfile): string|null {
|
||||||
|
return this.getDescription(profile) || null
|
||||||
|
}
|
||||||
|
|
||||||
getDescription (profile: TelnetProfile): string {
|
getDescription (profile: TelnetProfile): string {
|
||||||
return profile.options.host ? `${profile.options.host}:${profile.options.port}` : ''
|
return profile.options.host ? `${profile.options.host}:${profile.options.port}` : ''
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user