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

[Cloud Posture] search bar styles update #128361

Merged
merged 5 commits into from
Apr 6, 2022
Merged

Conversation

orouz
Copy link
Contributor

@orouz orouz commented Mar 23, 2022

Summary

this PR includes changes to the CSP Findings SearchBar:

  • move to the top of the page and update styles
  • remove date picker

it also includes some code to add support for theme context (using emotion) to get access to eui internal vars, which were needed to satisfy the design.

Screen Shot 2022-03-23 at 14 10 28


export const FINDINGS_SEARCH_PLACEHOLDER = i18n.translate(
'xpack.csp.findings.searchBar.searchPlaceholder',
{ defaultMessage: 'Search findings (eg. resource.type : "API Server")' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example is falsely,
To filter API Server the user would need to apply the following rule.section: "API Server"

@orouz orouz added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting v8.2.0 Team:Cloud Security Cloud Security team related labels Mar 29, 2022
@orouz orouz force-pushed the csp_findings_search branch from 1825a6e to 53b31b6 Compare April 4, 2022 10:33
@orouz orouz force-pushed the csp_findings_search branch from 53b31b6 to f0950b2 Compare April 4, 2022 17:26
@orouz orouz marked this pull request as ready for review April 5, 2022 08:02
@orouz orouz requested a review from a team as a code owner April 5, 2022 08:02
@orouz orouz added v8.3.0 and removed v8.2.0 labels Apr 5, 2022
<Route path="*" component={UnknownRoute} />
</Switch>
</I18nProvider>
<CspThemeProvider>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to wrap in a theme provider, our entire app is wrapped in a <KibanaThemeProvider /> which is a wrapper of <EuiThemeProvider />

Copy link
Contributor Author

@orouz orouz Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KibanaThemeProvider doesn't include the context for eui's emotion theme, which is what this bit adds

although if we manage to only use useEuiTheme() , we won't need this at all

removed this, not used anymore.

import { useTheme as useEmotionTheme } from '@emotion/react';
import { EuiTheme } from '../../../../../../src/plugins/kibana_react/common';

export function useTheme() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets drop this and use useEuiTheme from eui instead

Copy link
Contributor Author

@orouz orouz Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like useEuiTheme doesn't include the value of the emotion theme for euiPageBackgroundColor, and no similar value either. (will use that)

Copy link
Contributor

@ari-aviran ari-aviran Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It exists, look at shades in the colors documentation

colors.emptyShade

Used as the background color of primary page content and panels including modals and flyouts.

colors.body

The background color for the whole window (body) and is a computed value of colors.lightestShade. Provides denominator (background) value for contrast calculations.

@@ -22,6 +22,13 @@ import type { DataView } from '../../../../../../src/plugins/data/common';

jest.mock('../../common/api/use_kubebeat_data_view');
jest.mock('../../common/api/use_cis_kubernetes_integration');
jest.mock('../../common/hooks/use_theme', () => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of mocking this I suggest adding a theme provider to our <TestProvider />

Copy link
Contributor Author

@orouz orouz Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could this if you prefer, but we don't own the provider, we get it from eui for all kibana (not in our app providers) so adding it seems more complicated than mocking it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean, we do add it explicitly, Kibana does not do that for us (we add it here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

const pageHeader: EuiPageHeaderProps = {
pageTitle: FINDINGS,
};
const FindingsPageTemplate = styled(CspPageTemplate)`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to do anything, when I remove it and use CspPageTemplate directly the page looks the same. I think that removing the pageHeader prop removes the header, so no need for this hack

<FindingsTable setQuery={setUrlQuery} {...findingsQuery} {...findingsResult} />
<div
css={css`
padding: 24px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to start using sizes from the eui theme, lets use size.l instead of a fixed value here

const PageTitle = () => (
<EuiTitle size="l">
<h2>
<FormattedMessage id="xpack.csp.findings.findingsLabel" defaultMessage="Findings" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ID should end with findingsTitle as this is a title

@orouz orouz requested a review from ari-aviran April 5, 2022 14:14
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cloudSecurityPosture 369.7KB 370.0KB +352.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@orouz orouz merged commit 6681d88 into elastic:main Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants