1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-26 13:10:36 +03:00
This commit is contained in:
Eugene Pankov 2021-07-27 20:27:19 +02:00
parent 85fe9eb4ec
commit c853c96ae9
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
6 changed files with 23 additions and 18 deletions

View File

@ -23,7 +23,7 @@ title-bar(
*ngFor='let tab of app.tabs; let idx = index', *ngFor='let tab of app.tabs; let idx = index',
cdkDrag, cdkDrag,
[cdkDragData]='tab', [cdkDragData]='tab',
(cdkDragStarted)='onTabDragStart()', (cdkDragStarted)='onTabDragStart(tab)',
(cdkDragEnded)='onTabDragEnd()', (cdkDragEnded)='onTabDragEnd()',
[index]='idx', [index]='idx',
[tab]='tab', [tab]='tab',

View File

@ -182,8 +182,8 @@ export class AppRootComponent {
return this.config.store.appearance.tabsLocation === 'left' || this.config.store.appearance.tabsLocation === 'right' return this.config.store.appearance.tabsLocation === 'left' || this.config.store.appearance.tabsLocation === 'right'
} }
onTabDragStart () { onTabDragStart (tab: BaseTabComponent) {
this.app.emitTabDragStarted() this.app.emitTabDragStarted(tab)
} }
onTabDragEnd () { onTabDragEnd () {

View File

@ -56,7 +56,7 @@ export class AppService {
private tabOpened = new Subject<BaseTabComponent>() private tabOpened = new Subject<BaseTabComponent>()
private tabRemoved = new Subject<BaseTabComponent>() private tabRemoved = new Subject<BaseTabComponent>()
private tabClosed = new Subject<BaseTabComponent>() private tabClosed = new Subject<BaseTabComponent>()
private tabDragActive = new Subject<boolean>() private tabDragActive = new Subject<BaseTabComponent|null>()
private ready = new AsyncSubject<void>() private ready = new AsyncSubject<void>()
private completionObservers = new Map<BaseTabComponent, CompletionObserver>() private completionObservers = new Map<BaseTabComponent, CompletionObserver>()
@ -66,7 +66,7 @@ export class AppService {
get tabsChanged$ (): Observable<void> { return this.tabsChanged } get tabsChanged$ (): Observable<void> { return this.tabsChanged }
get tabRemoved$ (): Observable<BaseTabComponent> { return this.tabRemoved } get tabRemoved$ (): Observable<BaseTabComponent> { return this.tabRemoved }
get tabClosed$ (): Observable<BaseTabComponent> { return this.tabClosed } get tabClosed$ (): Observable<BaseTabComponent> { return this.tabClosed }
get tabDragActive$ (): Observable<boolean> { return this.tabDragActive } get tabDragActive$ (): Observable<BaseTabComponent|null> { return this.tabDragActive }
/** Fires once when the app is ready */ /** Fires once when the app is ready */
get ready$ (): Observable<void> { return this.ready } get ready$ (): Observable<void> { return this.ready }
@ -358,13 +358,13 @@ export class AppService {
} }
/** @hidden */ /** @hidden */
emitTabDragStarted (): void { emitTabDragStarted (tab: BaseTabComponent): void {
this.tabDragActive.next(true) this.tabDragActive.next(tab)
} }
/** @hidden */ /** @hidden */
emitTabDragEnded (): void { emitTabDragEnded (): void {
this.tabDragActive.next(false) this.tabDragActive.next(null)
} }
/** /**

View File

@ -26,7 +26,7 @@ interface StoredVault {
export interface VaultSecret { export interface VaultSecret {
type: string type: string
key: Record<string, any> key: VaultSecretKey
value: string value: string
} }
@ -42,6 +42,9 @@ export interface Vault {
secrets: VaultSecret[] secrets: VaultSecret[]
} }
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface VaultSecretKey { }
function migrateVaultContent (content: any): Vault { function migrateVaultContent (content: any): Vault {
return { return {
config: content.config, config: content.config,
@ -184,7 +187,7 @@ export class VaultService {
return _rememberedPassphrase! return _rememberedPassphrase!
} }
async getSecret (type: string, key: Record<string, any>): Promise<VaultSecret|null> { async getSecret (type: string, key: VaultSecretKey): Promise<VaultSecret|null> {
await this.ready$.toPromise() await this.ready$.toPromise()
const vault = await this.load() const vault = await this.load()
if (!vault) { if (!vault) {
@ -218,7 +221,7 @@ export class VaultService {
await this.save(vault) await this.save(vault)
} }
async removeSecret (type: string, key: Record<string, any>): Promise<void> { async removeSecret (type: string, key: VaultSecretKey): Promise<void> {
await this.ready$.toPromise() await this.ready$.toPromise()
const vault = await this.load() const vault = await this.load()
if (!vault) { if (!vault) {
@ -228,7 +231,7 @@ export class VaultService {
await this.save(vault) await this.save(vault)
} }
private keyMatches (key: Record<string, any>, secret: VaultSecret): boolean { private keyMatches (key: VaultSecretKey, secret: VaultSecret): boolean {
return Object.keys(key).every(k => secret.key[k] === key[k]) return Object.keys(key).every(k => secret.key[k] === key[k])
} }
@ -267,9 +270,9 @@ export class VaultFileProvider extends FileProvider {
if (!vault) { if (!vault) {
throw new Error('Vault is locked') throw new Error('Vault is locked')
} }
const files = vault.secrets.filter(x => x.type === VAULT_SECRET_TYPE_FILE) const files = vault.secrets.filter(x => x.type === VAULT_SECRET_TYPE_FILE) as VaultFileSecret[]
if (files.length) { if (files.length) {
const result = await this.selector.show<VaultSecret|null>('Select file', [ const result = await this.selector.show<VaultFileSecret|null>('Select file', [
{ {
name: 'Add a new file', name: 'Add a new file',
icon: 'fas fa-plus', icon: 'fas fa-plus',

View File

@ -23,7 +23,7 @@ export class TerminalService {
if (!profile) { if (!profile) {
profile = profiles.filter(x => x.type === 'local' && x.isBuiltin)[0] profile = profiles.filter(x => x.type === 'local' && x.isBuiltin)[0]
} }
return profile as PartialProfile<LocalProfile> return profile
} }
/** /**

View File

@ -74,13 +74,14 @@ export class VaultSettingsTabComponent extends BaseComponent {
getSecretLabel (secret: VaultSecret) { getSecretLabel (secret: VaultSecret) {
if (secret.type === 'ssh:password') { if (secret.type === 'ssh:password') {
return `SSH password for ${secret.key.user}@${secret.key.host}:${secret.key.port}` return `SSH password for ${(secret as any).key.user}@${(secret as any).key.host}:${(secret as any).key.port}`
} }
if (secret.type === 'ssh:key-passphrase') { if (secret.type === 'ssh:key-passphrase') {
return `Passphrase for a private key with hash ${secret.key.hash.substring(0, 8)}...` return `Passphrase for a private key with hash ${(secret as any).key.hash.substring(0, 8)}...`
} }
if (secret.type === VAULT_SECRET_TYPE_FILE) { if (secret.type === VAULT_SECRET_TYPE_FILE) {
return `File: ${secret.key.description}` // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
return `File: ${(secret as VaultFileSecret).key.description}`
} }
return `Unknown secret of type ${secret.type} for ${JSON.stringify(secret.key)}` return `Unknown secret of type ${secret.type} for ${JSON.stringify(secret.key)}`
} }
@ -129,6 +130,7 @@ export class VaultSettingsTabComponent extends BaseComponent {
async exportFile (secret: VaultFileSecret) { async exportFile (secret: VaultFileSecret) {
this.vault.forgetPassphrase() this.vault.forgetPassphrase()
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
secret = (await this.vault.getSecret(secret.type, secret.key)) as VaultFileSecret secret = (await this.vault.getSecret(secret.type, secret.key)) as VaultFileSecret
const content = Buffer.from(secret.value, 'base64') const content = Buffer.from(secret.value, 'base64')