File tree Expand file tree Collapse file tree 2 files changed +27
-19
lines changed
npm-packages/dashboard-common
src/features/data/components Expand file tree Collapse file tree 2 files changed +27
-19
lines changed Original file line number Diff line number Diff line change 1- const path = require ( "path" ) ;
2-
31module . exports = {
42 root : true ,
53 parserOptions : {
Original file line number Diff line number Diff line change @@ -76,24 +76,34 @@ export function useSingleTableSchemaStatus(
7676 const schemas = useQuery ( udfs . getSchemas . default , {
7777 componentId : useNents ( ) . selectedNent ?. id ?? null ,
7878 } ) ;
79- if ( ! schemas ) {
80- return undefined ;
81- }
82- const active : Schema | undefined = schemas . active
83- ? JSON . parse ( schemas . active )
79+
80+ const { isDefined, referencedByTable } = useMemo ( ( ) => {
81+ const active : Schema | undefined = schemas ?. active
82+ ? JSON . parse ( schemas . active )
83+ : undefined ;
84+
85+ return {
86+ isDefined :
87+ active ?. tables . find ( ( table ) => table . tableName === tableName ) !==
88+ undefined ,
89+ referencedByTable : active ?. tables . find ( ( table ) =>
90+ validatorReferencesTable (
91+ table . documentType ?? { type : "any" } ,
92+ tableName ,
93+ ) ,
94+ ) ?. tableName ,
95+ } ;
96+ } , [ schemas ?. active , tableName ] ) ;
97+
98+ const isValidationRunning = schemas ?. inProgress !== undefined ;
99+ return schemas
100+ ? {
101+ tableName,
102+ isDefined,
103+ referencedByTable,
104+ isValidationRunning,
105+ }
84106 : undefined ;
85- const isDefined =
86- active ?. tables . find ( ( table ) => table . tableName === tableName ) !== undefined ;
87- const referencedByTable = active ?. tables . find ( ( table ) =>
88- validatorReferencesTable ( table . documentType ?? { type : "any" } , tableName ) ,
89- ) ?. tableName ;
90- const isValidationRunning = schemas . inProgress !== undefined ;
91- return {
92- tableName,
93- isDefined,
94- referencedByTable,
95- isValidationRunning,
96- } ;
97107}
98108
99109export function useSingleTableEnforcedSchema ( tableName : string ) : Table | null {
You can’t perform that action at this time.
0 commit comments