Skip to content

Commit

Permalink
Merge branch 'master' into function-overloading
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshkky authored Feb 8, 2019
2 parents 48683fb + 9a6fa7f commit af88b7a
Show file tree
Hide file tree
Showing 47 changed files with 819 additions and 422 deletions.
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* @shahidhk
/server/ @0x777
/docs/ @rikinsk
/cli/ @shahidhk
/console/ @praveenweb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@ class ModifyCustomFunction extends React.Component {
}
componentDidMount() {
const { functionName, schema } = this.props.params;
if (!functionName) {
if (!functionName || !schema) {
this.props.dispatch(push(prefixUrl));
}
Promise.all([
this.props.dispatch(fetchCustomFunction(functionName, schema)),
]);
}
componentWillReceiveProps(nextProps) {
const { functionName, schema } = this.props.params;
if (functionName !== nextProps.params.functionName || schema !== nextProps.params.schema) {
Promise.all([
this.props.dispatch(fetchCustomFunction(nextProps.params.functionName, nextProps.params.schema)),
]);
}
}
loadRunSQLAndLoadPage() {
const { functionDefinition } = this.props.functions;
Promise.all([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import Helmet from 'react-helmet';
import CommonTabLayout from '../../../Layout/CommonTabLayout/CommonTabLayout';
import { Link } from 'react-router';
// import { Link } from 'react-router';
import { push } from 'react-router-redux';

import { pageTitle, appPrefix } from '../Modify/constants';
Expand All @@ -16,21 +16,25 @@ import { fetchCustomFunction } from '../customFunctionReducer';

class Permission extends React.Component {
componentDidMount() {
const { functionName } = this.props.params;
const { functionName, schema } = this.props.params;
if (!functionName) {
this.props.dispatch(push(prefixUrl));
}
Promise.all([this.props.dispatch(fetchCustomFunction(functionName))]);
Promise.all([
this.props.dispatch(fetchCustomFunction(functionName, schema)),
]);
}
render() {
const styles = require('../Modify/ModifyCustomFunction.scss');
const {
functionSchema: schema,
functionName,
setOffTable,
setOffTableSchema,
} = this.props.functions;

const baseUrl = `${appPrefix}/schema/${schema}/functions/${functionName}`;
const permissionTableUrl = `${appPrefix}/schema/${schema}/tables/${setOffTable}/permissions`;
const permissionTableUrl = `${prefixUrl}/schema/${setOffTableSchema}/tables/${setOffTable}/permissions`;

const breadCrumbs = [
{
Expand Down Expand Up @@ -78,14 +82,14 @@ class Permission extends React.Component {
applicable to the data returned by this function
</p>
<div className={styles.commonBtn}>
<Link to={permissionTableUrl}>
<a href={permissionTableUrl}>
<button
className={styles.yellow_button}
data-test={'custom-function-permission-btn'}
>
{`${setOffTable} Permissions`}
</button>
</Link>
</a>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,25 @@ const fetchCustomFunction = (functionName, schema) => {
const deleteFunctionSql = () => {
return (dispatch, getState) => {
const currentSchema = getState().tables.currentSchema;
const functionName = getState().functions.functionName;
const functionDefinition = getState().functions.functionDefinition;
const sqlDropFunction =
'DROP FUNCTION ' +
'"' +
currentSchema +
'"' +
'.' +
'"' +
functionName +
'"';
const {
functionName,
functionDefinition,
inputArgTypes,
} = getState().functions;
let functionWSchemaName =
'"' + currentSchema + '"' + '.' + '"' + functionName + '"';

if (inputArgTypes.length > 0) {
let functionString = '(';
inputArgTypes.forEach((i, index) => {
functionString +=
i + ' ' + (index === inputArgTypes.length - 1 ? ')' : ',');
});
functionWSchemaName += functionString;
}

const sqlDropFunction = 'DROP FUNCTION ' + functionWSchemaName;

const sqlUpQueries = [
{
type: 'run_sql',
Expand All @@ -203,9 +211,11 @@ const deleteFunctionSql = () => {
const errorMsg = 'Deleting function failed';

const customOnSuccess = () => {
dispatch(_push('/'));
dispatch(_push(`/schema/${currentSchema}`));
};
const customOnError = () => {
dispatch({ type: DELETE_CUSTOM_FUNCTION_FAIL });
};
const customOnError = () => {};

dispatch({ type: DELETING_CUSTOM_FUNCTION });
return dispatch(
Expand Down Expand Up @@ -318,6 +328,9 @@ const customFunctionReducer = (state = functionData, action) => {
functionSchema: action.data[0][0].function_schema || null,
functionDefinition: action.data[1][0].function_definition || null,
setOffTable: action.data[1][0].return_type_name || null,
setOffTableSchema: action.data[1][0].return_type_schema || null,
inputArgNames: action.data[1][0].input_arg_names || null,
inputArgTypes: action.data[1][0].input_arg_types || null,
isFetching: false,
isFetchError: null,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const functionData = {
functionSchema: '',
functionDefinition: '',
setOffTable: '',
setOffTableSchema: '',
inputArgNames: [],
inputArgTypes: [],
...asyncState,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ class PermissionBuilder extends React.Component {
} else if (isNotOperator(operator)) {
const newPath = pathSplit.slice(1).join('.');
_missingSchemas = findMissingSchemas(newPath, currTable);
} else if (
isColumnOperator(operator) ||
isArrayColumnOperator(operator)
) {
} else if (isColumnOperator(operator) || isArrayColumnOperator(operator)) {
// no missing schemas
} else {
const { allTableSchemas } = this.props;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,27 +122,30 @@ export function getTableDef(tableName, schema) {
export function getRefTable(rel, tableSchema) {
let _refTable = null;

if (rel.rel_type === 'array') {
if (rel.rel_def.foreign_key_constraint_on) {
// if manual relationship
if (rel.rel_def.manual_configuration) {
_refTable = rel.rel_def.manual_configuration.remote_table;
}

// if foreign-key based relationship
if (rel.rel_def.foreign_key_constraint_on) {
// if array relationship
if (rel.rel_type === 'array') {
_refTable = rel.rel_def.foreign_key_constraint_on.table;
} else if (rel.rel_def.manual_configuration) {
_refTable = rel.rel_def.manual_configuration.remote_table;
}
}

if (rel.rel_type === 'object') {
if (rel.rel_def.foreign_key_constraint_on) {
// if object relationship
if (rel.rel_type === 'object') {
const fkCol = rel.rel_def.foreign_key_constraint_on;

for (let i = 0; i < tableSchema.foreign_key_constraints.length; i++) {
const fkConstraint = tableSchema.foreign_key_constraints[i];
if (fkCol === Object.keys(fkConstraint.column_mapping)[0]) {
_refTable = fkConstraint.ref_table;
const fkConstraintCol = Object.keys(fkConstraint.column_mapping)[0];
if (fkCol === fkConstraintCol) {
_refTable = getTableDef(fkConstraint.ref_table, fkConstraint.ref_table_table_schema);
break;
}
}
} else if (rel.rel_def.manual_configuration) {
_refTable = rel.rel_def.manual_configuration.remote_table;
}
}

Expand Down
2 changes: 2 additions & 0 deletions docs/_static/hasura-custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ ul {
-webkit-box-shadow: -1px 2px 20px 2px rgba(217,217,217,1);
-moz-box-shadow: -1px 2px 20px 2px rgba(217,217,217,1);
box-shadow: -1px 2px 20px 2px rgba(217,217,217,1);
margin-top: 20px;
margin-bottom: 30px;
}

#docs-content img.no-shadow {
Expand Down
2 changes: 1 addition & 1 deletion docs/_theme/djangodocs/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<div>
<a target="_blank" href="https://github.com/hasura/graphql-engine/blob/master/docs/{{ pagename }}.rst">check this page on github</a>
| <a target="_blank" href="https://github.com/hasura/graphql-engine/blob/master/CONTRIBUTING.md">contributing guidelines</a>
| <a target="_blank" href="https://github.com/hasura/graphql-engine/issues/new">report an issue</a>
| <a target="_blank" href="https://github.com/hasura/graphql-engine/issues">report an issue</a>
</div>
<br/>
<div>
Expand Down
14 changes: 7 additions & 7 deletions docs/graphql/manual/api-reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ Request types

The following types of requests can be made using the GraphQL API:

- :doc:`Query/Subscription <query>`
- :doc:`Query / Subscription <query>`
- :doc:`Mutation <mutation>`

Schema/Metadata API
-------------------
Schema / Metadata API
---------------------

Hasura exposes a Schema/Metadata API for managing metadata for permissions/relationships or for directly
Hasura exposes a Schema / Metadata API for managing metadata for permissions/relationships or for directly
executing SQL on the underlying Postgres.

This is primarily intended to be used as an ``admin`` API to manage Hasura schema and metadata.
Expand All @@ -36,7 +36,7 @@ Request types

The following lists all the types of requests that can be made using the Schema/Metadata API:

- :ref:`Schema/Metadata API query types <query_syntax>`
- :ref:`Schema / Metadata API query types <Query>`

Supported PostgreSQL types
--------------------------
Expand All @@ -48,7 +48,7 @@ You can refer to the following to know about all PostgreSQL types supported by t
:maxdepth: 1
:hidden:

Query/Subscription <query>
Query / Subscription <query>
Mutation <mutation>
Schema/Metadata APIs <schema-metadata-api/index>
Schema / Metadata APIs <schema-metadata-api/index>
Supported PostgreSQL types <postgresql-types>
Loading

0 comments on commit af88b7a

Please sign in to comment.