-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Expose filter item from data plugin #94546
Expose filter item from data plugin #94546
Conversation
Pinging @elastic/uptime (Team:uptime) |
@elasticmachine merge upstream |
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.
LGTM, didn't test, one suggest 👇
@@ -154,83 +157,90 @@ export function FilterItem(props: Props) { | |||
|
|||
function getPanels() { | |||
const { negate, disabled } = filter.meta; | |||
return [ | |||
let mainPanelItems = [ |
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.
Can we type this EuiContextMenuPanelItemDescriptor & {id: PanelOptions}
and then use id
for filtering hiddenPanelOptions
🙏
Would be nice to have hiddenPanelOptions
type connected to actually panel items and not use an arbitrary data-test-subj
string for this
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.
i tried adding id or using EuiContextMenuPanelItemDescriptor, typescript goes crazy in both cases.
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.
working with EUI items types can be tricky , so i am not sure, how to solve this.
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.
Wow, indeed tricky!
To workaround eui types, I ended up with:
type PanelOptions = 'pinFilter' | 'editFilter' | 'negateFilter' | 'disableFilter' | 'deleteFilter';
interface PanelItem {
id: PanelOptions;
euiPanel: EuiContextMenuPanelItemDescriptor;
}
....
let mainPanelItems: PanelItem[] = [
{
id: 'pinFilter',
euiPanel: {
name: isFilterPinned(filter)
? props.intl.formatMessage({
id: 'data.filter.filterBar.unpinFilterButtonLabel',
defaultMessage: 'Unpin',
})
: props.intl.formatMessage({
id: 'data.filter.filterBar.pinFilterButtonLabel',
defaultMessage: 'Pin across all apps',
}),
icon: 'pin',
onClick: () => {
setIsPopoverOpen(false);
onTogglePinned();
},
'data-test-subj': 'pinFilter',
},
},
....
];
And then filter panels by id: 'pinFilter',
to be honest, I still think it is worth it
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.
^^ i don't think that will work.
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.
so i am leaving this improvement perhaps for future :)
💚 Build SucceededMetrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @shahzad31 |
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.
Change LGTM,
I still think it is worth improving type binding within the component:
https://github.com/elastic/kibana/pull/94546/files#r596662205
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
we are using this component in our exploratory view #94426
so exposing it from data plugin.