-
Notifications
You must be signed in to change notification settings - Fork 231
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
Bug 1505782 - Environment From Fix Drag & Order Display #2238
Bug 1505782 - Environment From Fix Drag & Order Display #2238
Conversation
@@ -52,7 +52,7 @@ | |||
</div> | |||
</div> | |||
|
|||
<div ng-if="!$ctrl.isReadonlyAny && !entry.isReadonlyValue" class="environment-from-editor-button"> | |||
<div ng-if="$ctrl.isEnvFromSelectable()" class="environment-from-editor-button"> |
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.
Going to look at placing the isReadonlyAny
and isReadonlyValue
back in...
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.
Separated out the options length check and encased both isReadonlyAny
and isReadonlyValue
within the isEnvFromReadonly
method
03a5544
to
d7a7b6c
Compare
entry.isReadonlyValue === true || | ||
((entry.secretRef || entry.configMapRef) && !entry.selectedEnvFrom) || | ||
_.isEmpty(ctrl.envFromSelectorOptions); | ||
return ctrl.isReadonlyAny || entry.isReadonlyValue === true || ((entry.secretRef || entry.configMapRef) && !entry.selectedEnvFrom); |
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 could simplify this a lot by just saying the whole thing is either read-only or it isn't. We currently don't have a need to make individual values read-only.
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 works, removing the "isReadonlyAny" and tweaking some of the related logic
@@ -50,11 +50,12 @@ | |||
ctrl.editEnvironmentFromForm.$setDirty(); | |||
}; | |||
|
|||
ctrl.isEnvFromSelectable = function() { |
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 suggest hasOptions
d7a7b6c
to
cda77e6
Compare
entry.isReadonlyValue === true || | ||
((entry.secretRef || entry.configMapRef) && !entry.selectedEnvFrom) || | ||
_.isEmpty(ctrl.envFromSelectorOptions); | ||
return entry.isReadonlyValue === true || ((entry.secretRef || entry.configMapRef) && !entry.selectedEnvFrom); |
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 was proposing getting rid of isReadonlyValue
and keeping only isReadonlyAny
:)
I don't think we have a need for only certain values being read only. Either the entire list is read only or it isn't
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.
Hahahaha whoops, I'll go the other direction...
Edit:
To remove some of the confusion around this considering a going to rename for the value to towards "isReadOnly".
The current Read Only behavior removes the related binding parameter/property that can be passed in individually, and relies only on the Options List being populated and a Can I check for Secrets and Config Maps.
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.
After trying to pick this apart looks like the piece around Secrets or Config maps and duplicate entries falls into a strange area. Specifically around when a user edits the Yaml and purposefully enters duplicates.
With the current version these duplicates become read only because they lack the additional property around "selectedEnvFrom" due to the way lodash and find is being used... this is unintended but has kinda given us an inadvertent solution to the duplicate issue. Similar to the below example...
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'm not sure I understand why we made duplicates read only, or missing secrets for that matter. Why prevent the user from editing those to fix the problem?
I think it should be a warning if it's there twice, but we shouldn't block it since it's not a validation error.
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.
Concur on the blocking at all, that shouldn't happen, and doesn't... kinda. The current implementation doesn't block a user from deleting or rearranging an item, just creating an additional duplicate/triplicate/quad/etc entry through the interface.
Can and will look at using lodash filter instead of find to handle the checks, this may correct the problem, keep you posted
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 looks like the aiming towards _.filter
achieved the desired result, no more entries being read only if they're duplicates. Leveraged the same concept to apply a temporary placeholder duplicate
class around the individual UI-Selects
@spadgett & @benjaminapetersen
On the Readonly state as an all or nothing piece... can push them up, just need a confirmation for the conditions on my local, which so far encompass...
- If options aren't populated, everything is Read Only
- If either the Secrets OR Config Maps "Can I" checks fail, everything is Read Only
- And finally, removed the block (similar to below) for binding attribute pass-through for Read Only
if('isReadonly' in $attrs) { ctrl.isReadonlyAny = true; }
/test |
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.
Just a couple optional nits, but works for me when tested. I still do see that flicker after edits, but that might be addressed in your other PR.
@@ -99,8 +100,23 @@ | |||
}); | |||
}; | |||
|
|||
var updateEnvFromEntries = function(entries) { | |||
ctrl.envFromEntries = entries || []; | |||
var getReferenceValues = function(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.
You might be able to nix the switch statements & eliminate some duplication with:
var getReferenceValues = function(option) {
var kindRef = _.camelCase(option.kind) + 'Ref';
return _.filter(ctrl.envFromEntries, [kindRef, 'name', option.metadata.name]);
};
(untested)
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.
Prob similar could be done to trim down lines 76-91
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.
@benjaminapetersen looks like coincidentally wiped some of the duplication out. Good catch on the switch
963e6d0
to
c5e53dd
Compare
}; | ||
|
||
ctrl.hasEntries = function() { | ||
return angular.toJson(ctrl.entries) !== '[{}]' && ctrl.entries && ctrl.entries.length >= 1; |
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.
return _.some(ctrl.entries, function(entry) {
return _.get(entry, 'configMapRef.name') || _.get(entry, 'secretRef.name');
});
break; | ||
} | ||
_.each(ctrl.envFromSelectorOptions, function(option) { | ||
_.each(getReferenceValues(option), function(val, i) { |
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 create two maps of options secretsByName
and configMapsByName
when options change. Then you can index directly into the map using configMapsByName[option.configMapRef.name]
, etc.
c5e53dd
to
2078a33
Compare
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(!ctrl.envFromEntries.length) { | ||
addEntry(ctrl.envFromEntries); | ||
} | ||
_.each(ctrl.envFromSelectorOptions, function(option) { | ||
optionsByName[option.metadata.name] = 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.
var secretsByName = {};
var configMapsByName = {};
_.each(ctrl.envFromSelectorOptions, function(option) {
switch(option.kind) {
case 'Secret':
secretsByName[option.metadata.name] = option;
break;
// ...
}
});
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.
b5f4b72
to
bdf9017
Compare
Fix for making sure the drag and order handles are hidden within a read only display
bdf9017
to
9dc660c
Compare
@cdcabrera The form is showing up as read only for me when it should be editable: |
I can no longer reproduce the readonly problem. |
/lgtm Needs #2367 to go in first or merge will fail |
/hold cancel |
Automatic merge from submit-queue. |
Fix for making sure the drag and drop/order handles are hidden within a read only display. Related to #2182
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1505782