diff --git a/static/css/directives/ui/expiration-status-view.css b/static/css/directives/ui/expiration-status-view.css new file mode 100644 index 000000000..1bfe18c4f --- /dev/null +++ b/static/css/directives/ui/expiration-status-view.css @@ -0,0 +1,23 @@ +.expiration-status-view-element .expired, .expiration-status-view-element .expired a { + color: #D64456; +} + +.expiration-status-view-element .critical, .expiration-status-view-element .critical a { + color: #F77454; +} + +.expiration-status-view-element .warning, .expiration-status-view-element .warning a { + color: #FCA657; +} + +.expiration-status-view-element .info, .expiration-status-view-element .info a { + color: #2FC98E; +} + +.expiration-status-view-element .no-expiration, .expiration-status-view-element .no-expiration a { + color: #aaa; +} + +.expiration-status-view-element .fa { + margin-right: 6px; +} diff --git a/static/css/directives/ui/service-keys-manager.css b/static/css/directives/ui/service-keys-manager.css index c7b1e54ae..b63b377f3 100644 --- a/static/css/directives/ui/service-keys-manager.css +++ b/static/css/directives/ui/service-keys-manager.css @@ -20,30 +20,10 @@ color: #777; } -.service-keys-manager-element .expired a { - color: #D64456; -} - -.service-keys-manager-element .critical a { - color: #F77454; -} - -.service-keys-manager-element .warning a { - color: #FCA657; -} - -.service-keys-manager-element .info a { - color: #2FC98E; -} - .service-keys-manager-element .rotation { color: #777; } -.service-keys-manager-element .no-expiration { - color: #128E72; -} - .service-keys-manager-element .approval-automatic { font-size: 12px; color: #777; diff --git a/static/directives/service-keys-manager.html b/static/directives/service-keys-manager.html index 1935846dc..cfd82507f 100644 --- a/static/directives/service-keys-manager.html +++ b/static/directives/service-keys-manager.html @@ -113,20 +113,14 @@ - + Automatically rotated - - - - - Expiresd - - - - - Does not expire + + + + diff --git a/static/js/directives/ui/expiration-status-view/expiration-status-view.component.html b/static/js/directives/ui/expiration-status-view/expiration-status-view.component.html new file mode 100644 index 000000000..780381518 --- /dev/null +++ b/static/js/directives/ui/expiration-status-view/expiration-status-view.component.html @@ -0,0 +1,10 @@ + + + + + + + + Never + + \ No newline at end of file diff --git a/static/js/directives/ui/expiration-status-view/expiration-status-view.component.ts b/static/js/directives/ui/expiration-status-view/expiration-status-view.component.ts new file mode 100644 index 000000000..b5f4859a2 --- /dev/null +++ b/static/js/directives/ui/expiration-status-view/expiration-status-view.component.ts @@ -0,0 +1,34 @@ +import { Input, Component, Inject } from 'ng-metadata/core'; +import * as moment from "moment"; + +/** + * A component that displays expiration status. + */ +@Component({ + selector: 'expiration-status-view', + templateUrl: '/static/js/directives/ui/expiration-status-view/expiration-status-view.component.html', +}) +export class ExpirationStatusViewComponent { + @Input('<') public expirationDate: Date; + + private getExpirationInfo(expirationDate): any { + if (!expirationDate) { + return ''; + } + + var expiration_date = moment(expirationDate); + if (moment().isAfter(expiration_date)) { + return {'className': 'expired', 'icon': 'fa-warning'}; + } + + if (moment().add(1, 'week').isAfter(expiration_date)) { + return {'className': 'critical', 'icon': 'fa-warning'}; + } + + if (moment().add(1, 'month').isAfter(expiration_date)) { + return {'className': 'warning', 'icon': 'fa-warning'}; + } + + return {'className': 'info', 'icon': 'fa-clock-o'}; + } +} \ No newline at end of file diff --git a/static/js/directives/ui/service-keys-manager.js b/static/js/directives/ui/service-keys-manager.js index d6a4da38f..636385019 100644 --- a/static/js/directives/ui/service-keys-manager.js +++ b/static/js/directives/ui/service-keys-manager.js @@ -80,32 +80,19 @@ angular.module('quay').directive('serviceKeysManager', function () { return moment(key.created_date).add(key.rotation_duration, 's').format('LLL'); }; - $scope.getExpirationInfo = function(key) { + $scope.willRotate = function(key) { if (!key.expiration_date) { - return ''; + return false; } if (key.rotation_duration) { var rotate_date = moment(key.created_date).add(key.rotation_duration, 's') if (moment().isBefore(rotate_date)) { - return {'className': 'rotation', 'icon': 'fa-refresh', 'willRotate': true}; + return true; } } - expiration_date = moment(key.expiration_date); - if (moment().isAfter(expiration_date)) { - return {'className': 'expired', 'icon': 'fa-warning'}; - } - - if (moment().add(1, 'week').isAfter(expiration_date)) { - return {'className': 'critical', 'icon': 'fa-warning'}; - } - - if (moment().add(1, 'month').isAfter(expiration_date)) { - return {'className': 'warning', 'icon': 'fa-warning'}; - } - - return {'className': 'info', 'icon': 'fa-check'}; + return false; }; $scope.showChangeName = function(key) { diff --git a/static/js/quay.module.ts b/static/js/quay.module.ts index 07f697bd7..014f2efec 100644 --- a/static/js/quay.module.ts +++ b/static/js/quay.module.ts @@ -31,6 +31,7 @@ import { MarkdownToolbarComponent } from './directives/ui/markdown/markdown-tool import { MarkdownEditorComponent } from './directives/ui/markdown/markdown-editor.component'; import { DockerfileCommandComponent } from './directives/ui/dockerfile-command/dockerfile-command.component'; import { ImageCommandComponent } from './directives/ui/image-command/image-command.component'; +import { ExpirationStatusViewComponent } from './directives/ui/expiration-status-view/expiration-status-view.component'; import { BrowserPlatform, browserPlatform } from './constants/platform.constant'; import { ManageTriggerComponent } from './directives/ui/manage-trigger/manage-trigger.component'; import { ClipboardCopyDirective } from './directives/ui/clipboard-copy/clipboard-copy.directive'; @@ -74,6 +75,7 @@ import * as Clipboard from 'clipboard'; ImageCommandComponent, TypeaheadDirective, ManageTriggerComponent, + ExpirationStatusViewComponent, ClipboardCopyDirective, TriggerDescriptionComponent, ],