-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dashboard] [Controls] Add
excludes
toggle to options list (#142780)
* Add buttons with no functionality * Added basic negate functionality * Add `NOT` text when negated * Clean up * Add jest and functional tests * Fix merge conflicts * Rename `negate` to `exclude` * Fix `unsaved changes` bug * Move erase button back to beside search * Clean up * Add chaining functional tests * Fix other unsaved changes bug * Fix mobile view of popover * Add option to disable exclude/include toggle * Prevent unsaved changes bug for options list settings * Add tooltip to run past timeout setting * Address review comments * Rename variable * Set `exclude` to `false` when footer is hidden
- Loading branch information
Showing
14 changed files
with
299 additions
and
12 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/plugins/controls/common/control_group/control_group_panel_diff_system.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import deepEqual from 'fast-deep-equal'; | ||
import { omit, isEqual } from 'lodash'; | ||
import { OptionsListEmbeddableInput, OPTIONS_LIST_CONTROL } from '../options_list/types'; | ||
|
||
import { ControlPanelState } from './types'; | ||
|
||
interface DiffSystem { | ||
getPanelIsEqual: (initialInput: ControlPanelState, newInput: ControlPanelState) => boolean; | ||
} | ||
|
||
export const genericControlPanelDiffSystem: DiffSystem = { | ||
getPanelIsEqual: (initialInput, newInput) => { | ||
return deepEqual(initialInput, newInput); | ||
}, | ||
}; | ||
|
||
export const ControlPanelDiffSystems: { | ||
[key: string]: DiffSystem; | ||
} = { | ||
[OPTIONS_LIST_CONTROL]: { | ||
getPanelIsEqual: (initialInput, newInput) => { | ||
if (!deepEqual(omit(initialInput, 'explicitInput'), omit(newInput, 'explicitInput'))) { | ||
return false; | ||
} | ||
|
||
const { | ||
exclude: excludeA, | ||
selectedOptions: selectedA, | ||
singleSelect: singleSelectA, | ||
hideExclude: hideExcludeA, | ||
runPastTimeout: runPastTimeoutA, | ||
...inputA | ||
}: Partial<OptionsListEmbeddableInput> = initialInput.explicitInput; | ||
const { | ||
exclude: excludeB, | ||
selectedOptions: selectedB, | ||
singleSelect: singleSelectB, | ||
hideExclude: hideExcludeB, | ||
runPastTimeout: runPastTimeoutB, | ||
...inputB | ||
}: Partial<OptionsListEmbeddableInput> = newInput.explicitInput; | ||
|
||
return ( | ||
Boolean(excludeA) === Boolean(excludeB) && | ||
Boolean(singleSelectA) === Boolean(singleSelectB) && | ||
Boolean(hideExcludeA) === Boolean(hideExcludeB) && | ||
Boolean(runPastTimeoutA) === Boolean(runPastTimeoutB) && | ||
isEqual(selectedA ?? [], selectedB ?? []) && | ||
deepEqual(inputA, inputB) | ||
); | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.