From fb011fa6a9fb9964c262602b00b56703b5c2d84b Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 23 Nov 2020 15:15:00 +0100 Subject: [PATCH] removed configuration context for now --- .../configuration_warning_context.tsx | 48 --- .../sections/edit_policy/edit_policy.tsx | 347 +++++++++--------- 2 files changed, 169 insertions(+), 226 deletions(-) delete mode 100644 x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/configuration_warning_context.tsx diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/configuration_warning_context.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/configuration_warning_context.tsx deleted file mode 100644 index ae02ccf0843a5..0000000000000 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/configuration_warning_context.tsx +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. - */ - -import React, { FunctionComponent, createContext, useMemo, useContext } from 'react'; -import { get } from 'lodash'; - -import { useFormData } from '../../../shared_imports'; - -interface Value { - multipleShrinkActions: boolean; -} - -const ConfigurationWarningContext = createContext(null as any); - -const hotShrinkPath = 'phases.hot.actions.shrink.number_of_shards'; -const warmShrinkPath = 'phases.warm.actions.shrink.number_of_shards'; - -export const ConfigurationWarningProvider: FunctionComponent = ({ children }) => { - const [formData] = useFormData({ - watch: [hotShrinkPath, warmShrinkPath], - }); - - const configurationWarnings: Value = useMemo( - () => ({ - multipleShrinkActions: get(formData, hotShrinkPath) && get(formData, warmShrinkPath), - }), - [formData] - ); - - return ( - - {children} - - ); -}; - -export const useConfigWarningContext = () => { - const ctx = useContext(ConfigurationWarningContext); - if (!ctx) { - throw new Error( - `"useConfigWarningContext" must be used inside of ConfigurationWarningProvider.` - ); - } - return ctx; -}; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx index 719c88fe81204..efa9652e05d84 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx @@ -47,7 +47,6 @@ import { import { schema, deserializer, createSerializer, createPolicyNameValidations } from './form'; import { useEditPolicyContext } from './edit_policy_context'; -import { ConfigurationWarningProvider } from './configuration_warning_context'; import { FormInternal } from './types'; export interface Props { @@ -150,198 +149,190 @@ export const EditPolicy: React.FunctionComponent = ({ history }) => {
- - - -

- + +

+ {' '} - - } - /> -

-
+ />{' '} + + } + /> +

+ - + - {isNewPolicy ? null : ( - - -

- - - - .{' '} + {isNewPolicy ? null : ( + + +

+ + + .{' '} + -

-
- - - - { - setSaveAsNew(e.target.checked); - }} - label={ - - - - } /> - -
- )} - - {saveAsNew || isNewPolicy ? ( - - +

+ + + + + { + setSaveAsNew(e.target.checked); + }} + label={ + -
- } - titleSize="s" - fullWidth - > - - path={policyNamePath} - config={{ - label: i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.policyNameLabel', - { - defaultMessage: 'Policy name', - } - ), - helpText: i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.validPolicyNameMessage', - { - defaultMessage: - 'A policy name cannot start with an underscore and cannot contain a question mark or a space.', - } - ), - validations: policyNameValidations, - }} - component={TextField} - componentProps={{ - fullWidth: false, - euiFieldProps: { - 'data-test-subj': 'policyNameField', - }, - }} + } /> - - ) : null} - - - - - - - - - - - - - - - - - - - - - - - - - {saveAsNew ? ( - - ) : ( - - )} - - - - - - - - - - - - - - {isShowingPolicyJsonFlyout ? ( + + + )} + + {saveAsNew || isNewPolicy ? ( + + - ) : ( + + + } + titleSize="s" + fullWidth + > + + path={policyNamePath} + config={{ + label: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.policyNameLabel', { + defaultMessage: 'Policy name', + }), + helpText: i18n.translate( + 'xpack.indexLifecycleMgmt.editPolicy.validPolicyNameMessage', + { + defaultMessage: + 'A policy name cannot start with an underscore and cannot contain a question mark or a space.', + } + ), + validations: policyNameValidations, + }} + component={TextField} + componentProps={{ + fullWidth: false, + euiFieldProps: { + 'data-test-subj': 'policyNameField', + }, + }} + /> + + ) : null} + + + + + + + + + + + + + + + + + + + + + + + + + {saveAsNew ? ( + + ) : ( + + )} + + + + + - )} - - - - - {isShowingPolicyJsonFlyout ? ( - setIsShowingPolicyJsonFlyout(false)} - /> - ) : null} - + + + + + + + + {isShowingPolicyJsonFlyout ? ( + + ) : ( + + )} + + + + + {isShowingPolicyJsonFlyout ? ( + setIsShowingPolicyJsonFlyout(false)} + /> + ) : null}