mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
parent
4bf9d19b13
commit
39982d459a
@ -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';
|
||||
@ -16,11 +16,13 @@ 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');
|
||||
@ -28,9 +30,11 @@ class Permission extends React.Component {
|
||||
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 = [
|
||||
{
|
||||
@ -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>
|
||||
);
|
||||
|
@ -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',
|
||||
@ -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(
|
||||
@ -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,
|
||||
};
|
||||
|
@ -12,6 +12,9 @@ const functionData = {
|
||||
functionSchema: '',
|
||||
functionDefinition: '',
|
||||
setOffTable: '',
|
||||
setOffTableSchema: '',
|
||||
inputArgNames: [],
|
||||
inputArgTypes: [],
|
||||
...asyncState,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user