Add experiment to hide the new Clair UI

This commit is contained in:
Joseph Schorr 2016-02-25 17:42:09 -05:00
parent 09d8e643c0
commit 4c5c46aa8f
7 changed files with 241 additions and 3 deletions

View file

@ -163,6 +163,9 @@ quayApp.config(['$routeProvider', '$locationProvider', 'pages', function($routeP
// Confirm Invite
.route('/confirminvite', 'confirm-invite')
// Experiments
.route('/__exp/newseclayout', 'exp-new-sec-layout')
// Default: Redirect to the landing page
.otherwise({redirectTo: '/'});
}]);

View file

@ -0,0 +1,84 @@
/**
* Old image security view until formally released.
*/
angular.module('quay').directive('oldImageSecurityView', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/old-image-security-view.html',
replace: false,
transclude: true,
restrict: 'C',
scope: {
'repository': '=repository',
'image': '=image',
'isEnabled': '=isEnabled',
'view': '@view'
},
controller: function($scope, $element, Config, ApiService, Features, VulnerabilityService, ImageMetadataService) {
var loadImageSecurity = function() {
if (!Features.SECURITY_SCANNER || $scope.securityResource) { return; }
$scope.VulnerabilityLevels = VulnerabilityService.getLevels();
$scope.options = {
'vulnFilter': '',
'packageFilter': ''
};
var params = {
'repository': $scope.repository.namespace + '/' + $scope.repository.name,
'imageid': $scope.image.id,
'vulnerabilities': true,
};
$scope.securityResource = ApiService.getRepoImageSecurityAsResource(params).get(function(resp) {
$scope.securityStatus = resp.status;
$scope.securityFeatures = [];
$scope.securityVulnerabilities = [];
if (resp.data && resp.data.Layer && resp.data.Layer.Features) {
resp.data.Layer.Features.forEach(function(feature) {
feature_obj = {
'name': feature.Name,
'namespace': feature.Namespace,
'version': feature.Version,
'addedBy': feature.AddedBy,
}
feature_vulnerabilities = []
if (feature.Vulnerabilities) {
feature.Vulnerabilities.forEach(function(vuln) {
vuln_obj = {
'name': vuln.Name,
'namespace': vuln.Namespace,
'description': vuln.Description,
'link': vuln.Link,
'severity': vuln.Severity,
'metadata': vuln.Metadata,
'feature': jQuery.extend({}, feature_obj),
'fixedBy': vuln.FixedBy,
'index': VulnerabilityService.LEVELS[vuln['Severity']]['index'],
}
feature_vulnerabilities.push(vuln_obj)
$scope.securityVulnerabilities.push(vuln_obj);
});
}
feature_obj['vulnerabilities'] = feature_vulnerabilities
$scope.securityFeatures.push(feature_obj);
});
}
return resp;
});
};
$scope.$watch('isEnabled', function(isEnabled) {
if ($scope.isEnabled && $scope.repository && $scope.image) {
loadImageSecurity();
}
});
}
};
return directiveDefinitionObject;
});

View file

@ -0,0 +1,19 @@
(function() {
/**
* Experiment enable page: New layout
*/
angular.module('quayPages').config(['pages', function(pages) {
pages.create('exp-new-sec-layout', 'exp-new-sec-layout.html', ExpCtrl, {
'newLayout': true
});
}]);
function ExpCtrl($scope, CookieService) {
$scope.isEnabled = CookieService.get('quay.exp-new-sec-layout') == 'true';
$scope.setEnabled = function(value) {
$scope.isEnabled = value;
CookieService.putPermanent('quay.exp-new-sec-layout', value.toString());
};
}
}());

View file

@ -10,13 +10,15 @@
})
}]);
function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, ImageMetadataService, Features) {
function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, ImageMetadataService, Features, CookieService) {
var namespace = $routeParams.namespace;
var name = $routeParams.name;
var imageid = $routeParams.image;
$scope.imageSecurityCounter = 0;
$scope.imagePackageCounter = 0;
$scope.newUIExperiment = CookieService.get('quay.exp-new-sec-layout') == 'true';
$scope.options = {
'vulnFilter': ''
};