diff --git a/cli/migrate/api/migrate.go b/cli/migrate/api/migrate.go
index 82ea5dff1fc..299f7cb3425 100644
--- a/cli/migrate/api/migrate.go
+++ b/cli/migrate/api/migrate.go
@@ -1,6 +1,7 @@
package api
import (
+ "fmt"
"net/http"
"net/url"
"strings"
@@ -130,7 +131,7 @@ func MigrateAPI(c *gin.Context) {
c.JSON(http.StatusInternalServerError, &Response{Code: "internal_error", Message: err.Error()})
return
}
- c.JSON(http.StatusOK, &Response{Name: request.Name})
+ c.JSON(http.StatusOK, &Response{Name: fmt.Sprintf("%d_%s", timestamp, request.Name)})
default:
c.JSON(http.StatusMethodNotAllowed, &gin.H{"message": "Method not allowed"})
}
diff --git a/console/cypress/integration/data/modify/spec.js b/console/cypress/integration/data/modify/spec.js
index cf28014bb7e..d7b32e61542 100644
--- a/console/cypress/integration/data/modify/spec.js
+++ b/console/cypress/integration/data/modify/spec.js
@@ -234,8 +234,7 @@ export const passRemoveUniqueKey = () => {
};
export const passMTDeleteCol = () => {
- // cy.get(getElementFromAlias(`edit-${getColName(0)}`)).click();
- // cy.wait(500);
+ cy.get(getElementFromAlias('modify-table-edit-column-1')).click();
cy.get(getElementFromAlias('modify-table-column-1-remove')).click();
cy.on('window:alert', str => {
expect(str === 'Are you sure you want to delete?').to.be.true;
diff --git a/console/src/components/App/Actions.js b/console/src/components/App/Actions.js
index ec64dcc5f8e..66ef1fd048a 100644
--- a/console/src/components/App/Actions.js
+++ b/console/src/components/App/Actions.js
@@ -40,31 +40,8 @@ const showNotification = ({
Notifications.show(
{
position,
- autoDismiss: level === 'error' ? 0 : 5,
- dismissible: level === 'error' ? 'click' : 'both',
- children: json ? jsonFormat(json) : null,
- ...options,
- },
- level
- )
- );
- };
-};
-
-const showTempNotification = ({
- level = 'info',
- position = 'tr',
- json,
- ...options
-} = {}) => {
- return dispatch => {
- dispatch(Notifications.removeAll());
- dispatch(
- Notifications.show(
- {
- position,
- autoDismiss: 2,
- dismissible: 'both',
+ autoDismiss: ['error', 'warning'].includes(level) ? 0 : 5,
+ dismissible: ['error', 'warning'].includes(level) ? 'button' : 'both',
children: json ? jsonFormat(json) : null,
...options,
},
@@ -161,5 +138,4 @@ export {
notifExpand,
notifMsg,
showNotification,
- showTempNotification,
};
diff --git a/console/src/components/Common/Common.scss b/console/src/components/Common/Common.scss
index 78ebdd0fe5c..ea8104f0294 100644
--- a/console/src/components/Common/Common.scss
+++ b/console/src/components/Common/Common.scss
@@ -853,6 +853,10 @@ code {
background: #f2f2f2 !important;
}
+.text_gray {
+ color: #767E96
+}
+
.docsButton {
background-color: #fff;
border-radius: 5px;
diff --git a/console/src/components/Services/Common/Notification.js b/console/src/components/Services/Common/Notification.js
index 16625f52c09..ecaf587da69 100644
--- a/console/src/components/Services/Common/Notification.js
+++ b/console/src/components/Services/Common/Notification.js
@@ -1,12 +1,12 @@
import React from 'react';
import AceEditor from 'react-ace';
-import { showNotification, showTempNotification } from '../../App/Actions';
+import { showNotification } from '../../App/Actions';
import { notifExpand, notifMsg } from '../../App/Actions';
import Button from '../../Common/Button/Button';
const styles = require('../../Common/TableCommon/Table.scss');
-const showErrorNotification = (title, message, reqBody, error) => {
+const showErrorNotification = (title, message, error) => {
let modMessage;
let refreshBtn;
@@ -36,7 +36,7 @@ const showErrorNotification = (title, message, reqBody, error) => {
} else {
modMessage = error.code;
}
- } else if (error && 'internal' in error) {
+ } else if (error && 'internal' in error && 'error' in error.internal) {
modMessage = error.code + ' : ' + error.internal.error.message;
} else if (error && 'custom' in error) {
modMessage = error.custom;
@@ -146,19 +146,6 @@ const showSuccessNotification = (title, message) => {
};
};
-const showTempErrorNotification = (title, message) => {
- return dispatch => {
- dispatch(
- showTempNotification({
- level: 'error',
- title,
- message: message ? message : null,
- autoDismiss: 3,
- })
- );
- };
-};
-
const showInfoNotification = title => {
return dispatch => {
dispatch(
@@ -170,9 +157,42 @@ const showInfoNotification = title => {
};
};
+const showWarningNotification = (title, message, dataObj) => {
+ const children = [];
+ if (dataObj) {
+ children.push(
+
diff --git a/console/src/components/Services/Data/TableModify/ColumnEditorList.js b/console/src/components/Services/Data/TableModify/ColumnEditorList.js
index de47f2f97d4..65fda1abbc8 100644
--- a/console/src/components/Services/Data/TableModify/ColumnEditorList.js
+++ b/console/src/components/Services/Data/TableModify/ColumnEditorList.js
@@ -71,16 +71,17 @@ const ColumnEditorList = ({
: false,
// uniqueConstraint: columnUniqueConstraints[colName],
default: col.column_default || '',
+ comment: col.comment || '',
};
- const onSubmit = () => {
- dispatch(saveColumnChangesSql(colName, col));
+ const onSubmit = toggleEditor => {
+ dispatch(saveColumnChangesSql(colName, col, toggleEditor));
};
const onDelete = () => {
const isOk = confirm('Are you sure you want to delete?');
if (isOk) {
- dispatch(deleteColumnSql(tableName, colName, col));
+ dispatch(deleteColumnSql(col, tableSchema));
}
};
@@ -91,11 +92,13 @@ const ColumnEditorList = ({
}
const isOk = window.confirm(confirmMessage);
if (isOk) {
- dispatch(deleteColumnSql(tableName, colName, col));
+ dispatch(deleteColumnSql(col, tableSchema));
}
};
const keyProperties = () => {
+ const propertiesDisplay = [];
+
const propertiesList = [];
propertiesList.push(columnProperties.display_type_name);
@@ -118,7 +121,17 @@ const ColumnEditorList = ({
const keyPropertiesString = propertiesList.join(', ');
- return
{keyPropertiesString && `- ${keyPropertiesString}`};
+ propertiesDisplay.push(
+
{keyPropertiesString && `- ${keyPropertiesString}`}
+ );
+ propertiesDisplay.push(
);
+ propertiesDisplay.push(
+
+ {columnProperties.comment && `${columnProperties.comment}`}
+
+ );
+
+ return propertiesDisplay;
};
const collapsedLabel = () => {
@@ -192,7 +205,6 @@ const ColumnEditorList = ({
tableName={tableName}
dispatch={dispatch}
currentSchema={currentSchema}
- columnComment={col.comment}
columnProperties={columnProperties}
selectedProperties={columnEdit}
editColumn={editColumn}
diff --git a/console/src/components/Services/Data/TableModify/ModifyActions.js b/console/src/components/Services/Data/TableModify/ModifyActions.js
index fd195751d90..a443da81d42 100644
--- a/console/src/components/Services/Data/TableModify/ModifyActions.js
+++ b/console/src/components/Services/Data/TableModify/ModifyActions.js
@@ -11,6 +11,7 @@ import { SET_SQL } from '../RawSQL/Actions';
import {
showErrorNotification,
showSuccessNotification,
+ showWarningNotification,
} from '../../Common/Notification';
import dataHeaders from '../Common/Headers';
import { UPDATE_MIGRATION_STATUS_ERROR } from '../../../Main/Actions';
@@ -497,7 +498,6 @@ const changeTableOrViewName = (isTable, oldName, newName) => {
showErrorNotification(
gqlValidationError[4],
gqlValidationError[1],
- gqlValidationError[2],
gqlValidationError[3]
)
);
@@ -750,12 +750,7 @@ const fetchViewDefinition = (viewName, isRedirect) => {
},
err => {
dispatch(
- showErrorNotification(
- 'Fetching definition failed!',
- err.error,
- reqBody,
- err
- )
+ showErrorNotification('Fetching definition failed!', err.error, err)
);
}
);
@@ -808,61 +803,191 @@ const deleteViewSql = viewName => {
};
};
-const deleteColumnSql = (tableName, colName) => {
+const deleteColumnSql = (column, tableSchema) => {
return (dispatch, getState) => {
- const currentSchema = getState().tables.currentSchema;
- const deleteQueryUp =
- 'ALTER TABLE ' +
- '"' +
- currentSchema +
- '"' +
- '.' +
- '"' +
- tableName +
- '"' +
- ' DROP COLUMN ' +
- '"' +
- colName +
- '"';
+ const name = column.column_name;
+ const tableName = column.table_name;
+ const currentSchema = column.table_schema;
+ const comment = column.comment;
+ const is_nullable = column.is_nullable;
+ const col_type = column.udt_name;
+ const foreign_key_constraints = tableSchema.foreign_key_constraints.filter(
+ fkc => {
+ const columnKeys = Object.keys(fkc.column_mapping);
+ return columnKeys.includes(name);
+ }
+ );
+ const opp_foreign_key_constraints = tableSchema.opp_foreign_key_constraints.filter(
+ fkc => {
+ const columnKeys = Object.values(fkc.column_mapping);
+ return columnKeys.includes(name);
+ }
+ );
+ const unique_constraints = tableSchema.unique_constraints.filter(uc =>
+ uc.columns.includes(name)
+ );
+ const alterStatement =
+ 'ALTER TABLE ' + '"' + currentSchema + '"' + '.' + '"' + tableName + '" ';
+
const schemaChangesUp = [
{
type: 'run_sql',
args: {
- sql: deleteQueryUp,
+ sql: alterStatement + 'DROP COLUMN ' + '"' + name + '" CASCADE',
},
},
];
+ const schemaChangesDown = [];
- /*
- const schemaChangesDown = [{
+ schemaChangesDown.push({
type: 'run_sql',
args: {
- 'sql': deleteQueryDown
- }
- }];
- */
+ sql: alterStatement + 'ADD COLUMN ' + '"' + name + '"' + ' ' + col_type,
+ },
+ });
+
+ if (is_nullable) {
+ schemaChangesDown.push({
+ type: 'run_sql',
+ args: {
+ sql:
+ alterStatement +
+ 'ALTER COLUMN ' +
+ '"' +
+ name +
+ '" ' +
+ 'DROP NOT NULL',
+ },
+ });
+ } else {
+ schemaChangesDown.push({
+ type: 'run_sql',
+ args: {
+ sql:
+ alterStatement +
+ 'ALTER COLUMN ' +
+ '"' +
+ name +
+ '" ' +
+ 'SET NOT NULL',
+ },
+ });
+ }
+
+ const merged_fkc = foreign_key_constraints.concat(opp_foreign_key_constraints);
+ if (merged_fkc.length > 0) {
+ merged_fkc.forEach(fkc => {
+ // add foreign key constraint to down migration
+ const lcol = Object.keys(fkc.column_mapping);
+ const rcol = Object.values(fkc.column_mapping);
+ const onUpdate = pgConfTypes[fkc.on_update];
+ const onDelete = pgConfTypes[fkc.on_delete];
+ schemaChangesDown.push({
+ type: 'run_sql',
+ args: {
+ sql:
+ alterStatement +
+ 'ADD CONSTRAINT ' +
+ `${fkc.constraint_name} ` +
+ 'FOREIGN KEY ' +
+ `(${lcol.join(', ')}) ` +
+ 'REFERENCES ' +
+ `"${fkc.ref_table_table_schema}"."${fkc.ref_table}" ` +
+ `(${rcol.join(', ')}) ` +
+ `ON DELETE ${onDelete} ` +
+ `ON UPDATE ${onUpdate}`,
+ },
+ });
+ });
+ }
+
+ if (unique_constraints.length > 0) {
+ unique_constraints.forEach(uc => {
+ // add unique constraint to down migration
+ schemaChangesDown.push({
+ type: 'run_sql',
+ args: {
+ sql:
+ alterStatement +
+ 'ADD CONSTRAINT ' +
+ `${uc.constraint_name} ` +
+ 'UNIQUE ' +
+ `(${uc.columns.join(', ')})`,
+ },
+ });
+ });
+ }
+
+ if (column.column_default !== null) {
+ // add column default to down migration
+ schemaChangesDown.push({
+ type: 'run_sql',
+ args: {
+ sql:
+ alterStatement +
+ 'ALTER COLUMN ' +
+ `"${name}" ` +
+ 'SET DEFAULT ' +
+ column.column_default,
+ },
+ });
+ }
+
+ // COMMENT ON COLUMN my_table.my_column IS 'Employee ID number';
+ if (comment) {
+ schemaChangesDown.push({
+ type: 'run_sql',
+ args: {
+ sql:
+ 'COMMENT ON COLUMN ' +
+ '"' +
+ currentSchema +
+ '"' +
+ '.' +
+ '"' +
+ tableName +
+ '"' +
+ '.' +
+ '"' +
+ name +
+ '"' +
+ ' ' +
+ 'IS ' +
+ "'" +
+ comment +
+ "'",
+ },
+ });
+ }
// Apply migrations
const migrationName =
- 'alter_table_' +
- currentSchema +
- '_' +
- tableName +
- '_drop_column_' +
- colName;
+ 'alter_table_' + currentSchema + '_' + tableName + '_drop_column_' + name;
const requestMsg = 'Deleting Column...';
const successMsg = 'Column deleted';
const errorMsg = 'Deleting column failed';
- const customOnSuccess = () => {};
+ const customOnSuccess = (data, consoleMode, migrationMode) => {
+ if (consoleMode === 'cli' && migrationMode) {
+ // show warning information
+ dispatch(
+ showWarningNotification(
+ 'Check down migration',
+ 'Please verify that the down migration will reset the DB to the previous state (you ' +
+ 'might need to add recreation of some dependent objects like indexes, etc.)',
+ data
+ )
+ );
+ }
+ };
const customOnError = () => {};
makeMigrationCall(
dispatch,
getState,
schemaChangesUp,
- [],
+ schemaChangesDown,
migrationName,
customOnSuccess,
customOnError,
@@ -1159,7 +1284,7 @@ const isColumnUnique = (tableSchema, colName) => {
);
};
-const saveColumnChangesSql = (colName, column) => {
+const saveColumnChangesSql = (colName, column, onSuccess) => {
// eslint-disable-line no-unused-vars
return (dispatch, getState) => {
const columnEdit = getState().tables.modify.columnEdit[colName];
@@ -1663,7 +1788,6 @@ const saveColumnChangesSql = (colName, column) => {
showErrorNotification(
gqlColumnErrorNotif[4],
gqlColumnErrorNotif[1],
- gqlColumnErrorNotif[2],
gqlColumnErrorNotif[3]
)
);
@@ -1696,7 +1820,8 @@ const saveColumnChangesSql = (colName, column) => {
const errorMsg = 'Modifying column failed';
const customOnSuccess = () => {
- dispatch(setColumnEdit(columnEdit));
+ dispatch(resetColumnEdit(colName));
+ onSuccess();
};
const customOnError = () => {};
@@ -1750,7 +1875,6 @@ const fetchColumnCasts = () => {
showErrorNotification(
'Error fetching column casts information',
'Kindly reach out to us in case you face this issue again',
- error,
error
)
);
diff --git a/console/src/components/Services/Data/TableRelationships/Actions.js b/console/src/components/Services/Data/TableRelationships/Actions.js
index 1f152525ead..bc5d946e1ee 100644
--- a/console/src/components/Services/Data/TableRelationships/Actions.js
+++ b/console/src/components/Services/Data/TableRelationships/Actions.js
@@ -371,7 +371,6 @@ const addRelViewMigrate = (tableSchema, toggleEditor) => (
showErrorNotification(
'Error adding relationship!',
'Please select a name for the relationship',
- '',
{ custom: 'Relationship name cannot be empty' }
)
);
@@ -380,7 +379,6 @@ const addRelViewMigrate = (tableSchema, toggleEditor) => (
showErrorNotification(
gqlRelErrorNotif[0],
gqlRelErrorNotif[1],
- gqlRelErrorNotif[2],
gqlRelErrorNotif[3]
)
);
diff --git a/console/src/components/Services/Data/TableRelationships/RelationshipEditor.js b/console/src/components/Services/Data/TableRelationships/RelationshipEditor.js
index 8db3bfa43e8..56aa568c3a8 100644
--- a/console/src/components/Services/Data/TableRelationships/RelationshipEditor.js
+++ b/console/src/components/Services/Data/TableRelationships/RelationshipEditor.js
@@ -52,7 +52,6 @@ class RelationshipEditor extends React.Component {
showErrorNotification(
gqlRelErrorNotif[4],
gqlRelErrorNotif[1],
- gqlRelErrorNotif[2],
gqlRelErrorNotif[3]
)
);
diff --git a/console/src/components/Services/Data/TableRelationships/Relationships.js b/console/src/components/Services/Data/TableRelationships/Relationships.js
index d82a504da06..8c9e184c02e 100644
--- a/console/src/components/Services/Data/TableRelationships/Relationships.js
+++ b/console/src/components/Services/Data/TableRelationships/Relationships.js
@@ -52,7 +52,6 @@ const addRelationshipCellView = (
showErrorNotification(
'Error adding relationship!',
'Please select a name for the relationship',
- '',
{ custom: 'Relationship name cannot be empty' }
)
);
@@ -62,7 +61,6 @@ const addRelationshipCellView = (
showErrorNotification(
gqlRelErrorNotif[0],
gqlRelErrorNotif[1],
- gqlRelErrorNotif[2],
gqlRelErrorNotif[3]
)
);
diff --git a/console/src/components/Services/EventTrigger/Add/AddActions.js b/console/src/components/Services/EventTrigger/Add/AddActions.js
index c04a8f54eaf..beb5e068110 100644
--- a/console/src/components/Services/EventTrigger/Add/AddActions.js
+++ b/console/src/components/Services/EventTrigger/Add/AddActions.js
@@ -1,7 +1,7 @@
import defaultState from './AddState';
import _push from '../push';
import { loadTriggers, makeMigrationCall, setTrigger } from '../EventActions';
-import { showSuccessNotification } from '../Notification';
+import { showSuccessNotification } from '../../Common/Notification';
import { UPDATE_MIGRATION_STATUS_ERROR } from '../../../Main/Actions';
import { updateSchemaInfo } from '../../Data/DataActions';
diff --git a/console/src/components/Services/EventTrigger/Add/AddTrigger.js b/console/src/components/Services/EventTrigger/Add/AddTrigger.js
index 2ab96608ae3..91242fbce6f 100644
--- a/console/src/components/Services/EventTrigger/Add/AddTrigger.js
+++ b/console/src/components/Services/EventTrigger/Add/AddTrigger.js
@@ -27,7 +27,7 @@ import {
loadTableList,
} from './AddActions';
import { listDuplicate } from '../../../../utils/data';
-import { showErrorNotification } from '../Notification';
+import { showErrorNotification } from '../../Common/Notification';
import { createTrigger } from './AddActions';
import DropdownButton from '../../../Common/DropdownButton/DropdownButton';
@@ -146,7 +146,7 @@ class AddTrigger extends Component {
this.props.dispatch(createTrigger());
} else {
this.props.dispatch(
- showErrorNotification('Error creating trigger!', errorMsg, '', {
+ showErrorNotification('Error creating trigger!', errorMsg, {
custom: customMsg,
})
);
diff --git a/console/src/components/Services/EventTrigger/EventActions.js b/console/src/components/Services/EventTrigger/EventActions.js
index 815b511703c..4bb50f7c127 100644
--- a/console/src/components/Services/EventTrigger/EventActions.js
+++ b/console/src/components/Services/EventTrigger/EventActions.js
@@ -5,7 +5,10 @@ import processedEventsReducer from './ProcessedEvents/ViewActions';
import pendingEventsReducer from './PendingEvents/ViewActions';
import runningEventsReducer from './RunningEvents/ViewActions';
import streamingLogsReducer from './StreamingLogs/LogActions';
-import { showErrorNotification, showSuccessNotification } from './Notification';
+import {
+ showSuccessNotification,
+ showErrorNotification,
+} from '../Common/Notification';
import dataHeaders from './Common/Headers';
import { loadMigrationStatus } from '../../Main/Actions';
import returnMigrateUrl from './Common/getMigrateUrl';
@@ -317,34 +320,23 @@ const setRedeliverEvent = eventId => dispatch => {
/* **********Shared functions between table actions********* */
const handleMigrationErrors = (title, errorMsg) => dispatch => {
- const requestMsg = title;
if (globals.consoleMode === SERVER_CONSOLE_MODE) {
// handle errors for run_sql based workflow
- dispatch(showErrorNotification(title, errorMsg.code, requestMsg, errorMsg));
+ dispatch(showErrorNotification(title, errorMsg.code, errorMsg));
} else if (errorMsg.code === 'migration_failed') {
- dispatch(
- showErrorNotification(title, 'Migration Failed', requestMsg, errorMsg)
- );
+ dispatch(showErrorNotification(title, 'Migration Failed', errorMsg));
} else if (errorMsg.code === 'data_api_error') {
const parsedErrorMsg = errorMsg;
parsedErrorMsg.message = JSON.parse(errorMsg.message);
dispatch(
- showErrorNotification(
- title,
- parsedErrorMsg.message.error,
- requestMsg,
- parsedErrorMsg
- )
+ showErrorNotification(title, parsedErrorMsg.message.error, parsedErrorMsg)
);
} else {
// any other unhandled codes
const parsedErrorMsg = errorMsg;
parsedErrorMsg.message = JSON.parse(errorMsg.message);
- dispatch(
- showErrorNotification(title, errorMsg.code, requestMsg, parsedErrorMsg)
- );
+ dispatch(showErrorNotification(title, errorMsg.code, parsedErrorMsg));
}
- // dispatch(showErrorNotification(msg, firstDisplay, request, response));
};
const makeMigrationCall = (
diff --git a/console/src/components/Services/EventTrigger/Modify/Actions.js b/console/src/components/Services/EventTrigger/Modify/Actions.js
index d82c3ad0c55..bfb3d76f1c0 100644
--- a/console/src/components/Services/EventTrigger/Modify/Actions.js
+++ b/console/src/components/Services/EventTrigger/Modify/Actions.js
@@ -1,7 +1,7 @@
import defaultState from './State';
import { loadTriggers, makeMigrationCall, setTrigger } from '../EventActions';
import { UPDATE_MIGRATION_STATUS_ERROR } from '../../../Main/Actions';
-import { showErrorNotification } from '../Notification';
+import { showErrorNotification } from '../../Common/Notification';
import { MANUAL_TRIGGER_VAR } from './utils';
@@ -70,7 +70,7 @@ export const REQUEST_COMPLETE = 'ModifyTrigger/REQUEST_COMPLETE';
export const showValidationError = message => {
return dispatch => {
dispatch(
- showErrorNotification('Error modifying trigger!', 'Invalid input', '', {
+ showErrorNotification('Error modifying trigger!', 'Invalid input', {
custom: message,
})
);
diff --git a/console/src/components/Services/EventTrigger/Notification.js b/console/src/components/Services/EventTrigger/Notification.js
deleted file mode 100644
index a0783112a59..00000000000
--- a/console/src/components/Services/EventTrigger/Notification.js
+++ /dev/null
@@ -1,178 +0,0 @@
-import React from 'react';
-import AceEditor from 'react-ace';
-import { showNotification, showTempNotification } from '../../App/Actions';
-import { notifExpand, notifMsg } from '../../App/Actions';
-import Button from '../../Common/Button/Button';
-
-const styles = require('../../Common/TableCommon/Table.scss');
-
-const showErrorNotification = (title, message, reqBody, error) => {
- let modMessage;
- let refreshBtn;
-
- if (
- error &&
- error.message &&
- (error.message.error === 'postgres query error' ||
- error.message.error === 'query execution failed')
- ) {
- if (error.message.internal) {
- modMessage =
- error.message.code + ': ' + error.message.internal.error.message;
- } else {
- modMessage = error.code + ': ' + error.message.error;
- }
- } else if (error && 'info' in error) {
- modMessage = error.info;
- } else if (error && 'message' in error) {
- if (error.code) {
- if (error.message.error) {
- modMessage = error.message.error.message;
- } else {
- modMessage = error.message;
- }
- } else if (error && error.message && 'code' in error.message) {
- modMessage = error.message.code + ' : ' + message;
- } else {
- modMessage = error.code;
- }
- } else if (error && 'internal' in error) {
- modMessage = error.code + ' : ' + error.internal.error.message;
- } else if (error && 'custom' in error) {
- modMessage = error.custom;
- } else if (error && 'code' in error && 'error' in error && 'path' in error) {
- // Data API error
- modMessage = error.error;
- } else {
- modMessage = error ? error : message;
- }
-
- let finalJson = error ? error.message : '{}';
-
- if (error && 'action' in error) {
- refreshBtn = (
-
- );
- finalJson = error.action;
- } else if (error && 'internal' in error) {
- finalJson = error.internal;
- }
-
- return dispatch => {
- const expandClicked = finalMsg => {
- // trigger a modal with a bigger view
- dispatch(notifExpand(true));
- dispatch(notifMsg(JSON.stringify(finalMsg, null, 4)));
- };
-
- const getNotificationAction = () => {
- let action = null;
-
- if (reqBody) {
- const notification = [
-
-
{
- e.preventDefault();
- expandClicked(finalJson);
- }}
- className={styles.aceBlockExpand + ' fa fa-expand'}
- />
-
- {refreshBtn}
- ,
- ];
-
- action = {
- label: 'Details',
- callback: () => {
- dispatch(
- showNotification({
- level: 'error',
- title,
- message: modMessage,
- dismissible: 'button',
- children: notification,
- })
- );
- },
- };
- }
-
- return action;
- };
-
- dispatch(
- showNotification({
- level: 'error',
- title,
- message: modMessage,
- action: getNotificationAction(),
- })
- );
- };
-};
-
-const showSuccessNotification = (title, message) => {
- return dispatch => {
- dispatch(
- showNotification({
- level: 'success',
- title,
- message: message ? message : null,
- })
- );
- };
-};
-
-const showTempErrorNotification = (title, message) => {
- return dispatch => {
- dispatch(
- showTempNotification({
- level: 'error',
- title,
- message: message ? message : null,
- autoDismiss: 3,
- })
- );
- };
-};
-
-const showInfoNotification = title => {
- return dispatch => {
- dispatch(
- showNotification({
- title,
- autoDismiss: 0,
- })
- );
- };
-};
-
-export {
- showErrorNotification,
- showSuccessNotification,
- showInfoNotification,
- showTempErrorNotification,
-};
diff --git a/console/src/components/Services/EventTrigger/ProcessedEvents/ViewActions.js b/console/src/components/Services/EventTrigger/ProcessedEvents/ViewActions.js
index 513bef2914e..31668efb198 100644
--- a/console/src/components/Services/EventTrigger/ProcessedEvents/ViewActions.js
+++ b/console/src/components/Services/EventTrigger/ProcessedEvents/ViewActions.js
@@ -6,7 +6,7 @@ import { findTableFromRel } from '../utils';
import {
showSuccessNotification,
showErrorNotification,
-} from '../Notification';
+} from '../../Common/Notification';
import dataHeaders from '../Common/Headers';
/* ****************** View actions *************/
@@ -192,9 +192,7 @@ const deleteItem = pkClause => {
);
},
err => {
- dispatch(
- showErrorNotification('Deleting row failed!', err.error, reqBody, err)
- );
+ dispatch(showErrorNotification('Deleting row failed!', err.error, err));
}
);
};
diff --git a/console/src/components/Services/Metadata/Actions.js b/console/src/components/Services/Metadata/Actions.js
index 8fa9f74992a..c7410740568 100644
--- a/console/src/components/Services/Metadata/Actions.js
+++ b/console/src/components/Services/Metadata/Actions.js
@@ -306,7 +306,6 @@ export const addAllowedQueries = (queries, isEmptyList, callback) => {
showErrorNotification(
'Adding query to allow-list failed',
null,
- null,
error
)
);
@@ -338,7 +337,6 @@ export const deleteAllowList = () => {
showErrorNotification(
'Deleting queries from allow-list failed',
null,
- null,
error
)
);
@@ -372,7 +370,6 @@ export const deleteAllowedQuery = (queryName, isLastQuery) => {
showErrorNotification(
'Deleting query from allow-list failed',
null,
- null,
error
)
);
@@ -399,12 +396,7 @@ export const updateAllowedQuery = (queryName, newQuery) => {
error => {
console.error(error);
dispatch(
- showErrorNotification(
- 'Updating allow-list query failed',
- null,
- null,
- error
- )
+ showErrorNotification('Updating allow-list query failed', null, error)
);
}
);
diff --git a/console/src/components/Services/Metadata/MetadataOptions/ExportMetadata.js b/console/src/components/Services/Metadata/MetadataOptions/ExportMetadata.js
index f8044374355..816542461cd 100644
--- a/console/src/components/Services/Metadata/MetadataOptions/ExportMetadata.js
+++ b/console/src/components/Services/Metadata/MetadataOptions/ExportMetadata.js
@@ -63,7 +63,6 @@ class ExportMetadata extends Component {
showErrorNotification(
'Metadata export failed',
'Something is wrong.',
- requestBody,
parsedErrorMsg
)
);
diff --git a/console/src/components/Services/Metadata/MetadataOptions/ImportMetadata.js b/console/src/components/Services/Metadata/MetadataOptions/ImportMetadata.js
index dfbf93ededc..7f3e2db6bca 100644
--- a/console/src/components/Services/Metadata/MetadataOptions/ImportMetadata.js
+++ b/console/src/components/Services/Metadata/MetadataOptions/ImportMetadata.js
@@ -63,7 +63,6 @@ class ImportMetadata extends Component {
showErrorNotification(
'Metadata import failed',
'Something is wrong.',
- requestBody,
parsedErrorMsg
)
);
diff --git a/console/src/components/Services/Metadata/MetadataOptions/ResetMetadata.js b/console/src/components/Services/Metadata/MetadataOptions/ResetMetadata.js
index 02763e123af..50458139bdf 100644
--- a/console/src/components/Services/Metadata/MetadataOptions/ResetMetadata.js
+++ b/console/src/components/Services/Metadata/MetadataOptions/ResetMetadata.js
@@ -66,7 +66,6 @@ class ResetMetadata extends Component {
showErrorNotification(
'Metadata reset failed',
'Something went wrong.',
- requestBody,
parsedErrorMsg
)
);