Skip to content

Commit d3900fe

Browse files
committed
Added 'no projects and cant create' empty state to process-template, deploy-image, and from-file
1 parent a7bc1f0 commit d3900fe

File tree

12 files changed

+517
-410
lines changed

12 files changed

+517
-410
lines changed

app/scripts/directives/deployImage.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ angular.module("openshiftConsole")
2525
controller: function($scope) {
2626
// Must be initialized the controller. The link function is too late.
2727
$scope.forms = {};
28+
$scope.noProjectsCantCreate = false;
2829
},
2930
link: function($scope) {
3031
$scope.input = {
@@ -44,6 +45,12 @@ angular.module("openshiftConsole")
4445
value: ''
4546
}];
4647

48+
var noProjectsCantCreateWatch;
49+
50+
noProjectsCantCreateWatch = $scope.$on('no-projects-cannot-create', function() {
51+
$scope.noProjectsCantCreate = true;
52+
});
53+
4754
var orderByDisplayName = $filter('orderByDisplayName');
4855
var getErrorDetails = $filter('getErrorDetails');
4956

@@ -387,7 +394,10 @@ angular.module("openshiftConsole")
387394
// button is outside the component since it is in the wizard footer. Listen
388395
// for an event for when the button is clicked.
389396
$scope.$on('newAppFromDeployImage', $scope.create);
390-
$scope.$on('$destroy', hideErrorNotifications);
397+
$scope.$on('$destroy', function() {
398+
hideErrorNotifications();
399+
noProjectsCantCreateWatch();
400+
});
391401
}
392402
};
393403
});

app/scripts/directives/deployImageDialog.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
function DeployImageDialog($scope, $routeParams, DataService) {
2121
var ctrl = this;
22+
var noProjectsCantCreateWatch;
2223

2324
ctrl.$onInit = function() {
2425
ctrl.loginBaseUrl = DataService.openshiftAPIBaseUrl();
@@ -27,6 +28,9 @@
2728
if (!$routeParams.project) {
2829
ctrl.showProjectName = true;
2930
}
31+
noProjectsCantCreateWatch = $scope.$on('no-projects-cannot-create', function() {
32+
ctrl.deployForm.$setValidity('required', false);
33+
});
3034
};
3135

3236
ctrl.deployImage = function() {
@@ -40,6 +44,10 @@
4044
ctrl.currentStep = "Results";
4145
});
4246

47+
ctrl.$onDestroy = function() {
48+
noProjectsCantCreateWatch();
49+
};
50+
4351
ctrl.close = function() {
4452
var cb = ctrl.onDialogClosed();
4553
if (_.isFunction(cb)) {

app/scripts/directives/fromFile.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,17 @@ angular.module("openshiftConsole")
2323
templateUrl: "views/directives/from-file.html",
2424
controller: function($scope) {
2525
var aceEditorSession;
26+
var noProjectsCantCreateWatch;
27+
$scope.noProjectsCantCreate = false;
28+
2629
var humanizeKind = $filter('humanizeKind');
2730
var getErrorDetails = $filter('getErrorDetails');
2831
TaskList.clear();
2932

33+
noProjectsCantCreateWatch = $scope.$on('no-projects-cannot-create', function() {
34+
$scope.noProjectsCantCreate = true;
35+
});
36+
3037
$scope.input = {
3138
selectedProject: $scope.project
3239
};
@@ -511,7 +518,10 @@ angular.module("openshiftConsole")
511518
// button is outside the component since it is in the wizard footer. Listen
512519
// for an event for when the button is clicked.
513520
$scope.$on('importFileFromYAMLOrJSON', $scope.create);
514-
$scope.$on('$destroy', hideErrorNotifications);
521+
$scope.$on('$destroy', function() {
522+
hideErrorNotifications();
523+
noProjectsCantCreateWatch();
524+
});
515525
}
516526
};
517527
});

app/scripts/directives/fromFileDialog.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
function FromFileDialog($scope, $timeout, $routeParams, $filter, DataService) {
2323
var ctrl = this;
24+
var noProjectsCantCreateWatch;
2425
var annotation = $filter('annotation');
2526
var imageForIconClass = $filter('imageForIconClass');
2627

@@ -31,6 +32,9 @@
3132
if (!$routeParams.project) {
3233
ctrl.showProjectName = true;
3334
}
35+
noProjectsCantCreateWatch = $scope.$on('no-projects-cannot-create', function() {
36+
ctrl.importForm.$setValidity('required', false);
37+
});
3438
};
3539

3640
function getIconClass() {
@@ -109,5 +113,9 @@
109113
}
110114
return true;
111115
};
116+
117+
ctrl.$onDestroy = function() {
118+
noProjectsCantCreateWatch();
119+
};
112120
}
113121
})();

app/scripts/directives/processTemplate.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
var displayName = $filter('displayName');
5151
var humanize = $filter('humanize');
5252

53+
var noProjectsCantCreateWatch;
54+
ctrl.noProjectsCantCreate = false;
55+
5356
function getHelpLinks(template) {
5457
var helpLinkName = /^helplink\.(.*)\.title$/;
5558
var helpLinkURL = /^helplink\.(.*)\.url$/;
@@ -80,6 +83,11 @@
8083
ctrl.template = angular.copy(ctrl.template);
8184
ctrl.templateDisplayName = displayName(ctrl.template);
8285
ctrl.selectedProject = ctrl.project;
86+
87+
noProjectsCantCreateWatch = $scope.$on('no-projects-cannot-create', function() {
88+
ctrl.noProjectsCantCreate = true;
89+
});
90+
8391
setTemplateParams();
8492
};
8593

@@ -261,7 +269,10 @@
261269
// button is outside the component since it is in the wizard footer. Listen
262270
// for an event for when the button is clicked.
263271
$scope.$on('instantiateTemplate', ctrl.createFromTemplate);
264-
$scope.$on('$destroy', hideNotificationErrors);
272+
$scope.$on('$destroy', function() {
273+
hideNotificationErrors();
274+
noProjectsCantCreateWatch();
275+
});
265276

266277
var shouldAddAppLabel = function() {
267278
// If the template defines its own app label, we don't need to add one at all

0 commit comments

Comments
 (0)