Skip to content

Commit

Permalink
Add Pin Button for SFTP Panel
Browse files Browse the repository at this point in the history
  • Loading branch information
GeminiLn committed Jul 13, 2024
1 parent acedcdd commit 4a70ed4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
5 changes: 5 additions & 0 deletions tabby-ssh/src/components/sftpPanel.component.pug
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
button.btn.btn-link.btn-sm.flex-shrink-0.d-flex((click)='upload()')
i.fas.fa-upload.me-1
div(translate) Upload

button.btn.btn-link.btn-sm.flex-shrink-0.d-flex((click)='togglePinSFTPPanel()')
i.fas.fa-thumbtack
span(*ngIf='pinSFTPPanel', translate) Unpin
span(*ngIf='!pinSFTPPanel', translate) Pin

button.btn.btn-link.text-decoration-none((click)='close()') !{require('../../../tabby-core/src/icons/times.svg')}

Expand Down
9 changes: 8 additions & 1 deletion tabby-ssh/src/components/sftpPanel.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as C from 'constants'
import { posix as path } from 'path'
import { Component, Input, Output, EventEmitter, Inject, Optional } from '@angular/core'
import { Component, Input, Output, EventEmitter, Inject, Optional, HostBinding } from '@angular/core'
import { FileUpload, MenuItemOptions, NotificationsService, PlatformService } from 'tabby-core'
import { SFTPSession, SFTPFile } from '../session/sftp'
import { SSHSession } from '../session/ssh'
Expand Down Expand Up @@ -28,6 +28,8 @@ export class SFTPPanelComponent {
pathSegments: PathSegment[] = []
@Input() cwdDetectionAvailable = false
editingPath: string|null = null
@HostBinding('class.pinned') pinSFTPPanel = false
@Output() pinStateChange = new EventEmitter<boolean>()

constructor (
private ngbModal: NgbModal,
Expand Down Expand Up @@ -246,6 +248,11 @@ export class SFTPPanelComponent {
this.editingPath = null
}

togglePinSFTPPanel() {

Check failure on line 251 in tabby-ssh/src/components/sftpPanel.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Missing return type on function

Check failure on line 251 in tabby-ssh/src/components/sftpPanel.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Missing space before function parentheses
this.pinSFTPPanel = !this.pinSFTPPanel;

Check failure on line 252 in tabby-ssh/src/components/sftpPanel.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Extra semicolon
this.pinStateChange.emit(this.pinSFTPPanel);

Check failure on line 253 in tabby-ssh/src/components/sftpPanel.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Extra semicolon
}

close (): void {
this.closed.emit()
}
Expand Down
26 changes: 23 additions & 3 deletions tabby-ssh/src/components/sshTab.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
import colors from 'ansi-colors'
import { Component, Injector, HostListener } from '@angular/core'
import { Component, Injector, HostListener, ViewChild } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { Platform, ProfilesService } from 'tabby-core'
import { BaseTerminalTabComponent, ConnectableTerminalTabComponent } from 'tabby-terminal'
Expand All @@ -10,6 +10,7 @@ import { SSHPortForwardingModalComponent } from './sshPortForwardingModal.compon
import { SSHProfile } from '../api'
import { SSHShellSession } from '../session/shell'
import { SSHMultiplexerService } from '../services/sshMultiplexer.service'
import { SFTPPanelComponent } from './sftpPanel.component'

/** @hidden */
@Component({
Expand All @@ -26,9 +27,11 @@ export class SSHTabComponent extends ConnectableTerminalTabComponent<SSHProfile>
sshSession: SSHSession|null = null
session: SSHShellSession|null = null
sftpPanelVisible = false
isSftpPanelPinned = false;

Check failure on line 30 in tabby-ssh/src/components/sshTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Extra semicolon
sftpPath = '/'
enableToolbar = true
activeKIPrompt: KeyboardInteractivePrompt|null = null
@ViewChild(SFTPPanelComponent, { static: false }) sftpPanel: SFTPPanelComponent;

Check warning on line 34 in tabby-ssh/src/components/sshTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Unquoted reserved word 'static' used as key

Check failure on line 34 in tabby-ssh/src/components/sshTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Extra semicolon

constructor (
injector: Injector,
Expand Down Expand Up @@ -220,9 +223,26 @@ export class SSHTabComponent extends ConnectableTerminalTabComponent<SSHProfile>
}, 100)
}

ngAfterViewChecked() {

Check failure on line 226 in tabby-ssh/src/components/sshTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Missing return type on function

Check failure on line 226 in tabby-ssh/src/components/sshTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Missing space before function parentheses
if (this.sftpPanel && !this.sftpPanel.pinStateChange.observers.length) {

Check failure on line 227 in tabby-ssh/src/components/sshTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Unnecessary conditional, value is always truthy
this.subscribeToPinState();
}
}

subscribeToPinState() {
this.sftpPanel.pinStateChange.subscribe((isPinned: boolean) => {
this.isSftpPanelPinned = isPinned;
});
this.sftpPanel.closed.subscribe(() => {
this.isSftpPanelPinned = false;
});
}

@HostListener('click')
onClick (): void {
this.sftpPanelVisible = false
onClick(): void {
if (!this.isSftpPanelPinned) {
this.sftpPanelVisible = false;
}
}

protected isSessionExplicitlyTerminated (): boolean {
Expand Down

0 comments on commit 4a70ed4

Please sign in to comment.