Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
import '@testing-library/jest-dom';
import { act, fireEvent, render, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { EntityType } from '../../../enums/entity.enum';
import {
DataContract,
Expand Down Expand Up @@ -624,6 +625,28 @@ describe('ContractSecurityFormTab', () => {
expect(form).toBeInTheDocument();
});

it('keeps a tag field collapsed so the rest of the form stays accessible', async () => {
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
const onSubmit = jest.fn((event: Event) => event.preventDefault());
const { container } = render(
<ContractSecurityFormTab {...commonProps} />
);
container.querySelector('form')?.addEventListener('submit', onSubmit);
const identities = within(
screen.getByTestId('identities-input-0')
).getByRole('combobox');

await user.click(identities);
await user.type(identities, 'user1{Enter}');
await user.keyboard('{ArrowDown}');

expect(screen.getByText('user1')).toBeInTheDocument();
expect(identities).toHaveAttribute('aria-expanded', 'false');
// Role queries skip aria-hidden nodes, which an open combobox creates.
expect(screen.getByRole('button', { name: /next/i })).toBeInTheDocument();
expect(onSubmit).not.toHaveBeenCalled();
});

it('should have proper labels for form fields', () => {
render(<ContractSecurityFormTab {...commonProps} />);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import { useTranslation } from 'react-i18next';
import { ReactComponent as DeleteIcon } from '../../../assets/svg/ic-trash.svg';
import { SUPPORTED_ROW_FILTER_ENTITIES } from '../../../constants/DataContract.constants';
import { TAG_INPUT_COMBOBOX_PROPS } from '../../../constants/Form.constants';
import { EntityType } from '../../../enums/entity.enum';
import {
ContractSecurity,
Expand Down Expand Up @@ -130,6 +131,7 @@
name,
placeholder,
props: {
...TAG_INPUT_COMBOBOX_PROPS,
allowsCreation: true,
'data-testid': testId,
hideDropdown: true,
Expand Down Expand Up @@ -362,7 +364,7 @@
const security = initialValues?.security;
form.reset(toFormValues(security, columnItems));
setEditingKey(isEmpty(security) || !isEmpty(security?.policies) ? 0 : null);
}, [initialValues?.security]);

Check warning on line 367 in openmetadata-ui/src/main/resources/ui/src/components/DataContract/ContractSecurityFormTab/ContractSecurityFormTab.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useEffect has missing dependencies: 'columnItems' and 'form'. Either include them or remove the dependency array

useEffect(() => {
const { unsubscribe } = form.watch((values, { type }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Plus, Trash01 } from '@openmetadata/ui-core-components/icons';
import { useCallback, useMemo } from 'react';
import { Control, useFieldArray, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { TAG_INPUT_COMBOBOX_PROPS } from '../../../constants/Form.constants';
import { EntityType } from '../../../enums/entity.enum';
import { useEntityRules } from '../../../hooks/useEntityRules';
import { validateReferenceURL } from '../../../utils/GlossaryPureUtils';
Expand Down Expand Up @@ -118,6 +119,7 @@ const AddGlossaryTermForm = ({
name: 'synonyms',
placeholder: t('message.synonym-placeholder'),
props: {
...TAG_INPUT_COMBOBOX_PROPS,
'data-testid': 'synonyms',
allowsCreation: true,
hideDropdown: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import { useTranslation } from 'react-i18next';
import { NO_DATA_PLACEHOLDER } from '../../../../constants/constants';
import { EntityField } from '../../../../constants/Feeds.constants';
import { TAG_INPUT_COMBOBOX_PROPS } from '../../../../constants/Form.constants';
import { MAX_VISIBLE_SYNONYMS } from '../../../../constants/Glossary.contant';
import { GlossaryTerm } from '../../../../generated/entity/data/glossaryTerm';
import { ChangeDescription } from '../../../../generated/entity/type';
Expand Down Expand Up @@ -161,7 +162,7 @@
</BadgeWithButton>
);

const getSynonyms = () =>

Check warning on line 165 in openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/tabs/GlossaryTermSynonyms.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

The 'getSynonyms' function makes the dependencies of useCallback Hook (at line 268) change on every render. Move it inside the useCallback callback. Alternatively, wrap the definition of 'getSynonyms' in its own useCallback() Hook
!canEditAll || !isEmpty(synonyms) ? (
<Box align="center" gap={1} wrap="wrap">
{(isListExpanded
Expand Down Expand Up @@ -304,6 +305,7 @@
ref={editorRef}
onKeyDownCapture={handleEditorKeyDownCapture}>
<Autocomplete
{...TAG_INPUT_COMBOBOX_PROPS}
allowsCreation
hideDropdown
multiple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import { isArray, isEmpty, isObject, startCase } from 'lodash';
import { Key, KeyboardEvent, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { TAG_INPUT_COMBOBOX_PROPS } from '../../../constants/Form.constants';
import { DEPRECATED_SSO_PROPERTIES } from '../../../constants/Services.constant';
import { useClipboard } from '../../../hooks/useClipBoard';
import { splitCSV } from '../../../utils/CSV/CSVPureUtils';
Expand Down Expand Up @@ -145,7 +146,7 @@
: uniqueValues;
props.onChange(convertedValue);
}
}, [onPasteFromClipBoard, props.onChange, value, isUrlField, isScopeField]);

Check warning on line 149 in openmetadata-ui/src/main/resources/ui/src/components/SettingsSso/SSOConfigurationForm/SsoConfigurationFormArrayFieldTemplate.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useCallback has a missing dependency: 'props'. Either include it or remove the dependency array. However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the useCallback call and refer to those specific props inside useCallback

const handleInputSplit = useCallback(
(inputValue: string) => {
Expand Down Expand Up @@ -175,7 +176,7 @@
props.onChange(convertedValue);
}
},
[value, props.onChange, isUrlField, isScopeField]

Check warning on line 179 in openmetadata-ui/src/main/resources/ui/src/components/SettingsSso/SSOConfigurationForm/SsoConfigurationFormArrayFieldTemplate.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useCallback has a missing dependency: 'props'. Either include it or remove the dependency array. However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the useCallback call and refer to those specific props inside useCallback
);

const handleChange = useCallback(
Expand All @@ -194,13 +195,13 @@
props.formContext.clearFieldError(props.idSchema.$id);
}
},
[isScopeField, props.onChange, props.formContext, props.idSchema.$id]

Check warning on line 198 in openmetadata-ui/src/main/resources/ui/src/components/SettingsSso/SSOConfigurationForm/SsoConfigurationFormArrayFieldTemplate.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useCallback has a missing dependency: 'props'. Either include it or remove the dependency array. However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the useCallback call and refer to those specific props inside useCallback
);

const handleBlur = useCallback(() => {
const convertedValue = isScopeField ? value.join(' ') : value;
props.onBlur(id, convertedValue);
}, [isScopeField, value, props.onBlur, id]);

Check warning on line 204 in openmetadata-ui/src/main/resources/ui/src/components/SettingsSso/SSOConfigurationForm/SsoConfigurationFormArrayFieldTemplate.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useCallback has a missing dependency: 'props'. Either include it or remove the dependency array. However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the useCallback call and refer to those specific props inside useCallback

const isDeprecated = useMemo(
() =>
Expand Down Expand Up @@ -231,6 +232,7 @@
</Grid.Item>
<Grid.Item className="layout-column tw:mt-1" span={24}>
<Autocomplete
{...(options ? undefined : TAG_INPUT_COMBOBOX_PROPS)}
multiple
allowsCreation={!options}
aria-label={startCase(props.name)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import React, { Key, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { ReactComponent as CopyLeft } from '../../../../../assets/svg/copy-left.svg';
import { TAG_INPUT_COMBOBOX_PROPS } from '../../../../../constants/Form.constants';
import { useClipboard } from '../../../../../hooks/useClipBoard';
import { splitCSV } from '../../../../../utils/CSV/CSVPureUtils';
const WorkflowArrayFieldTemplate = (props: FieldProps) => {
Expand Down Expand Up @@ -71,7 +72,7 @@
e.stopPropagation();
await onCopyToClipBoard();
},
[value, onCopyToClipBoard]

Check warning on line 75 in openmetadata-ui/src/main/resources/ui/src/components/common/Form/JSONSchema/JSONSchemaTemplate/WorkflowArrayFieldTemplate.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useCallback has an unnecessary dependency: 'value'. Either exclude it or remove the dependency array
);

const handlePaste = useCallback(async () => {
Expand All @@ -98,7 +99,7 @@
const uniqueValues = Array.from(new Set([...value, ...processedValues]));
props.onChange(uniqueValues);
}
}, [onPasteFromClipBoard, props.onChange, value]);

Check warning on line 102 in openmetadata-ui/src/main/resources/ui/src/components/common/Form/JSONSchema/JSONSchemaTemplate/WorkflowArrayFieldTemplate.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useCallback has a missing dependency: 'props'. Either include it or remove the dependency array. However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the useCallback call and refer to those specific props inside useCallback

const handleInputSplit = useCallback(
(inputValue: string) => {
Expand All @@ -111,7 +112,7 @@
const uniqueValues = Array.from(new Set([...value, ...processedValues]));
props.onChange(uniqueValues);
},
[value, props.onChange]

Check warning on line 115 in openmetadata-ui/src/main/resources/ui/src/components/common/Form/JSONSchema/JSONSchemaTemplate/WorkflowArrayFieldTemplate.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useCallback has a missing dependency: 'props'. Either include it or remove the dependency array. However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the useCallback call and refer to those specific props inside useCallback
);

return (
Expand All @@ -128,6 +129,7 @@
span={24}>
<div className="tw:min-w-0 tw:flex-1">
<Autocomplete
{...(options ? undefined : TAG_INPUT_COMBOBOX_PROPS)}
multiple
allowsCreation={!options}
aria-label={startCase(props.name)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
const NAME_PATTERN_MESSAGE = String(i18n.t('message.entity-name-validation'));
const DISPLAY_NAME_SIZE_MESSAGE = sizeMessage('label.display-name');

// TODO(open-metadata/openmetadata-collate#6893): drop the antd `Rule[]` shapes

Check warning on line 37 in openmetadata-ui/src/main/resources/ui/src/constants/Form.constants.ts

View check run for this annotation

SonarQubeCloud / [open-metadata-ui] SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=open-metadata-ui&issues=AaFDic2XXgciB2bknv3w&open=AaFDic2XXgciB2bknv3w&pullRequest=35419
// once the last antd forms (alerts, custom metrics) move to react-hook-form.
export const NAME_FIELD_RULES: Rule[] = [
{ required: true, message: NAME_REQUIRED_MESSAGE },
Expand All @@ -60,3 +60,15 @@
message: DISPLAY_NAME_SIZE_MESSAGE,
},
};

/**
* Spread onto a creatable `Autocomplete` that has no suggestion list
* (`hideDropdown`). An open react-aria combobox aria-hides the rest of the
* page, so a field with nothing to list must not open: it never opens on focus
* or typing, and react-stately closes an empty list that a click or arrow key
* opened. Without this, a fast type → Enter → move-on could leave it open.
*/
export const TAG_INPUT_COMBOBOX_PROPS = {
allowsEmptyCollection: false,
menuTrigger: 'manual',
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import { List, Plus, Trash01 } from '@openmetadata/ui-core-components/icons';
import { Key, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { TAG_INPUT_COMBOBOX_PROPS } from '../../../constants/Form.constants';
import { JsonSchemaObject } from '../../../rest/taskFormSchemasAPI';
import {
buildDesignerSchema,
Expand All @@ -46,7 +47,7 @@
getDesignerPreviewPayload,
TaskFormDesignerField,
} from '../../../utils/TaskFormDesignerUtils';
import TaskPayloadSchemaFields from '../../TasksPage/shared/TaskPayloadSchemaFields';

Check warning on line 50 in openmetadata-ui/src/main/resources/ui/src/pages/TaskFormSettingsPage/components/TaskFormBuilderSection.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

Page features must not import another page feature. Move shared code to components, hooks, interfaces, or pure utilities

/** Switching field type keeps options only for selects and defaults JSON to an object. */
const withFieldType = (
Expand Down Expand Up @@ -239,8 +240,8 @@
data-testid={`${testIdPrefix}-field-type-${index}`}
items={FIELD_TYPE_OPTIONS}
label="Field type"
selectedKey={field.type}

Check warning on line 243 in openmetadata-ui/src/main/resources/ui/src/pages/TaskFormSettingsPage/components/TaskFormBuilderSection.tsx

View check run for this annotation

SonarQubeCloud / [open-metadata-ui] SonarCloud Code Analysis

'selectedKey' is deprecated.

See more on https://sonarcloud.io/project/issues?id=open-metadata-ui&issues=AaFDicoWXgciB2bknv3s&open=AaFDicoWXgciB2bknv3s&pullRequest=35419
onSelectionChange={(key) =>

Check warning on line 244 in openmetadata-ui/src/main/resources/ui/src/pages/TaskFormSettingsPage/components/TaskFormBuilderSection.tsx

View check run for this annotation

SonarQubeCloud / [open-metadata-ui] SonarCloud Code Analysis

'onSelectionChange' is deprecated.

See more on https://sonarcloud.io/project/issues?id=open-metadata-ui&issues=AaFDicoWXgciB2bknv3t&open=AaFDicoWXgciB2bknv3t&pullRequest=35419
key !== null &&
updateField(index, (currentField) =>
withFieldType(
Expand All @@ -260,8 +261,8 @@
data-testid={`${testIdPrefix}-field-schema-type-${index}`}
items={JSON_SCHEMA_TYPE_OPTIONS}
label="JSON shape"
selectedKey={field.schemaType ?? 'object'}

Check warning on line 264 in openmetadata-ui/src/main/resources/ui/src/pages/TaskFormSettingsPage/components/TaskFormBuilderSection.tsx

View check run for this annotation

SonarQubeCloud / [open-metadata-ui] SonarCloud Code Analysis

'selectedKey' is deprecated.

See more on https://sonarcloud.io/project/issues?id=open-metadata-ui&issues=AaFDicoWXgciB2bknv3u&open=AaFDicoWXgciB2bknv3u&pullRequest=35419
onSelectionChange={(key) =>

Check warning on line 265 in openmetadata-ui/src/main/resources/ui/src/pages/TaskFormSettingsPage/components/TaskFormBuilderSection.tsx

View check run for this annotation

SonarQubeCloud / [open-metadata-ui] SonarCloud Code Analysis

'onSelectionChange' is deprecated.

See more on https://sonarcloud.io/project/issues?id=open-metadata-ui&issues=AaFDicoWXgciB2bknv3v&open=AaFDicoWXgciB2bknv3v&pullRequest=35419
key !== null &&
updateField(index, (currentField) => ({
...currentField,
Expand All @@ -277,6 +278,7 @@

{supportsOptions ? (
<Autocomplete
{...TAG_INPUT_COMBOBOX_PROPS}
allowsCreation
hideDropdown
multiple
Expand Down
Loading