From 6ab960aeb6f6a96fd18909f9320ac39e1f65f977 Mon Sep 17 00:00:00 2001 From: wawhal Date: Thu, 28 Feb 2019 11:40:25 +0530 Subject: [PATCH 1/4] fix #1629 --- .../Services/EventTrigger/Add/AddActions.js | 47 +++++++++++++++++-- .../Services/EventTrigger/Add/AddTrigger.js | 8 ++-- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/console/src/components/Services/EventTrigger/Add/AddActions.js b/console/src/components/Services/EventTrigger/Add/AddActions.js index 19656a5a73405..87e6bd2e076fd 100644 --- a/console/src/components/Services/EventTrigger/Add/AddActions.js +++ b/console/src/components/Services/EventTrigger/Add/AddActions.js @@ -26,6 +26,7 @@ const REQUEST_ERROR = 'AddTrigger/REQUEST_ERROR'; const VALIDATION_ERROR = 'AddTrigger/VALIDATION_ERROR'; const UPDATE_TABLE_LIST = 'AddTrigger/UPDATE_TABLE_LIST'; const TOGGLE_COLUMNS = 'AddTrigger/TOGGLE_COLUMNS'; +const TOGGLE_ALL_COLUMNS = 'AddTrigger/TOGGLE_ALL_COLUMNS'; const TOGGLE_QUERY_TYPE_SELECTED = 'AddTrigger/TOGGLE_QUERY_TYPE_SELECTED'; const TOGGLE_QUERY_TYPE_DESELECTED = 'AddTrigger/TOGGLE_QUERY_TYPE_DESELECTED'; const REMOVE_HEADER = 'AddTrigger/REMOVE_HEADER'; @@ -221,8 +222,28 @@ const fetchTableListBySchema = schemaName => (dispatch, getState) => { ); }; -const operationToggleColumn = (column, operation) => { +const operationToggleColumn = ( + column, + operation, + supportColumnChangeFeature +) => { return (dispatch, getState) => { + if (supportColumnChangeFeature) { + if (operation === 'update') { + const currentOperations = getState().addTrigger.operations; + const currentCols = currentOperations[operation]; + // check if column is in currentCols. if not, push + const isExists = currentCols.includes(column); + let finalCols = currentCols; + if (isExists) { + finalCols = currentCols.filter(col => col !== column); + } else { + finalCols.push(column); + } + dispatch({ type: TOGGLE_COLUMNS, cols: finalCols, op: operation }); + } + return; + } const currentOperations = getState().addTrigger.operations; const currentCols = currentOperations[operation]; // check if column is in currentCols. if not, push @@ -237,11 +258,18 @@ const operationToggleColumn = (column, operation) => { }; }; -const operationToggleAllColumns = columns => { +const operationToggleAllColumns = ( + columns, + supportListeningToColumnsUpdate +) => { return dispatch => { - dispatch({ type: TOGGLE_COLUMNS, cols: columns, op: 'insert' }); - dispatch({ type: TOGGLE_COLUMNS, cols: columns, op: 'update' }); - dispatch({ type: TOGGLE_COLUMNS, cols: columns, op: 'delete' }); + if (supportListeningToColumnsUpdate) { + dispatch({ type: TOGGLE_ALL_COLUMNS, cols: columns }); + } else { + dispatch({ type: TOGGLE_COLUMNS, cols: columns, op: 'insert' }); + dispatch({ type: TOGGLE_COLUMNS, cols: columns, op: 'update' }); + dispatch({ type: TOGGLE_COLUMNS, cols: columns, op: 'delete' }); + } }; }; @@ -377,6 +405,15 @@ const addTriggerReducer = (state = defaultState, action) => { const operations = state.operations; operations[action.op] = action.cols; return { ...state, operations: { ...operations } }; + case TOGGLE_ALL_COLUMNS: + return { + ...state, + operations: { + insert: '*', + delete: '*', + update: action.cols, + }, + }; case TOGGLE_QUERY_TYPE_SELECTED: const selectedOperations = state.selectedOperations; selectedOperations[action.data] = true; diff --git a/console/src/components/Services/EventTrigger/Add/AddTrigger.js b/console/src/components/Services/EventTrigger/Add/AddTrigger.js index db7a83b3aca38..18d969154dc65 100644 --- a/console/src/components/Services/EventTrigger/Add/AddTrigger.js +++ b/console/src/components/Services/EventTrigger/Add/AddTrigger.js @@ -253,7 +253,6 @@ class AddTrigger extends Component { const tableSchema = tableListBySchema.find( t => t.table_name === e.target.value ); - const columns = []; if (tableSchema) { tableSchema.columns.map(colObj => { @@ -261,7 +260,7 @@ class AddTrigger extends Component { columns.push(column); }); } - dispatch(operationToggleAllColumns(columns)); + dispatch(operationToggleAllColumns(columns, supportColumnChangeFeature)); }; const handleOperationSelection = e => { @@ -271,7 +270,9 @@ class AddTrigger extends Component { const getColumnList = type => { const dispatchToggleColumn = e => { const column = e.target.value; - dispatch(operationToggleColumn(column, type)); + dispatch( + operationToggleColumn(column, type, supportColumnChangeFeature) + ); }; const tableSchema = tableListBySchema.find( t => t.table_name === tableName @@ -310,7 +311,6 @@ class AddTrigger extends Component { } return null; }; - const advancedColumnSection = supportColumnChangeFeature ? (

