diff --git a/console/src/components/Services/Data/TableBrowseRows/EditItem.js b/console/src/components/Services/Data/TableBrowseRows/EditItem.js
index e56d85b4bc130..ebda8bb9dcf3d 100644
--- a/console/src/components/Services/Data/TableBrowseRows/EditItem.js
+++ b/console/src/components/Services/Data/TableBrowseRows/EditItem.js
@@ -6,6 +6,19 @@ import globals from '../../../../Globals';
import { modalClose } from './EditActions';
import Button from '../../Layout/Button/Button';
+import {
+ getPlaceholder,
+ INTEGER,
+ BIGINT,
+ NUMERIC,
+ DATE,
+ BOOLEAN,
+ UUID,
+ JSONDTYPE,
+ JSONB,
+ TIMESTAMP,
+ TIMETZ,
+} from '../../../../constants';
// import RichTextEditor from 'react-rte';
import { replace } from 'react-router-redux';
@@ -72,7 +85,7 @@ class EditItem extends Component {
// Text type
let typedInput = (
);
- } else if (colType === 'numeric') {
+ } else if (colType === BIGINT) {
typedInput = (
);
- } else if (colType === 'timestamp with time zone') {
+ } else if (colType === NUMERIC) {
typedInput = (
);
- } else if (colType === 'date') {
+ } else if (colType === TIMESTAMP) {
typedInput = (
);
- } else if (colType === 'timetz') {
- const time = new Date().toISOString().slice(11, 19);
+ } else if (colType === DATE) {
typedInput = (
);
- } else if (colType === 'json' || colType === 'jsonb') {
+ } else if (colType === TIMETZ) {
typedInput = (
+ );
+ } else if (colType === JSONDTYPE || colType === JSONB) {
+ typedInput = (
+
);
- } else if (colType === 'boolean') {
+ } else if (colType === BOOLEAN) {
typedInput = (
);
+ } else if (colType === UUID) {
+ typedInput = (
+
+ );
} else {
// everything else is text.
// find value to be shown. rich text editor vs clone
diff --git a/console/src/components/Services/Data/TableInsertItem/InsertItem.js b/console/src/components/Services/Data/TableInsertItem/InsertItem.js
index f2256cf7205d2..d056d1a6462bf 100644
--- a/console/src/components/Services/Data/TableInsertItem/InsertItem.js
+++ b/console/src/components/Services/Data/TableInsertItem/InsertItem.js
@@ -5,6 +5,12 @@ import { insertItem, I_RESET } from './InsertActions';
import { ordinalColSort } from '../utils';
import { setTable } from '../DataActions';
import Button from '../../Layout/Button/Button';
+import {
+ getPlaceholder,
+ BOOLEAN,
+ JSONB,
+ JSONDTYPE,
+} from '../../../../constants';
class InsertItem extends Component {
constructor() {
@@ -109,32 +115,6 @@ class InsertItem extends Component {
type: 'text',
};
- const getPlaceholder = type => {
- switch (type) {
- case 'integer':
- return 'integer';
- case 'bigint':
- return 'BIG integer';
- case 'numeric':
- return 'float';
- case 'timestamp with time zone':
- return new Date().toISOString();
- case 'date':
- return new Date().toISOString().slice(0, 10);
- case 'timetz':
- const time = new Date().toISOString().slice(11, 19);
- return `${time}Z or ${time}+05:30`;
- case 'uuid':
- return 'UUID';
- case 'json':
- return '{"name": "foo"} or [12, "asdf"]';
- case 'jsonb':
- return '{"name": "foo"} or [12, "asdf"]';
- default:
- return 'text';
- }
- };
-
const colType = col.data_type;
let typedInput = (
@@ -150,7 +130,7 @@ class InsertItem extends Component {
);
}
- if (colType === 'json' || colType === 'jsonb') {
+ if (colType === JSONDTYPE || colType === JSONB) {
// JSON/JSONB
typedInput = (
{
+ switch (type) {
+ case 'integer':
+ return 'integer';
+ case 'bigint':
+ return 'BIG integer';
+ case 'numeric':
+ return 'float';
+ case 'timestamp with time zone':
+ return new Date().toISOString();
+ case 'date':
+ return new Date().toISOString().slice(0, 10);
+ case 'timetz':
+ const time = new Date().toISOString().slice(11, 19);
+ return `${time}Z or ${time}+05:30`;
+ case 'uuid':
+ return 'UUID';
+ case 'json':
+ return '{"name": "foo"} or [12, "bar"]';
+ case 'jsonb':
+ return '{"name": "foo"} or [12, "bar"]';
+ default:
+ return 'text';
+ }
+};