added TSLint for TypeScript code style checking, fixed associated errors

This commit is contained in:
alecmerdler 2017-06-19 23:17:42 -07:00
parent 6a7722cadb
commit 41e7e559a6
43 changed files with 253 additions and 730 deletions

View file

@ -9,7 +9,8 @@
"test:node": "JASMINE_CONFIG_PATH=static/test/jasmine.json ./node_modules/.bin/jasmine-ts './static/js/**/*.spec.ts'", "test:node": "JASMINE_CONFIG_PATH=static/test/jasmine.json ./node_modules/.bin/jasmine-ts './static/js/**/*.spec.ts'",
"e2e": "./node_modules/.bin/ts-node ./node_modules/.bin/protractor static/test/protractor.conf.ts", "e2e": "./node_modules/.bin/ts-node ./node_modules/.bin/protractor static/test/protractor.conf.ts",
"build": "NODE_ENV=production ./node_modules/.bin/webpack --progress", "build": "NODE_ENV=production ./node_modules/.bin/webpack --progress",
"watch": "./node_modules/.bin/webpack --watch" "watch": "./node_modules/.bin/webpack --watch",
"lint": "./node_modules/.bin/tslint --type-check -p tsconfig.json -e **/*.spec.ts"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -54,7 +55,6 @@
"@types/react-dom": "0.14.17", "@types/react-dom": "0.14.17",
"@types/showdown": "^1.4.32", "@types/showdown": "^1.4.32",
"angular-mocks": "1.6.2", "angular-mocks": "1.6.2",
"angular-ts-decorators": "0.0.19",
"css-loader": "0.25.0", "css-loader": "0.25.0",
"html-loader": "^0.4.5", "html-loader": "^0.4.5",
"jasmine-core": "^2.5.2", "jasmine-core": "^2.5.2",
@ -73,8 +73,8 @@
"ts-loader": "^0.9.5", "ts-loader": "^0.9.5",
"ts-mocks": "^0.2.2", "ts-mocks": "^0.2.2",
"ts-node": "^3.0.6", "ts-node": "^3.0.6",
"tslint": "^5.4.3",
"typescript": "^2.2.1", "typescript": "^2.2.1",
"typings": "1.4.0",
"webpack": "^2.2" "webpack": "^2.2"
} }
} }

View file

@ -7,5 +7,5 @@ export function Inject(value: string) {
return (target: any, propertyKey: string | symbol, parameterIndex: number): void => { return (target: any, propertyKey: string | symbol, parameterIndex: number): void => {
target.$inject = target.$inject = []; target.$inject = target.$inject = [];
target.$inject[parameterIndex] = value; target.$inject[parameterIndex] = value;
} };
} }

View file

@ -38,4 +38,4 @@ export class QuayRequireDirective implements AfterContentInit {
this.$transclude this.$transclude
]); ]);
} }
} }

View file

@ -9,7 +9,9 @@ import { Input, Component, Inject } from 'ng-metadata/core';
templateUrl: '/static/js/directives/ui/app-public-view/app-public-view.component.html' templateUrl: '/static/js/directives/ui/app-public-view/app-public-view.component.html'
}) })
export class AppPublicViewComponent { export class AppPublicViewComponent {
@Input('<') public repository: any; @Input('<') public repository: any;
private settingsShown: number = 0; private settingsShown: number = 0;
private logsShown: number = 0; private logsShown: number = 0;
@ -17,11 +19,6 @@ export class AppPublicViewComponent {
this.updateDescription = this.updateDescription.bind(this); this.updateDescription = this.updateDescription.bind(this);
} }
private updateDescription(content: string) {
this.repository.description = content;
this.repository.put();
}
public showSettings(): void { public showSettings(): void {
this.settingsShown++; this.settingsShown++;
} }
@ -29,4 +26,9 @@ export class AppPublicViewComponent {
public showLogs(): void { public showLogs(): void {
this.logsShown++; this.logsShown++;
} }
private updateDescription(content: string) {
this.repository.description = content;
this.repository.put();
}
} }

View file

@ -44,4 +44,4 @@ export class ChannelIconComponent {
var num: number = parseInt(hash.substr(0, 4)); var num: number = parseInt(hash.substr(0, 4));
return this.colors[num % this.colors.length]; return this.colors[num % this.colors.length];
} }
} }

View file

@ -60,4 +60,4 @@ export class ClipboardCopyDirective implements AfterContentInit, OnDestroy {
this.clipboard.destroy(); this.clipboard.destroy();
} }
} }
} }

View file

@ -1,4 +1,4 @@
import { NgModule } from 'ng-metadata/core' import { NgModule } from 'ng-metadata/core';
import { CorTabsComponent } from './cor-tabs.component'; import { CorTabsComponent } from './cor-tabs.component';
import { CorTabComponent } from './cor-tab/cor-tab.component'; import { CorTabComponent } from './cor-tab/cor-tab.component';
import { CorNavTabsDirective } from './cor-nav-tabs/cor-nav-tabs.directive'; import { CorNavTabsDirective } from './cor-nav-tabs/cor-nav-tabs.directive';

View file

