Skip to content

Commit 71a047b

Browse files
Do not allow 'Select from Project' when there are no projects
1 parent fe5fdfe commit 71a047b

File tree

6 files changed

+177
-153
lines changed

6 files changed

+177
-153
lines changed

app/scripts/controllers/landingPage.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ angular.module('openshiftConsole')
1111
DataService,
1212
Navigate,
1313
NotificationsService,
14+
ProjectsService,
1415
RecentlyViewedServiceItems,
1516
GuidedTourService,
1617
HTMLService,
@@ -20,6 +21,7 @@ angular.module('openshiftConsole')
2021
$location) {
2122
var tourConfig = _.get(Constants, 'GUIDED_TOURS.landing_page_tour');
2223
var tourEnabled = tourConfig && tourConfig.enabled && tourConfig.steps;
24+
var watches = [];
2325

2426
$scope.saasOfferings = Constants.SAAS_OFFERINGS;
2527

@@ -103,12 +105,21 @@ angular.module('openshiftConsole')
103105
$scope.catalogItems = items;
104106
dataLoaded();
105107
}));
108+
ProjectsService.list().then(function(projectData) {
109+
var projects = _.toArray(projectData.by('metadata.name'));
110+
$scope.projectsExist = _.size(projects) > 0;
111+
watches.push(ProjectsService.watch($scope, function(projectData){
112+
var projects = _.toArray(projectData.by('metadata.name'));
113+
$scope.projectsExist = _.size(projects) > 0;
114+
}));
115+
});
106116
});
107117

108118
$scope.$on('$destroy', function() {
109119
// If the template dialog was open when the scope was destroyed, still
110120
// add the item to recently-viewed. No-op if the dialog is not open.
111121
addTemplateToRecentlyViewed();
122+
DataService.unwatchAll(watches);
112123
});
113124

114125
function findParamServiceItem() {

app/scripts/directives/processTemplateDialog.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898

9999
ctrl.projectEmptyState = {
100100
title: 'No Project Selected',
101-
info: 'Please select a project from the dropdown to load Templates from that project.'
101+
info: 'Please select a project from the dropdown to load templates from that project.'
102102
};
103103

104104
ctrl.templatesEmptyState = {
@@ -326,6 +326,12 @@
326326
ctrl.searchEnabled = !_.isEmpty(filteredProjects);
327327

328328
ctrl.templateProjects = RecentlyViewedProjectsService.orderByMostRecentlyViewed(projects);
329+
ctrl.numTemplateProjects = _.size(ctrl.templateProjects);
330+
331+
if (ctrl.numTemplateProjects === 1) {
332+
ctrl.templateProject = _.head(ctrl.templateProjects);
333+
ctrl.templateProjectChange();
334+
}
329335
};
330336

331337
function listProjects() {

app/views/directives/process-template-dialog/process-template-select.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<div class="select-project-for-template">
44
<h2>Select from Project</h2>
55
<ui-select
6+
ng-disabled="$ctrl.numTemplateProjects < 2"
67
name="selectProject"
78
ng-model="$ctrl.templateProject"
89
ng-change="$ctrl.templateProjectChange()"

app/views/landing-page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
base-project-url="project"
2121
on-deploy-image-selected="deployImageSelected"
2222
on-from-file-selected="fromFileSelected"
23-
on-create-from-project="fromProjectSelected">
23+
on-create-from-project="projectsExist ? fromProjectSelected : undefined">
2424
</services-view>
2525
</landingbody>
2626
<landingside>

0 commit comments

Comments
 (0)