-
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.
[Monitor Management UI] Add "locations" column to monitor management …
- Loading branch information
Showing
3 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
...ck/plugins/uptime/public/components/monitor_management/monitor_list/monitor_locations.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,49 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
import { EuiBadge, EuiBadgeGroup } from '@elastic/eui'; | ||
import { ServiceLocations, ServiceLocation } from '../../../../common/runtime_types'; | ||
import { EXPAND_LOCATIONS_LABEL } from '../../overview/monitor_list/columns/translations'; | ||
|
||
interface Props { | ||
locations: ServiceLocations; | ||
} | ||
|
||
const INITIAL_LIMIT = 3; | ||
|
||
export const MonitorLocations = ({ locations }: Props) => { | ||
const [toDisplay, setToDisplay] = useState(INITIAL_LIMIT); | ||
|
||
const locationsToDisplay = locations.slice(0, toDisplay); | ||
|
||
return ( | ||
<EuiBadgeGroup> | ||
{locationsToDisplay.map((location: ServiceLocation) => ( | ||
<EuiBadge | ||
key={location.id} | ||
color="hollow" | ||
className="eui-textTruncate" | ||
style={{ maxWidth: 120 }} | ||
> | ||
{location.label} | ||
</EuiBadge> | ||
))} | ||
{locations.length > toDisplay && ( | ||
<EuiBadge | ||
color="hollow" | ||
onClick={() => { | ||
setToDisplay(locations.length); | ||
}} | ||
onClickAriaLabel={EXPAND_LOCATIONS_LABEL} | ||
> | ||
+{locations.length - INITIAL_LIMIT} | ||
</EuiBadge> | ||
)} | ||
</EuiBadgeGroup> | ||
); | ||
}; |
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