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

Support EnvFrom in the Env Editors #2133

Merged
merged 1 commit into from
Sep 27, 2017

Conversation

cdcabrera
Copy link
Contributor

@cdcabrera cdcabrera commented Sep 21, 2017

https://trello.com/c/rOB7X4pj

Add dropdown support to give the ability to add bulk additions within the environment editors. Design documentation located here

Notes:

  • Comment clean up still required
  • CSS/Styling
  • Some awkward behavior around validation and allowing a save when removing the last "envFrom" entry

sep-28-2017 09-42-03

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.

@cdcabrera Great start. One general comment on names containing valueFrom.

Can you look at the logic here?

https://github.com/openshift/origin-web-console/blob/master/app/scripts/directives/editEnvironmentVariables.js#L50-L57

We have some code to check if the environment has changed on watch updates. We'll want to check envFrom as well.

bindings: {
addRowLink: '@',
entries: '=',
valueFromSelectorOptions: '<',
Copy link
Member

Choose a reason for hiding this comment

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

envFromOptions ?

Copy link
Contributor Author

@cdcabrera cdcabrera Sep 21, 2017

Choose a reason for hiding this comment

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

np, can change. Just reused the valueFromSelectorOptions since it helps generate the same list... can change the name no problem

return _.includes(cannotDeleteSome, name);
};

ctrl.isValueFromReadonly = function() {
Copy link
Member

Choose a reason for hiding this comment

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

We should avoid valueFrom in names throughout this control. That refers specifically to choosing an individual key from a secret. It's going to get confusing if we use that in names for envFrom.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 21, 2017
@spadgett spadgett added this to the 3.7.0 milestone Sep 22, 2017
@cdcabrera
Copy link
Contributor Author

@openshift/team-ux-review need some input on the tooltip copy for the Environment From section...

The original tooltip copy that shows up in the designs...

All keys from these config maps and secrets will be added as environment variables.

And a possible alternative...

Environment From lets you add all key value pairs from a config map or secret.

@cdcabrera
Copy link
Contributor Author

@spadgett looks like updating the Environment Service requires an update to the associated unit test, or some additional checks within the service.

I could update the test to avoid this failure by placing an empty array for envFrom: [] within the expected results?

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 22, 2017
@spadgett
Copy link
Member

I could update the test to avoid this failure by placing an empty array for envFrom: [] within the expected results?

This is fine as long as we handle the case where envFrom is missing from the resource we pass in. It's an optional field.

@cdcabrera
Copy link
Contributor Author

cdcabrera commented Sep 25, 2017

@spadgett verified the "env" vs "envFrom" aspects of the unit tests. Behavior appears to be the same with the addition of an empty array vs the missing resource. Going to push the updated unit test change.

Edit: there is a minor difference where "env" comes back as a literal undefined and envFrom won't appear at all in the testing... there may be an additional process running on "env" vs "envFrom" or vice versa

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 25, 2017
@cdcabrera cdcabrera force-pushed the envfrom-enveditors branch 2 times, most recently from ffb97c1 to 24e22d2 Compare September 25, 2017 19:07
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 25, 2017
ng-if="$ctrl.showHeader"
class="key-value-editor-entry key-value-editor-entry-header">
<div class="form-group key-value-editor-header value-header">
<div class="input-group">
Copy link
Member

Choose a reason for hiding this comment

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

Why wrap in a form-group and input-group?

Copy link
Contributor Author

@cdcabrera cdcabrera Sep 26, 2017

Choose a reason for hiding this comment

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

Part of the classes copied over from the variables component (heads up... may be some clean up there too), also part of the CSS clean up we've been going through, lots of extras to remove.

Copy link
Member

@spadgett spadgett Sep 26, 2017

Choose a reason for hiding this comment

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

OK to leave if it's reusing the styles and needed

@@ -0,0 +1,94 @@
<ng-form name="forms.editEnvironmentFrom" novalidate>
Copy link
Member

Choose a reason for hiding this comment

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

Should this be $ctrl.editEnvironmentFrom here and below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that a vote to remove the ng-form?

I may be able to, but was under the impression we were trying to maintain the parent-child relationship with the parent form?

Copy link
Member

Choose a reason for hiding this comment

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

You should be able to keep ng-form and use $ctrl.editEnvironmentForm I think. Is this sharing the same form object as the parent? I don't think that should be necessary.

<div class="faux-form-control readonly">
Set to values in {{entry.selectedEnvFrom.kind | humanizeKind : true | lowercase}}
<span
ng-if="!('configmaps' | canI : 'get') || !('secrets' | canI : 'get')">
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look right. If the value is a config map, we should be able to link to that even if I can't view secrets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can adjust the logic, look at separating it out

href=""
class="add-row-link"
role="button"
aria-label="Add row"
Copy link
Member

Choose a reason for hiding this comment

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

Probably don't want aria-label here so that the screen reader uses addRowLink

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove sure thing, just heads up... it's copied from the variables display

Copy link
Member

Choose a reason for hiding this comment

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

Let's fix it there, too.

<span class="pficon pficon-info"
aria-hidden="true"
data-toggle="tooltip"
data-original-title="Environment From lets you add all key value pairs from a config map or secret."></span>
Copy link
Member

Choose a reason for hiding this comment

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

"Environment From lets you add all key-value pairs from a config map or secret as environment variables."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy update, np

@spadgett
Copy link
Member

We might rethink the "View Secret" link since it navigates away from the page, losing your edits.

cc @beanh66

@spadgett
Copy link
Member

I noticed the highlighted item is not very legible:

screen shot 2017-09-26 at 9 23 12 am


<h4>
Environment From
<span class="pficon pficon-info"
Copy link
Member

Choose a reason for hiding this comment

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

We usually use a ?(pficon-help) for these tooltips, for instance:

openshift web console 2017-09-26 09-25-53

@beanh66 Any objection to switching for consistency?

@spadgett
Copy link
Member

spadgett commented Sep 26, 2017

These labels should be updated as well as in the design:

openshift web console 2017-09-26 09-30-50

@spadgett
Copy link
Member

I think the "Variables" heading is self-evident. I wonder if we should just remove that heading?

@spadgett
Copy link
Member

Mobile styles are off:

openshift web console 2017-09-26 09-39-33

@spadgett
Copy link
Member

Need to fix experience when logged in as a project viewer. You can add a user with view role using the Resources -> Membership page.

openshift web console 2017-09-26 10-10-03

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 26, 2017
@beanh66
Copy link
Member

beanh66 commented Sep 26, 2017

@spadgett agreed on the view secret link! I talked to @cdcabrera about having the link be called "View Details" or "View Variables" instead and clicking the link would pop a modal to display the secret or config map variables (rather than navigating away). I also mentioned that if we go this route, the link should be available right away after a selection is made. Previously we were only showing that link after the save button was clicked. Thoughts?

@benjaminapetersen
Copy link
Contributor

Seeing some premature collapse of the "x" to a new column @ tablet-ish size:

screen shot 2017-09-26 at 4 38 43 pm

ctrl.$onInit = function() {
ctrl.updateEnvFromEntries(ctrl.entries);
findReferenceValueForEntries(ctrl.envFromEntries, ctrl.envFromSelectorOptions);

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you wanting to continue supporting cannotAdd, cannotSort, isReadonly, showHeader as the <key-value-editor> had them? If so, I'd prob suggest including them in bindings above. I believe this chunk of if statements was so you could put the attrib on the DOM node w/o a value:

<edit-environment-from cannot-add></edit-environment-from>
<!-- both works -->
<edit-environment-from cannot-add="'true'"></edit-environment-from>

}
});
};

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: for consistency, prob can drop the angular.extend and just do ctrl.dragControlListeners = since the rest of the file uses this style.


