mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-03 06:11:57 +08: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>>
|
||||
|
||||
getSuggestedName (profile: PartialProfile<P>): string|null {
|
||||
return null
|
||||
}
|
||||
|
||||
abstract getDescription (profile: PartialProfile<P>): string
|
||||
|
||||
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 {
|
||||
return profile.options?.command ?? ''
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import { SerialProfileSettingsComponent } from './components/serialProfileSettin
|
||||
import { SerialTabComponent } from './components/serialTab.component'
|
||||
import { SerialService } from './services/serial.service'
|
||||
import { BAUD_RATES, SerialProfile } from './api'
|
||||
import { profileEnd } from 'console'
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
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 {
|
||||
return profile.options.port
|
||||
}
|
||||
|
@ -63,12 +63,20 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
||||
})),
|
||||
)
|
||||
}
|
||||
const profile = deepClone(base)
|
||||
profile.id = null
|
||||
profile.name = `${profile.name} copy`
|
||||
const profile: PartialProfile<Profile> = deepClone(base)
|
||||
delete profile.id
|
||||
if (base.isTemplate) {
|
||||
profile.name = ''
|
||||
} else if (!base.isBuiltin) {
|
||||
profile.name = `${base.name} copy`
|
||||
}
|
||||
profile.isBuiltin = false
|
||||
profile.isTemplate = false
|
||||
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()}`
|
||||
this.config.store.profiles = [profile, ...this.config.store.profiles]
|
||||
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 {
|
||||
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 {
|
||||
return profile.options.host ? `${profile.options.host}:${profile.options.port}` : ''
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user