Skip to content
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

Inform the user when no projects to select templates from #2399

Merged
merged 1 commit into from
Oct 31, 2017

Conversation

jeff-phillips-18
Copy link
Member

@jeff-phillips-18 jeff-phillips-18 commented Oct 30, 2017

Also disables the project selection dropdown where there is but one project.

fixes #2396

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 30, 2017
@jeff-phillips-18
Copy link
Member Author

When there is one project and no templates:
image

ProjectsService.list().then(function(projectData) {
var projects = _.toArray(projectData.by('metadata.name'));
$scope.projectsExist = _.size(projects) > 0;
watches.push(ProjectsService.watch($scope, function(projectData){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't watch large project lists.

If you have hundreds or thousands of projects, it's not likely they'll all be deleted anyway while you're on this page :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They could delete the only project. I could handle no projects in the dialog to avoid the watch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They could delete the only project.

I'm saying only watch the project list if it's under a certain size like we do in other places.

@@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to pay the cost to convert to an array. I'd guess that _.isEmpty is constant time even for large maps because it only needs to check if at least one item exists.

var projects = projectsData.by('metadata.name');
$scope.projectsExist = !_.isEmpty(projects);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we need to know if there is 0, 1 or more than one. :/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we don't need to know that until the dialog comes up. Will fix.

@@ -3,6 +3,7 @@
<div class="select-project-for-template">
<h2>Select from Project</h2>
<ui-select
ng-disabled="$ctrl.numTemplateProjects < 2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a disabled select, is it better to just have static text saying the project name here? That's what we've done elsewhere in the console (e.g. container picker on the view logs tab).

If the select is disabled, I would wonder why. I don't think it's obvious because you only have one project.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the same, but @beanh66 thought it better to be consistent with the select-project component.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spadgett I was trying to be consistent with what we did for the catalog wizard @dtaylor113 worked on. When there is only 1 project there, the dropdown is disabled. @cshinn any thoughts?

@spadgett
Copy link
Member

I'm tempted to say just show a "no projects" empty state message in the dialog. It would also be consistent with the "no projects, can't create" message @dtaylor113 added to other dialogs. I'm a little worried these checks might be expensive just to decide whether to hide one link.

@jeff-phillips-18
Copy link
Member Author

I thought the same but since we cache the projects anyhow, thought maybe this would be the route to go. I'm ok with it either way. @beanh66?

@beanh66
Copy link
Member

beanh66 commented Oct 31, 2017

@jeff-phillips-18 that works, we can do something similar to what Dave has added for the catalog. I believe his says "No Projects Found" for the title with some description text.

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 31, 2017
@jeff-phillips-18 jeff-phillips-18 changed the title Do not allow 'Select from Project' when there are no projects Inform the user when no projects to select templates from Oct 31, 2017
@jeff-phillips-18
Copy link
Member Author

When there are no projects:
image

@jeff-phillips-18
Copy link
Member Author

When only one project:
image

@beanh66
Copy link
Member

beanh66 commented Oct 31, 2017

LGTM @jeff-phillips-18

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spadgett
Copy link
Member

/kind bug
/lgtm

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Oct 31, 2017
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 31, 2017
@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue.

@openshift-merge-robot openshift-merge-robot merged commit b066a73 into openshift:master Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Select from Project should not show if no projects
5 participants