@@ -40,6 +40,8 @@ const transformationTypes = {
4040 }
4141}
4242
43+ const TABLE_MUST_BE_DEFINED_ERROR = 'Table must be defined'
44+
4345/**
4446 * Component that renders fields for one feed transformation
4547 * (e.g., ReplaceFileFromStringTransformation).
@@ -49,6 +51,15 @@ export default class FeedTransformation extends Component<Props, {errors: Array<
4951 errors : [ ]
5052 }
5153
54+ componentDidUpdate ( prevProps : Props ) {
55+ // Update error state if props.transformation.table changed
56+ // and 'Table must be defined' no longer applies.
57+ const { table } = this . props . transformation
58+ if ( table && prevProps . transformation . table !== table ) {
59+ this . setState ( { errors : this . state . errors . filter ( e => e !== TABLE_MUST_BE_DEFINED_ERROR ) } )
60+ }
61+ }
62+
5263 _getFieldsForType = ( type : string ) => {
5364 const { feedSource, index, onChange, transformation} = this . props
5465 const FieldsComponent = transformationTypes [ type ] . component
@@ -66,7 +77,7 @@ export default class FeedTransformation extends Component<Props, {errors: Array<
6677 _onValidationErrors = ( errors : Array < string > ) => {
6778 const issues : Array < string > = [ ]
6879 if ( ! this . props . transformation . table ) {
69- issues . push ( 'Table must be defined' )
80+ issues . push ( TABLE_MUST_BE_DEFINED_ERROR )
7081 }
7182 this . setState ( { errors : issues . concat ( errors ) } )
7283 }
0 commit comments