Skip to content

Commit

Permalink
Do not allow 'Select from Project' when there are no projects
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-phillips-18 committed Oct 30, 2017
1 parent fe5fdfe commit 71a047b
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 153 deletions.
11 changes: 11 additions & 0 deletions app/scripts/controllers/landingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ angular.module('openshiftConsole')
DataService,
Navigate,
NotificationsService,
ProjectsService,
RecentlyViewedServiceItems,
GuidedTourService,
HTMLService,
Expand All @@ -20,6 +21,7 @@ angular.module('openshiftConsole')
$location) {
var tourConfig = _.get(Constants, 'GUIDED_TOURS.landing_page_tour');
var tourEnabled = tourConfig && tourConfig.enabled && tourConfig.steps;
var watches = [];

$scope.saasOfferings = Constants.SAAS_OFFERINGS;

Expand Down Expand Up @@ -103,12 +105,21 @@ angular.module('openshiftConsole')
$scope.catalogItems = items;
dataLoaded();
}));
ProjectsService.list().then(function(projectData) {
var projects = _.toArray(projectData.by('metadata.name'));
$scope.projectsExist = _.size(projects) > 0;
watches.push(ProjectsService.watch($scope, function(projectData){
var projects = _.toArray(projectData.by('metadata.name'));
$scope.projectsExist = _.size(projects) > 0;
}));
});
});

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

function findParamServiceItem() {
Expand Down
8 changes: 7 additions & 1 deletion app/scripts/directives/processTemplateDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@

ctrl.projectEmptyState = {
title: 'No Project Selected',
info: 'Please select a project from the dropdown to load Templates from that project.'
info: 'Please select a project from the dropdown to load templates from that project.'
};

ctrl.templatesEmptyState = {
Expand Down Expand Up @@ -326,6 +326,12 @@
ctrl.searchEnabled = !_.isEmpty(filteredProjects);

ctrl.templateProjects = RecentlyViewedProjectsService.orderByMostRecentlyViewed(projects);
ctrl.numTemplateProjects = _.size(ctrl.templateProjects);

if (ctrl.numTemplateProjects === 1) {
ctrl.templateProject = _.head(ctrl.templateProjects);
ctrl.templateProjectChange();
}
};

function listProjects() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div class="select-project-for-template">
<h2>Select from Project</h2>
<ui-select
ng-disabled="$ctrl.numTemplateProjects < 2"
name="selectProject"
ng-model="$ctrl.templateProject"
ng-change="$ctrl.templateProjectChange()"
Expand Down
2 changes: 1 addition & 1 deletion app/views/landing-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
base-project-url="project"
on-deploy-image-selected="deployImageSelected"
on-from-file-selected="fromFileSelected"
on-create-from-project="fromProjectSelected">
on-create-from-project="projectsExist ? fromProjectSelected : undefined">
</services-view>
</landingbody>
<landingside>
Expand Down
Loading

0 comments on commit 71a047b

Please sign in to comment.