var canI = $filter('canI');
var humanizeKind = $filter('humanizeKind');

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you are using ctrl.$id in the view, so can prob change this to var id.


<div
class="form-group key-value-editor-input"
ng-class="{ 'has-error': (forms.editEnvironmentFrom[uniqueForValue(unique, $index)].$invalid && forms.editEnvironmentFrom[uniqueForValue(unique, $index)].$touched) }">
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the has-error class will ever be applied, as uniqueForValue is a function that doesn't exist. It is added to $scope in key-value-editor, if you want to use it prob need to add it as $ctrl.uniqueForValue.

https://github.com/openshift/origin-web-console/blob/master/app/scripts/directives/keyValueEditor.js#L207-L208

Copy link
Contributor

Choose a reason for hiding this comment

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

Also in uniqueForValue(unique, $index), unique is $scope.unique, which is also missing here (would be ctrl.unique).
https://github.com/openshift/origin-web-console/blob/master/app/scripts/directives/keyValueEditor.js#L202

Copy link
Contributor

Choose a reason for hiding this comment

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

Btw, the uniqueFor helpers are to generate uniqueIds for the inputs, and match up the labels, has-error classes, etc.

https://github.com/openshift/origin-web-console/blob/master/app/views/directives/key-value-editor.html#L37

The ctrl.unique is used in key-value-editor to ensure that you can have more than one editor on a page w/o collisions. Basically forms.editEnvironmentFrom[uniqueForValue(unique, $index)] returns the matching id of one of the <input id="???"> elements.

Copy link
Contributor Author

@cdcabrera cdcabrera Sep 26, 2017

Choose a reason for hiding this comment

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

Agreed! Removing the forms reference from the earlier review and the lack of the uniqueForValue method seemed to build/accumulate, looks like an adjustment for the readonly section needs to take place

