-
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
[Dashboard] [Controls] Add excludes
toggle to options list
#142780
Merged
Heenawter
merged 22 commits into
elastic:main
from
Heenawter:add-excludes-to-options-list_2022-10-04
Oct 25, 2022
Merged
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3921c34
Add buttons with no functionality
Heenawter c9ac4d2
Added basic negate functionality
Heenawter 08e68a2
Add `NOT` text when negated
Heenawter 0b060dc
Clean up
Heenawter a36f0b4
Add jest and functional tests
Heenawter 621bf85
Fix merge conflicts
Heenawter 224c311
Rename `negate` to `exclude`
Heenawter 662550e
Fix `unsaved changes` bug
Heenawter d473222
Move erase button back to beside search
Heenawter c19d1d6
Clean up
Heenawter 084a713
Add chaining functional tests
Heenawter 22f7dd7
Fix other unsaved changes bug
Heenawter 0d53045
Fix mobile view of popover
Heenawter c282f64
Merge branch 'main' into add-excludes-to-options-list_2022-10-04
Heenawter 0cc604a
Merge branch 'main' into add-excludes-to-options-list_2022-10-04
Heenawter 3a10350
Add option to disable exclude/include toggle
Heenawter 78bd312
Prevent unsaved changes bug for options list settings
Heenawter aeb6d28
Add tooltip to run past timeout setting
Heenawter 4cdfbb9
Address review comments
Heenawter 9367369
Rename variable
Heenawter fe520ed
Merge branch 'main' into add-excludes-to-options-list_2022-10-04
Heenawter f1c69e7
Set `exclude` to `false` when footer is hidden
Heenawter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
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,64 @@ | ||
/* | ||
* 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 { RANGE_SLIDER_CONTROL } from '../range_slider/types'; | ||
import { TIME_SLIDER_CONTROL } from '../time_slider/types'; | ||
|
||
import { ControlGroupDiffSystem, ControlPanelState } from './types'; | ||
|
||
interface DiffSystem { | ||
getPanelIsEqual: (initialInput: ControlPanelState, newInput: ControlPanelState) => boolean; | ||
} | ||
|
||
const genericControlPanelDiffSystem: DiffSystem = { | ||
getPanelIsEqual: (initialInput, newInput) => { | ||
return deepEqual(initialInput, newInput); | ||
}, | ||
}; | ||
|
||
export const ControlPanelDiffSystems: { | ||
[key in ControlGroupDiffSystem]: DiffSystem; | ||
} = { | ||
[OPTIONS_LIST_CONTROL]: { | ||
getPanelIsEqual: (initialInput, newInput) => { | ||
if (!deepEqual(omit(initialInput, 'explicitInput'), omit(newInput, 'explicitInput'))) | ||
return false; | ||
Heenawter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const { | ||
exclude: excludeA, | ||
selectedOptions: selectedA, | ||
singleSelect: singleSelectA, | ||
allowExclude: allowExcludeA, | ||
runPastTimeout: runPastTimeoutA, | ||
...inputA | ||
}: Partial<OptionsListEmbeddableInput> = initialInput.explicitInput; | ||
const { | ||
exclude: excludeB, | ||
selectedOptions: selectedB, | ||
singleSelect: singleSelectB, | ||
allowExclude: allowExcludeB, | ||
runPastTimeout: runPastTimeoutB, | ||
...inputB | ||
}: Partial<OptionsListEmbeddableInput> = newInput.explicitInput; | ||
|
||
return ( | ||
Boolean(excludeA) === Boolean(excludeB) && | ||
Boolean(singleSelectA) === Boolean(singleSelectB) && | ||
Boolean(allowExcludeA) === Boolean(allowExcludeB) && | ||
Boolean(runPastTimeoutA) === Boolean(runPastTimeoutB) && | ||
Heenawter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
isEqual(selectedA ?? [], selectedB ?? []) && | ||
Heenawter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
deepEqual(inputA, inputB) | ||
); | ||
}, | ||
}, | ||
[RANGE_SLIDER_CONTROL]: genericControlPanelDiffSystem, | ||
Heenawter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[TIME_SLIDER_CONTROL]: genericControlPanelDiffSystem, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ export interface OptionsListEmbeddableInput extends DataControlInput { | |
selectedOptions?: string[]; | ||
runPastTimeout?: boolean; | ||
singleSelect?: boolean; | ||
allowExclude?: boolean; | ||
exclude?: boolean; | ||
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.
|
||
} | ||
|
||
export type OptionsListField = FieldSpec & { | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This
ControlPanelDiffSystems
should be temporary and will be removed/cleaned up as part of the Portable Dashboards project (already discussed with @ThomThomson to confirm).Basically, if we had access to the
ControlGroupContainer
during the dashboard diff process rather than justPersistableControlGroupInput
, we could then make use of the embeddablegetExplicitInputIsEqual
function for each child embeddable of the control group. However, this is a fairly large refactor that does not fit in to this PR, so theControlPanelDiffSystems
serves as a temporary workaround.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.
Nice usage of function registry type architecture! It's temporary, but it's set up like a microcosm of the actual embeddable diffing system, so it'll be super easy to migrate over, even if we end up needing diffing systems for multiple control types in the meantime.
Note to self: I was thinking about when to move this into the embeddable, and I think it makes the most sense to do so when we tackle
Control Group as a Panel
, so let's keep that in mind when we write up that issue.