@ -1,6 +1,7 @@
import { Input, Output, Component, Inject } from 'ng-metadata/core'; import { Input, Component, Inject } from 'ng-metadata/core';
import * as moment from "moment"; import * as moment from "moment";
/** /**
* A component that allows for selecting a time duration. * A component that allows for selecting a time duration.
*/ */
@ -9,6 +10,7 @@ import * as moment from "moment";
templateUrl: '/static/js/directives/ui/duration-input/duration-input.component.html' templateUrl: '/static/js/directives/ui/duration-input/duration-input.component.html'
}) })
export class DurationInputComponent implements ng.IComponentController { export class DurationInputComponent implements ng.IComponentController {
@Input('<') public min: string; @Input('<') public min: string;
@Input('<') public max: string; @Input('<') public max: string;
@Input('=?') public value: string; @Input('=?') public value: string;
@ -17,7 +19,7 @@ export class DurationInputComponent implements ng.IComponentController {
private min_s: number; private min_s: number;
private max_s: number; private max_s: number;
constructor (@Inject('$scope') private $scope: ng.IScope) { constructor(@Inject('$scope') private $scope: ng.IScope) {
} }
@ -33,7 +35,7 @@ export class DurationInputComponent implements ng.IComponentController {
} }
private updateValue(): void { private updateValue(): void {
this.value = this.seconds + 's'; this.value = `${this.seconds}s`;
} }
private refresh(): void { private refresh(): void {
@ -41,8 +43,8 @@ export class DurationInputComponent implements ng.IComponentController {
this.max_s = this.toSeconds(this.max || '1h'); this.max_s = this.toSeconds(this.max || '1h');
if (this.value) { if (this.value) {
this.seconds = this.toSeconds(this.value || '0s') this.seconds = this.toSeconds(this.value || '0s');
}; }
} }
private durationExplanation(durationSeconds: string): string { private durationExplanation(durationSeconds: string): string {

View file

@ -75,4 +75,4 @@ export class LinearWorkflowComponent {
export type SectionInfo = { export type SectionInfo = {
index: number; index: number;
component: LinearWorkflowSectionComponent; component: LinearWorkflowSectionComponent;
} };

View file

@ -17,7 +17,9 @@ export class ManageTriggerComponent implements OnChanges {
@Input('<') public githost: string = 'custom-git'; @Input('<') public githost: string = 'custom-git';
@Input('<') public repository: Repository; @Input('<') public repository: Repository;
@Input('<') public trigger: Trigger; @Input('<') public trigger: Trigger;
@Output() public activateTrigger: EventEmitter<{config: TriggerConfig, pull_robot?: any}> = new EventEmitter(); @Output() public activateTrigger: EventEmitter<{config: TriggerConfig, pull_robot?: any}> = new EventEmitter();
public config: TriggerConfig; public config: TriggerConfig;
public local: Local = { public local: Local = {
selectedRepository: {name: ''}, selectedRepository: {name: ''},
@ -28,6 +30,7 @@ export class ManageTriggerComponent implements OnChanges {
repositoryOptions: {filter: '', predicate: 'score', reverse: false, page: 0, hideStale: true}, repositoryOptions: {filter: '', predicate: 'score', reverse: false, page: 0, hideStale: true},
robotOptions: {filter: '', predicate: 'score', reverse: false, page: 0}, robotOptions: {filter: '', predicate: 'score', reverse: false, page: 0},
}; };
private namespacesPerPage: number = 10; private namespacesPerPage: number = 10;
private repositoriesPerPage: number = 10; private repositoriesPerPage: number = 10;
private robotsPerPage: number = 10; private robotsPerPage: number = 10;
@ -174,7 +177,7 @@ export class ManageTriggerComponent implements OnChanges {
} }
private setPossibleContexts(path: string) { private setPossibleContexts(path: string) {
if (this.local.dockerfileLocations.contextMap){ if (this.local.dockerfileLocations.contextMap) {
this.local.contexts = this.local.dockerfileLocations.contextMap[path] || []; this.local.contexts = this.local.dockerfileLocations.contextMap[path] || [];
} else { } else {
this.local.contexts = [path.split('/').slice(0, -1).join('/').concat('/')]; this.local.contexts = [path.split('/').slice(0, -1).join('/').concat('/')];
@ -288,7 +291,7 @@ export class ManageTriggerComponent implements OnChanges {
const kind = ref.kind == 'branch' ? 'heads' : 'tags'; const kind = ref.kind == 'branch' ? 'heads' : 'tags';
const icon = ref.kind == 'branch' ? 'fa-code-fork' : 'fa-tag'; const icon = ref.kind == 'branch' ? 'fa-code-fork' : 'fa-tag';
return { return {
'value': kind + '/' + ref.name, 'value': `${kind}/${ref.name}`,
'icon': icon, 'icon': icon,
'title': ref.name 'title': ref.name
}; };

View file

@ -16,10 +16,13 @@ export class ManageTriggerViewObject {
private customGitRepoInput: ElementFinder = element(by.model('$ctrl.buildSource')); private customGitRepoInput: ElementFinder = element(by.model('$ctrl.buildSource'));
private dockerfileLocationInput: ElementFinder = this.sections['dockerfilelocation'].$('input'); private dockerfileLocationInput: ElementFinder = this.sections['dockerfilelocation'].$('input');
private dockerfileLocationDropdownButton: ElementFinder = this.sections['dockerfilelocation'].$('button[data-toggle=dropdown'); private dockerfileLocationDropdownButton: ElementFinder = this.sections['dockerfilelocation']
.$('button[data-toggle=dropdown');
private dockerContextInput: ElementFinder = this.sections['contextlocation'].$('input'); private dockerContextInput: ElementFinder = this.sections['contextlocation'].$('input');
private dockerContextDropdownButton: ElementFinder = this.sections['contextlocation'].$('button[data-toggle=dropdown'); private dockerContextDropdownButton: ElementFinder = this.sections['contextlocation']
private robotAccountOptions: ElementFinder = this.sections['robot'].element(by.repeater('$ctrl.orderedData.visibleEntries')); .$('button[data-toggle=dropdown');
private robotAccountOptions: ElementFinder = this.sections['robot']
.element(by.repeater('$ctrl.orderedData.visibleEntries'));
public continue(): Promise<void> { public continue(): Promise<void> {
return Promise.resolve(element(by.buttonText('Continue')).click()); return Promise.resolve(element(by.buttonText('Continue')).click());

View file

@ -16,8 +16,10 @@ export class MarkdownEditorComponent {
@Input('<') public content: string; @Input('<') public content: string;
@Output() public save: EventEmitter<{editedContent: string}> = new EventEmitter(); @Output() public save: EventEmitter<{editedContent: string}> = new EventEmitter();
@Output() public discard: EventEmitter<any> = new EventEmitter(); @Output() public discard: EventEmitter<any> = new EventEmitter();
// Textarea is public for testability, should not be directly accessed // Textarea is public for testability, should not be directly accessed
@ViewChild('#markdown-textarea') public textarea: ng.IAugmentedJQuery; @ViewChild('#markdown-textarea') public textarea: ng.IAugmentedJQuery;
private editMode: EditMode = "write"; private editMode: EditMode = "write";
constructor(@Inject('$document') private $document: ng.IDocumentService, constructor(@Inject('$document') private $document: ng.IDocumentService,
@ -115,9 +117,9 @@ export class MarkdownEditorComponent {
private insertText(text: string, startPos: number, endPos: number): void { private insertText(text: string, startPos: number, endPos: number): void {
if (this.browserPlatform === 'firefox') { if (this.browserPlatform === 'firefox') {
// FIXME: Ctrl-Z highlights previous text // FIXME: Ctrl-Z highlights previous text
this.textarea.val(this.textarea.val().substr(0, startPos) + this.textarea.val(<string>this.textarea.val().substr(0, startPos) +
text + text +
this.textarea.val().substr(endPos, this.textarea.val().length)); <string>this.textarea.val().substr(endPos, this.textarea.val().length));
} }
else { else {
// TODO: Test other platforms (IE...) // TODO: Test other platforms (IE...)

View file

@ -1,6 +1,7 @@
import { Input, Component, Inject } from 'ng-metadata/core'; import { Input, Component, Inject } from 'ng-metadata/core';
import { Repository } from '../../../types/common.types'; import { Repository } from '../../../types/common.types';
/** /**
* A component that displays the configuration and options for repository signing. * A component that displays the configuration and options for repository signing.
*/ */
@ -9,12 +10,13 @@ import { Repository } from '../../../types/common.types';
templateUrl: '/static/js/directives/ui/repository-signing-config/repository-signing-config.component.html', templateUrl: '/static/js/directives/ui/repository-signing-config/repository-signing-config.component.html',
}) })
export class RepositorySigningConfigComponent { export class RepositorySigningConfigComponent {
@Input('<') public repository: Repository; @Input('<') public repository: Repository;
private enableTrustInfo: {[key: string]: string} = null; private enableTrustInfo: {[key: string]: string} = null;
private disableTrustInfo: {[key: string]: string} = null; private disableTrustInfo: {[key: string]: string} = null;
constructor (@Inject("ApiService") private ApiService: any) { constructor(@Inject("ApiService") private ApiService: any) {
} }
@ -41,4 +43,4 @@ export class RepositorySigningConfigComponent {
callback(true); callback(true);
}, errorDisplay); }, errorDisplay);
} }
} }

View file

@ -43,7 +43,7 @@ export class SearchBoxComponent {
private onSelected($event): void { private onSelected($event): void {
this.autocompleteSelected = true; this.autocompleteSelected = true;
this.$timeout(() => { this.$timeout(() => {
this.$location.url($event['result']['href']) this.$location.url($event['result']['href']);
}, 100); }, 100);
} }
@ -54,4 +54,4 @@ export class SearchBoxComponent {
this.$location.search('q', $event['value']); this.$location.search('q', $event['value']);
}, 10); }, 10);
} }
} }

View file

@ -2,6 +2,7 @@ import { Input, Component, Inject } from 'ng-metadata/core';
import { ApostilleDelegationsSet, ApostilleSignatureDocument, ApostilleTagDocument } from '../../../types/common.types'; import { ApostilleDelegationsSet, ApostilleSignatureDocument, ApostilleTagDocument } from '../../../types/common.types';
import * as moment from "moment"; import * as moment from "moment";
type TagSigningInfo = { type TagSigningInfo = {
delegations: DelegationInfo[]; delegations: DelegationInfo[];
delegationsByName: {[delegationName: string]: DelegationInfo}; delegationsByName: {[delegationName: string]: DelegationInfo};
@ -9,7 +10,8 @@ type TagSigningInfo = {
hasExpiringSoon: boolean; hasExpiringSoon: boolean;
hasExpired: boolean; hasExpired: boolean;
hasInvalid: boolean; hasInvalid: boolean;
} };
type DelegationInfo = { type DelegationInfo = {
delegationName: string; delegationName: string;
@ -20,7 +22,9 @@ type DelegationInfo = {
isExpiringSoon: boolean isExpiringSoon: boolean
}; };
var RELEASES = ['targets/releases', 'targets'];
const RELEASES = ['targets/releases', 'targets'];
/** /**
* A component that displays the signing status of a tag in the repository view. * A component that displays the signing status of a tag in the repository view.
@ -30,13 +34,16 @@ var RELEASES = ['targets/releases', 'targets'];
templateUrl: '/static/js/directives/ui/tag-signing-display/tag-signing-display.component.html', templateUrl: '/static/js/directives/ui/tag-signing-display/tag-signing-display.component.html',
}) })
export class TagSigningDisplayComponent { export class TagSigningDisplayComponent {
@Input('<') public compact: boolean; @Input('<') public compact: boolean;
@Input('<') public tag: any; @Input('<') public tag: any;
@Input('<') public delegations: ApostilleDelegationsSet; @Input('<') public delegations: ApostilleDelegationsSet;
private cachedSigningInfo: TagSigningInfo | null = null; private cachedSigningInfo: TagSigningInfo | null = null;
constructor(@Inject("$sanitize") private $sanitize: ng.sanitize.ISanitizeService) {} constructor(@Inject("$sanitize") private $sanitize: ng.sanitize.ISanitizeService) {
}
private base64ToHex(base64String: string): string { private base64ToHex(base64String: string): string {
// Based on: http://stackoverflow.com/questions/39460182/decode-base64-to-hexadecimal-string-with-javascript // Based on: http://stackoverflow.com/questions/39460182/decode-base64-to-hexadecimal-string-with-javascript
@ -49,13 +56,15 @@ export class TagSigningDisplayComponent {
var hexString = ''; var hexString = '';
for (var i = 0; i < raw.length; ++i) { for (var i = 0; i < raw.length; ++i) {
var char = raw.charCodeAt(i); var char = raw.charCodeAt(i);
var hex = char.toString(16) var hex = char.toString(16);
hexString += (hex.length == 2 ? hex : '0' + hex); hexString += (hex.length == 2 ? hex : '0' + hex);
} }
return hexString; return hexString;
} }
private buildDelegationInfo(tag: any, delegationName: string, delegation: ApostilleSignatureDocument): DelegationInfo { private buildDelegationInfo(tag: any,
delegationName: string,
delegation: ApostilleSignatureDocument): DelegationInfo {
var digest_without_prefix = tag.manifest_digest.substr('sha256:'.length); var digest_without_prefix = tag.manifest_digest.substr('sha256:'.length);
var hex_signature = this.base64ToHex(delegation.targets[tag.name].hashes['sha256']); var hex_signature = this.base64ToHex(delegation.targets[tag.name].hashes['sha256']);
@ -70,7 +79,7 @@ export class TagSigningDisplayComponent {
'delegationHash': hex_signature, 'delegationHash': hex_signature,
'isExpired': expires.isSameOrBefore(now), 'isExpired': expires.isSameOrBefore(now),
'isExpiringSoon': !expires.isSameOrBefore(now) && expires.isSameOrBefore(withOneWeek), 'isExpiringSoon': !expires.isSameOrBefore(now) && expires.isSameOrBefore(withOneWeek),
} };
} }
private buildTagSigningInfo(tag: any, delegationSet: ApostilleDelegationsSet): TagSigningInfo { private buildTagSigningInfo(tag: any, delegationSet: ApostilleDelegationsSet): TagSigningInfo {
@ -80,13 +89,13 @@ export class TagSigningDisplayComponent {
'hasExpired': false, 'hasExpired': false,
'hasExpiringSoon': false, 'hasExpiringSoon': false,
'hasInvalid': false, 'hasInvalid': false,
} };
// Find all delegations containing the tag as a target. // Find all delegations containing the tag as a target.
Object.keys(delegationSet.delegations).forEach((delegationName) => { Object.keys(delegationSet.delegations).forEach((delegationName) => {
var delegation = delegationSet.delegations[delegationName]; var delegation = delegationSet.delegations[delegationName];
if (delegation.targets[tag.name]) { if (delegation.targets[tag.name]) {
var DelegationInfo = this.buildDelegationInfo(tag, delegationName, delegation) var DelegationInfo = this.buildDelegationInfo(tag, delegationName, delegation);
info.delegations.push(DelegationInfo); info.delegations.push(DelegationInfo);
info.delegationsByName[delegationName] = DelegationInfo; info.delegationsByName[delegationName] = DelegationInfo;
@ -173,4 +182,4 @@ export class TagSigningDisplayComponent {
return 'invalid-signed'; return 'invalid-signed';
} }
} }

View file

@ -1,6 +1,7 @@
import { Input, Component, Inject } from 'ng-metadata/core'; import { Input, Component, Inject } from 'ng-metadata/core';
import * as moment from "moment"; import * as moment from "moment";
/** /**
* A component that displays settings for a namespace for time machine. * A component that displays settings for a namespace for time machine.
*/ */
@ -9,6 +10,7 @@ import * as moment from "moment";
templateUrl: '/static/js/directives/ui/time-machine-settings/time-machine-settings.component.html' templateUrl: '/static/js/directives/ui/time-machine-settings/time-machine-settings.component.html'
}) })
export class TimeMachineSettingsComponent implements ng.IComponentController { export class TimeMachineSettingsComponent implements ng.IComponentController {
@Input('<') public user: any; @Input('<') public user: any;
@Input('<') public organization: any; @Input('<') public organization: any;
@ -16,7 +18,7 @@ export class TimeMachineSettingsComponent implements ng.IComponentController {
private current_s: number; private current_s: number;
private updating: boolean; private updating: boolean;
constructor (@Inject('Config') private Config: any, @Inject('ApiService') private ApiService: any, constructor(@Inject('Config') private Config: any, @Inject('ApiService') private ApiService: any,
@Inject('Features') private Features: any) { @Inject('Features') private Features: any) {
this.current_s = 0; this.current_s = 0;
this.initial_s = 0; this.initial_s = 0;
@ -51,7 +53,7 @@ export class TimeMachineSettingsComponent implements ng.IComponentController {
this.updating = true; this.updating = true;
var errorDisplay = this.ApiService.errorDisplay('Could not update time machine setting', () => { var errorDisplay = this.ApiService.errorDisplay('Could not update time machine setting', () => {
this.updating = false; this.updating = false;
}) });
var method = (this.user ? this.ApiService.changeUserDetails : var method = (this.user ? this.ApiService.changeUserDetails :
this.ApiService.changeOrganizationDetails); this.ApiService.changeOrganizationDetails);

View file

@ -1,6 +1,7 @@
import { Input, Output, Directive, Inject, AfterContentInit, EventEmitter, HostListener } from 'ng-metadata/core'; import { Input, Output, Directive, Inject, AfterContentInit, EventEmitter, HostListener } from 'ng-metadata/core';
import * as $ from 'jquery'; import * as $ from 'jquery';
/** /**
* Directive which decorates an <input> with a typeahead autocomplete. * Directive which decorates an <input> with a typeahead autocomplete.
*/ */
@ -8,15 +9,15 @@ import * as $ from 'jquery';
selector: '[typeahead]', selector: '[typeahead]',
}) })
export class TypeaheadDirective implements AfterContentInit { export class TypeaheadDirective implements AfterContentInit {
@Output('typeahead') typeahead = new EventEmitter<any>();
@Input('taDisplayKey') displayKey: string = ''; @Input('taDisplayKey') public displayKey: string = '';
@Input('taSuggestionTmpl') suggestionTemplate: string = ''; @Input('taSuggestionTmpl') public suggestionTemplate: string = '';
@Input('taClearOnSelect') clearOnSelect: boolean = false; @Input('taClearOnSelect') public clearOnSelect: boolean = false;
@Input('taDebounce') debounce: number = 250; @Input('taDebounce') public debounce: number = 250;
@Output('taSelected') selected = new EventEmitter<any>(); @Output('typeahead') public typeahead = new EventEmitter<any>();
@Output('taEntered') entered = new EventEmitter<any>(); @Output('taSelected') public selected = new EventEmitter<any>();
@Output('taEntered') public entered = new EventEmitter<any>();
private itemSelected: boolean = false; private itemSelected: boolean = false;
private existingTimer: ng.IPromise<void> = null; private existingTimer: ng.IPromise<void> = null;
@ -28,10 +29,25 @@ export class TypeaheadDirective implements AfterContentInit {
@Inject('$timeout') private $timeout: ng.ITimeoutService) { @Inject('$timeout') private $timeout: ng.ITimeoutService) {
} }
@HostListener('keyup', ['$event'])
public onKeyup(event: JQueryKeyEventObject): void {
if (!this.itemSelected && event.keyCode == 13) {
this.entered.emit({
'value': $(this.$element).typeahead('val'),
'callback': (reset: boolean) => {
if (reset) {
this.itemSelected = false;
$(this.$element).typeahead('val', '');
}
}
});
}
}
public ngAfterContentInit(): void { public ngAfterContentInit(): void {
var templates = null; var templates = null;
if (this.suggestionTemplate) { if (this.suggestionTemplate) {
templates = {} templates = {};
if (this.suggestionTemplate) { if (this.suggestionTemplate) {
templates['suggestion'] = this.buildTemplateHandler(this.suggestionTemplate); templates['suggestion'] = this.buildTemplateHandler(this.suggestionTemplate);
@ -42,7 +58,7 @@ export class TypeaheadDirective implements AfterContentInit {
if (this.clearOnSelect) { if (this.clearOnSelect) {
$(this.$element).typeahead('val', ''); $(this.$element).typeahead('val', '');
} }
this.selected.emit({'result': suggestion}) this.selected.emit({'result': suggestion});
this.itemSelected = true; this.itemSelected = true;
}); });
@ -72,21 +88,6 @@ export class TypeaheadDirective implements AfterContentInit {
}, this.debounce); }, this.debounce);
} }
@HostListener('keyup', ['$event'])
public onKeyup(event: JQueryKeyEventObject): void {
if (!this.itemSelected && event.keyCode == 13) {
this.entered.emit({
'value': $(this.$element).typeahead('val'),
'callback': (reset: boolean) => {
if (reset) {
this.itemSelected = false;
$(this.$element).typeahead('val', '');
}
}
});
}
}
private buildTemplateHandler(templateUrl: string): Function { private buildTemplateHandler(templateUrl: string): Function {
return (value) => { return (value) => {
var resultDiv = document.createElement('div'); var resultDiv = document.createElement('div');
@ -101,4 +102,4 @@ export class TypeaheadDirective implements AfterContentInit {
return resultDiv; return resultDiv;
}; };
} }
} }

View file

@ -10,9 +10,6 @@ import { Input, Component } from 'ng-metadata/core';
templateUrl: '/static/js/directives/ui/visibility-indicator/visibility-indicator.component.html' templateUrl: '/static/js/directives/ui/visibility-indicator/visibility-indicator.component.html'
}) })
export class VisibilityIndicatorComponent { export class VisibilityIndicatorComponent {
@Input('<') public repository: any; @Input('<') public repository: any;
constructor() {
}
} }

View file

@ -84,7 +84,8 @@ function provideConfig($provide: ng.auto.IProvideService,
var tooltipFactory: any = $tooltipProvider.$get[$tooltipProvider.$get.length - 1]; var tooltipFactory: any = $tooltipProvider.$get[$tooltipProvider.$get.length - 1];
$tooltipProvider.$get[$tooltipProvider.$get.length - 1] = function($window: ng.IWindowService) { $tooltipProvider.$get[$tooltipProvider.$get.length - 1] = function($window: ng.IWindowService) {
if ('ontouchstart' in $window) { if ('ontouchstart' in $window) {
var existing: any = tooltipFactory.apply(this, arguments); const existing: any = tooltipFactory.apply(this, arguments);
return function(element) { return function(element) {
// Note: We only disable bs-tooltip's themselves. $tooltip is used for other things // Note: We only disable bs-tooltip's themselves. $tooltip is used for other things
// (such as the datepicker), so we need to be specific when canceling it. // (such as the datepicker), so we need to be specific when canceling it.

View file

@ -45,7 +45,8 @@ export function provideRun($rootScope: QuayRunScope,
return true; return true;
} }
const invalid_token: boolean = response.data['title'] == 'invalid_token' || response.data['error_type'] == 'invalid_token'; const invalid_token: boolean = response.data['title'] == 'invalid_token' ||
response.data['error_type'] == 'invalid_token';
if (response !== undefined && if (response !== undefined &&
response.status == 401 && response.status == 401 &&
invalid_token && invalid_token &&
@ -92,7 +93,7 @@ export function provideRun($rootScope: QuayRunScope,
} }
}); });
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) { $rootScope.$on('$routeChangeSuccess', function(event, current, previous) {
$rootScope.current = current.$$route; $rootScope.current = current.$$route;
$rootScope.currentPage = current; $rootScope.currentPage = current;
$rootScope.pageClass = ''; $rootScope.pageClass = '';
@ -126,7 +127,7 @@ interface QuayRunScope extends ng.IRootScopeService {
currentPage: any; currentPage: any;
current: any; current: any;
title: any; title: any;
description: string, description: string;
pageClass: any; pageClass: any;
newLayout: any; newLayout: any;
fixFooter: any; fixFooter: any;

View file

@ -13,7 +13,9 @@ import { CorTableComponent } from './directives/ui/cor-table/cor-table.component
import { CorTableColumn } from './directives/ui/cor-table/cor-table-col.component'; import { CorTableColumn } from './directives/ui/cor-table/cor-table-col.component';
import { ChannelIconComponent } from './directives/ui/channel-icon/channel-icon.component'; import { ChannelIconComponent } from './directives/ui/channel-icon/channel-icon.component';
import { TagSigningDisplayComponent } from './directives/ui/tag-signing-display/tag-signing-display.component'; import { TagSigningDisplayComponent } from './directives/ui/tag-signing-display/tag-signing-display.component';
import { RepositorySigningConfigComponent } from './directives/ui/repository-signing-config/repository-signing-config.component'; import {
RepositorySigningConfigComponent
} from './directives/ui/repository-signing-config/repository-signing-config.component';
import { TimeMachineSettingsComponent } from './directives/ui/time-machine-settings/time-machine-settings.component'; import { TimeMachineSettingsComponent } from './directives/ui/time-machine-settings/time-machine-settings.component';
import { DurationInputComponent } from './directives/ui/duration-input/duration-input.component'; import { DurationInputComponent } from './directives/ui/duration-input/duration-input.component';
import { SearchBoxComponent } from './directives/ui/search-box/search-box.component'; import { SearchBoxComponent } from './directives/ui/search-box/search-box.component';
@ -22,7 +24,6 @@ import { BuildServiceImpl } from './services/build/build.service.impl';
import { AvatarServiceImpl } from './services/avatar/avatar.service.impl'; import { AvatarServiceImpl } from './services/avatar/avatar.service.impl';
import { DockerfileServiceImpl } from './services/dockerfile/dockerfile.service.impl'; import { DockerfileServiceImpl } from './services/dockerfile/dockerfile.service.impl';
import { DataFileServiceImpl } from './services/datafile/datafile.service.impl'; import { DataFileServiceImpl } from './services/datafile/datafile.service.impl';
import { UtilServiceImpl } from './services/util/util.service.impl';
import { QuayRequireDirective } from './directives/structural/quay-require/quay-require.directive'; import { QuayRequireDirective } from './directives/structural/quay-require/quay-require.directive';
import { MarkdownInputComponent } from './directives/ui/markdown/markdown-input.component'; import { MarkdownInputComponent } from './directives/ui/markdown/markdown-input.component';
import { MarkdownViewComponent } from './directives/ui/markdown/markdown-view.component'; import { MarkdownViewComponent } from './directives/ui/markdown/markdown-view.component';

View file

@ -47,4 +47,4 @@ export class AvatarServiceImpl implements AvatarService {
return this.cache[cacheKey] = hash; return this.cache[cacheKey] = hash;
} }
} }

View file

@ -19,4 +19,4 @@ export abstract class AvatarService {
* @return hash The hash for the avatar image. * @return hash The hash for the avatar image.
*/ */
public abstract computeHash(email?: string, name?: string): string; public abstract computeHash(email?: string, name?: string): string;
} }

View file

@ -73,7 +73,8 @@ export class BuildServiceImpl implements BuildService {
break; break;
case 'internalerror': case 'internalerror':
message = 'An internal system error occurred while building; the build will be retried in the next few minutes.'; message = 'An internal system error occurred while building; ' +
'the build will be retried in the next few minutes.';
break; break;
case 'cancelled': case 'cancelled':
@ -86,4 +87,4 @@ export class BuildServiceImpl implements BuildService {
return message; return message;
} }
} }

View file

@ -16,4 +16,4 @@ export abstract class BuildService {
* @return buildMessage The message associated with the given phase. * @return buildMessage The message associated with the given phase.
*/ */
public abstract getBuildMessage(phase: string): string; public abstract getBuildMessage(phase: string): string;
} }

View file

@ -86,7 +86,7 @@ export class DataFileServiceImpl implements DataFileService {
var zip = null; var zip = null;
var zipFiles = null; var zipFiles = null;
try { try {
var zip = new JSZip(buf); zip = new JSZip(buf);
zipFiles = zip.files; zipFiles = zip.files;
} catch (e) { } catch (e) {
failure(); failure();
@ -164,9 +164,9 @@ export class DataFileServiceImpl implements DataFileService {
'name': this.getName(path), 'name': this.getName(path),
'path': path, 'path': path,
'canRead': true, 'canRead': true,
'toBlob': (function(currentFile) { 'toBlob': (function(file) {
return function() { return function() {
return new Blob([currentFile.buffer], {type: 'application/octet-binary'}); return new Blob([file.buffer], {type: 'application/octet-binary'});
}; };
}(currentFile)) }(currentFile))
}); });
@ -179,4 +179,4 @@ export class DataFileServiceImpl implements DataFileService {
failure(); failure();
} }
} }
} }

