This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/ui/dockerfile-path-select/dockerfile-path-select.component.ts
Alec Merdler 7a352ddfbc Use ng-metadata as a Backport of Angular 2+ API (#2486)
* starting UtilService refactor

* pre find-replace angular.module('quay') => angular.module('QuayModule')

* successfully switched to ng-metadata for backported Angular2 API

* working with parent component reference in child

* fixing @Output to use EventEmitter

* fixed @Output events for custom git trigger

* more fixes

* refactored QuayPages module for backwards-compatibility

* reinitialized test.db

* use minified libraries

* replaced references for angular-ts-decorators

* fixed ng-show
2017-04-05 14:14:08 -07:00

47 lines
1.6 KiB
TypeScript

import { Input, Component, OnChanges, SimpleChanges } from 'ng-metadata/core';
/**
* A component that allows the user to select the location of the Dockerfile in their source code repository.
*/
@Component({
selector: 'dockerfile-path-select',
templateUrl: '/static/js/directives/ui/dockerfile-path-select/dockerfile-path-select.component.html'
})
export class DockerfilePathSelectComponent implements OnChanges {
// FIXME: Use one-way data binding
@Input('=') public currentPath: string;
@Input('=') public isValidPath: boolean;
@Input('=') public paths: string[];
@Input('=') public supportsFullListing: boolean;
private isUnknownPath: boolean = true;
private selectedPath: string | null = null;
public ngOnChanges(changes: SimpleChanges): void {
this.isValidPath = this.checkPath(this.currentPath, this.paths, this.supportsFullListing);
}
public setPath(path: string): void {
this.currentPath = path;
this.selectedPath = null;
this.isValidPath = this.checkPath(path, this.paths, this.supportsFullListing);
}
public setSelectedPath(path: string): void {
this.currentPath = path;
this.selectedPath = path;
this.isValidPath = this.checkPath(path, this.paths, this.supportsFullListing);
}
private checkPath(path: string = '', paths: string[] = [], supportsFullListing: boolean): boolean {
this.isUnknownPath = false;
var isValidPath: boolean = false;
if (path.length > 0 && path[0] === '/') {
isValidPath = true;
this.isUnknownPath = supportsFullListing && paths.indexOf(path) < 0;
}
return isValidPath;
}
}