Skip to content

Commit

Permalink
[App Search] Minor log retention refactors (#88140)
Browse files Browse the repository at this point in the history
* Move reused log retention components to own folder

- e.g., logic file, helpers used by other views & not just settings

* Update settings-specific views to reference top-level folder

- I'm leaving the panel and the confirmation modal within settings as that isn't used anywhere outside the settings page, but we can revisit this if needed or if people think it makes more sense to keep everything log related together

* [bug] Fix nested <p> error in log retention confirmation modal
  • Loading branch information
Constance authored Jan 13, 2021
1 parent 94ca8ab commit 64275cd
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { LogRetentionLogic } from './log_retention_logic';
export * from './types';
export * from './messaging';
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { LogicMounter } from '../../../../__mocks__/kea.mock';
import { LogicMounter } from '../../../__mocks__/kea.mock';

import { mockHttpValues } from '../../../../__mocks__';
jest.mock('../../../../shared/http', () => ({
import { mockHttpValues } from '../../../__mocks__';
jest.mock('../../../shared/http', () => ({
HttpLogic: { values: mockHttpValues },
}));
const { http } = mockHttpValues;

jest.mock('../../../../shared/flash_messages', () => ({
jest.mock('../../../shared/flash_messages', () => ({
flashAPIErrors: jest.fn(),
}));
import { flashAPIErrors } from '../../../../shared/flash_messages';
import { flashAPIErrors } from '../../../shared/flash_messages';

import { LogRetentionOptions } from './types';
import { LogRetentionLogic } from './log_retention_logic';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

import { kea, MakeLogicType } from 'kea';

import { HttpLogic } from '../../../shared/http';
import { flashAPIErrors } from '../../../shared/flash_messages';

import { LogRetentionOptions, LogRetention, LogRetentionServer } from './types';
import { HttpLogic } from '../../../../shared/http';
import { flashAPIErrors } from '../../../../shared/flash_messages';
import { convertLogRetentionFromServerToClient } from './utils/convert_log_retention';

interface LogRetentionActions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../../../__mocks__/kea.mock';
import { setMockValues } from '../../../../../__mocks__';
import '../../../../__mocks__/kea.mock';
import { setMockValues } from '../../../../__mocks__';

import React from 'react';
import { shallow } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';
import { useValues } from 'kea';
import moment from 'moment';

import { AppLogic } from '../../../../app_logic';
import { AppLogic } from '../../../app_logic';
import { LogRetentionLogic } from '../log_retention_logic';
import { LogRetentionOptions } from '../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { convertLogRetentionFromServerToClient } from './convert_log_retention';

describe('convertLogRetentionFromServerToClient', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const GenericConfirmationModal: React.FC<GenericConfirmationModalProps> =
<p>
<strong>{subheading}</strong>
</p>
<p>{description}</p>
{description}
</EuiText>
<EuiSpacer />
<EuiFormRow
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { LogRetentionPanel } from './log_retention_panel';
export { LogRetentionConfirmationModal } from './log_retention_confirmation_modal';
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { setMockActions, setMockValues } from '../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';

import { LogRetentionConfirmationModal } from './log_retention_confirmation_modal';
import { LogRetentionOptions } from './types';
import { LogRetentionOptions } from '../../log_retention';
import { GenericConfirmationModal } from './generic_confirmation_modal';
import { LogRetentionConfirmationModal } from './log_retention_confirmation_modal';

describe('<LogRetentionConfirmationModal />', () => {
const actions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import { i18n } from '@kbn/i18n';
import { EuiTextColor, EuiOverlayMask } from '@elastic/eui';
import { useActions, useValues } from 'kea';

import { LogRetentionLogic, LogRetentionOptions } from '../../log_retention';
import { GenericConfirmationModal } from './generic_confirmation_modal';
import { LogRetentionLogic } from './log_retention_logic';

import { LogRetentionOptions } from './types';

export const LogRetentionConfirmationModal: React.FC = () => {
const CANNOT_BE_RECOVERED_TEXT = i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { setMockActions, setMockValues } from '../../../../__mocks__';
import React from 'react';
import { shallow } from 'enzyme';

import { LogRetention } from '../../log_retention/types';
import { LogRetentionPanel } from './log_retention_panel';
import { LogRetention } from './types';

describe('<LogRetentionPanel />', () => {
const actions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import { useActions, useValues } from 'kea';

import { DOCS_PREFIX } from '../../../routes';

import { LogRetentionLogic } from './log_retention_logic';
import { AnalyticsLogRetentionMessage, ApiLogRetentionMessage } from './messaging';
import { LogRetentionOptions } from './types';
import {
LogRetentionLogic,
LogRetentionOptions,
AnalyticsLogRetentionMessage,
ApiLogRetentionMessage,
} from '../../log_retention';

export const LogRetentionPanel: React.FC = () => {
const { toggleLogRetention, fetchLogRetention } = useActions(LogRetentionLogic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import {

import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { FlashMessages } from '../../../shared/flash_messages';
import { LogRetentionPanel } from './log_retention/log_retention_panel';
import { LogRetentionConfirmationModal } from './log_retention/log_retention_confirmation_modal';

import { LogRetentionPanel, LogRetentionConfirmationModal } from './log_retention';
import { SETTINGS_TITLE } from './';

export const Settings: React.FC = () => {
Expand Down

0 comments on commit 64275cd

Please sign in to comment.