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

[release-4.5] Bug 1861433: Show descriptions for all dynamic form fields #6136

Merged
merged 1 commit into from Aug 20, 2020

Conversation

TheRealJon
Copy link
Member

Manual cherry pick of #6054

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. label Jul 28, 2020
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1861433, which is invalid:

  • expected the bug to target the "4.5.z" release, but it targets "4.6.0" instead
  • expected dependent Bugzilla bug 1854198 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is ON_QA instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1861433: Show descriptions for all dynamic form fields

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 bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. component/core Related to console core functionality labels Jul 28, 2020
@openshift-ci-robot openshift-ci-robot added the component/shared Related to console-shared label Jul 28, 2020
@TheRealJon
Copy link
Member Author

/bugzilla refresh

@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1861433, which is invalid:

  • expected dependent Bugzilla bug 1854198 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is ON_QA instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

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.

@TheRealJon TheRealJon changed the title Bug 1861433: Show descriptions for all dynamic form fields [release-4.5] Bug 1861433: Show descriptions for all dynamic form fields Jul 28, 2020
@spadgett
Copy link
Member

@TheRealJon Were there just a few small merge conflicts or did you have to rewrite this for 4.5? Can you point me to where the changes from 4.6 are?

@TheRealJon
Copy link
Member Author

There were not many conflicts. The high line count for changes came from moving some components around mainly. I'll leave some comments where the main changes were made.

Comment on lines 1 to +22
import * as _ from 'lodash';
import * as classnames from 'classnames';
import * as React from 'react';
import { FieldProps } from 'react-jsonschema-form';
import { JSONSchema6 } from 'json-schema';
import { getUiOptions } from 'react-jsonschema-form/lib/utils';
import { FieldProps, UiSchema } from 'react-jsonschema-form';
import SchemaField, {
SchemaFieldProps,
} from 'react-jsonschema-form/lib/components/fields/SchemaField';
import { LinkifyExternal, SelectorInput, Dropdown } from '@console/internal/components/utils';
import { AccordionContent, AccordionItem, AccordionToggle, Switch } from '@patternfly/react-core';
import { MatchExpressions } from '@console/operator-lifecycle-manager/src/components/descriptors/spec/match-expressions';
import { ResourceRequirements } from '@console/operator-lifecycle-manager/src/components/descriptors/spec/resource-requirements';
import { FieldSet, FormField } from './templates';
import { ConfigureUpdateStrategy } from '@console/internal/components/modals/configure-update-strategy-modal';
import {
ConfigureUpdateStrategy,
UPDATE_STRATEGY_DESCRIPTION,
} from '@console/internal/components/modals/configure-update-strategy-modal';
import {
NodeAffinity,
PodAffinity,
} from '@console/operator-lifecycle-manager/src/components/descriptors/spec/affinity';
import { MatchExpressions } from '@console/operator-lifecycle-manager/src/components/descriptors/spec/match-expressions';
import { getUiOptions } from 'react-jsonschema-form/lib/utils';
import { Switch } from '@patternfly/react-core';
import SchemaField, {
SchemaFieldProps,
} from 'react-jsonschema-form/lib/components/fields/SchemaField';
import { getSchemaErrors } from './utils';
import { getSchemaErrors, useSchemaDescription, useSchemaLabel } from './utils';
Copy link
Member Author

Choose a reason for hiding this comment

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

Almost all of this was from moving components around and adjusting types.


export const DescriptionField: React.FC<FieldProps> = ({ id, description }) =>
const Description = ({ id, description }) =>
Copy link
Member Author

Choose a reason for hiding this comment

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

Pulled this out so that it can be used in components that don't have all FieldProps.

<Description id={id} description={description} />
);

