Skip to content

Commit

Permalink
Merge branch 'master' into docs-bool-exp
Browse files Browse the repository at this point in the history
  • Loading branch information
rikinsk authored Dec 17, 2019
2 parents adc2b6c + 7abe5dd commit 98438fa
Show file tree
Hide file tree
Showing 28 changed files with 117 additions and 308 deletions.
24 changes: 2 additions & 22 deletions console/src/components/Main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
setLoveConsentState,
} from './loveConsentLocalStorage';

import { versionGT, FT_JWT_ANALYZER } from '../../helpers/versionUtils';
import { versionGT } from '../../helpers/versionUtils';
import { getSchemaBaseRoute } from '../Common/utils/routesUtils';

class Main extends React.Component {
Expand Down Expand Up @@ -65,22 +65,8 @@ class Main extends React.Component {
this.setShowUpdateNotification();
});
});
}

componentWillReceiveProps(nextProps) {
const {
[FT_JWT_ANALYZER]: currJwtAnalyzerCompatibility,
} = this.props.featuresCompatibility;
const {
[FT_JWT_ANALYZER]: nextJwtAnalyzerCompatibility,
} = nextProps.featuresCompatibility;

if (
currJwtAnalyzerCompatibility !== nextJwtAnalyzerCompatibility &&
nextJwtAnalyzerCompatibility
) {
this.fetchServerConfig();
}
dispatch(fetchServerConfig());
}

setShowUpdateNotification() {
Expand All @@ -105,12 +91,6 @@ class Main extends React.Component {
}
}

fetchServerConfig() {
const { dispatch } = this.props;

dispatch(fetchServerConfig());
}