ng-href="{{entry.selectedEnvFrom | navigateResourceURL}}"
class="pficon"
ng-show="entry.selectedEnvFrom"
ng-click="$ctrl.viewDetail(entry)">View {{entry.selectedEnvFrom.kind | humanizeKind : true}}</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think $ctrl.viewDetail doesn't exist? the href works, tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeahhhhhhhh =), removing appears superfluous looks like it was from a previous iteration

<edit-environment-from
entries="container.envFrom"
selector-placeholder="Secret/Config Map"
env-from-selector-options="$ctrl.valueFromObjects"
Copy link
Contributor

Choose a reason for hiding this comment

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

See above about env-from-selector-options.

],
bindings: {
addRowLink: '@',
entries: '=',
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I'm crazy about envFromSelectorOptions...I'd at least like a comment about what it means. Its config for something, but at a glance I'm not sure what (might be my ignorance re: EnvironmentFrom).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An annotation couldn't hurt, we'll add one in

@cdcabrera
Copy link
Contributor Author

@spadgett @benjaminapetersen there's still a missing method around edit-environment-from.html and uniqueForValue to help generate unique select Ids...

  • the Read Only, in general, logic probably needs additional adjustment...
  • and the "has-error" class, which feels like it should be removed from the Read Only section
ng-class="{ 'has-error': ($ctrl.editEnvironmentFromForm[uniqueForValue(unique, $index)].$invalid && $ctrl.editEnvironmentFromForm[uniqueForValue(unique, $index)].$touched) }">

@spadgett
Copy link
Member

Let's fix the readonly state

openshift web console 2017-09-27 13-16-39


var canI = $filter('canI');
var humanizeKind = $filter('humanizeKind');
var namespace = $routeParams.project;
Copy link
Member

Choose a reason for hiding this comment

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

Better to pass the project in than read it from route params. But why is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the comment chain, related to the below dummy values referenced in editEnvironmentFrom.js

namespace: namespace
}
});
});
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather not set dummy values. Is there another way to handle this? Is this for handling secrets that have been deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the comment chain, we're removing this as discussed

ng-hide="$ctrl.cannotDeleteAny"
ng-click="$ctrl.deleteEntry($index, 1)"></a>
<a
ng-if="!$ctrl.editEnvironmentFromForm.$dirty"
Copy link
Member

Choose a reason for hiding this comment

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

We can't just check this form because the normal env var form above might have changed.

I suggest we handle "View Secret" as a follow on issue and remove it for now.

@@ -32,6 +34,21 @@
add-row-with-selectors-link="Add Environment Variable Using a Config Map or Secret"
show-header>
Copy link
Member

Choose a reason for hiding this comment

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

Just above this line:

add-row-link="Add Variable"
add-row-with-selectors-link="Add Variable from Config Map or Secret"

@beanh66
Copy link
Member

beanh66 commented Sep 27, 2017

@spadgett Do we want to change the Environment From title? @cdcabrera the field level help next to Environment From also doesn't appear to be using the PatternFly styling here, can you take a look? I liked your suggestion for the wording change regarding the tooltip though.

@spadgett
Copy link
Member

@cdcabrera the field level help next to Environment From also doesn't appear to be using the PatternFly styling here, can you take a look?

@beanh66 It's using the style we use for help tooltips throughout the console. I'm not opposed to changing, but I'd like to change them everywhere to be consistent (and probably out of scope for this PR).

That said, the icon is larger here than it is in other places. For instance, this is the build config editor with a similar help tooltip:

screen shot 2017-09-27 at 2 09 59 pm

@spadgett
Copy link
Member

openshift web console 2017-09-27 14-44-34

No secrets or config maps have been added as Environment From.
</div>
<div ng-if="entry.configMapRef.name || entry.secretRef.name" class="faux-form-control readonly">
Set to values in {{entry.configMapRef.name || entry.secretRef.name}}
Copy link
Member

Choose a reason for hiding this comment

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

Probably should say Use all keys and values from <kind> <name>.

Copy link
Member

Choose a reason for hiding this comment

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

Use all keys and values from
<span ng-if="entry.configMapRef.name">config map {{entry.configMapRef.name}}</span>
<span ng-if="entry.secretRef.name">secret {{entry.secretRef.name}}</span>

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 27, 2017
@spadgett spadgett changed the title [WIP] Support EnvFrom in the Env Editors Support EnvFrom in the Env Editors Sep 27, 2017
@spadgett
Copy link
Member

[merge]

@spadgett
Copy link
Member

@cdcabrera

Built /dist does not match what is committed, run 'grunt build' and include the results in your commit.

Add dropdown support to give the ability to add bulk additions within
the environment editors
@spadgett
Copy link
Member

[merge]

@openshift-bot
Copy link

Evaluated for origin web console merge up to 7165cef

@openshift-bot
Copy link

openshift-bot commented Sep 27, 2017

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin_web_console/284/) (Base Commit: ac5246b) (PR Branch Commit: 7165cef)

@openshift-bot openshift-bot merged commit 18330d5 into openshift:master Sep 27, 2017
@spadgett spadgett removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants