console: refactor PermissionBuilder.js to typescript

### Changelog

no changelog required

### Affected components

- [ ] Server
- [x] Console
- [ ] CLI
- [ ] Docs
- [ ] Community Content
- [ ] Build System
- [ ] Tests
- [ ] Other (list it)

https://github.com/hasura/graphql-engine-mono/pull/2122

GitOrigin-RevId: d12d225454659621198286c15965345c7a8a8e01
This commit is contained in:
Ikechukwu Eze 2021-09-08 15:10:54 +01:00 committed by hasura-bot
parent 81df199169
commit dc4713b9d3
4 changed files with 334 additions and 287 deletions

View File

@ -165,7 +165,11 @@ export const isStringArray = (str: string): boolean => {
/* JSON utils */ /* JSON utils */
export function getAllJsonPaths(json: any, leafKeys: any[], prefix = '') { export function getAllJsonPaths(
json: any,
leafKeys: any[],
prefix = ''
): Record<string, any>[] | string[] {
const paths = []; const paths = [];
const addPrefix = (subPath: string) => { const addPrefix = (subPath: string) => {
@ -175,7 +179,7 @@ export function getAllJsonPaths(json: any, leafKeys: any[], prefix = '') {
const handleSubJson = (subJson: any, newPrefix: string) => { const handleSubJson = (subJson: any, newPrefix: string) => {
const subPaths = getAllJsonPaths(subJson, leafKeys, newPrefix); const subPaths = getAllJsonPaths(subJson, leafKeys, newPrefix);
subPaths.forEach(subPath => { subPaths.forEach((subPath: typeof subPaths[0]) => {
paths.push(subPath); paths.push(subPath);
}); });

View File

@ -3,7 +3,7 @@ import React from 'react';
import styles from './PermissionBuilder.scss'; import styles from './PermissionBuilder.scss';
import { addToPrefix } from './utils'; import { addToPrefix } from './utils';
type OptGroup = { optGroupTitle: string; options: string[] }; export type OptGroup = { optGroupTitle: string; options: string[] };
interface SelectGroupProps { interface SelectGroupProps {
selectDispatchFunc: (value: string) => void; selectDispatchFunc: (value: string) => void;
value: string; value: string;

View File

@ -82,6 +82,7 @@ export type CheckConstraint = {
}; };
export type ComputedField = { export type ComputedField = {
name?: string;
computed_field_name: string; computed_field_name: string;
definition: { definition: {
function: FunctionDefinition; function: FunctionDefinition;