mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Hide or button if needed (#116124)
This commit is contained in:
parent
27866cec6e
commit
9c3c489e48
4 changed files with 40 additions and 13 deletions
|
@ -81,6 +81,7 @@ export interface ExceptionBuilderProps {
|
|||
isAndDisabled: boolean;
|
||||
isNestedDisabled: boolean;
|
||||
isOrDisabled: boolean;
|
||||
isOrHidden?: boolean;
|
||||
listId: string;
|
||||
listNamespaceType: NamespaceType;
|
||||
listType: ExceptionListType;
|
||||
|
@ -103,6 +104,7 @@ export const ExceptionBuilderComponent = ({
|
|||
isAndDisabled,
|
||||
isNestedDisabled,
|
||||
isOrDisabled,
|
||||
isOrHidden = false,
|
||||
listId,
|
||||
listNamespaceType,
|
||||
listType,
|
||||
|
@ -433,6 +435,7 @@ export const ExceptionBuilderComponent = ({
|
|||
<EuiFlexItem grow={1}>
|
||||
<BuilderLogicButtons
|
||||
isOrDisabled={isOrDisabled ? isOrDisabled : disableOr}
|
||||
isOrHidden={isOrHidden}
|
||||
isAndDisabled={isAndDisabled ? isAndDisabled : disableAnd}
|
||||
isNestedDisabled={isNestedDisabled ? isNestedDisabled : disableNested}
|
||||
isNested={addNested}
|
||||
|
|
|
@ -34,6 +34,25 @@ describe('BuilderLogicButtons', () => {
|
|||
expect(wrapper.find('[data-test-subj="exceptionsNestedButton"] button')).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('it hides "or" button', () => {
|
||||
const wrapper = mount(
|
||||
<BuilderLogicButtons
|
||||
isAndDisabled={false}
|
||||
isOrDisabled={false}
|
||||
isOrHidden={true}
|
||||
isNestedDisabled={false}
|
||||
isNested={false}
|
||||
showNestedButton={false}
|
||||
onOrClicked={jest.fn()}
|
||||
onAndClicked={jest.fn()}
|
||||
onNestedClicked={jest.fn()}
|
||||
onAddClickWhenNested={jest.fn()}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(wrapper.find('[data-test-subj="exceptionsOrButton"] button')).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('it invokes "onOrClicked" when "or" button is clicked', () => {
|
||||
const onOrClicked = jest.fn();
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ interface BuilderLogicButtonsProps {
|
|||
isNested: boolean;
|
||||
isNestedDisabled: boolean;
|
||||
isOrDisabled: boolean;
|
||||
isOrHidden?: boolean;
|
||||
showNestedButton: boolean;
|
||||
onAddClickWhenNested: () => void;
|
||||
onAndClicked: () => void;
|
||||
|
@ -32,6 +33,7 @@ export const BuilderLogicButtons: React.FC<BuilderLogicButtonsProps> = ({
|
|||
isNested,
|
||||
isNestedDisabled = true,
|
||||
isOrDisabled = false,
|
||||
isOrHidden = false,
|
||||
showNestedButton = false,
|
||||
onAddClickWhenNested,
|
||||
onAndClicked,
|
||||
|
@ -50,18 +52,20 @@ export const BuilderLogicButtons: React.FC<BuilderLogicButtonsProps> = ({
|
|||
{i18n.AND}
|
||||
</MyEuiButton>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<MyEuiButton
|
||||
fill
|
||||
size="s"
|
||||
iconType="plusInCircle"
|
||||
onClick={onOrClicked}
|
||||
isDisabled={isOrDisabled}
|
||||
data-test-subj="exceptionsOrButton"
|
||||
>
|
||||
{i18n.OR}
|
||||
</MyEuiButton>
|
||||
</EuiFlexItem>
|
||||
{!isOrHidden && (
|
||||
<EuiFlexItem grow={false}>
|
||||
<MyEuiButton
|
||||
fill
|
||||
size="s"
|
||||
iconType="plusInCircle"
|
||||
onClick={onOrClicked}
|
||||
isDisabled={isOrDisabled}
|
||||
data-test-subj="exceptionsOrButton"
|
||||
>
|
||||
{i18n.OR}
|
||||
</MyEuiButton>
|
||||
</EuiFlexItem>
|
||||
)}
|
||||
{showNestedButton && (
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButton
|
||||
|
|
|
@ -129,7 +129,8 @@ export const EventFiltersForm: React.FC<EventFiltersFormProps> = memo(
|
|||
listNamespaceType: 'agnostic',
|
||||
ruleName: RULE_NAME,
|
||||
indexPatterns,
|
||||
isOrDisabled: true, // TODO: pending to be validated
|
||||
isOrDisabled: true,
|
||||
isOrHidden: true,
|
||||
isAndDisabled: false,
|
||||
isNestedDisabled: false,
|
||||
dataTestSubj: 'alert-exception-builder',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue