Commit ba048498 by Samuel Padgett

Add NotificationService.hideNotification

Also truncate long text in toast notifications (with a "See All" link).
parent eb8c2167
......@@ -383,7 +383,15 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <span class=\"{{notification.type | alertIcon}}\" aria-hidden=\"true\"></span>\n" +
" <span class=\"sr-only\">{{notification.type}}</span>\n" +
" <span class=\"toast-notification-message\" ng-if=\"notification.message\">{{notification.message}}</span>\n" +
" <span ng-if=\"notification.details\">{{notification.details}}</span>\n" +
" <span ng-if=\"notification.details\">\n" +
" <truncate-long-text\n" +
" limit=\"200\"\n" +
" content=\"notification.details\"\n" +
" use-word-boundary=\"true\"\n" +
" expandable=\"true\"\n" +
" hide-collapse=\"true\">\n" +
" </truncate-long-text>\n" +
" </span>\n" +
" <span ng-repeat=\"link in notification.links\">\n" +
" <a ng-if=\"!link.href\" href=\"\" ng-click=\"onClick(notification, link)\" role=\"button\">{{link.label}}</a>\n" +
" <a ng-if=\"link.href\" ng-href=\"{{link.href}}\" ng-attr-target=\"{{link.target}}\">{{link.label}}</a>\n" +
......@@ -411,11 +419,11 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" </span>\n" +
" <span ng-if=\"toggles.expanded\">\n" +
" <div ng-if=\"prettifyJson\" class=\"well\">\n" +
" <span class=\"pull-right\" style=\"margin-top: -10px;\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-if=\"!hideCollapse\" class=\"pull-right\" style=\"margin-top: -10px;\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-bind-html=\"content | prettifyJSON | highlightKeywords : keywords\" class=\"pretty-json truncated-content\"></span>\n" +
" </div>\n" +
" <span ng-if=\"!prettifyJson\">\n" +
" <span class=\"pull-right\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-if=\"!hideCollapse\" class=\"pull-right\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-bind-html=\"content | highlightKeywords : keywords\" class=\"truncated-content\"></span>\n" +
" </span>\n" +
" </span>\n" +
......@@ -932,6 +940,8 @@ angular.module('openshiftCommonUI')
newlineLimit: '=',
useWordBoundary: '=',
expandable: '=',
// When expandable is on, optionally hide the collapse link so text can only be expanded. (Used for toast notifications.)
hideCollapse: '=',
keywords: '=highlightKeywords', // optional keywords to highlight using the `highlightKeywords` filter
prettifyJson: '=' // prettifies JSON blobs when expanded, only used if expandable is true
},
......@@ -1712,6 +1722,18 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
notifications.push(notification);
};
var hideNotification = function (notificationID) {
if (!notificationID) {
return;
}
_.each(notifications, function(notification) {
if (notification.id === notificationID) {
notification.hidden = true;
}
});
};
var getNotifications = function () {
return notifications;
};
......@@ -1746,9 +1768,7 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
};
var isAutoDismiss = function(notification) {
return _.find(autoDismissTypes, function(type) {
return type === notification.type;
});
return _.includes(autoDismissTypes, notification.type);
};
// Also handle `addNotification` events on $rootScope, which is used by DataService.
......@@ -1758,6 +1778,7 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
return {
addNotification: addNotification,
hideNotification: hideNotification,
getNotifications: getNotifications,
clearNotifications: clearNotifications,
isNotificationPermanentlyHidden: isNotificationPermanentlyHidden,
......
......@@ -554,7 +554,15 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <span class=\"{{notification.type | alertIcon}}\" aria-hidden=\"true\"></span>\n" +
" <span class=\"sr-only\">{{notification.type}}</span>\n" +
" <span class=\"toast-notification-message\" ng-if=\"notification.message\">{{notification.message}}</span>\n" +
" <span ng-if=\"notification.details\">{{notification.details}}</span>\n" +
" <span ng-if=\"notification.details\">\n" +
" <truncate-long-text\n" +
" limit=\"200\"\n" +
" content=\"notification.details\"\n" +
" use-word-boundary=\"true\"\n" +
" expandable=\"true\"\n" +
" hide-collapse=\"true\">\n" +
" </truncate-long-text>\n" +
" </span>\n" +
" <span ng-repeat=\"link in notification.links\">\n" +
" <a ng-if=\"!link.href\" href=\"\" ng-click=\"onClick(notification, link)\" role=\"button\">{{link.label}}</a>\n" +
" <a ng-if=\"link.href\" ng-href=\"{{link.href}}\" ng-attr-target=\"{{link.target}}\">{{link.label}}</a>\n" +
......@@ -582,11 +590,11 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" </span>\n" +
" <span ng-if=\"toggles.expanded\">\n" +
" <div ng-if=\"prettifyJson\" class=\"well\">\n" +
" <span class=\"pull-right\" style=\"margin-top: -10px;\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-if=\"!hideCollapse\" class=\"pull-right\" style=\"margin-top: -10px;\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-bind-html=\"content | prettifyJSON | highlightKeywords : keywords\" class=\"pretty-json truncated-content\"></span>\n" +
" </div>\n" +
" <span ng-if=\"!prettifyJson\">\n" +
" <span class=\"pull-right\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-if=\"!hideCollapse\" class=\"pull-right\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-bind-html=\"content | highlightKeywords : keywords\" class=\"truncated-content\"></span>\n" +
" </span>\n" +
" </span>\n" +
......@@ -1103,6 +1111,8 @@ angular.module('openshiftCommonUI')
newlineLimit: '=',
useWordBoundary: '=',
expandable: '=',
// When expandable is on, optionally hide the collapse link so text can only be expanded. (Used for toast notifications.)
hideCollapse: '=',
keywords: '=highlightKeywords', // optional keywords to highlight using the `highlightKeywords` filter
prettifyJson: '=' // prettifies JSON blobs when expanded, only used if expandable is true
},
......@@ -4807,6 +4817,18 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
notifications.push(notification);
};
var hideNotification = function (notificationID) {
if (!notificationID) {
return;
}
_.each(notifications, function(notification) {
if (notification.id === notificationID) {
notification.hidden = true;
}
});
};
var getNotifications = function () {
return notifications;
};
......@@ -4841,9 +4863,7 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
};
var isAutoDismiss = function(notification) {
return _.find(autoDismissTypes, function(type) {
return type === notification.type;
});
return _.includes(autoDismissTypes, notification.type);
};
// Also handle `addNotification` events on $rootScope, which is used by DataService.
......@@ -4853,6 +4873,7 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
return {
addNotification: addNotification,
hideNotification: hideNotification,
getNotifications: getNotifications,
clearNotifications: clearNotifications,
isNotificationPermanentlyHidden: isNotificationPermanentlyHidden,
......
......@@ -365,7 +365,15 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" <span class=\"{{notification.type | alertIcon}}\" aria-hidden=\"true\"></span>\n" +
" <span class=\"sr-only\">{{notification.type}}</span>\n" +
" <span class=\"toast-notification-message\" ng-if=\"notification.message\">{{notification.message}}</span>\n" +
" <span ng-if=\"notification.details\">{{notification.details}}</span>\n" +
" <span ng-if=\"notification.details\">\n" +
" <truncate-long-text\n" +
" limit=\"200\"\n" +
" content=\"notification.details\"\n" +
" use-word-boundary=\"true\"\n" +
" expandable=\"true\"\n" +
" hide-collapse=\"true\">\n" +
" </truncate-long-text>\n" +
" </span>\n" +
" <span ng-repeat=\"link in notification.links\">\n" +
" <a ng-if=\"!link.href\" href=\"\" ng-click=\"onClick(notification, link)\" role=\"button\">{{link.label}}</a>\n" +
" <a ng-if=\"link.href\" ng-href=\"{{link.href}}\" ng-attr-target=\"{{link.target}}\">{{link.label}}</a>\n" +
......@@ -393,11 +401,11 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" </span>\n" +
" <span ng-if=\"toggles.expanded\">\n" +
" <div ng-if=\"prettifyJson\" class=\"well\">\n" +
" <span class=\"pull-right\" style=\"margin-top: -10px;\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-if=\"!hideCollapse\" class=\"pull-right\" style=\"margin-top: -10px;\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-bind-html=\"content | prettifyJSON | highlightKeywords : keywords\" class=\"pretty-json truncated-content\"></span>\n" +
" </div>\n" +
" <span ng-if=\"!prettifyJson\">\n" +
" <span class=\"pull-right\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-if=\"!hideCollapse\" class=\"pull-right\"><a href=\"\" ng-click=\"toggles.expanded = false\" class=\"truncation-collapse-link\">Collapse</a></span>\n" +
" <span ng-bind-html=\"content | highlightKeywords : keywords\" class=\"truncated-content\"></span>\n" +
" </span>\n" +
" </span>\n" +
......
......@@ -9,7 +9,15 @@
<span class="{{notification.type | alertIcon}}" aria-hidden="true"></span>
<span class="sr-only">{{notification.type}}</span>
<span class="toast-notification-message" ng-if="notification.message">{{notification.message}}</span>
<span ng-if="notification.details">{{notification.details}}</span>
<span ng-if="notification.details">
<truncate-long-text
limit="200"
content="notification.details"
use-word-boundary="true"
expandable="true"
hide-collapse="true">
</truncate-long-text>
</span>
<span ng-repeat="link in notification.links">
<a ng-if="!link.href" href="" ng-click="onClick(notification, link)" role="button">{{link.label}}</a>
<a ng-if="link.href" ng-href="{{link.href}}" ng-attr-target="{{link.target}}">{{link.label}}</a>
......
......@@ -13,11 +13,11 @@
</span>
<span ng-if="toggles.expanded">
<div ng-if="prettifyJson" class="well">
<span class="pull-right" style="margin-top: -10px;"><a href="" ng-click="toggles.expanded = false" class="truncation-collapse-link">Collapse</a></span>
<span ng-if="!hideCollapse" class="pull-right" style="margin-top: -10px;"><a href="" ng-click="toggles.expanded = false" class="truncation-collapse-link">Collapse</a></span>
<span ng-bind-html="content | prettifyJSON | highlightKeywords : keywords" class="pretty-json truncated-content"></span>
</div>
<span ng-if="!prettifyJson">
<span class="pull-right"><a href="" ng-click="toggles.expanded = false" class="truncation-collapse-link">Collapse</a></span>
<span ng-if="!hideCollapse" class="pull-right"><a href="" ng-click="toggles.expanded = false" class="truncation-collapse-link">Collapse</a></span>
<span ng-bind-html="content | highlightKeywords : keywords" class="truncated-content"></span>
</span>
</span>
......
......@@ -12,6 +12,8 @@ angular.module('openshiftCommonUI')
newlineLimit: '=',
useWordBoundary: '=',
expandable: '=',
// When expandable is on, optionally hide the collapse link so text can only be expanded. (Used for toast notifications.)
hideCollapse: '=',
keywords: '=highlightKeywords', // optional keywords to highlight using the `highlightKeywords` filter
prettifyJson: '=' // prettifies JSON blobs when expanded, only used if expandable is true
},
......
......@@ -25,6 +25,18 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
notifications.push(notification);
};
var hideNotification = function (notificationID) {
if (!notificationID) {
return;
}
_.each(notifications, function(notification) {
if (notification.id === notificationID) {
notification.hidden = true;
}
});
};
var getNotifications = function () {
return notifications;
};
......@@ -59,9 +71,7 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
};
var isAutoDismiss = function(notification) {
return _.find(autoDismissTypes, function(type) {
return type === notification.type;
});
return _.includes(autoDismissTypes, notification.type);
};
// Also handle `addNotification` events on $rootScope, which is used by DataService.
......@@ -71,6 +81,7 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
return {
addNotification: addNotification,
hideNotification: hideNotification,
getNotifications: getNotifications,
clearNotifications: clearNotifications,
isNotificationPermanentlyHidden: isNotificationPermanentlyHidden,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment