Skip to content

Conversation

@yzhao583
Copy link
Contributor

This PR contains the change for the new "arrayFieldGroup" Spec Descriptor for the OLM Create Operand Form. With this descriptor, the Field Group can be added to the Field Group Array or removed from the Field Group Array.

Concepts

ArrayFieldGroup: ArrayFieldGroup is a Spec Descriptor which allows you to specify a set of fields together as an array item. Nested fields will automatically be grouped using the CRD’s OpenAPI validation.
Field Group: Field Group is a set of fields.
Field Group Array: Field Group Array is an array containing many Field Group.

X-descriptor Structure

The “arrayFieldGroup” x-descriptor allows users to specify a Field Group Array. In the array, each element is a Field Group, users can add/remove Field Group. The following image demonstrates the structure of the Descriptor.
image

Usage

  • Add the “arrayFieldGroup” x-descriptor into the “x-descriptors” array of the field object.

  • Replace the “FIELD_GROUP_ARRAY_NAME” with the real name.

@openshift-ci-robot
Copy link
Contributor

Hi @yzhao583. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. component/olm Related to OLM labels Jan 22, 2020
@spadgett
Copy link
Member

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 23, 2020
@spadgett
Copy link
Member

/assign @TheRealJon

@spadgett spadgett added this to the v4.4 milestone Jan 23, 2020
@tlwu2013
Copy link
Contributor

Hey @yzhao583 , it's noticed the "add/remove" behavior in this PR is a bit counterintuitive..

The "add/remove" behavior we were thinking is:
Screen Shot 2020-01-23 at 10 14 54 AM

Can you help check this out? Thanks!

@TheRealJon
Copy link
Member

TheRealJon commented Jan 23, 2020

For any others reviewing, this is the current functionality:
video-convert

And this is more along the lines of what Tony and I discussed:
image

@yzhao583 yzhao583 force-pushed the modify-arrayFieldGroup-descriptor-to-allow-add-or-remove-fields-from-the-group branch from b4b0bd2 to 9bf84e9 Compare January 24, 2020 02:08
@yzhao583
Copy link
Contributor Author

@tlwu2013 @TheRealJon @spadgett Thanks for the clarification. I really appreciate that. However, considering the time line, can we merge this PR as the initial implementation of this feature? I will submit another PR to fix the bug ASAP. Thanks.

Copy link
Member

@TheRealJon TheRealJon left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

I think this is ok to merge.

As follow on, I think we could improve readability by breaking out a few more helper functions, adding some comments, using string interpolation instead of concat where appropriate, and incorporating more ES6 syntax for manipulating and referencing collections.


const getArrayFieldGroups = () => {
const arrayFieldGroupList = fields.reduce(
(groups, field) =>
Copy link
Member

Choose a reason for hiding this comment

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

Should probably just use a const to hold the arrayFieldGroup value for the current field. It will make this easier to read an only iterate over the capabilities array once:

(groups, field) =>  {
  const arrayFieldGroup = field.capabilities.find((c) => c.startsWith(SpecCapability.arrayFieldGroup);
  return arrayFiledGroup ? groups.add(arrayFieldGroup) : groups;
}

const getArrayFieldGroups = () => {
const arrayFieldGroupList = fields.reduce(
(groups, field) =>
field.capabilities.find((c) => c.startsWith(SpecCapability.arrayFieldGroup))
Copy link
Member

Choose a reason for hiding this comment

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

No change needed now, but we should create a helper function to retrieve the arrayFieldGroup descriptor from a field.

.filter((f) => !_.isNil(inputFor(f)));

return (
!_.isEmpty(fieldList) && (
Copy link
Member

Choose a reason for hiding this comment

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

Not new, but just noticing that this could throw a runtime error if fieldList is empty. Need to explicitly return null if it is.

return (
!_.isEmpty(fieldList) && (
<div id={group} key={group}>
{[...arrayFieldGroups].filter((fieldGroup) =>
Copy link
Member

Choose a reason for hiding this comment

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

No need for spread operator here.

const groupNumIndex = pathInfoList.indexOf(groupInfo);
const groupIndex = group.split(groupName.concat(':'))[1];
const newGroupName = groupName
.concat('[')
Copy link
Member

Choose a reason for hiding this comment

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

Don't need to change now, but use string interpolation instead of chained concat.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 24, 2020
@spadgett
Copy link
Member

/approve

@spadgett spadgett added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 24, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: spadgett, TheRealJon, yzhao583

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@spadgett
Copy link
Member

/hold
for merge queue fix #4065

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 24, 2020
@spadgett
Copy link
Member

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 25, 2020
@openshift-merge-robot openshift-merge-robot merged commit 2ae261f into openshift:master Jan 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/olm Related to OLM lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants