initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
|
@ -0,0 +1,38 @@
|
|||
<div class="dockerfile-path-select-element">
|
||||
<div class="dropdown-select"
|
||||
placeholder="'Enter path containing a Dockerfile'"
|
||||
selected-item="$ctrl.selectedPath"
|
||||
lookahead-items="$ctrl.paths"
|
||||
handle-input="$ctrl.setPath(input)"
|
||||
handle-item-selected="$ctrl.setSelectedPath(datum.value)"
|
||||
allow-custom-input="true"
|
||||
hide-dropdown="!$ctrl.supportsFullListing">
|
||||
<!-- Icons -->
|
||||
<i class="dropdown-select-icon none-icon fa fa-folder-o fa-lg"
|
||||
ng-show="$ctrl.isUnknownPath"></i>
|
||||
<i class="dropdown-select-icon none-icon fa fa-folder fa-lg" style="color: black;"
|
||||
ng-show="!$ctrl.isUnknownPath"></i>
|
||||
<i class="dropdown-select-icon fa fa-folder fa-lg"></i>
|
||||
|
||||
<!-- Dropdown menu -->
|
||||
<ul class="dropdown-select-menu pull-right" role="menu">
|
||||
<li ng-repeat="path in $ctrl.paths">
|
||||
<a ng-click="$ctrl.setSelectedPath(path)"
|
||||
ng-if="path">
|
||||
<i class="fa fa-folder fa-lg"></i> {{ path }}
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown-header" role="presentation"
|
||||
ng-show="!$ctrl.paths.length">
|
||||
No Dockerfiles found in repository
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div style="padding: 10px">
|
||||
<div class="co-alert co-alert-danger"
|
||||
ng-show="!$ctrl.isValidPath && $ctrl.currentPath">
|
||||
Path entered for folder containing Dockerfile is invalid: Must start with a '/'.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,110 @@
|
|||
import { DockerfilePathSelectComponent, PathChangeEvent } from './dockerfile-path-select.component';
|
||||
|
||||
|
||||
describe("DockerfilePathSelectComponent", () => {
|
||||
var component: DockerfilePathSelectComponent;
|
||||
var currentPath: string;
|
||||
var isValidPath: boolean;
|
||||
var paths: string[];
|
||||
var supportsFullListing: boolean;
|
||||
|
||||
beforeEach(() => {
|
||||
component = new DockerfilePathSelectComponent();
|
||||
currentPath = '/';
|
||||
isValidPath = false;
|
||||
paths = ['/'];
|
||||
supportsFullListing = true;
|
||||
component.currentPath = currentPath;
|
||||
component.isValidPath = isValidPath;
|
||||
component.paths = paths;
|
||||
component.supportsFullListing = supportsFullListing;
|
||||
});
|
||||
|
||||
describe("ngOnChanges", () => {
|
||||
|
||||
it("sets valid path flag to true if current path is valid", () => {
|
||||
component.ngOnChanges({});
|
||||
|
||||
expect(component.isValidPath).toBe(true);
|
||||
});
|
||||
|
||||
it("sets valid path flag to false if current path is invalid", () => {
|
||||
component.currentPath = "asdfdsf";
|
||||
component.ngOnChanges({});
|
||||
|
||||
expect(component.isValidPath).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setPath", () => {
|
||||
var newPath: string;
|
||||
|
||||
beforeEach(() => {
|
||||
newPath = '/conf';
|
||||
});
|
||||
|
||||
it("sets current path to given path", () => {
|
||||
component.setPath(newPath);
|
||||
|
||||
expect(component.currentPath).toEqual(newPath);
|
||||
});
|
||||
|
||||
it("sets valid path flag to true if given path is valid", () => {
|
||||
component.setPath(newPath);
|
||||
|
||||
expect(component.isValidPath).toBe(true);
|
||||
});
|
||||
|
||||
it("sets valid path flag to false if given path is invalid", () => {
|
||||
component.setPath("asdfsadfs");
|
||||
|
||||
expect(component.isValidPath).toBe(false);
|
||||
});
|
||||
|
||||
it("emits output event indicating Dockerfile path has changed", (done) => {
|
||||
component.pathChanged.subscribe((event: PathChangeEvent) => {
|
||||
expect(event.path).toEqual(newPath);
|
||||
expect(event.isValid).toBe(component.isValidPath);
|
||||
done();
|
||||
});
|
||||
|
||||
component.setPath(newPath);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setCurrentPath", () => {
|
||||
var newPath: string;
|
||||
|
||||
beforeEach(() => {
|
||||
newPath = '/conf';
|
||||
});
|
||||
|
||||
it("sets current path to given path", () => {
|
||||
component.setSelectedPath(newPath);
|
||||
|
||||
expect(component.currentPath).toEqual(newPath);
|
||||
});
|
||||
|
||||
it("sets valid path flag to true if given path is valid", () => {
|
||||
component.setSelectedPath(newPath);
|
||||
|
||||
expect(component.isValidPath).toBe(true);
|
||||
});
|
||||
|
||||
it("sets valid path flag to false if given path is invalid", () => {
|
||||
component.setSelectedPath("a;lskjdf;ldsa");
|
||||
|
||||
expect(component.isValidPath).toBe(false);
|
||||
});
|
||||
|
||||
it("emits output event indicating Dockerfile path has changed", (done) => {
|
||||
component.pathChanged.subscribe((event: PathChangeEvent) => {
|
||||
expect(event.path).toEqual(newPath);
|
||||
expect(event.isValid).toBe(component.isValidPath);
|
||||
done();
|
||||
});
|
||||
|
||||
component.setSelectedPath(newPath);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,60 @@
|
|||
import { Input, Output, EventEmitter, 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 {
|
||||
|
||||
@Input('<') public currentPath: string = '';
|
||||
@Input('<') public paths: string[];
|
||||
@Input('<') public supportsFullListing: boolean;
|
||||
@Output() public pathChanged: EventEmitter<PathChangeEvent> = new EventEmitter();
|
||||
public isValidPath: 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);
|
||||
|
||||
this.pathChanged.emit({path: this.currentPath, isValid: this.isValidPath});
|
||||
}
|
||||
|
||||
public setSelectedPath(path: string): void {
|
||||
this.currentPath = path;
|
||||
this.selectedPath = path;
|
||||
this.isValidPath = this.checkPath(path, this.paths, this.supportsFullListing);
|
||||
|
||||
this.pathChanged.emit({path: this.currentPath, isValid: this.isValidPath});
|
||||
}
|
||||
|
||||
private checkPath(path: string = '', paths: string[] = [], supportsFullListing: boolean): boolean {
|
||||
this.isUnknownPath = false;
|
||||
var isValidPath: boolean = false;
|
||||
|
||||
if (path != null && path.length > 0 && path[0] === '/') {
|
||||
isValidPath = true;
|
||||
this.isUnknownPath = supportsFullListing && paths.indexOf(path) < 0;
|
||||
}
|
||||
return isValidPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dockerfile path changed event.
|
||||
*/
|
||||
export type PathChangeEvent = {
|
||||
path: string;
|
||||
isValid: boolean;
|
||||
};
|
Reference in a new issue