这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions console/cypress/integration/validators/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,11 @@ 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.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 ===
Expand Down
47 changes: 42 additions & 5 deletions console/src/components/Services/EventTrigger/Add/AddActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand All @@ -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' });
}
};
};

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,14 @@ class AddTrigger extends Component {
const tableSchema = tableListBySchema.find(
t => t.table_name === e.target.value
);

const columns = [];
if (tableSchema) {
tableSchema.columns.map(colObj => {
const column = colObj.column_name;
columns.push(column);
});
}
dispatch(operationToggleAllColumns(columns));
dispatch(operationToggleAllColumns(columns, supportColumnChangeFeature));
};

const handleOperationSelection = e => {
Expand All @@ -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
Expand Down Expand Up @@ -310,7 +311,6 @@ class AddTrigger extends Component {
}
return null;
};

const advancedColumnSection = supportColumnChangeFeature ? (
<div>
<h4 className={styles.subheading_text}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -235,7 +239,6 @@ const reducer = (state = defaultState, action) => {
[action.query]: { columns: [...queryColumns, action.column] },
},
};

case SET_RETRY_NUM:
return {
...state,
Expand Down