-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Cases] Delete custom field #167167
[Cases] Delete custom field #167167
Changes from 7 commits
de7fdd1
49f83df
f97a383
69f0e41
8f8829b
5b71acc
65c2bcd
b31832f
80a5eb2
c54bb61
927d4b8
d35b8ae
4e4bdab
e605af4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,20 @@ | |
|
||
import React, { useMemo } from 'react'; | ||
import { sortBy } from 'lodash'; | ||
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import { css } from '@emotion/react'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiText, useEuiTheme } from '@elastic/eui'; | ||
|
||
import type { CasesConfigurationUI } from '../../../common/ui'; | ||
import { builderMap as customFieldsBuilderMap } from '../custom_fields/builder'; | ||
import * as i18n from './translations'; | ||
|
||
interface Props { | ||
isLoading: boolean; | ||
customFieldsConfiguration: CasesConfigurationUI['customFields']; | ||
} | ||
|
||
const CustomFieldsComponent: React.FC<Props> = ({ isLoading, customFieldsConfiguration }) => { | ||
const { euiTheme } = useEuiTheme(); | ||
const sortedCustomFields = useMemo( | ||
() => sortCustomFieldsByLabel(customFieldsConfiguration), | ||
[customFieldsConfiguration] | ||
|
@@ -41,6 +45,17 @@ const CustomFieldsComponent: React.FC<Props> = ({ isLoading, customFieldsConfigu | |
|
||
return ( | ||
<EuiFlexGroup direction="column" gutterSize="s"> | ||
{customFieldsComponents.length ? ( | ||
<EuiText | ||
size="m" | ||
css={css` | ||
font-weight: ${euiTheme.font.weight.bold}; | ||
`} | ||
> | ||
{i18n.ADDITIONAL_FIELDS} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed this header from the designs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about using an |
||
</EuiText> | ||
) : null} | ||
<EuiSpacer size="xs" /> | ||
<EuiFlexItem data-test-subj="create-case-custom-fields">{customFieldsComponents}</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import React, { useCallback, useMemo } from 'react'; | |
import { Form, useForm } from '@kbn/es-ui-shared-plugin/static/forms/hook_form_lib'; | ||
import { isEmpty } from 'lodash'; | ||
import { NONE_CONNECTOR_ID } from '../../../common/constants'; | ||
import { CaseSeverity } from '../../../common/types/domain'; | ||
import { CaseSeverity, CustomFieldTypes } from '../../../common/types/domain'; | ||
import type { FormProps } from './schema'; | ||
import { schema } from './schema'; | ||
import { getNoneConnector, normalizeActionConnector } from '../configure_cases/utils'; | ||
|
@@ -106,9 +106,11 @@ export const FormContext: React.FC<Props> = ({ | |
|
||
for (const [key, value] of Object.entries(customFields)) { | ||
const configCustomField = customFieldsConfiguration.find((item) => item.key === key); | ||
const fieldValue = isEmpty(value) ? null : [value]; | ||
|
||
if (configCustomField) { | ||
const fieldValue = | ||
configCustomField.type === CustomFieldTypes.TEXT && isEmpty(value) ? null : [value]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a bug where you switch the toggle field as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of checking specifically for a custom field type we can do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check still have issue when When we have more custom fields in future, we can create some util function to handle different types. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, you are right. Ok! |
||
|
||
transformedCustomFields.push({ | ||
key: configCustomField.key, | ||
type: configCustomField.type, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that the whole component should not be returned if the are no custom fields configured. Maybe we can either return
null
for the whole component ({customFieldsComponents.length ? ( <EuiFlexGroup direction="column" gutterSize="s">....
) or inx-pack/plugins/cases/public/components/create/form.tsx
check ifcustomFieldsConfiguration
and not renderCustomFields
if they are empty.