From 97f65b19c80d17650f3c9f7dbeec2f5e63766d3e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 31 Oct 2017 09:17:18 -0400 Subject: [PATCH] convert action buttons component to ts --- src/popup/app/app.js | 1 - ...ons.html => action-buttons.component.html} | 0 .../components/action-buttons.component.ts | 49 +++++++++++++++++++ src/popup/app/components/components.module.ts | 2 + src/popup/app/components/icon.component.ts | 3 -- 5 files changed, 51 insertions(+), 4 deletions(-) rename src/popup/app/components/{views/actionButtons.html => action-buttons.component.html} (100%) create mode 100644 src/popup/app/components/action-buttons.component.ts diff --git a/src/popup/app/app.js b/src/popup/app/app.js index 19980afa84..135236597c 100644 --- a/src/popup/app/app.js +++ b/src/popup/app/app.js @@ -59,7 +59,6 @@ require('./directives/formDirective.js'); require('./directives/stopClickDirective.js'); require('./directives/stopPropDirective.js'); require('./directives/fallbackSrcDirective.js'); -require('./components/actionButtonsComponent.js'); require('./services/backgroundService.js'); require('./services/authService.js'); require('./services/validationService.js'); diff --git a/src/popup/app/components/views/actionButtons.html b/src/popup/app/components/action-buttons.component.html similarity index 100% rename from src/popup/app/components/views/actionButtons.html rename to src/popup/app/components/action-buttons.component.html diff --git a/src/popup/app/components/action-buttons.component.ts b/src/popup/app/components/action-buttons.component.ts new file mode 100644 index 0000000000..73170f5324 --- /dev/null +++ b/src/popup/app/components/action-buttons.component.ts @@ -0,0 +1,49 @@ +import * as template from './action-buttons.component.html'; + +class ActionButtonsController implements ng.IController { + onView: Function; + + cipher: any; + showView: boolean; + i18n: any; + constants: any; + + constructor(private i18nService: any, private $analytics: any, private constantsService: any, private toastr: any, + private $timeout: any, private $window: any, private utilsService: any) { + this.i18n = i18nService; + this.constants = constantsService; + } + + launch() { + const self = this; + this.$timeout(() => { + if (self.cipher.login.uri.startsWith('http://') || self.cipher.login.uri.startsWith('https://')) { + self.$analytics.eventTrack('Launched Website From Listing'); + chrome.tabs.create({ url: self.cipher.login.uri }); + if (self.utilsService.inPopup(self.$window)) { + self.$window.close(); + } + } + }); + } + + clipboardError(e: any) { + this.toastr.info(this.i18nService.browserNotSupportClipboard); + } + + clipboardSuccess(e: any, type: string, aType: string) { + e.clearSelection(); + this.$analytics.eventTrack('Copied ' + aType); + this.toastr.info(type + this.i18nService.valueCopied); + } +} + +export const ActionButtonsComponent = { + bindings: { + cipher: '<', + showView: '<', + onView: '&', + }, + controller: ActionButtonsController, + template, +}; diff --git a/src/popup/app/components/components.module.ts b/src/popup/app/components/components.module.ts index 7ff1b44eae..a613d2bd8c 100644 --- a/src/popup/app/components/components.module.ts +++ b/src/popup/app/components/components.module.ts @@ -1,4 +1,5 @@ import * as angular from 'angular'; +import { ActionButtonsComponent } from './action-buttons.component'; import { CipherItemsComponent } from './cipher-items.component'; import { IconComponent } from './icon.component'; @@ -6,4 +7,5 @@ export default angular .module('bit.components', []) .component('cipherItems', CipherItemsComponent) .component('icon', IconComponent) + .component('actionButtons', ActionButtonsComponent) .name; diff --git a/src/popup/app/components/icon.component.ts b/src/popup/app/components/icon.component.ts index c21476065d..0e5276c5cb 100644 --- a/src/popup/app/components/icon.component.ts +++ b/src/popup/app/components/icon.component.ts @@ -1,9 +1,6 @@ import * as template from './icon.component.html'; class IconController implements ng.IController { - onSelected: Function; - onView: Function; - cipher: any; icon: string; image: string;