Skip to content

Commit

Permalink
Fix TS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed Oct 19, 2020
1 parent 74be93f commit 48ed86c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export const StateProvider: React.FC = ({ children }) => {
configuration: {
defaultValue: {},
data: {
raw: {},
internal: {},
format: () => ({}),
},
validate: () => Promise.resolve(true),
},
templates: {
defaultValue: {},
data: {
raw: {},
internal: {},
format: () => ({}),
},
validate: () => Promise.resolve(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ export const reducer = (state: State, action: Action): State => {
configuration: {
...state.configuration,
data: {
raw: action.value.configuration,
internal: action.value.configuration,
format: () => action.value.configuration,
},
defaultValue: action.value.configuration,
},
templates: {
...state.templates,
data: {
raw: action.value.templates,
internal: action.value.templates,
format: () => action.value.templates,
},
defaultValue: action.value.templates,
Expand Down Expand Up @@ -217,7 +217,7 @@ export const reducer = (state: State, action: Action): State => {
isValid: true,
defaultValue: action.value,
data: {
raw: action.value,
internal: action.value,
format: () => action.value,
},
validate: async () => true,
Expand All @@ -241,7 +241,7 @@ export const reducer = (state: State, action: Action): State => {
isValid: true,
defaultValue: action.value,
data: {
raw: action.value,
internal: action.value,
format: () => action.value,
},
validate: async () => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React, { FunctionComponent, useEffect, useState } from 'react';
import { i18n } from '@kbn/i18n';

import { get } from 'lodash';
import {
FIELD_TYPES,
UseField,
Expand Down Expand Up @@ -44,8 +44,8 @@ export const Json: FunctionComponent = () => {
const form = useFormContext();
const [isAddToPathDisabled, setIsAddToPathDisabled] = useState<boolean>(false);
useEffect(() => {
const subscription = form.subscribe(({ data: { raw: rawData } }) => {
const hasTargetField = !!rawData[TARGET_FIELD_PATH];
const subscription = form.subscribe(({ data: { internal } }) => {
const hasTargetField = !!get(internal, TARGET_FIELD_PATH);
if (hasTargetField && !isAddToPathDisabled) {
setIsAddToPathDisabled(true);
form.getFields()[ADD_TO_ROOT_FIELD_PATH].setValue(false);
Expand Down

0 comments on commit 48ed86c

Please sign in to comment.