-
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.
[TableListView] Enhance tag filtering (#142108)
- Loading branch information
Showing
41 changed files
with
1,319 additions
and
211 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
45 changes: 45 additions & 0 deletions
45
packages/content-management/table_list/src/components/tag_badge.tsx
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,45 @@ | ||
/* | ||
* 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 React, { FC } from 'react'; | ||
import { EuiBadge } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import type { Tag } from '../types'; | ||
|
||
const isMac = navigator.platform.toLowerCase().indexOf('mac') >= 0; | ||
|
||
export interface Props { | ||
tag: Tag; | ||
onClick: (tag: Tag, withModifierKey: boolean) => void; | ||
} | ||
|
||
/** | ||
* The badge representation of a Tag, which is the default display to be used for them. | ||
*/ | ||
export const TagBadge: FC<Props> = ({ tag, onClick }) => { | ||
return ( | ||
<EuiBadge | ||
color={tag.color} | ||
title={tag.description} | ||
data-test-subj={`tag-${tag.id}`} | ||
onClick={(e) => { | ||
const withModifierKey = (isMac && e.metaKey) || (!isMac && e.ctrlKey); | ||
onClick(tag, withModifierKey); | ||
}} | ||
onClickAriaLabel={i18n.translate('contentManagement.tableList.tagBadge.buttonLabel', { | ||
defaultMessage: '{tagName} tag button.', | ||
values: { | ||
tagName: tag.name, | ||
}, | ||
})} | ||
> | ||
{tag.name} | ||
</EuiBadge> | ||
); | ||
}; |
Oops, something went wrong.