Skip to content

Commit

Permalink
feat: backport
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfrancois committed Oct 24, 2023
1 parent 2085bc0 commit 4886736
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export default class ArrayWidget extends Component {
<Widget
{...this.props}
{...extraProps}
index={index}
disabled={this.props.schema.disabled}
id={this.props.id && `${this.props.id}-${index}`}
schema={getArrayElementSchema(this.props.schema, index)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { InlineMessageInformation } from '@talend/design-system';
import CollapsiblePanel from '@talend/react-components/lib/CollapsiblePanel';
import { InlineMessageInformation, CollapsiblePanel } from '@talend/design-system';
import get from 'lodash/get';
import Widget from '../../Widget';
import { generateDescriptionId } from '../../Message/generateId';
Expand Down Expand Up @@ -75,34 +74,38 @@ export function defaultTitle(formData, schema, options) {
export default function createCollapsibleFieldset(title = defaultTitle) {
function CollapsibleFieldset(props) {
function toggle(event) {

Check warning on line 76 in packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.js#L76

[@typescript-eslint/no-unused-vars] 'event' is defined but never used.
event.stopPropagation();
event.preventDefault();
// event.stopPropagation();
// event.preventDefault();
const payload = {
schema: props.schema,
value: {
...props.value,
isClosed: !props.value.isClosed,
},
};
props.onChange(event, payload);
props.onChange(undefined, payload);
}

const { id, schema, value, actions, ...restProps } = props;
const { id, schema, value, actions, index, ...restProps } = props;
const { items } = schema;
const displayAction = actions.map(action => ({
...action,
displayMode: CollapsiblePanel.displayModes.TYPE_ACTION,
}));

return (
<fieldset
className={classNames('form-group', theme['collapsible-panel'], 'collapsible-panel')}
>
<CollapsiblePanel
id={`${id}`}
header={[{ label: title(value, schema) }, displayAction]}
title={title(value, schema)}
onToggleExpanded={toggle}
onToggle={toggle}
index={index}
managed
expanded={!value.isClosed}
action={
actions?.[0] && {
...actions[0],
callback: actions[0].onClick,
}
}
>
{schema.description ? (
<InlineMessageInformation
Expand All @@ -115,8 +118,8 @@ export default function createCollapsibleFieldset(title = defaultTitle) {
) : (
''
)}
{items.map((itemSchema, index) => (
<Widget {...restProps} id={id} key={index} schema={itemSchema} value={value} />
{items.map((itemSchema, idx) => (
<Widget {...restProps} id={id} key={idx} schema={itemSchema} value={value} />
))}
</CollapsiblePanel>
</fieldset>
Expand All @@ -132,6 +135,7 @@ export default function createCollapsibleFieldset(title = defaultTitle) {
if (process.env.NODE_ENV !== 'production') {

Check warning on line 135 in packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.js#L135

[no-undef] 'process' is not defined.
CollapsibleFieldset.propTypes = {
id: PropTypes.string,
index: PropTypes.number,
onChange: PropTypes.func.isRequired,
schema: PropTypes.shape({
items: PropTypes.array.isRequired,
Expand Down

0 comments on commit 4886736

Please sign in to comment.