handleBodyClick(e) {
const heartDropDown = document.getElementById('dropdown_wrapper');
const heartDropDownOpen = document.querySelectorAll(
Expand Down
16 changes: 2 additions & 14 deletions console/src/components/Services/Data/DataActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import { loadInconsistentObjects } from '../Settings/Actions';
import { filterInconsistentMetadataObjects } from '../Settings/utils';
import globals from '../../../Globals';

import { COMPUTED_FIELDS_SUPPORT } from '../../../helpers/versionUtils';

import {
fetchTrackedTableReferencedFkQuery,
fetchTrackedTableFkQuery,
Expand Down Expand Up @@ -61,16 +59,6 @@ const MAKE_REQUEST = 'ModifyTable/MAKE_REQUEST';
const REQUEST_SUCCESS = 'ModifyTable/REQUEST_SUCCESS';
const REQUEST_ERROR = 'ModifyTable/REQUEST_ERROR';

const useCompositeFnsNewCheck =
globals.featuresCompatibility &&
globals.featuresCompatibility[COMPUTED_FIELDS_SUPPORT];

const compositeFnCheck = useCompositeFnsNewCheck
? 'c'
: {
$ilike: '%composite%',
};

const initQueries = {
schemaList: {
type: 'select',
Expand Down Expand Up @@ -134,7 +122,7 @@ const initQueries = {
function_schema: '', // needs to be set later
has_variadic: false,
returns_set: true,
return_type_type: compositeFnCheck, // COMPOSITE type
return_type_type: 'c', // COMPOSITE type
$or: [
{
function_type: {
Expand Down Expand Up @@ -178,7 +166,7 @@ const initQueries = {
$not: {
has_variadic: false,
returns_set: true,
return_type_type: compositeFnCheck, // COMPOSITE type
return_type_type: 'c', // COMPOSITE type
$or: [
{
function_type: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import { showSuccessNotification } from '../../Common/Notification';

import { fetchTrackedFunctions } from '../DataActions';

import { COMPUTED_FIELDS_SUPPORT } from '../../../../helpers/versionUtils';

import _push from '../push';
import { getSchemaBaseRoute } from '../../../Common/utils/routesUtils';

Expand Down Expand Up @@ -186,15 +184,8 @@ const deleteFunctionSql = () => {
inputArgTypes.forEach((inputArg, i) => {
functionArgString += i > 0 ? ', ' : '';

if (
globals.featuresCompatibility &&
globals.featuresCompatibility[COMPUTED_FIELDS_SUPPORT]
) {
functionArgString +=
'"' + inputArg.schema + '"' + '.' + '"' + inputArg.name + '"';
} else {
functionArgString += inputArg;
}
functionArgString +=
'"' + inputArg.schema + '"' + '.' + '"' + inputArg.name + '"';
});
functionArgString += ')';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import CustomInputAutoSuggest from '../../../Common/CustomInputAutoSuggest/Custo

import { getValidAlterOptions } from './utils';
import Tooltip from '../../../Common/Tooltip/Tooltip';
import {
checkFeatureSupport,
CUSTOM_GRAPHQL_FIELDS_SUPPORT,
} from '../../../../helpers/versionUtils';

const ColumnEditor = ({
onSubmit,
Expand Down Expand Up @@ -80,8 +76,6 @@ const ColumnEditor = ({
};

const getColumnCustomFieldInput = () => {
if (!checkFeatureSupport(CUSTOM_GRAPHQL_FIELDS_SUPPORT)) return;

return (
<div className={`${styles.display_flex} form-group`}>
<label className={'col-xs-4'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import GqlCompatibilityWarning from '../../../Common/GqlCompatibilityWarning/Gql

import styles from './ModifyTable.scss';
import { getConfirmation } from '../../../Common/utils/jsUtils';
import {
checkFeatureSupport,
CUSTOM_GRAPHQL_FIELDS_SUPPORT,
} from '../../../../helpers/versionUtils';

const ColumnEditorList = ({
tableSchema,
Expand Down Expand Up @@ -82,12 +78,9 @@ const ColumnEditorList = ({
// uniqueConstraint: columnUniqueConstraints[colName],
default: col.column_default || '',
comment: col.comment || '',
customFieldName: customColumnNames[colName] || '',
};

if (checkFeatureSupport(CUSTOM_GRAPHQL_FIELDS_SUPPORT)) {
columnProperties.customFieldName = customColumnNames[colName] || '';
}

const onSubmit = toggleEditor => {
dispatch(saveColumnChangesSql(colName, col, toggleEditor));
};
Expand Down
129 changes: 64 additions & 65 deletions console/src/components/Services/Data/TableModify/ModifyActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ import {
getTableModifyRoute,
} from '../../../Common/utils/routesUtils';

import {
checkFeatureSupport,
CUSTOM_GRAPHQL_FIELDS_SUPPORT,
} from '../../../../helpers/versionUtils';

const DELETE_PK_WARNING =
'Without a primary key there is no way to uniquely identify a row of a table';

Expand Down Expand Up @@ -1623,42 +1618,46 @@ const saveColumnChangesSql = (colName, column, onSuccess) => {
: [];

/* column custom field up/down migration*/
if (checkFeatureSupport(CUSTOM_GRAPHQL_FIELDS_SUPPORT)) {
const existingCustomColumnNames = getTableCustomColumnNames(table);
const existingRootFields = getTableCustomRootFields(table);
const newCustomColumnNames = { ...existingCustomColumnNames };
let isCustomFieldNameChanged = false;
if (customFieldName) {
if (customFieldName !== existingCustomColumnNames[colName]) {
isCustomFieldNameChanged = true;
newCustomColumnNames[colName] = customFieldName;
}
} else {
if (existingCustomColumnNames[colName]) {
isCustomFieldNameChanged = true;
delete newCustomColumnNames[colName];
}
const existingCustomColumnNames = getTableCustomColumnNames(table);
const existingRootFields = getTableCustomRootFields(table);
const newCustomColumnNames = { ...existingCustomColumnNames };
let isCustomFieldNameChanged = false;
if (customFieldName) {
if (customFieldName !== existingCustomColumnNames[colName]) {
isCustomFieldNameChanged = true;
newCustomColumnNames[colName] = customFieldName.trim();
}
if (isCustomFieldNameChanged) {
schemaChangesUp.push(
getSetCustomRootFieldsQuery(
tableDef,
existingRootFields,
newCustomColumnNames
)
);
schemaChangesDown.push(
getSetCustomRootFieldsQuery(
tableDef,
existingRootFields,
existingCustomColumnNames
)
);
} else {
if (existingCustomColumnNames[colName]) {
isCustomFieldNameChanged = true;
delete newCustomColumnNames[colName];
}
}
if (isCustomFieldNameChanged) {
schemaChangesUp.push(
getSetCustomRootFieldsQuery(
tableDef,
existingRootFields,
newCustomColumnNames
)
);
schemaChangesDown.push(
getSetCustomRootFieldsQuery(
tableDef,
existingRootFields,
existingCustomColumnNames
)
);
}

const colDefaultWithQuotes = (colType === 'text' && !isPostgresFunction(colDefault)) ? `'${colDefault}'` : colDefault;
const originalColDefaultWithQuotes = (colType === 'text' && !isPostgresFunction(originalColDefault)) ? `'${originalColDefault}'` : originalColDefault;
const colDefaultWithQuotes =
colType === 'text' && !isPostgresFunction(colDefault)
? `'${colDefault}'`
: colDefault;
const originalColDefaultWithQuotes =
colType === 'text' && !isPostgresFunction(originalColDefault)
? `'${originalColDefault}'`
: originalColDefault;

/* column default up/down migration */
let columnDefaultUpQuery;
Expand Down Expand Up @@ -1701,37 +1700,37 @@ const saveColumnChangesSql = (colName, column, onSuccess) => {

if (originalColDefault !== '') {
columnDefaultDownQuery =
'ALTER TABLE ONLY ' +
'"' +
currentSchema +
'"' +
'.' +
'"' +
tableName +
'"' +
' ALTER COLUMN ' +
'"' +
colName +
'"' +
' SET DEFAULT ' +
originalColDefaultWithQuotes +
';';
'ALTER TABLE ONLY ' +
'"' +
currentSchema +
'"' +
'.' +
'"' +
tableName +
'"' +
' ALTER COLUMN ' +
'"' +
colName +
'"' +
' SET DEFAULT ' +
originalColDefaultWithQuotes +
';';
} else {
// there was no default value originally. so drop default.
columnDefaultDownQuery =
'ALTER TABLE ONLY ' +
'"' +
currentSchema +
'"' +
'.' +
'"' +
tableName +
'"' +
' ALTER COLUMN ' +
'"' +
colName +
'"' +
' DROP DEFAULT;';
'ALTER TABLE ONLY ' +
'"' +
currentSchema +
'"' +
'.' +
'"' +
tableName +
'"' +
' ALTER COLUMN ' +
'"' +
colName +
'"' +
' DROP DEFAULT;';
}

// check if default is unchanged and then do a drop. if not skip
Expand Down
14 changes: 0 additions & 14 deletions console/src/components/Services/Data/TableModify/ModifyTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ import TableHeader from '../TableCommon/TableHeader';

import { getAllDataTypeMap } from '../Common/utils';

import {
checkFeatureSupport,
CUSTOM_GRAPHQL_FIELDS_SUPPORT,
TABLE_ENUMS_SUPPORT,
} from '../../../../helpers/versionUtils';
import globals from '../../../../Globals';

import {
deleteTableSql,
untrackTableSql,
Expand Down Expand Up @@ -136,11 +129,6 @@ class ModifyTable extends React.Component {
);

const getEnumsSection = () => {
const supportEnums =
globals.featuresCompatibility &&
globals.featuresCompatibility[TABLE_ENUMS_SUPPORT];
if (!supportEnums) return null;

const toggleEnum = () => dispatch(toggleTableAsEnum(table.is_enum));

return (
Expand All @@ -157,8 +145,6 @@ class ModifyTable extends React.Component {

// if (table.primary_key.columns > 0) {}
const getTableRootFieldsSection = () => {
if (!checkFeatureSupport(CUSTOM_GRAPHQL_FIELDS_SUPPORT)) return null;

const existingRootFields = getTableCustomRootFields(table);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import Button from '../../../Common/Button/Button';
import { NotFoundError } from '../../../Error/PageNotFound';

import { getConfirmation } from '../../../Common/utils/jsUtils';
import {
checkFeatureSupport,
CUSTOM_GRAPHQL_FIELDS_SUPPORT,
} from '../../../../helpers/versionUtils';
import {
findTable,
generateTableDef,
Expand Down Expand Up @@ -117,8 +113,6 @@ class ModifyView extends Component {
};

const getViewRootFieldsSection = () => {
if (!checkFeatureSupport(CUSTOM_GRAPHQL_FIELDS_SUPPORT)) return null;

const existingRootFields = getTableCustomRootFields(tableSchema);

return (
Expand Down
Loading

0 comments on commit 98438fa

Please sign in to comment.