-
Notifications
You must be signed in to change notification settings - Fork 232
Show toast notifications in create from builder flow #1681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
"use strict"; | ||
|
||
angular.module("openshiftConsole") | ||
.controller("CreateFromImageController", function ($scope, | ||
Logger, | ||
$q, | ||
$routeParams, | ||
APIService, | ||
DataService, | ||
ProjectsService, | ||
Navigate, | ||
ApplicationGenerator, | ||
LimitRangesService, | ||
MetricsService, | ||
HPAService, | ||
QuotaService, | ||
SecretsService, | ||
ImagesService, | ||
TaskList, | ||
failureObjectNameFilter, | ||
$filter, | ||
$parse, | ||
$uibModal, | ||
SOURCE_URL_PATTERN, | ||
keyValueEditorUtils | ||
){ | ||
.controller("CreateFromImageController", | ||
function($scope, | ||
$filter, | ||
$parse, | ||
$q, | ||
$routeParams, | ||
$uibModal, | ||
APIService, | ||
ApplicationGenerator, | ||
DataService, | ||
HPAService, | ||
ImagesService, | ||
LimitRangesService, | ||
Logger, | ||
MetricsService, | ||
Navigate, | ||
NotificationsService, | ||
ProjectsService, | ||
QuotaService, | ||
SOURCE_URL_PATTERN, | ||
SecretsService, | ||
TaskList, | ||
failureObjectNameFilter, | ||
keyValueEditorUtils) { | ||
var displayNameFilter = $filter('displayName'); | ||
var humanize = $filter('humanize'); | ||
|
||
|
@@ -60,20 +61,21 @@ angular.module("openshiftConsole") | |
title: breadcrumbTitle | ||
} | ||
]; | ||
$scope.alerts = {}; | ||
$scope.quotaAlerts = {}; | ||
|
||
var appLabel = {name: 'app', value: ''}; | ||
|
||
var orderByDisplayName = $filter('orderByDisplayName'); | ||
var getErrorDetails = $filter('getErrorDetails'); | ||
|
||
var displayError = function(errorMessage, errorDetails) { | ||
$scope.alerts['from-value-objects'] = { | ||
type: "error", | ||
message: errorMessage, | ||
details: errorDetails | ||
}; | ||
var quotaAlerts = {}; | ||
var hideErrorNotifications = function() { | ||
NotificationsService.hideNotification("create-builder-list-config-maps-error"); | ||
NotificationsService.hideNotification("create-builder-list-secrets-error"); | ||
_.each(quotaAlerts, function(alert) { | ||
if (alert.id && (alert.type === 'error' || alert.type === 'warning')) { | ||
NotificationsService.hideNotification(alert.id); | ||
} | ||
}); | ||
}; | ||
|
||
ProjectsService | ||
|
@@ -174,7 +176,12 @@ angular.module("openshiftConsole") | |
return; | ||
} | ||
|
||
displayError('Could not load config maps', getErrorDetails(e)); | ||
NotificationsService.addNotification({ | ||
id: "create-builder-list-config-maps-error", | ||
type: "error", | ||
message: "Could not load config maps.", | ||
details: getErrorDetails(e) | ||
}); | ||
}); | ||
|
||
DataService.list("secrets", context, null, { errorNotification: false }).then(function(secretData) { | ||
|
@@ -191,7 +198,12 @@ angular.module("openshiftConsole") | |
return; | ||
} | ||
|
||
displayError('Could not load secrets', getErrorDetails(e)); | ||
NotificationsService.addNotification({ | ||
id: "create-builder-list-secrets-error", | ||
type: "error", | ||
message: "Could not load secrets.", | ||
details: getErrorDetails(e) | ||
}); | ||
}); | ||
|
||
DataService.get("imagestreams", scope.imageName, {namespace: (scope.namespace || $routeParams.project)}).then(function(imageStream){ | ||
|
@@ -279,7 +291,7 @@ angular.module("openshiftConsole") | |
var helpLinks = {}; | ||
|
||
TaskList.clear(); | ||
TaskList.add(titles, helpLinks, $routeParams.project, function(){ | ||
TaskList.add(titles, helpLinks, $routeParams.project, function() { | ||
var d = $q.defer(); | ||
DataService.batch(generatedResources, context) | ||
//refactor these helpers to be common for 'newfromtemplate' | ||
|
@@ -313,16 +325,7 @@ angular.module("openshiftConsole") | |
} | ||
); | ||
return d.promise; | ||
}, | ||
function(result) { // failure | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assume DataService.batch was never resulting in a rejected promise? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We were passing an extra argument to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah yep didnt have my curly braces matched up right, got it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation and nesting makes it really hard to follow in this file :( |
||
$scope.alerts["create"] = | ||
{ | ||
type: "error", | ||
message: "An error occurred creating the application.", | ||
details: "Status: " + result.status + ". " + result.data | ||
}; | ||
} | ||
); | ||
}); | ||
Navigate.toNextSteps($scope.name, $scope.projectName, { | ||
usingSampleRepo: $scope.usingSampleRepo(), | ||
breadcrumbTitle: breadcrumbTitle | ||
|
@@ -351,12 +354,16 @@ angular.module("openshiftConsole") | |
}; | ||
|
||
var showWarningsOrCreate = function(result){ | ||
// Hide any previous notifications. | ||
hideErrorNotifications(); | ||
// Now that all checks are completed, show any Alerts if we need to | ||
var quotaAlerts = result.quotaAlerts || []; | ||
var errorAlerts = _.filter(quotaAlerts, {type: 'error'}); | ||
if ($scope.nameTaken || !_.isEmpty(errorAlerts)) { | ||
quotaAlerts = result.quotaAlerts || []; | ||
if ($scope.nameTaken || _.some(quotaAlerts, { type: 'error' })) { | ||
$scope.disableInputs = false; | ||
$scope.quotaAlerts = quotaAlerts; | ||
_.each(quotaAlerts, function(alert) { | ||
alert.id = _.uniqueId('create-builder-alert-'); | ||
NotificationsService.addNotification(alert); | ||
}); | ||
} | ||
else if (!_.isEmpty(quotaAlerts)) { | ||
launchConfirmationDialog(quotaAlerts); | ||
|
@@ -373,7 +380,7 @@ angular.module("openshiftConsole") | |
|
||
$scope.createApp = function(){ | ||
$scope.disableInputs = true; | ||
$scope.alerts = {}; | ||
hideErrorNotifications(); | ||
$scope.buildConfig.envVars = keyValueEditorUtils.compactEntries($scope.buildConfigEnvVars); | ||
$scope.deploymentConfig.envVars = keyValueEditorUtils.compactEntries($scope.DCEnvVarsFromUser); | ||
var userLabels = keyValueEditorUtils.mapEntries(keyValueEditorUtils.compactEntries($scope.userDefinedLabels)); | ||
|
@@ -401,4 +408,9 @@ angular.module("openshiftConsole") | |
nameTakenPromise.then(setNameTaken, setNameTaken).then(showWarningsOrCreate, showWarningsOrCreate); | ||
}; | ||
})); | ||
|
||
$scope.cancel = function() { | ||
hideErrorNotifications(); | ||
Navigate.toProjectOverview($scope.projectName); | ||
}; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only change to dependencies is
NotificationsService
. But I sorted and reformatted the list.