Skip to content
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

add logic so that the group sort order for dashboard panel list might be inferred from the DOM #191828

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,13 @@ export const DashboardPanelSelectionListFlyout: React.FC<
>
{panelsSearchResult?.some(({ isDisabled }) => !isDisabled) ? (
panelsSearchResult.map(
({ id, title, items, isDisabled, ['data-test-subj']: dataTestSubj }) =>
({ id, title, items, isDisabled, ['data-test-subj']: dataTestSubj, order }) =>
!isDisabled ? (
<EuiFlexItem key={id} data-test-subj={dataTestSubj}>
<EuiFlexItem
key={id}
data-test-subj={dataTestSubj}
data-group-sort-order={order}
>
<EuiTitle id={`${id}-group`} size="xxs">
{typeof title === 'string' ? <h3>{title}</h3> : title}
</EuiTitle>
Expand Down
19 changes: 10 additions & 9 deletions src/plugins/embeddable/public/lib/embeddables/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,13 @@ import { i18n } from '@kbn/i18n';
import { UiActionsPresentableGroup } from '@kbn/ui-actions-plugin/public';

export const COMMON_EMBEDDABLE_GROUPING: { [key: string]: UiActionsPresentableGroup<unknown> } = {
legacy: {
id: 'legacy',
getDisplayName: () =>
i18n.translate('embeddableApi.common.constants.grouping.legacy', {
defaultMessage: 'Legacy',
}),
order: -2,
},
annotation: {
id: 'annotation-and-navigation',
getDisplayName: () =>
i18n.translate('embeddableApi.common.constants.grouping.annotations', {
defaultMessage: 'Annotations and Navigation',
}),
order: 900, // This is the order of the group in the context menu
},
other: {
id: 'other',
Expand All @@ -32,6 +25,14 @@ export const COMMON_EMBEDDABLE_GROUPING: { [key: string]: UiActionsPresentableGr
defaultMessage: 'Other',
}),
getIconType: () => 'empty',
order: -1,
order: -1, // Given an item that doesn't specify a group is assigned zero, this forces other to come after all intentionally grouped section
},
legacy: {
id: 'legacy',
getDisplayName: () =>
i18n.translate('embeddableApi.common.constants.grouping.legacy', {
defaultMessage: 'Legacy',
}),
order: -2, // Given an item that doesn't specify a group is assigned zero, this forces it to the bottom of the list
},
};