-
Notifications
You must be signed in to change notification settings - Fork 232
Adjust radio buttons to drop down selector on create storage page #997
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
Conversation
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.
Hi @zherman0, a few comments. Can you add a screenshot?
<div class="help-block"> | ||
Type: {{sclass.parameters.type}} | Zone: {{sclass.parameters.zone}} | ||
<span ng-if="sclass.metadata.annotations.description"> | {{sclass.metadata.annotations.description}}</span> | ||
<a ng-href="{{'storage_classes' | helpLink}}" target="_blank">Learn more <i class="fa fa-external-link" aria-hidden="true"> </i></a> |
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.
We've switched the learn more links to headline case, "Learn More"
</span> | ||
</ui-select-match> | ||
<ui-select-choices | ||
repeat="sclass as sclass in storageClasses | orderBy: 'metadata.name'"> |
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.
We should enable type ahead filtering. Here's an example:
description: "No storage class will be assigned unless a default class has been assigned by the system administrator." | ||
} | ||
} | ||
}; |
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.
My understanding is the default storage class has an annotation, so we should know if there is one and which one it is. I think we can improve the user experience here. Rather than a dummy "no storage class" option, we might just let users leave the field blank and then say in the help text what the default is (when there is a default).
cc @jwforres
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.
@spadgett - how do I create a none option in the drop down. Currently, after you select an option, you cannot unselect. This why I added the "No Storage Class" option. I would like to remove it if the user can choose blank or none in the drop down.
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.
Yeah it's a quirk with ui-select. There is an issue in their repo to add this, but it's not supported natively in their widget. We solved it in osc-secrets.html by adding an x
beside the field to clear, although it made more sense there because you could have more than one secret.
I'm OK with "No Storage Class", but we might want to change the label to "Use Default Storage Class" when there is a default.
repeat="sclass as sclass in storageClasses | orderBy: 'metadata.name'"> | ||
<div>{{ sclass.metadata.name }}</div> | ||
<div ng-if="sclass | annotation : 'description'"> | ||
<small> </small> |
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.
Rather than non-breaking spaces, we should use CSS margins.
This can probably all be one small
tag.
} | ||
} | ||
}; | ||
storageClasses._data["No Storage Class"] = noclass; |
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.
You should not be changing _data
directly. That is a private field.
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.
It's also cached by DataService and shared across controllers, so anyone else asking for storage classes would get the "no storage class" item you added.
Suggest we keep the description on the same line and use We might want to stack the description at mobile resolutions, though. |
Made all updated suggestions and created slightly different UX for whether a default storage class was set by admin or not, please note the newly attach images. |
repeat="sclass as sclass in storageClasses | toArray | filter : { metadata: { name: $select.search } } | orderBy: 'metadata.name'"> | ||
<div>{{ sclass.metadata.name }} | ||
<span ng-if="sclass | annotation : 'description'" class="text-muted"> | ||
<small> - |
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.
Use &ndash
(or maybe —
)
<small ng-if="sclass | annotation : 'description'" class="text-muted">
–
...
</small>
If there's not enough margin, you could use
<small ng-if="sclass | annotation : 'description'" class="text-muted mar-left-sm">
–
...
</small>
<div id="claim-storage-class-help" class="help-block mar-bottom-lg"> | ||
<span ng-if="defaultStorageClass">"{{defaultStorageClass}}" is currently set as the default storage class.<br/></span> |
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.
I'd remove the <br>
and move this after the description to be consistent with help text we use on other forms.
<div id="claim-storage-class-help" class="help-block mar-bottom-lg">
Storage classes are set by the administrator to define types of storage the users can select.
<span ng-if="defaultStorageClass">If not set, default storage class <var>{{defaultStorageClass}}</var> will be used.</span>
</div>
I'm curious why mar-bottom-lg
is needed. I thought the help-block
and learn-more-block
styles had appropriate margins. It's better not to set it if we can avoid it so that spacing is consistent across pages.
if ("annotations" in sclass.metadata && defaultClassAnnotation in sclass.metadata.annotations && sclass.metadata.annotations[defaultClassAnnotation] === "true") { | ||
scope.defaultStorageClass = sclass.metadata.name; | ||
} | ||
}); |
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.
This can be
var annotation = $filter('annotation');
scope.defaultStorageClass = _.find(scope.storageClasses, function(storageClass) {
return annotation(storageClass, 'storageclass.beta.kubernetes.io/is-default-class') === 'true';
});
You'll need to add dependency $filter
above when declaring the the directive.
Even better to add a isDefaultStorageClass
method to StorageService
, though. Then this becomes
scope.defaultStorageClass = _.find(scope.storageClasses, StorageService.isDefaultStorageClass);
Note that this sets it to the object rather than the name.
scope.defaultStorageClass = sclass.metadata.name; | ||
} | ||
}); | ||
if (scope.defaultStorageClass === "") { //if there is no default, set a no storage class option |
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.
if (!scope.defaultStorageClass) { ... }
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.
I think we can leave the "no storage class" option even if there is a default as long as we say the default will be used in the help text. cc @jwforres opinion?
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.
i havent been following the whole thread, but if we are able to know there is a default then 'no storage class' doesn't really make sense as the option. If we know which storage class is the default I would rather see us pre-select that option and have an indicator like (Default) next to that name.
If we know there is a default but don't know which one is the default, then I would expect "No Storage Class" just becomes "Default storage class"
If we have no way at all to know if there is a default, then yeah we are stuck with "No storage class" and explaining it in the help text that it may select the default if one exists.
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.
If we know which storage class is the default I would rather see us pre-select that option and have an indicator like (Default) next to that name.
I'm fine with that. I wasn't sure if there is ever a reason to leave it blank instead of explicitly setting the default.
name: "No Storage Class", | ||
labels: {}, | ||
annotations: { | ||
description: "No storage class will be assigned unless a default class has been assigned by the system administrator." |
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.
This description doesn't make sense if we're only showing the option when there's no default.
</ui-select-match> | ||
<ui-select-choices | ||
repeat="sclass as sclass in storageClasses | toArray | filter : { metadata: { name: $select.search } } | orderBy: 'metadata.name'"> | ||
<div>{{ sclass.metadata.name }} |
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.
So that the filter match is highlighted:
<div>
<span ng-bind-html="sclass.metadata.name | highlight : $select.search"><span>
...
</div>
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.
the match is highlighted with the code I have in place, but your suggestion truncates the descriptions
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.
the match is highlighted with the code
I pulled down your changes, and it's not highlighting the matching text.
The truncation is because of this CSS style.
@rhamilto Can we remove or change that style? It's caused problems more than once :/
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.
Sorry, @rhamilto I'm wrong. The problem is a typo because the span is not closed.
<span ng-bind-html="sclass.metadata.name | highlight : $select.search"></span>
@zherman0 ping |
@spadgett - I am getting back to this now, should have the latest round of requests done by tomorrow |
@spadgett - how does this look now? |
@zherman0 I don't think I see the updates. Did you forget to |
Try now please
…On Wed, Jan 11, 2017 at 2:22 PM, Sam Padgett ***@***.***> wrote:
@zherman0 <https://github.com/zherman0> I don't think I seeing the
updates. Did you forget to git add?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#997 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AR3HmZeS-IVZGYvN2o7qYcQQ8XA3PfAdks5rRUgqgaJpZM4LGw1j>
.
--
Zac Herman
<[email protected]>
Emerging Tech - Senior Software Engineer
Red Hat Inc
|
if (!scope.defaultStorageClass) { //if there is no default, set a no storage class option | ||
var noclass = { | ||
metadata: { | ||
name: "\u0020No Storage Class", //unicode char to make this first alphabetically |
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.
unicode char to make this first alphabetically
I'd rather sort the list in the controller and prepend the no class option.
DataService.list({group: 'storage.k8s.io', resource: 'storageclasses'}, {}, function(storageClassData) {
var storageClasses = storageClassData.by('metadata.name');
scope.storageClasses = _.orderBy(storageClasses, 'metadata.name');
// ...
if (!scope.defaultStorageClass) {
// ...
scope.storageClasses.unshift(noclass);
}
Then remove the orderBy
from the view.
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.
This will perform better as well since you're not resorting the list on every Angular digest loop, just once when we request it.
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.
hey @spadgett - I am trying to do the change with the _orderBy, but it keeps throwing an exception and I cannot figure out why. The call works fine. I need to do the orderBy to get the object to an array so I can do the unshift call.
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.
Sorry, _.orderBy
is lodash v4. We have v3, which uses _.sortBy
. Try
scope.storageClasses = _.sortBy(storageClasses, 'metadata.name');
Storage classes are set by the administrator to define types of storage the users can select. | ||
<span ng-if="defaultStorageClass"> If not set, default storage class <var>{{defaultStorageClass.metadata.name}}</var> will be used.</span> |
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.
If I'm reading the code right, there's no way to NOT set a storage class when there's a default since there's no empty option. In which case we don't need this message. But we should make sure the default is initially selected in the controller.
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.
I think the message is still important so users understand why they do not have the option to chose no storage class.
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.
That's fair, but I think we need to adjust the wording still since "If not set" isn't possible. And we should preselect the default.
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.
@spadgett - can you help me set the default? For some reason I cannot get it to work.
if (!scope.defaultStorageClass) { //if there is no default, set a no storage class option | ||
var noclass = { | ||
metadata: { | ||
name: "No Storage Class", //unicode char to make this first alphabetically |
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.
Remove the comment since it no longer applies
labels: {}, | ||
annotations: { | ||
description: "No storage class will be assigned" | ||
} |
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.
indentation
<div id="claim-storage-class-help" class="help-block mar-bottom-lg"> | ||
<label>Storage Class</label> | ||
<div> | ||
<ui-select |
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.
indentation
search-enabled="true" | ||
title="Select a storage class" | ||
class="select-role" | ||
flex> |
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.
Missed this on previous review, but I don't think flex
is necessary here. Can you try without?
Storage classes are set by the administrator to define types of storage the users can select. | ||
<span ng-if="defaultStorageClass"> If not set, default storage class <var>{{defaultStorageClass.metadata.name}}</var> will be used.</span> |
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.
That's fair, but I think we need to adjust the wording still since "If not set" isn't possible. And we should preselect the default.
Does this work? scope.defaultStorageClass = _.find(scope.storageClasses, function(storageClass) {
return annotation(storageClass, 'storageclass.beta.kubernetes.io/is-default-class') === 'true';
});
if (scope.defaultStorageClass) {
scope.claim.storageClass = scope.defaultStorageClass;
} else {
// if there is no default, set a no storage class option
// ...
} |
@@ -95,7 +95,7 @@ angular.module('openshiftConsole') | |||
_.set(pvc, 'spec.selector.matchLabels', selectorLabel); | |||
} | |||
} | |||
if ($scope.claim.storageClass ) { | |||
if ($scope.claim.storageClass && $scope.claim.storageClass.metadata.name !== "No Storage Class") { |
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.
The controller probably shouldn't know this detail of the pvc directive's implementation, but we can fix in a follow on.
[merge] |
Evaluated for origin web console merge up to 888a686 |
Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/933/) (Base Commit: 04dcf30) |
Removed radio buttons for storage classes in favor of drop down selector in case the number of storage classes is very large