Skip to content

Commit

Permalink
[Discover][Alerts] fix: add mobile width and fix title row wrap (#201354
Browse files Browse the repository at this point in the history
)

## Summary

Closes [#200162](#200162)

Long data view names weren't truncated on mobile view. Also noticed the
"X" icon to go on the second row - fixed it within the same PR.

Before:

![image](https://github.com/user-attachments/assets/de30a487-8025-41a3-8487-eb8f43108f79)

After:

<img width="471" alt="Screenshot 2024-11-22 at 11 55 47"
src="https://github.com/user-attachments/assets/c047c8f6-cace-4b99-814f-038bbc595572">


### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [x] No risks identified
  • Loading branch information
akowalska622 authored Nov 22, 2024
1 parent 4f7fd39 commit 9c4785b
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';
import {
EuiButtonEmpty,
EuiButtonIcon,
Expand All @@ -19,6 +20,7 @@ import {
EuiPopoverTitle,
EuiText,
useEuiPaddingCSS,
useIsWithinBreakpoints,
} from '@elastic/eui';
import { DataViewEditorStart } from '@kbn/data-view-editor-plugin/public';
import type {
Expand All @@ -30,6 +32,9 @@ import { DataViewSelector } from '@kbn/unified-search-plugin/public';
import type { DataViewListItemEnhanced } from '@kbn/unified-search-plugin/public/dataview_picker/dataview_list';
import { EsQueryRuleMetaData } from '../es_query/types';

const DESKTOP_WIDTH = 450;
const MOBILE_WIDTH = 350;

export interface DataViewSelectPopoverProps {
dependencies: {
dataViews: DataViewsPublicPluginStart;
Expand Down Expand Up @@ -61,6 +66,8 @@ export const DataViewSelectPopover: React.FunctionComponent<DataViewSelectPopove
const [dataViewItems, setDataViewsItems] = useState<DataViewListItemEnhanced[]>([]);
const [dataViewPopoverOpen, setDataViewPopoverOpen] = useState(false);

const isMobile = useIsWithinBreakpoints(['xs']);

const closeDataViewEditor = useRef<() => void | undefined>();

const allDataViewItems = useMemo(
Expand Down Expand Up @@ -179,9 +186,14 @@ export const DataViewSelectPopover: React.FunctionComponent<DataViewSelectPopove
anchorPosition="downLeft"
display="block"
>
<div style={{ width: '450px' }} data-test-subj="chooseDataViewPopoverContent">
<div
css={css`
width: ${isMobile ? `${MOBILE_WIDTH}px` : `${DESKTOP_WIDTH}px`};
`}
data-test-subj="chooseDataViewPopoverContent"
>
<EuiPopoverTitle>
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexGroup alignItems="center" gutterSize="s" responsive={false}>
<EuiFlexItem>
{i18n.translate('xpack.stackAlerts.components.ui.alertParams.dataViewPopoverTitle', {
defaultMessage: 'Data view',
Expand Down

0 comments on commit 9c4785b

Please sign in to comment.