View file

@ -45,4 +45,4 @@ export abstract class DataFileService {
progress: (percent: number) => void, progress: (percent: number) => void,
error: () => void, error: () => void,
loaded: (uint8array: Uint8Array) => void): void; loaded: (uint8array: Uint8Array) => void): void;
} }

View file

@ -104,11 +104,11 @@ export class DockerfileInfoImpl implements DockerfileInfo {
return null; return null;
} }
if (baseImage.indexOf(this.config.getDomain() + '/') != 0) { if (baseImage.indexOf(`${this.config.getDomain()}/`) != 0) {
return null; return null;
} }
return baseImage.substring(this.config.getDomain().length + 1); return baseImage.substring(<number>this.config.getDomain().length + 1);
} }
public getBaseImage(): string | null { public getBaseImage(): string | null {
@ -152,4 +152,4 @@ export class DockerfileInfoImpl implements DockerfileInfo {
return baseImageAndTag; return baseImageAndTag;
} }
} }

View file

@ -35,4 +35,4 @@ export abstract class DockerfileInfo {
* @return baseImageAndTag The base image and tag. * @return baseImageAndTag The base image and tag.
*/ */
public abstract getBaseImageAndTag(): string | null; public abstract getBaseImageAndTag(): string | null;
} }

View file

@ -1,15 +1,11 @@
import { Injectable } from 'ng-metadata/core'; import { Injectable } from 'ng-metadata/core';
import { PageService } from './page.service'; import { PageService, QuayPage, QuayPageProfile } from './page.service';
@Injectable(PageService.name) @Injectable(PageService.name)
export class PageServiceImpl implements ng.IServiceProvider { export class PageServiceImpl implements ng.IServiceProvider {
private pages: any = {}; private pages: {[pageName: string]: QuayPage} = {};
constructor() {
}
public create(pageName: string, public create(pageName: string,
templateName: string, templateName: string,
@ -26,8 +22,8 @@ export class PageServiceImpl implements ng.IServiceProvider {
} }
} }
public get(pageName: string, profiles: any[]): any[] | null { public get(pageName: string, profiles: QuayPageProfile[]): [QuayPageProfile, QuayPage] | null {
for (var i = 0; i < profiles.length; ++i) { for (let i = 0; i < profiles.length; ++i) {
var current = profiles[i]; var current = profiles[i];
var key = current.id + ':' + pageName; var key = current.id + ':' + pageName;
var page = this.pages[key]; var page = this.pages[key];

View file

@ -22,7 +22,7 @@ export abstract class PageService implements ng.IServiceProvider {
* @param pageName The name of the page. * @param pageName The name of the page.
* @param profiles Available profiles to search. * @param profiles Available profiles to search.
*/ */
public abstract get(pageName: string, profiles: any[]): any[] | null; public abstract get(pageName: string, profiles: QuayPageProfile[]): [QuayPageProfile, QuayPage] | null;
/** /**
* Provide the service instance. * Provide the service instance.
@ -30,3 +30,24 @@ export abstract class PageService implements ng.IServiceProvider {
*/ */
public abstract $get(): PageService; public abstract $get(): PageService;
} }
/**
* A type representing a registered application page.
*/
export type QuayPage = {
name: string;
controller: ng.IController;
templateName: string,
flags: {[key: string]: any};
};
/**
* Represents a page profile type.
*/
export type QuayPageProfile = {
id: string;
templatePath: string;
};

View file

@ -1,13 +1,13 @@
import { RouteBuilder } from './route-builder.service'; import { RouteBuilder } from './route-builder.service';
import { Injectable, Inject } from 'ng-metadata/core'; import { Injectable, Inject } from 'ng-metadata/core';
import { PageService } from '../page/page.service'; import { PageService, QuayPage, QuayPageProfile } from '../page/page.service';
@Injectable(RouteBuilder.name) @Injectable(RouteBuilder.name)
export class RouteBuilderImpl implements RouteBuilder { export class RouteBuilderImpl implements RouteBuilder {
public currentProfile: string = 'layout'; public currentProfile: string = 'layout';
public profiles: any[] = [ public profiles: QuayPageProfile[] = [
// Start with the old pages (if we asked for it). // Start with the old pages (if we asked for it).
{id: 'old-layout', templatePath: '/static/partials/'}, {id: 'old-layout', templatePath: '/static/partials/'},
// Fallback back combined new/existing pages. // Fallback back combined new/existing pages.
@ -50,4 +50,4 @@ export class RouteBuilderImpl implements RouteBuilder {
return this; return this;
} }
} }

View file

@ -15,4 +15,4 @@ export abstract class RouteBuilder {
* @param pagename The name of the page to associate with this route. * @param pagename The name of the page to associate with this route.
*/ */
public abstract route(path: string, pagename: string): RouteBuilder; public abstract route(path: string, pagename: string): RouteBuilder;
} }

View file

@ -1,40 +0,0 @@
import { UtilServiceImpl } from './util.service.impl';
describe("UtilServiceImpl", () => {
var utilServiceImpl: UtilServiceImpl;
var $sanitizeMock: ng.sanitize.ISanitizeService;
beforeEach(() => {
$sanitizeMock = jasmine.createSpy('$sanitizeSpy').and.returnValue("");
utilServiceImpl = new UtilServiceImpl($sanitizeMock);
});
describe("isAdBlockEnabled", () => {
// TODO
});
describe("isEmailAddress", () => {
// TODO
});
describe("getMarkedDown", () => {
// TODO
});
describe("getFirstMarkdownLineAsText", () => {
// TODO
});
describe("escapeHtmlString", () => {
// TODO
});
describe("getRestUrl", () => {
// TODO
});
describe("textToSafeHtml", () => {
// TODO
});
});

View file

@ -1,39 +0,0 @@
import { Injectable, Inject } from 'ng-metadata/core';
import { UtilService } from './util.service';
@Injectable(UtilService.name)
export class UtilServiceImpl implements UtilService {
constructor(@Inject('$sanitize') private $sanitize: ng.sanitize.ISanitizeService) {
}
public isAdBlockEnabled(callback: (isEnabled: boolean) => void): void {
}
public isEmailAddress(str: string): boolean {
return null;
}
public getMarkedDown(str: string): string {
return null;
}
public getFirstMarkdownLineAsText(commentString: string, placeholderNeeded: boolean): string {
return null;
}
public escapeHtmlString(text: string): string {
return null;
}
public getRestUrl(args: any[]): string {
return null;
}
public textToSafeHtml(text: string): string {
return null;
}
}

View file

@ -1,19 +0,0 @@
/**
* Service which exposes various utility methods.
*/
export abstract class UtilService {
public abstract isAdBlockEnabled(callback: (isEnabled: boolean) => void): void;
public abstract isEmailAddress(str: string): boolean;
public abstract getMarkedDown(str: string): string;
public abstract getFirstMarkdownLineAsText(commentString: string, placeholderNeeded: boolean): string;
public abstract escapeHtmlString(text: string): string;
public abstract getRestUrl(args: any[]): string;
public abstract textToSafeHtml(text: string): string;
}

View file

@ -93,4 +93,4 @@ export class ViewArrayImpl implements ViewArray {
this.timerRef = null; this.timerRef = null;
} }
} }
} }

