mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
console: filter custom functions with table args from "Untracked custom functions" list (close #6438)
GitOrigin-RevId: c4bb6950872ff2e75054cb64ce7f91fb68de0767
This commit is contained in:
parent
94a886ee94
commit
52aa55904b
@ -50,6 +50,7 @@ import {
|
||||
} from '../../../../metadata/selector';
|
||||
import { RightContainer } from '../../../Common/Layout/RightContainer';
|
||||
import { TrackableFunctionsList } from './FunctionsList';
|
||||
import { getTrackableFunctions } from './utils';
|
||||
|
||||
const DeleteSchemaButton = ({ dispatch, migrationMode, currentDataSource }) => {
|
||||
const successCb = () => {
|
||||
@ -264,18 +265,6 @@ class Schema extends Component {
|
||||
dispatch(updateCurrentSchema(e.target.value, currentDataSource));
|
||||
};
|
||||
|
||||
const _getTrackableFunctions = () => {
|
||||
const trackedFuncNames = trackedFunctions.map(fn => fn.function_name);
|
||||
|
||||
// Assuming schema for both function and tables are same
|
||||
// return function which are tracked
|
||||
const filterCondition = func => {
|
||||
return !trackedFuncNames.includes(func.function_name);
|
||||
};
|
||||
|
||||
return functionsList.filter(filterCondition);
|
||||
};
|
||||
|
||||
const getSectionHeading = (headingText, tooltip, actionElement = null) => {
|
||||
return (
|
||||
<div>
|
||||
@ -293,8 +282,11 @@ class Schema extends Component {
|
||||
const allUntrackedTables = getUntrackedTables(
|
||||
getSchemaTables(schema, currentSchema)
|
||||
);
|
||||
const trackableFuncs = _getTrackableFunctions();
|
||||
|
||||
const trackableFuncs = getTrackableFunctions(
|
||||
functionsList,
|
||||
trackedFunctions
|
||||
);
|
||||
const getCreateBtn = () => {
|
||||
let createBtn = null;
|
||||
|
||||
|
23
console/src/components/Services/Data/Schema/utils.ts
Normal file
23
console/src/components/Services/Data/Schema/utils.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import {
|
||||
ArgType,
|
||||
PGFunction,
|
||||
PGInputArgType,
|
||||
} from '../../../../dataSources/services/postgresql/types';
|
||||
|
||||
export const getTrackableFunctions = (
|
||||
functionsList: PGFunction[],
|
||||
trackedFunctions: PGFunction[]
|
||||
): PGFunction[] => {
|
||||
const trackedFuncNames = trackedFunctions.map(fn => fn.function_name);
|
||||
const containsTableArgs = (arg: PGInputArgType): boolean =>
|
||||
arg.type.toLowerCase() === ArgType.CompositeType;
|
||||
// Assuming schema for both function and tables are same
|
||||
// return function which are tracked
|
||||
const filterCondition = (func: PGFunction) => {
|
||||
return (
|
||||
!trackedFuncNames.includes(func.function_name) &&
|
||||
!func.input_arg_types?.some(containsTableArgs)
|
||||
);
|
||||
};
|
||||
return functionsList.filter(filterCondition);
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
export type PGInputArgType = {
|
||||
schema: string;
|
||||
name: string;
|
||||
type: string;
|
||||
type: ArgType;
|
||||
};
|
||||
|
||||
export type PGFunction = {
|
||||
@ -57,11 +57,16 @@ export interface PostgresTrigger {
|
||||
event_manipulation: string;
|
||||
}
|
||||
|
||||
type InputArgType = {
|
||||
export type InputArgType = {
|
||||
schema: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export enum ArgType {
|
||||
CompositeType = 'c',
|
||||
BaseType = 'b',
|
||||
}
|
||||
|
||||
export interface FunctionState {
|
||||
functionName: string;
|
||||
inputArgTypes: InputArgType[];
|
||||
|
Loading…
Reference in New Issue
Block a user