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/namespace-input.js

39 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-11-12 16:09:47 +00:00
/**
* An element which displays an input box for creating a namespace.
*/
angular.module('quay').directive('namespaceInput', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/namespace-input.html',
replace: false,
transclude: true,
restrict: 'C',
scope: {
'binding': '=binding',
'backIncompatMessage': '=backIncompatMessage',
'hasExternalError': '=?hasExternalError',
'namespaceTitle': '@namespaceTitle',
},
controller: function($scope, $element, NAME_PATTERNS) {
$scope.USERNAME_PATTERN = NAME_PATTERNS.USERNAME_PATTERN;
$scope.usernamePattern = new RegExp(NAME_PATTERNS.USERNAME_PATTERN);
$scope.$watch('binding', function(binding) {
if (!binding) {
$scope.backIncompatMessage = null;
return;
}
if (binding.indexOf('-') > 0 || binding.indexOf('.') > 0) {
$scope.backIncompatMessage = 'Namespaces with dashes or dots are only compatible with Docker 1.9+';
} else if (binding.length < 4 || binding.length > 30) {
$scope.backIncompatMessage = 'Namespaces less than 4 or more than 30 characters are only compatible with Docker 1.6+';
} else {
$scope.backIncompatMessage = null;
}
})
}
};
return directiveDefinitionObject;
});