export const FormField: React.FC<FormFieldProps> = ({
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved FormField component from templates file and use instead of FieldWrapper component since these two were very similar components. Moving it here was mostly to prevent dependency cycles.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also refined the props for this component so that it's more easily reused between field and template components.

</dd>
</dl>
</FieldSet>
export const FieldSet: React.FC<FieldSetProps> = ({
Copy link
Member Author

Choose a reason for hiding this comment

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

Move FieldSet component from templates file to prevent dependency cycle.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same as FormField component. Refined props so that they are more easily reused or calculated in field or template components.

);
};

export const UpdateStrategyField: React.FC<FieldProps> = (props) => {
const { formData = {}, idSchema, onChange } = props;
export const ResourceRequirementsField: React.FC<FieldProps> = ({
Copy link
Member Author

Choose a reason for hiding this comment

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

This just got pushed down because of the other components that were added at the top of the file. The rest of the changes in this file were mostly just getting rid of the spread operator where FieldSet is used and making better use of the null coalescence operator.

Comment on lines +85 to 92
<FieldSet
defaultLabel={title}
idSchema={idSchema}
required={required}
schema={schema}
uiSchema={uiSchema}
>
<div className="co-dynamic-form__field-group-content">
Copy link
Member Author

Choose a reason for hiding this comment

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

New props for FieldSet and getting rid of spread operator

return (
<FieldSet {...props}>
{_.map(items, (item) => {
<FieldSet
Copy link
Member Author

Choose a reason for hiding this comment

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

New props for FieldSet

Comment on lines -2 to -40
import * as classnames from 'classnames';
import * as React from 'react';
import {
ArrayFieldTemplateProps,
FieldTemplateProps,
ObjectFieldTemplateProps,
FieldProps,
} from 'react-jsonschema-form';
import {
AccordionItem,
AccordionToggle,
AccordionContent,
Button,
Alert,
} from '@patternfly/react-core';
import { Button, Alert, FormHelperText } from '@patternfly/react-core';
import { MinusCircleIcon, PlusCircleIcon } from '@patternfly/react-icons';
import { JSON_SCHEMA_GROUP_TYPES } from './const';
import { getUiOptions, getSchemaType } from 'react-jsonschema-form/lib/utils';
import { ExpandCollapse } from '@console/internal/components/utils';

export const FieldLabel: React.FC<FieldLabelProps> = ({ htmlFor, label, required }) => (
<label className={classnames('form-label', { 'co-required': required })} htmlFor={htmlFor}>
{label}
</label>
);

export const FormField: React.FC<FormFieldProps> = ({
children,
displayTitle = true,
id,
required,
title,
}) => {
return (
<div id={`${id}_field`} className="form-group">
{displayTitle && <FieldLabel label={title || 'Value'} required={required} htmlFor={id} />}
{children}
</div>
);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is just from moving FieldSet and FormField components to the fields.tsx file.

Comment on lines -75 to -116
export const FieldSet: React.FC<FieldSetProps> = ({
children,
idSchema,
name,
required = false,
schema,
title,
uiSchema = {},
}) => {
const [expanded, setExpanded] = React.useState(false);
const options = getUiOptions(uiSchema);
const { label: showLabel = true } = options;
const displayName = (options?.title as string) ?? schema?.title ?? title ?? name;
const onToggle = (e) => {
e.preventDefault();
setExpanded((current) => !current);
};
return showLabel && displayName ? (
<div id={`${idSchema.$id}_field-group`} className="co-dynamic-form__field-group">
<AccordionItem>
<AccordionToggle
id={`${idSchema.$id}_accordion-toggle`}
onClick={onToggle}
isExpanded={expanded}
>
<label
className={classnames({ 'co-required': required })}
htmlFor={`${idSchema.$id}_accordion-content`}
>
{_.startCase(displayName)}
</label>
</AccordionToggle>
<AccordionContent id={`${idSchema.$id}_accordion-content`} isHidden={!expanded}>
{children}
</AccordionContent>
</AccordionItem>
</div>
) : (
<>{children}</>
);
};

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to fields.tsx

Comment on lines +26 to +33
const { showDescription = true } = props;
return (
<>
<div className="co-m-form-row">
<p>How should the pods be replaced when a new revision is created?</p>
</div>

{showDescription && (
<div className="co-m-form-row">
<p>{UPDATE_STRATEGY_DESCRIPTION}</p>
</div>
)}
Copy link
Member Author

Choose a reason for hiding this comment

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

Needed to override default description when one is provided through a descriptor or schema property.

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.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 29, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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

The pull request process is described here

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

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

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

@openshift-ci-robot
Copy link
Contributor

@openshift-bot: This pull request references Bugzilla bug 1861433, which is invalid:

  • expected dependent Bugzilla bug 1854198 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is ON_QA instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

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-bot
Copy link
Contributor

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

@openshift-ci-robot
Copy link
Contributor

@openshift-bot: This pull request references Bugzilla bug 1861433, which is invalid:

  • expected dependent Bugzilla bug 1854198 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is ON_QA instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

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.

@TheRealJon
Copy link
Member Author

/bugzilla refresh

@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1861433, which is invalid:

  • expected dependent Bugzilla bug 1854198 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is ON_QA instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

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-bot
Copy link
Contributor

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

@openshift-ci-robot
Copy link
Contributor

@openshift-bot: This pull request references Bugzilla bug 1861433, which is invalid:

  • expected dependent Bugzilla bug 1854198 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is ON_QA instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

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-bot
Copy link
Contributor

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

@openshift-ci-robot
Copy link
Contributor

@openshift-bot: This pull request references Bugzilla bug 1861433, which is invalid:

  • expected dependent Bugzilla bug 1854198 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is ON_QA instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

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-bot
Copy link
Contributor

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

@openshift-ci-robot
Copy link
Contributor

@openshift-bot: This pull request references Bugzilla bug 1861433, which is invalid:

  • expected dependent Bugzilla bug 1854198 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is ON_QA instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

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.

@TheRealJon
Copy link
Member Author

/bugzilla refresh

@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1861433, which is valid. The bug has been moved to the POST state.

6 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.z) matches configured target release for branch (4.5.z)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
  • dependent bug Bugzilla bug 1854198 is in the state VERIFIED, which is one of the valid states (VERIFIED, RELEASE_PENDING, CLOSED (ERRATA))
  • dependent Bugzilla bug 1854198 targets the "4.6.0" release, which is one of the valid target releases: 4.6.0, 4.6.z
  • bug has dependents

In response to this:

/bugzilla refresh

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 bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Aug 3, 2020
@jwforres jwforres added the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Aug 20, 2020
@openshift-merge-robot openshift-merge-robot merged commit b8c0309 into openshift:release-4.5 Aug 20, 2020
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: All pull requests linked via external trackers have merged: openshift/console#6136. Bugzilla bug 1861433 has been moved to the MODIFIED state.

In response to this:

[release-4.5] Bug 1861433: Show descriptions for all dynamic form fields

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.

@spadgett spadgett added this to the v4.5.z milestone Aug 20, 2020
@TheRealJon TheRealJon deleted the 1861433-bz branch January 27, 2022 21:54
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. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. component/core Related to console core functionality component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants