Skip to content

Commit

Permalink
Merge branch 'master' into fix/cli-dev-mode-exit
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Mar 30, 2021
2 parents 31f6b6d + a1bc9a5 commit 3138c25
Show file tree
Hide file tree
Showing 117 changed files with 1,805 additions and 939 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import React, { Component } from 'react';
import React, { Component, FormEvent } from 'react';

import {
EuiFormRow,
Expand Down Expand Up @@ -72,80 +72,87 @@ export class CustomizePanelModal extends Component<CustomizePanelProps, State> {
<EuiFocusTrap clickOutsideDisables={true} initialFocus={'.panelTitleInputText'}>
<EuiOutsideClickDetector onOutsideClick={this.props.cancel}>
<div role="dialog" aria-modal="true" aria-labelledby={titleId} className="euiModal__flex">
<EuiModalHeader>
<EuiModalHeaderTitle data-test-subj="customizePanelTitle">
<h2 id={titleId}>Customize panel</h2>
</EuiModalHeaderTitle>
</EuiModalHeader>
<form
onSubmit={(event: FormEvent) => {
event.preventDefault();
this.save();
}}
>
<EuiModalHeader>
<EuiModalHeaderTitle data-test-subj="customizePanelTitle">
<h2 id={titleId}>Customize panel</h2>
</EuiModalHeaderTitle>
</EuiModalHeader>

<EuiModalBody>
<EuiFormRow>
<EuiSwitch
checked={!this.state.hideTitle}
data-test-subj="customizePanelHideTitle"
id="hideTitle"
label={
<FormattedMessage
defaultMessage="Show panel title"
id="embeddableApi.customizePanel.modal.showTitle"
/>
}
onChange={this.onHideTitleToggle}
/>
</EuiFormRow>
<EuiFormRow
label={i18n.translate(
'embeddableApi.customizePanel.modal.optionsMenuForm.panelTitleFormRowLabel',
{
defaultMessage: 'Panel title',
}
)}
>
<EuiFieldText
id="panelTitleInput"
className="panelTitleInputText"
data-test-subj="customEmbeddablePanelTitleInput"
name="min"
type="text"
disabled={this.state.hideTitle}
value={this.state.title || ''}
onChange={(e) => this.setState({ title: e.target.value })}
aria-label={i18n.translate(
'embeddableApi.customizePanel.modal.optionsMenuForm.panelTitleInputAriaLabel',
<EuiModalBody>
<EuiFormRow>
<EuiSwitch
checked={!this.state.hideTitle}
data-test-subj="customizePanelHideTitle"
id="hideTitle"
label={
<FormattedMessage
defaultMessage="Show panel title"
id="embeddableApi.customizePanel.modal.showTitle"
/>
}
onChange={this.onHideTitleToggle}
/>
</EuiFormRow>
<EuiFormRow
label={i18n.translate(
'embeddableApi.customizePanel.modal.optionsMenuForm.panelTitleFormRowLabel',
{
defaultMessage: 'Enter a custom title for your panel',
defaultMessage: 'Panel title',
}
)}
append={
<EuiButtonEmpty
data-test-subj="resetCustomEmbeddablePanelTitle"
onClick={this.reset}
disabled={this.state.hideTitle}
>
<FormattedMessage
id="embeddableApi.customizePanel.modal.optionsMenuForm.resetCustomDashboardButtonLabel"
defaultMessage="Reset"
/>
</EuiButtonEmpty>
}
/>
</EuiFormRow>
</EuiModalBody>
<EuiModalFooter>
<EuiButtonEmpty onClick={() => this.props.cancel()}>
<FormattedMessage
id="embeddableApi.customizePanel.modal.cancel"
defaultMessage="Cancel"
/>
</EuiButtonEmpty>
>
<EuiFieldText
id="panelTitleInput"
className="panelTitleInputText"
data-test-subj="customEmbeddablePanelTitleInput"
name="min"
type="text"
disabled={this.state.hideTitle}
value={this.state.title || ''}
onChange={(e) => this.setState({ title: e.target.value })}
aria-label={i18n.translate(
'embeddableApi.customizePanel.modal.optionsMenuForm.panelTitleInputAriaLabel',
{
defaultMessage: 'Enter a custom title for your panel',
}
)}
append={
<EuiButtonEmpty
data-test-subj="resetCustomEmbeddablePanelTitle"
onClick={this.reset}
disabled={this.state.hideTitle}
>
<FormattedMessage
id="embeddableApi.customizePanel.modal.optionsMenuForm.resetCustomDashboardButtonLabel"
defaultMessage="Reset"
/>
</EuiButtonEmpty>
}
/>
</EuiFormRow>
</EuiModalBody>
<EuiModalFooter>
<EuiButtonEmpty onClick={() => this.props.cancel()}>
<FormattedMessage
id="embeddableApi.customizePanel.modal.cancel"
defaultMessage="Cancel"
/>
</EuiButtonEmpty>

<EuiButton data-test-subj="saveNewTitleButton" onClick={this.save} fill>
<FormattedMessage
id="embeddableApi.customizePanel.modal.saveButtonTitle"
defaultMessage="Save"
/>
</EuiButton>
</EuiModalFooter>
<EuiButton data-test-subj="saveNewTitleButton" onClick={this.save} fill>
<FormattedMessage
id="embeddableApi.customizePanel.modal.saveButtonTitle"
defaultMessage="Save"
/>
</EuiButton>
</EuiModalFooter>
</form>
</div>
</EuiOutsideClickDetector>
</EuiFocusTrap>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,67 @@
* 2.0.
*/

import { setMockValues, setMockActions, rerender } from '../../../__mocks__';
import '../../../__mocks__/shallow_useeffect.mock';

import React from 'react';

import { shallow } from 'enzyme';
import { shallow, ShallowWrapper } from 'enzyme';

import { EuiPageHeader } from '@elastic/eui';

import { Loading } from '../../../shared/loading';
import { LogRetentionCallout, LogRetentionTooltip } from '../log_retention';

import { ApiLogs } from './';

describe('ApiLogs', () => {
const values = {
dataLoading: false,
apiLogs: [],
meta: { page: { current: 1 } },
};
const actions = {
fetchApiLogs: jest.fn(),
pollForApiLogs: jest.fn(),
};

let wrapper: ShallowWrapper;

beforeEach(() => {
jest.clearAllMocks();
setMockValues(values);
setMockActions(actions);
wrapper = shallow(<ApiLogs engineBreadcrumb={['some engine']} />);
});

it('renders', () => {
const wrapper = shallow(<ApiLogs engineBreadcrumb={['some engine']} />);

expect(wrapper.find(EuiPageHeader).prop('pageTitle')).toEqual('API Logs');
// TODO: Check for ApiLogsTable + NewApiEventsPrompt when those get added

expect(wrapper.find(LogRetentionCallout).prop('type')).toEqual('api');
expect(wrapper.find(LogRetentionTooltip).prop('type')).toEqual('api');
});

it('renders a loading screen', () => {
setMockValues({ ...values, dataLoading: true, apiLogs: [] });
rerender(wrapper);

expect(wrapper.find(Loading)).toHaveLength(1);
});

describe('effects', () => {
it('calls a manual fetchApiLogs on page load and pagination', () => {
expect(actions.fetchApiLogs).toHaveBeenCalledTimes(1);

setMockValues({ ...values, meta: { page: { current: 2 } } });
rerender(wrapper);

expect(actions.fetchApiLogs).toHaveBeenCalledTimes(2);
});

it('starts pollForApiLogs on page load', () => {
expect(actions.pollForApiLogs).toHaveBeenCalledTimes(1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,40 @@
* 2.0.
*/

import React from 'react';
import React, { useEffect } from 'react';

import { useValues, useActions } from 'kea';

import { EuiPageHeader, EuiTitle, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';

import { FlashMessages } from '../../../shared/flash_messages';
import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { BreadcrumbTrail } from '../../../shared/kibana_chrome/generate_breadcrumbs';
import { Loading } from '../../../shared/loading';

import { LogRetentionCallout, LogRetentionTooltip, LogRetentionOptions } from '../log_retention';

import { API_LOGS_TITLE, RECENT_API_EVENTS } from './constants';

import { ApiLogsLogic } from './';

interface Props {
engineBreadcrumb: BreadcrumbTrail;
}
export const ApiLogs: React.FC<Props> = ({ engineBreadcrumb }) => {
const { dataLoading, apiLogs, meta } = useValues(ApiLogsLogic);
const { fetchApiLogs, pollForApiLogs } = useActions(ApiLogsLogic);

useEffect(() => {
fetchApiLogs();
}, [meta.page.current]);

useEffect(() => {
pollForApiLogs();
}, []);

if (dataLoading && !apiLogs.length) return <Loading />;

return (
<>
<SetPageChrome trail={[...engineBreadcrumb, API_LOGS_TITLE]} />
Expand Down
Loading

0 comments on commit 3138c25

Please sign in to comment.