View file

@ -68,4 +68,4 @@ export abstract class ViewArray {
* @return viewArray New ViewArray instance. * @return viewArray New ViewArray instance.
*/ */
public abstract create(): ViewArrayImpl; public abstract create(): ViewArrayImpl;
} }

View file

@ -1,22 +1,17 @@
{ {
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "baseUrl": ".",
"jsx": "react",
"module": "commonjs", "module": "commonjs",
"outDir": "./build/", "outDir": "./build/",
"target": "es5", "target": "es5",
"lib": ["es2017", "dom"], "lib": ["es2017", "dom"],
"experimentalDecorators": true, "experimentalDecorators": true,
"sourceMap": true, "sourceMap": true
"paths": {
"sass/*": ["./static/css/directives/components/pages/*"]
}
}, },
"exclude": [ "exclude": [
"node_modules" "node_modules"
], ],
"include": [ "include": [
"./static/js/**/*.tsx",
"./static/js/**/*.ts" "./static/js/**/*.ts"
] ]
} }

View file

@ -1,5 +1,29 @@
{ {
"rules": { "rules": {
"no-default-export": true "no-default-export": true,
"member-access": true,
"member-ordering": [true, {"order": "fields-first"}],
"no-empty-interface": true,
"no-namespace": true,
"no-reference": true,
"curly": true,
"no-conditional-assignment": true,
"no-duplicate-super": true,
"no-empty": true,
"no-invalid-template-strings": true,
"no-misused-new": true,
"no-shadowed-variable": true,
"no-unbound-method": true,
"restrict-plus-operands": true,
"eofline": true,
"indent": [true, "spaces", 2],
"max-line-length": [true, 120],
"class-name": true,
"import-spacing": true,
"align": true,
"new-parens": true,
"semicolon": true,
"space-before-function-paren": [true, "never"],
"whitespace": [true, "check-decl", "check-operator", "check-module", "check-separator", "check-type", "check-preblock"]
} }
} }

View file

@ -1,6 +0,0 @@
{
"globalDependencies": {
"react": "registry:dt/react#0.14.0+20160927082313",
"react-dom": "registry:dt/react-dom#0.14.0+20160412154040"
}
}

View file

@ -21,7 +21,7 @@ var config = {
module: { module: {
rules: [ rules: [
{ {
test: /\.tsx?$/, test: /\.ts?$/,
use: ["ts-loader"], use: ["ts-loader"],
exclude: /node_modules/ exclude: /node_modules/
}, },

586
yarn.lock

File diff suppressed because it is too large Load diff