From 511f60dab88b4d01abe5573aedbef2692672dbea Mon Sep 17 00:00:00 2001 From: wawhal Date: Thu, 28 Feb 2019 11:48:06 +0530 Subject: [PATCH 2/4] add star as coluim while modifying trigger --- .../src/components/Services/EventTrigger/Modify/Actions.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/console/src/components/Services/EventTrigger/Modify/Actions.js b/console/src/components/Services/EventTrigger/Modify/Actions.js index 070fab30f6d38..5ec9fb8b3be86 100644 --- a/console/src/components/Services/EventTrigger/Modify/Actions.js +++ b/console/src/components/Services/EventTrigger/Modify/Actions.js @@ -207,7 +207,11 @@ const reducer = (state = defaultState, action) => { case TOGGLE_QUERY_TYPE: const newDefinition = { ...state.definition }; if (action.value) { - newDefinition[action.query] = { columns: action.columns }; + if (action.query === 'update') { + newDefinition[action.query] = { columns: action.columns }; + } else { + newDefinition[action.query] = { columns: '*' }; + } } else { delete newDefinition[action.query]; } @@ -235,7 +239,6 @@ const reducer = (state = defaultState, action) => { [action.query]: { columns: [...queryColumns, action.column] }, }, }; - case SET_RETRY_NUM: return { ...state, From e0d7fcb1eebd45c6ff205e175de1792ec7ed0b5f Mon Sep 17 00:00:00 2001 From: wawhal Date: Thu, 28 Feb 2019 14:18:53 +0530 Subject: [PATCH 3/4] update tests for the given change --- console/cypress/integration/validators/validators.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/console/cypress/integration/validators/validators.js b/console/cypress/integration/validators/validators.js index d369526be1854..5b46739df2665 100644 --- a/console/cypress/integration/validators/validators.js +++ b/console/cypress/integration/validators/validators.js @@ -360,9 +360,9 @@ export const validateCTrigger = (triggerName, result) => { expect(response.status === 200).to.be.true; expect(response.body.length === 1).to.be.true; const trigger = response.body[0]; - expect(trigger.configuration.definition.insert.columns.length === 3).to.be + expect(trigger.configuration.definition.insert.columns === '*').to.be .true; - expect(trigger.configuration.definition.update.columns.length === 3).to.be + expect(trigger.configuration.definition.update.columns === '*').to.be .true; expect(trigger.configuration.definition.delete.columns.length === 3).to.be .true; From 069b145d40e11fe38d1f7f734525b8d9b9729ec1 Mon Sep 17 00:00:00 2001 From: wawhal Date: Thu, 28 Feb 2019 16:26:01 +0530 Subject: [PATCH 4/4] fix a bug in test --- console/cypress/integration/validators/validators.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/console/cypress/integration/validators/validators.js b/console/cypress/integration/validators/validators.js index 5b46739df2665..1efac049d601b 100644 --- a/console/cypress/integration/validators/validators.js +++ b/console/cypress/integration/validators/validators.js @@ -362,9 +362,9 @@ export const validateCTrigger = (triggerName, result) => { const trigger = response.body[0]; expect(trigger.configuration.definition.insert.columns === '*').to.be .true; - expect(trigger.configuration.definition.update.columns === '*').to.be + expect(trigger.configuration.definition.delete.columns === '*').to.be .true; - expect(trigger.configuration.definition.delete.columns.length === 3).to.be + expect(trigger.configuration.definition.update.columns.length === 3).to.be .true; expect( trigger.configuration.retry_conf.interval_sec ===