From 14222be9feea549ff8063e4a9d23473f6d4785fe Mon Sep 17 00:00:00 2001 From: alecmerdler Date: Sat, 18 Feb 2017 01:45:00 -0800 Subject: [PATCH] working on ManageTriggerGithostComponent --- .../manage-trigger-custom-git.component.ts | 2 +- .../directives/ui/manage-trigger-githost.js | 2 +- .../manage-trigger-githost.component.html | 355 ++++++++++++++++++ .../manage-trigger-githost.component.spec.ts | 47 +++ .../manage-trigger-githost.component.ts | 148 ++++++++ static/js/quay.module.ts | 2 + test/data/test.db | Bin 1306624 -> 1314816 bytes 7 files changed, 554 insertions(+), 2 deletions(-) create mode 100644 static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.html create mode 100644 static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.spec.ts create mode 100644 static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.ts diff --git a/static/js/directives/ui/manage-trigger-custom-git/manage-trigger-custom-git.component.ts b/static/js/directives/ui/manage-trigger-custom-git/manage-trigger-custom-git.component.ts index 4addf1a24..c4e88f7cf 100644 --- a/static/js/directives/ui/manage-trigger-custom-git/manage-trigger-custom-git.component.ts +++ b/static/js/directives/ui/manage-trigger-custom-git/manage-trigger-custom-git.component.ts @@ -12,7 +12,7 @@ export class ManageTriggerCustomGitComponent implements ng.IComponentController // FIXME: Use one-way data binding @Input('=') public trigger: {config: any}; - @Output() public activateTrigger: any; + @Output() public activateTrigger: (trigger: {config: any}) => void; private config: any = {}; private currentState: any | null; diff --git a/static/js/directives/ui/manage-trigger-githost.js b/static/js/directives/ui/manage-trigger-githost.js index c63c86199..3a4a24f4b 100644 --- a/static/js/directives/ui/manage-trigger-githost.js +++ b/static/js/directives/ui/manage-trigger-githost.js @@ -11,7 +11,6 @@ angular.module('quay').directive('manageTriggerGithost', function () { scope: { 'repository': '=repository', 'trigger': '=trigger', - 'activateTrigger': '&activateTrigger' }, controller: function($scope, $element, ApiService, TableService, TriggerService, RolesService) { @@ -52,6 +51,7 @@ angular.module('quay').directive('manageTriggerGithost', function () { }; $scope.createTrigger = function() { + console.log($scope.local); var config = { 'build_source': $scope.local.selectedRepository.full_name, 'subdir': $scope.local.dockerfilePath.substr(1) // Remove starting / diff --git a/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.html b/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.html new file mode 100644 index 000000000..ad35aa864 --- /dev/null +++ b/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.html @@ -0,0 +1,355 @@ +
+
+ + +
+
+

Select {{ $ctrl.namespaceTitle }}

+ + Please select the {{ $ctrl.namespaceTitle }} under which the repository lives + + +
+
+ + +
+
+ + + + + + + + + + + + + +
+ {{ $ctrl.namespaceTitle }} +
+ + + + {{ $ctrl.namespace.id }} +
+
+
No matching {{ $ctrl.namespaceTitle }} found.
+
Try expanding your filtering terms.
+
+
+ +
+ Retrieving {{ $ctrl.namespaceTitle }}s +
+ +
+ + +
+ +
+

Select Repository

+ + Select a repository in + + {{ $ctrl.local.selectedNamespace.id }} + + +
+
+ + +
+ +
+
+
+ + + + + + + + + + + + + + + +
+ Repository Name + + Last Updated +
+ + + + + + + {{ repository.name }} + + +
+
+
No matching repositories found.
+
Try expanding your filtering terms.
+
+
+ +
+ Retrieving repositories +
+ + +
+ + +
+
+

Configure Trigger

