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

fix(892): use a LongTextField for Expression field #927

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/ui-tests/cypress/support/next-commands/design.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ Cypress.Commands.add('interactWithDataformatInputObject', (inputName: string, va

Cypress.Commands.add('interactWithConfigInputObject', (inputName: string, value?: string) => {
if (value !== undefined && value !== null) {
cy.get(`input[name="${inputName}"]`).clear();
cy.get(`input[name="${inputName}"]`).type(value);
cy.get(`input[name="${inputName}"], textarea[name="${inputName}"]`).clear();
cy.get(`input[name="${inputName}"], textarea[name="${inputName}"]`).type(value);
} else {
cy.get(`input[name="${inputName}"]`).click();
cy.get(`input[name="${inputName}"], textarea[name="${inputName}"]`).click();
}
});

Cypress.Commands.add('checkConfigCheckboxObject', (inputName: string, value: boolean) => {
const checked = value ? '' : 'not.';
cy.get(`input[name="${inputName}"]`).should(`${checked}be.checked`);
cy.get(`input[name="${inputName}"], textarea[name="${inputName}"]`).should(`${checked}be.checked`);
});

Cypress.Commands.add('checkConfigInputObject', (inputName: string, value: string) => {
cy.get(`input[name="${inputName}"]`).should('have.value', value);
cy.get(`input[name="${inputName}"], textarea[name="${inputName}"]`).should('have.value', value);
});

Cypress.Commands.add('removeNodeByName', (nodeName: string, nodeIndex?: number) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"lint:style:fix": "yarn lint:style --fix"
},
"dependencies": {
"@kaoto-next/uniforms-patternfly": "^0.6.6",
"@kaoto-next/uniforms-patternfly": "^0.6.8",
"@kie-tools-core/editor": "0.32.0",
"@kie-tools-core/notifications": "0.32.0",
"@patternfly/patternfly": "5.2.0",
Expand Down
20 changes: 16 additions & 4 deletions packages/ui/src/components/Form/CustomAutoField.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { DateField, ListField, NestField, RadioField, TextField, BoolField } from '@kaoto-next/uniforms-patternfly';
import {
BoolField,
DateField,
ListField,
LongTextField,
NestField,
RadioField,
TextField,
} from '@kaoto-next/uniforms-patternfly';
import { createAutoField } from 'uniforms';
import { TypeaheadField } from './customField/TypeaheadField';
import { DisabledField } from './customField/DisabledField';
import { getValue } from '../../utils';
import { BeanReferenceField } from './bean/BeanReferenceField';
import { DisabledField } from './customField/DisabledField';
import { TypeaheadField } from './customField/TypeaheadField';
import { ExpressionAwareNestField } from './expression/ExpressionAwareNestField';
import { ExpressionField } from './expression/ExpressionField';
import { PropertiesField } from './properties/PropertiesField';
Expand All @@ -16,7 +25,8 @@ export const CustomAutoField = createAutoField((props) => {
return props.checkboxes && props.fieldType !== Array ? RadioField : TypeaheadField;
}

const comment = props['$comment'] as string;
const title = getValue(props, 'field.title');
const comment = getValue(props, '$comment');
// Assuming generic object field without any children to use PropertiesField
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (props.fieldType === Object && (props.field as any)?.type === 'object' && !(props.field as any)?.properties) {
Expand Down Expand Up @@ -45,6 +55,8 @@ export const CustomAutoField = createAutoField((props) => {
/* catalog preprocessor put 'string' as a type and the javaType as a schema $comment */
if (comment?.startsWith('class:')) {
return BeanReferenceField;
} else if (title === 'Expression') {
return LongTextField;
}
return TextField;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ describe('ExpressionAwareNestField', () => {

const expressionInput = screen
.getAllByRole('textbox')
.filter((textbox) => textbox.getAttribute('label') === 'Expression');
.filter((textbox) => textbox.getAttribute('name') === 'expression');
expect(expressionInput).toHaveLength(1);
expect(expressionInput[0].getAttribute('value')).toEqual('${body}');
expect(expressionInput[0].textContent).toEqual('${body}');
act(() => {
fireEvent.input(expressionInput[0], { target: { value: '${header.foo}' } });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ describe('ExpressionField', () => {

const expressionInput = screen
.getAllByRole('textbox')
.filter((textbox) => textbox.getAttribute('label') === 'Expression');
.filter((textbox) => textbox.getAttribute('name') === 'expression');
expect(expressionInput).toHaveLength(1);
expect(expressionInput[0].getAttribute('value')).toEqual('${body}');
expect(expressionInput[0].textContent).toEqual('${body}');
act(() => {
fireEvent.input(expressionInput[0], { target: { value: '${header.foo}' } });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ describe('ExpressionModalLauncher', () => {

const expressionInput = screen
.getAllByRole('textbox')
.filter((textbox) => textbox.getAttribute('label') === 'Expression');
.filter((textbox) => textbox.getAttribute('name') === 'expression');
expect(expressionInput).toHaveLength(1);
expect(expressionInput[0].getAttribute('value')).toEqual('${body}');
expect(expressionInput[0].textContent).toEqual('${body}');
expect(mockOnChange.mock.calls).toHaveLength(0);
expect(mockOnConfirm.mock.calls).toHaveLength(0);
act(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe('CanvasForm', () => {
});
const expressionInput = screen
.getAllByRole('textbox')
.filter((textbox) => textbox.getAttribute('label') === 'Expression');
.filter((textbox) => textbox.getAttribute('name') === 'expression');
const applyBtn = screen.getAllByRole('button').filter((button) => button.textContent === 'Apply');
act(() => {
fireEvent.input(expressionInput[0], { target: { value: '${header.foo}' } });
Expand Down Expand Up @@ -279,7 +279,7 @@ describe('CanvasForm', () => {
});
const expressionInput = screen
.getAllByRole('textbox')
.filter((textbox) => textbox.getAttribute('label') === 'Expression');
.filter((textbox) => textbox.getAttribute('name') === 'expression');
const applyBtn = screen.getAllByRole('button').filter((button) => button.textContent === 'Apply');
act(() => {
fireEvent.input(expressionInput[0], { target: { value: '${header.foo}' } });
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2453,7 +2453,7 @@ __metadata:
"@babel/preset-react": ^7.18.6
"@babel/preset-typescript": ^7.21.5
"@kaoto-next/camel-catalog": "workspace:*"
"@kaoto-next/uniforms-patternfly": ^0.6.6
"@kaoto-next/uniforms-patternfly": ^0.6.8
"@kie-tools-core/editor": 0.32.0
"@kie-tools-core/notifications": 0.32.0
"@patternfly/patternfly": 5.2.0
Expand Down Expand Up @@ -2528,16 +2528,16 @@ __metadata:
languageName: unknown
linkType: soft

"@kaoto-next/uniforms-patternfly@npm:^0.6.6":
version: 0.6.6
resolution: "@kaoto-next/uniforms-patternfly@npm:0.6.6"
"@kaoto-next/uniforms-patternfly@npm:^0.6.8":
version: 0.6.8
resolution: "@kaoto-next/uniforms-patternfly@npm:0.6.8"
dependencies:
invariant: ^2.2.4
lodash: ^4.17.21
react: ^18.2.0
react-dom: ^18.2.0
uniforms: 4.0.0-alpha.5
checksum: 57cff54c6cd2739bcbea8fd79b7570b4fea89f9ce3a305ab8d716afc16ce01935dada2ede89e70e5f417cfd92eee4dedb0365db969c71948112734975362fe29
checksum: 882aa818eba9af30b73fd54a7f0b5c17871feda34e53b6fedb098662fc8f4206387fa2dccc077d9a8437133d90a1ab5e80349c3db6e7dc540abedf609cb5371f
languageName: node
linkType: hard

Expand Down
Loading