Skip to content

Commit

Permalink
Merge branch 'main' into edit_add_logstash_output_strings
Browse files Browse the repository at this point in the history
  • Loading branch information
dedemorton authored Apr 6, 2022
2 parents f08275a + 554ee7b commit 31849f8
Show file tree
Hide file tree
Showing 424 changed files with 3,247 additions and 1,367 deletions.
5 changes: 2 additions & 3 deletions nav-kibana-dev.docnav.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
},
{ "id": "kibDevTutorialCI" },
{ "id": "kibDevTutorialServerEndpoint" },
{ "id": "kibDevTutorialAdvancedSettings"},
{ "id": "kibDevSharePluginReadme"}
{ "id": "kibDevTutorialAdvancedSettings" },
{ "id": "kibDevSharePluginReadme" }
]
},
{
Expand Down Expand Up @@ -103,7 +103,6 @@
{ "id": "kibDataViewsPluginApi" },
{ "id": "kibDataQueryPluginApi" },
{ "id": "kibDataSearchPluginApi" },
{ "id": "kibDataUiPluginApi" },
{ "id": "kibBfetchPluginApi" },
{ "id": "kibAlertingPluginApi" },
{ "id": "kibTaskManagerPluginApi" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ export const IndexPatternTable = ({
dataViews,
overlays,
uiSettings,
onDelete: () => loadDataViews(),
onDelete: () => {
setSelectedItems([]);
loadDataViews();
},
});
if (selectedItems.length === 0) {
return;
Expand Down
1 change: 0 additions & 1 deletion src/plugins/discover/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

export const APP_ID = 'discover';
export const DEFAULT_COLUMNS_SETTING = 'defaultColumns';
export const SAMPLE_SIZE_SETTING = 'discover:sampleSize';
export const SORT_DEFAULT_ORDER_SETTING = 'discover:sort:defaultOrder';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,17 @@ describe('Test Discover Context ActionBar for successor | predecessor records',
);
}
});

test(`${type}: Load button disabled when defaultStepSize is 0`, () => {
const wrapperWhenZeroStep = mountWithIntl(<ActionBar {...props} defaultStepSize={0} />);
const inputWhenZeroStep = findTestSubject(wrapperWhenZeroStep, `${type}CountPicker`);
const btnWhenZeroStep = findTestSubject(wrapperWhenZeroStep, `${type}LoadMoreButton`);
expect(btnWhenZeroStep.props().disabled).toBe(true);
btnWhenZeroStep.simulate('click');
expect(onChangeCount).toHaveBeenCalledTimes(0);
inputWhenZeroStep.simulate('change', { target: { valueAsNumber: 3 } });
btnWhenZeroStep.simulate('click');
expect(onChangeCount).toHaveBeenCalledTimes(1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function ActionBar({
const showWarning = !isDisabled && !isLoading && docCountAvailable < docCount;
const isSuccessor = type === SurrDocType.SUCCESSORS;
const [newDocCount, setNewDocCount] = useState(docCount);
const canLoadMore = defaultStepSize > 0 || newDocCount !== docCount;
const isValid = (value: number) => value >= MIN_CONTEXT_SIZE && value <= MAX_CONTEXT_SIZE;
const onSubmit = (ev: React.FormEvent<HTMLFormElement>) => {
ev.preventDefault();
Expand All @@ -92,7 +93,7 @@ export function ActionBar({
<EuiFlexItem grow={false}>
<EuiButtonEmpty
data-test-subj={`${type}LoadMoreButton`}
isDisabled={isDisabled}
isDisabled={isDisabled || !canLoadMore}
isLoading={isLoading}
onClick={() => {
const value = newDocCount + defaultStepSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import { getUiActions } from '../../../../../kibana_services';
import type { DataViewField } from '../../../../../../../data_views/public';
import { KBN_FIELD_TYPES } from '../../../../../../../data/public';
import { APP_ID } from '../../../../../../common';

function getTriggerConstant(type: string) {
return type === KBN_FIELD_TYPES.GEO_POINT || type === KBN_FIELD_TYPES.GEO_SHAPE
Expand Down Expand Up @@ -54,7 +53,6 @@ export function triggerVisualizeActions(
indexPatternId,
fieldName: field.name,
contextualFields,
originatingApp: APP_ID,
};
getUiActions().getTrigger(trigger).exec(triggerOptions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

import { i18n } from '@kbn/i18n';

export const CLOUD_POSTURE = i18n.translate('xpack.csp.navigation.cloudPosture', {
export const CLOUD_POSTURE = i18n.translate('xpack.csp.navigation.cloudPostureBreadcrumbLabel', {
defaultMessage: 'Cloud Posture',
});

export const FINDINGS = i18n.translate('xpack.csp.navigation.findings', {
export const FINDINGS = i18n.translate('xpack.csp.navigation.findingsPageLabel', {
defaultMessage: 'Findings',
});

export const DASHBOARD = i18n.translate('xpack.csp.navigation.dashboard', {
export const DASHBOARD = i18n.translate('xpack.csp.navigation.dashboardPageLabel', {
defaultMessage: 'Dashboard',
});

export const MY_BENCHMARKS = i18n.translate('xpack.csp.navigation.my_benchmarks', {
export const MY_BENCHMARKS = i18n.translate('xpack.csp.navigation.myBenchmarksPageLabel', {
defaultMessage: 'My Benchmarks',
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';
import { EuiBadge, type EuiBadgeProps } from '@elastic/eui';
import { CSP_EVALUATION_BADGE_FAILED, CSP_EVALUATION_BADGE_PASSED } from './translations';
import { FormattedMessage } from '@kbn/i18n-react';

interface Props {
type: 'passed' | 'failed';
Expand All @@ -21,6 +21,10 @@ const getColor = (type: Props['type']): EuiBadgeProps['color'] => {

export const CspEvaluationBadge = ({ type }: Props) => (
<EuiBadge color={getColor(type)}>
{type === 'failed' ? CSP_EVALUATION_BADGE_FAILED : CSP_EVALUATION_BADGE_PASSED}
{type === 'failed' ? (
<FormattedMessage id="xpack.csp.cspEvaluationBadge.failedLabel" defaultMessage="FAILED" />
) : (
<FormattedMessage id="xpack.csp.cspEvaluationBadge.passedLabel" defaultMessage="PASSED" />
)}
</EuiBadge>
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,37 @@

import React from 'react';
import { EuiBadge } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import type { Score } from '../../common/types';
import * as TEXT from './translations';

interface Props {
value: Score;
}

export const CspHealthBadge = ({ value }: Props) => {
if (value <= 65) return <EuiBadge color="danger">{TEXT.CRITICAL}</EuiBadge>;
if (value <= 86) return <EuiBadge color="warning">{TEXT.WARNING}</EuiBadge>;
if (value <= 100) return <EuiBadge color="success">{TEXT.HEALTHY}</EuiBadge>;
if (value <= 65) {
return (
<EuiBadge color="danger">
<FormattedMessage id="xpack.csp.cspHealthBadge.criticalLabel" defaultMessage="Critical" />
</EuiBadge>
);
}

if (value <= 86) {
return (
<EuiBadge color="warning">
<FormattedMessage id="xpack.csp.cspHealthBadge.warningLabel" defaultMessage="Warning" />
</EuiBadge>
);
}

if (value <= 100) {
return (
<EuiBadge color="success">
<FormattedMessage id="xpack.csp.cspHealthBadge.healthyLabel" defaultMessage="Healthy" />
</EuiBadge>
);
}

return null;
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner } from '@elastic/eui';
import React from 'react';

export const cspLoadingStateTestId = 'csp_loading_state';

export const CspLoadingState: React.FunctionComponent = ({ children }) => (
<EuiFlexGroup direction="column" alignItems="center" data-test-subj={cspLoadingStateTestId}>
export const CspLoadingState: React.FunctionComponent<{ ['data-test-subj']?: string }> = ({
children,
...rest
}) => (
<EuiFlexGroup direction="column" alignItems="center" data-test-subj={rest['data-test-subj']}>
<EuiFlexItem>
<EuiLoadingSpinner size="xl" />
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ import { coreMock } from '../../../../../src/core/public/mocks';
import { createNavigationItemFixture } from '../test/fixtures/navigation_item';
import { createReactQueryResponse } from '../test/fixtures/react_query';
import { TestProvider } from '../test/test_provider';
import { CspPageTemplate, getSideNavItems, isCommonError } from './csp_page_template';
import { LOADING, PACKAGE_NOT_INSTALLED_TEXT, DEFAULT_NO_DATA_TEXT } from './translations';
import {
CspPageTemplate,
ERROR_STATE_TEST_SUBJECT,
getSideNavItems,
isCommonError,
LOADING_STATE_TEST_SUBJECT,
} from './csp_page_template';
import { PACKAGE_NOT_INSTALLED_TEXT, DEFAULT_NO_DATA_TEXT } from './translations';
import { useCisKubernetesIntegration } from '../common/api/use_cis_kubernetes_integration';
import { UseQueryResult } from 'react-query';

const chance = new Chance();

// Synchronized to the error message in the formatted message in `csp_page_template.tsx`
const ERROR_LOADING_DATA_DEFAULT_MESSAGE = "We couldn't fetch your cloud security posture data";
const packageNotInstalledUniqueTexts = [
PACKAGE_NOT_INSTALLED_TEXT.PAGE_TITLE,
PACKAGE_NOT_INSTALLED_TEXT.DESCRIPTION,
Expand Down Expand Up @@ -85,8 +89,8 @@ describe('<CspPageTemplate />', () => {
renderCspPageTemplate({ children });

expect(screen.getByText(children)).toBeInTheDocument();
expect(screen.queryByText(LOADING)).not.toBeInTheDocument();
expect(screen.queryByText(ERROR_LOADING_DATA_DEFAULT_MESSAGE)).not.toBeInTheDocument();
expect(screen.queryByTestId(LOADING_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
expect(screen.queryByTestId(ERROR_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
packageNotInstalledUniqueTexts.forEach((text) =>
expect(screen.queryByText(text)).not.toBeInTheDocument()
);
Expand All @@ -105,8 +109,8 @@ describe('<CspPageTemplate />', () => {
expect(screen.getAllByText(text)[0]).toBeInTheDocument()
);
expect(screen.queryByText(children)).not.toBeInTheDocument();
expect(screen.queryByText(LOADING)).not.toBeInTheDocument();
expect(screen.queryByText(ERROR_LOADING_DATA_DEFAULT_MESSAGE)).not.toBeInTheDocument();
expect(screen.queryByTestId(LOADING_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
expect(screen.queryByTestId(ERROR_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
});

it('renders default loading text when query isLoading', () => {
Expand All @@ -117,9 +121,9 @@ describe('<CspPageTemplate />', () => {
const children = chance.sentence();
renderCspPageTemplate({ children, query });

expect(screen.getByText(LOADING)).toBeInTheDocument();
expect(screen.getByTestId(LOADING_STATE_TEST_SUBJECT)).toBeInTheDocument();
expect(screen.queryByText(children)).not.toBeInTheDocument();
expect(screen.queryByText(ERROR_LOADING_DATA_DEFAULT_MESSAGE)).not.toBeInTheDocument();
expect(screen.queryByTestId(ERROR_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
packageNotInstalledUniqueTexts.forEach((text) =>
expect(screen.queryByText(text)).not.toBeInTheDocument()
);
Expand All @@ -144,10 +148,11 @@ describe('<CspPageTemplate />', () => {
const children = chance.sentence();
renderCspPageTemplate({ children, query });

[ERROR_LOADING_DATA_DEFAULT_MESSAGE, error, message, statusCode].forEach((text) =>
[error, message, statusCode].forEach((text) =>
expect(screen.getByText(text, { exact: false })).toBeInTheDocument()
);
expect(screen.queryByText(LOADING)).not.toBeInTheDocument();
expect(screen.getByTestId(ERROR_STATE_TEST_SUBJECT)).toBeInTheDocument();
expect(screen.queryByTestId(LOADING_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
expect(screen.queryByText(children)).not.toBeInTheDocument();
packageNotInstalledUniqueTexts.forEach((text) =>
expect(screen.queryByText(text)).not.toBeInTheDocument()
Expand Down Expand Up @@ -178,10 +183,9 @@ describe('<CspPageTemplate />', () => {
});

expect(screen.getByText(message)).toBeInTheDocument();
[ERROR_LOADING_DATA_DEFAULT_MESSAGE, error, statusCode].forEach((text) =>
expect(screen.queryByText(text)).not.toBeInTheDocument()
);
expect(screen.queryByText(LOADING)).not.toBeInTheDocument();
[error, statusCode].forEach((text) => expect(screen.queryByText(text)).not.toBeInTheDocument());
expect(screen.queryByTestId(ERROR_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
expect(screen.queryByTestId(LOADING_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
expect(screen.queryByText(children)).not.toBeInTheDocument();
packageNotInstalledUniqueTexts.forEach((text) =>
expect(screen.queryByText(text)).not.toBeInTheDocument()
Expand All @@ -203,8 +207,8 @@ describe('<CspPageTemplate />', () => {
});

expect(screen.getByText(loading)).toBeInTheDocument();
expect(screen.queryByText(ERROR_LOADING_DATA_DEFAULT_MESSAGE)).not.toBeInTheDocument();
expect(screen.queryByText(LOADING)).not.toBeInTheDocument();
expect(screen.queryByTestId(ERROR_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
expect(screen.queryByTestId(LOADING_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
expect(screen.queryByText(children)).not.toBeInTheDocument();
packageNotInstalledUniqueTexts.forEach((text) =>
expect(screen.queryByText(text)).not.toBeInTheDocument()
Expand All @@ -221,9 +225,9 @@ describe('<CspPageTemplate />', () => {
renderCspPageTemplate({ children, query });

expect(screen.getByText(DEFAULT_NO_DATA_TEXT.PAGE_TITLE)).toBeInTheDocument();
expect(screen.queryByText(LOADING)).not.toBeInTheDocument();
expect(screen.queryByTestId(LOADING_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
expect(screen.queryByText(children)).not.toBeInTheDocument();
expect(screen.queryByText(ERROR_LOADING_DATA_DEFAULT_MESSAGE)).not.toBeInTheDocument();
expect(screen.queryByTestId(ERROR_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
packageNotInstalledUniqueTexts.forEach((text) =>
expect(screen.queryByText(text)).not.toBeInTheDocument()
);
Expand All @@ -248,9 +252,9 @@ describe('<CspPageTemplate />', () => {

expect(screen.getByText(pageTitle)).toBeInTheDocument();
expect(screen.getAllByText(solution, { exact: false })[0]).toBeInTheDocument();
expect(screen.queryByText(LOADING)).not.toBeInTheDocument();
expect(screen.queryByTestId(LOADING_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
expect(screen.queryByText(children)).not.toBeInTheDocument();
expect(screen.queryByText(ERROR_LOADING_DATA_DEFAULT_MESSAGE)).not.toBeInTheDocument();
expect(screen.queryByTestId(ERROR_STATE_TEST_SUBJECT)).not.toBeInTheDocument();
packageNotInstalledUniqueTexts.forEach((text) =>
expect(screen.queryByText(text)).not.toBeInTheDocument()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ import {
} from '../../../../../src/plugins/kibana_react/public';
import { allNavigationItems } from '../common/navigation/constants';
import type { CspNavigationItem } from '../common/navigation/types';
import { CLOUD_SECURITY_POSTURE } from '../common/translations';
import { CspLoadingState } from './csp_loading_state';
import { DEFAULT_NO_DATA_TEXT, LOADING, PACKAGE_NOT_INSTALLED_TEXT } from './translations';
import {
CLOUD_SECURITY_POSTURE,
DEFAULT_NO_DATA_TEXT,
PACKAGE_NOT_INSTALLED_TEXT,
} from './translations';
import { useCisKubernetesIntegration } from '../common/api/use_cis_kubernetes_integration';
import { useCISIntegrationLink } from '../common/navigation/use_navigate_to_cis_integration';

Expand Down Expand Up @@ -77,6 +80,9 @@ export const DEFAULT_NO_DATA_CONFIG: KibanaPageTemplateProps['noDataConfig'] = {
actions: {},
};

export const LOADING_STATE_TEST_SUBJECT = 'csp_page_template_loading';
export const ERROR_STATE_TEST_SUBJECT = 'csp_page_template_error';

const getPackageNotInstalledNoDataConfig = (
cisIntegrationLink: string
): KibanaPageTemplateProps['noDataConfig'] => ({
Expand All @@ -94,12 +100,20 @@ const getPackageNotInstalledNoDataConfig = (
},
});

const DefaultLoading = () => <CspLoadingState>{LOADING}</CspLoadingState>;
const DefaultLoading = () => (
<CspLoadingState data-test-subj={LOADING_STATE_TEST_SUBJECT}>
<FormattedMessage
id="xpack.csp.cspPageTemplate.loadingDescription"
defaultMessage="Loading..."
/>
</CspLoadingState>
);

const DefaultError = (error: unknown) => (
<EuiEmptyPrompt
color="danger"
iconType="alert"
data-test-subj={ERROR_STATE_TEST_SUBJECT}
title={
<>
<EuiTitle>
Expand Down
Loading

0 comments on commit 31849f8

Please sign in to comment.