+ + Configure trigger options for + + {{ $ctrl.local.selectedNamespace.id }}/{{ $ctrl.local.selectedRepository.name }} + + +
+ +
+
+ +
+
+ +
+ Retrieving repository refs +
+ +
+ + +
+
+
+ {{ $ctrl.local.dockerfileLocations.message }} +
+
+ +
+

Select Dockerfile

+ + Please select the location of the Dockerfile to build when this trigger is invoked {{ $ctrl.local.paths }} + + + +
+ +
+ Retrieving Dockerfile locations +
+ +
+ + +
+ +
+

Verification Error

+ + There was an error when verifying the state of + {{ $ctrl.local.selectedNamespace.id }}/{{ $ctrl.local.selectedRepository.name }} + + + {{ $ctrl.local.triggerAnalysis.message }} +
+ + +
+

Verification Warning

+ {{ $ctrl.local.triggerAnalysis.message }} +
+ + +
+

Ready to go!

+ Click "Create Trigger" to complete setup of this build trigger +
+ + +
+

Robot Account Required

+

The selected Dockerfile in the selected repository depends upon a private base image

+

A robot account with access to the base image is required to setup this trigger, but you are not the administrator of this namespace.

+

Administrative access is required to continue to ensure security of the robot credentials.

+
+ + +
+

Select Robot Account

+ + The selected Dockerfile in the selected repository depends upon a private base image. Select a robot account with access: + + +
+
+ + +
+
+ + + + + + + + + + + + + +
+ Robot Account + + Has Read Access +
+ + + + + Can Read + Read access will be added if selected +
+
+
No matching robot accounts found.
+
Try expanding your filtering terms.
+
+
+ + +
+ +
\ No newline at end of file diff --git a/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.spec.ts b/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.spec.ts new file mode 100644 index 000000000..e7cdeacf8 --- /dev/null +++ b/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.spec.ts @@ -0,0 +1,47 @@ +import { ManageTriggerGithostComponent, Local, Trigger } from './manage-trigger-githost.component'; + + +describe("ManageTriggerGithostComponent", () => { + var component: ManageTriggerGithostComponent; + var apiServiceMock: any; + var tableServiceMock: any; + var triggerServiceMock: any; + var rolesServiceMock: any; + var repository: any; + var trigger: Trigger; + + beforeEach(() => { + apiServiceMock = jasmine.createSpyObj('apiServiceMock', ['listTriggerBuildSourceNamespaces']); + tableServiceMock = jasmine.createSpyObj('tableServiceMock', ['buildOrderedItems']); + triggerServiceMock = jasmine.createSpyObj('triggerServiceMock', ['getIcon']); + rolesServiceMock = jasmine.createSpyObj('rolesServiceMock', ['setRepositoryRole']); + component = new ManageTriggerGithostComponent(apiServiceMock, tableServiceMock, triggerServiceMock, rolesServiceMock); + trigger = {service: "serviceMock", id: 1}; + component.trigger = trigger; + }); + + describe("constructor", () => { + + }); + + describe("$onInit", () => { + + }); + + describe("$onChanges", () => { + + }); + + describe("getTriggerIcon", () => { + + it("calls trigger service to get icon", () => { + component.getTriggerIcon(); + + expect(triggerServiceMock.getIcon.calls.argsFor(0)[0]).toEqual(component.trigger.service); + }); + }); + + describe("createTrigger", () => { + + }); +}); \ No newline at end of file diff --git a/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.ts b/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.ts new file mode 100644 index 000000000..473bde6eb --- /dev/null +++ b/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.ts @@ -0,0 +1,148 @@ +import { Input, Output, Component } from 'angular-ts-decorators'; + + +@Component({ + selector: 'manageTriggerGithost', + templateUrl: '/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.html' +}) +export class ManageTriggerGithostComponent implements ng.IComponentController { + + @Input('=') public repository: any; + @Input('=') public trigger: Trigger; + @Output() public activateTrigger: (trigger: {config: any, pull_robot: any}) => void; + private config: any; + private local: Local = { + namespaceOptions: { + filter: '', + predicate: 'score', + reverse: false, + page: 0 + }, + repositoryOptions: { + filter: '', + predicate: 'score', + reverse: false, + page: 0, + hideStale: true + }, + robotOptions: { + filter: '', + predicate: 'score', + reverse: false, + page: 0 + } + }; + private currentState: any | null; + private namespacesPerPage: number = 10; + private repositoriesPerPage: number = 10; + private robotsPerPage: number = 10; + + constructor(private ApiService: any, + private TableService: any, + private TriggerService: any, + private RolesService: any) { + + } + + public $onInit(): void { + + } + + public $onChanges(changes: ng.IOnChangesObject): void { + + } + + public getTriggerIcon(): any { + return this.TriggerService.getIcon(this.trigger.service); + } + + public createTrigger(): void { + var config: any = { + build_source: this.local.selectedRepository.full_name, + subdir: this.local.dockerfilePath.substr(1) // Remove starting / + }; + + if (this.local.triggerOptions.hasBranchTagFilter && + this.local.triggerOptions.branchTagFilter) { + config['branchtag_regex'] = this.local.triggerOptions.branchTagFilter; + } + + var activate = () => { + this.activateTrigger({'config': config, 'pull_robot': this.local.robotAccount}); + }; + + if (this.local.robotAccount) { + if (this.local.robotAccount.can_read) { + activate(); + } else { + // Add read permission onto the base repository for the robot and then activate the + // trigger. + var robot_name = this.local.robotAccount.name; + this.RolesService.setRepositoryRole(this.repository, 'read', 'robot', robot_name, activate); + } + } else { + activate(); + } + } + + private buildOrderedNamespaces(): void { + + } + + private loadNamespaces(): void { + + } + + private buildOrderedRepositories(): void { + + } + + private loadRepositories(): void { + + } + + private loadRepositoryRefs(repository: any): void { + + } + + private loadDockerfileLocations(repository: any): void { + + } + + private buildOrderedRobotAccounts(): void { + + } + + private checkDockerfilePath(repository: any, path: string): void { + + } +} + + +export type Local = { + namespaceOptions: { + filter: string; + predicate: string; + reverse: boolean; + page: number; + }; + repositoryOptions: { + filter: string; + predicate: string; + reverse: boolean; + page: number; + hideStale: boolean; + }; + robotOptions: { + filter: string; + predicate: string; + reverse: boolean; + page: number; + }; +} + + +export type Trigger = { + id: number; + service: any; +} \ No newline at end of file diff --git a/static/js/quay.module.ts b/static/js/quay.module.ts index 229c16a09..a318c4a38 100644 --- a/static/js/quay.module.ts +++ b/static/js/quay.module.ts @@ -8,6 +8,7 @@ import { NgModule } from "angular-ts-decorators"; import { QuayRoutes } from "./quay-routes.module"; import { DockerfilePathSelectComponent } from './directives/ui/dockerfile-path-select/dockerfile-path-select.component'; import { ManageTriggerCustomGitComponent } from './directives/ui/manage-trigger-custom-git/manage-trigger-custom-git.component'; +import { ManageTriggerGithostComponent } from './directives/ui/manage-trigger-githost/manage-trigger-githost.component'; var quayDependencies: any[] = [ @@ -57,6 +58,7 @@ if (INJECTED_CONFIG && INJECTED_CONFIG.RECAPTCHA_SITE_KEY) { RegexMatchViewComponent, DockerfilePathSelectComponent, ManageTriggerCustomGitComponent, + ManageTriggerGithostComponent, ], providers: [ ViewArrayImpl, diff --git a/test/data/test.db b/test/data/test.db index 5b1af4074de1911cda2ad7635c99851d7c652caf..b089c3c80ea413126624be51bd6269ce9088a0e9 100644 GIT binary patch delta 4217 zcmcgvTZkjsd6ueYrl++%Q!{ZckY4ZhHp?cq(oWYCz9m^JI{ZbFdpF4%zuV?rPh;(o9n4EvNfgCG6i4S9$|9%2HXCG0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