|
|
@@ -1,10 +1,19 @@
|
|
|
import * as yaml from 'js-yaml'
|
|
|
-import * as path from 'path'
|
|
|
-import * as fs from 'mz/fs'
|
|
|
-import { exec } from 'mz/child_process'
|
|
|
import { Subscription } from 'rxjs'
|
|
|
import { Component, Inject, Input } from '@angular/core'
|
|
|
-import { ElectronService, DockingService, ConfigService, IHotkeyDescription, HotkeyProvider, BaseTabComponent, Theme, HostAppService, Platform, HomeBaseService } from 'terminus-core'
|
|
|
+import {
|
|
|
+ ElectronService,
|
|
|
+ DockingService,
|
|
|
+ ConfigService,
|
|
|
+ IHotkeyDescription,
|
|
|
+ HotkeyProvider,
|
|
|
+ BaseTabComponent,
|
|
|
+ Theme,
|
|
|
+ HostAppService,
|
|
|
+ Platform,
|
|
|
+ HomeBaseService,
|
|
|
+ ShellIntegrationService
|
|
|
+} from 'terminus-core'
|
|
|
|
|
|
import { SettingsTabProvider } from '../api'
|
|
|
|
|
|
@@ -24,11 +33,8 @@ export class SettingsTabComponent extends BaseTabComponent {
|
|
|
Platform = Platform
|
|
|
configDefaults: any
|
|
|
configFile: string
|
|
|
- automatorWorkflowsInstalled = false
|
|
|
+ isShellIntegrationInstalled = false
|
|
|
private configSubscription: Subscription
|
|
|
- private automatorWorkflows = ['Open Terminus here.workflow', 'Paste path into Terminus.workflow']
|
|
|
- private automatorWorkflowsLocation: string
|
|
|
- private automatorWorkflowsDestination: string
|
|
|
|
|
|
constructor (
|
|
|
public config: ConfigService,
|
|
|
@@ -36,6 +42,7 @@ export class SettingsTabComponent extends BaseTabComponent {
|
|
|
public docking: DockingService,
|
|
|
public hostApp: HostAppService,
|
|
|
public homeBase: HomeBaseService,
|
|
|
+ public shellIntegration: ShellIntegrationService,
|
|
|
@Inject(HotkeyProvider) hotkeyProviders: HotkeyProvider[],
|
|
|
@Inject(SettingsTabProvider) public settingsProviders: SettingsTabProvider[],
|
|
|
@Inject(Theme) public themes: Theme[],
|
|
|
@@ -52,19 +59,10 @@ export class SettingsTabComponent extends BaseTabComponent {
|
|
|
this.configSubscription = config.changed$.subscribe(() => {
|
|
|
this.configFile = config.readRaw()
|
|
|
})
|
|
|
-
|
|
|
- this.automatorWorkflowsLocation = path.join(
|
|
|
- path.dirname(path.dirname(this.electron.app.getPath('exe'))),
|
|
|
- 'Resources',
|
|
|
- 'extras',
|
|
|
- 'automator-workflows',
|
|
|
- )
|
|
|
-
|
|
|
- this.automatorWorkflowsDestination = path.join(process.env.HOME, 'Library', 'Services')
|
|
|
}
|
|
|
|
|
|
async ngOnInit () {
|
|
|
- this.automatorWorkflowsInstalled = await fs.exists(path.join(this.automatorWorkflowsDestination, this.automatorWorkflows[0]))
|
|
|
+ this.isShellIntegrationInstalled = await this.shellIntegration.isInstalled()
|
|
|
}
|
|
|
|
|
|
getRecoveryToken (): any {
|
|
|
@@ -96,10 +94,8 @@ export class SettingsTabComponent extends BaseTabComponent {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async installAutomatorWorkflows () {
|
|
|
- for (let wf of this.automatorWorkflows) {
|
|
|
- await exec(`cp -r "${this.automatorWorkflowsLocation}/${wf}" "${this.automatorWorkflowsDestination}"`)
|
|
|
- }
|
|
|
- this.automatorWorkflowsInstalled = true
|
|
|
+ async installShellIntegration () {
|
|
|
+ await this.shellIntegration.install()
|
|
|
+ this.isShellIntegrationInstalled = true
|
|
|
}
|
|
|
}
|