diff --git a/console/src/components/Common/utils/pgUtils.js b/console/src/components/Common/utils/pgUtils.js index c039c5d248c..ee6847b59c6 100644 --- a/console/src/components/Common/utils/pgUtils.js +++ b/console/src/components/Common/utils/pgUtils.js @@ -197,6 +197,16 @@ export const getTablePermissions = (table, role = null, action = null) => { return tablePermissions; }; +/*** Table/View Check Constraints utils ***/ + +export const getTableCheckConstraints = table => { + return table.check_constraints; +}; + +export const findTableCheckConstraint = (checkConstraints, constraintName) => { + return checkConstraints.find(c => c.constraint_name === constraintName); +}; + /*** Function utils ***/ export const getFunctionSchema = pgFunction => { diff --git a/console/src/components/Services/Data/TableModify/CheckConstraints.js b/console/src/components/Services/Data/TableModify/CheckConstraints.js new file mode 100644 index 00000000000..3eeb5e76572 --- /dev/null +++ b/console/src/components/Services/Data/TableModify/CheckConstraints.js @@ -0,0 +1,67 @@ +import React from 'react'; +import AceEditor from 'react-ace'; +import ExpandableEditor from '../../../Common/Layout/ExpandableEditor/Editor'; +import styles from './ModifyTable.scss'; +import { removeCheckConstraint } from './ModifyActions'; + +const CheckConstraints = ({ constraints, dispatch }) => { + // if no constraints are present + if (!constraints.length) { + return 'No check constraints'; + } + + // map over constraints + return constraints.map((constraint, i) => { + const { constraint_name, check } = constraint; + + // constraint name as expanded and collapsed label + const label = () => { + return ( +