@@ -5,16 +5,14 @@ import { useStoreState } from 'pullstate';
5
5
import { ErrorBoundary } from 'react-error-boundary' ;
6
6
7
7
import instanceState from '../../../functions/state/instanceState' ;
8
- import describeTable from '../../../functions/api/instance/describeTable' ;
9
8
10
9
import ErrorFallback from '../../shared/ErrorFallback' ;
11
10
import addError from '../../../functions/api/lms/addError' ;
12
11
import useInstanceAuth from '../../../functions/state/instanceAuths' ;
13
12
import EmptyPrompt from '../../shared/EmptyPrompt' ;
14
- import buildInstanceStructure from '../../../functions/instance/browse/buildInstanceStructure' ;
15
13
import { clearTableDescriptionCache } from '../../../functions/instance/state/describeTableCache' ;
16
14
17
- const DataTable = lazy ( ( ) => import ( /* webpackChunkName: "browse-datatable" */ './BrowseDatatable' ) ) ;
15
+ const BrowseDatatable = lazy ( ( ) => import ( /* webpackChunkName: "browse-datatable" */ './BrowseDatatable' ) ) ;
18
16
const EntityManager = lazy ( ( ) => import ( /* webpackChunkName: "browse-entitymanager" */ './EntityManager' ) ) ;
19
17
const JSONEditor = lazy ( ( ) => import ( /* webpackChunkName: "browse-jsonviewer" */ './JSONEditor' ) ) ;
20
18
const CSVUpload = lazy ( ( ) => import ( /* webpackChunkName: "browse-csvupload" */ './CsvUpload' ) ) ;
@@ -40,7 +38,7 @@ function NoPrimaryKeyMessage({ table }) {
40
38
< Card className = "my-3 missing-primary-key" >
41
39
< CardBody >
42
40
< CardTitle > No Primary Key</ CardTitle >
43
- < i className = "fa fa-warning mt-3 " />
41
+ < i className = "mt-3 fa fa-warning" />
44
42
< span className = "mt-3" >
45
43
The table { `'${ table } '` } does not have a primary key. The HarperDB Studio does not currently support tables
46
44
without a primary key defined. Please see the{ ' ' }
@@ -59,16 +57,13 @@ function BrowseIndex() {
59
57
const location = useLocation ( ) ;
60
58
const { schema, table, action, customer_id, compute_stack_id } = useParams ( ) ;
61
59
const [ instanceAuths ] = useInstanceAuth ( { } ) ;
62
- const auth = instanceAuths ?. [ compute_stack_id ] ;
63
- const url = useStoreState ( instanceState , ( s ) => s . url ) ;
64
60
const registration = useStoreState ( instanceState , ( s ) => s . registration ) ;
65
61
const version = registration ?. version ;
66
62
const [ major , minor ] = version ?. split ( '.' ) || [ ] ;
67
63
const versionAsFloat = `${ major } .${ minor } ` ;
68
64
const structure = useStoreState ( instanceState , ( s ) => s . structure ) ;
69
65
const [ entities , setEntities ] = useState ( { schemas : [ ] , tables : [ ] , activeTable : false } ) ;
70
66
const [ tableState , setTableState ] = useState ( defaultTableState ) ;
71
- const [ tableDescription , setTableDescription ] = useState ( null ) ;
72
67
const baseUrl = `/o/${ customer_id } /i/${ compute_stack_id } /browse` ;
73
68
const showForm = instanceAuths [ compute_stack_id ] ?. super || instanceAuths [ compute_stack_id ] ?. structure === true ;
74
69
const showTableForm =
@@ -81,29 +76,11 @@ function BrowseIndex() {
81
76
: "This user has not been granted access to any tables. A super-user must update this user's role." ;
82
77
const [ hasHashAttr , setHasHashAttr ] = useState ( true ) ;
83
78
84
- const syncInstanceStructure = ( ) => {
85
- buildInstanceStructure ( { auth, url } ) ;
86
- } ;
87
-
88
- useEffect ( ( ) => {
89
- const fetchDescribeTable = async ( ) => {
90
- if ( table ) {
91
- try {
92
- const result = await describeTable ( { auth, url, schema, table } ) ;
93
- setTableDescription ( result ) ;
94
- } catch ( e ) {
95
- addError ( e ) ;
96
- }
97
- }
98
- } ;
99
- fetchDescribeTable ( ) ;
100
- } , [ auth , url , schema , table ] ) ;
101
-
102
79
useEffect ( ( ) => {
103
- if ( tableDescription ) {
104
- setHasHashAttr ( Boolean ( tableDescription . hash_attribute ) ) ;
80
+ if ( tableState ) {
81
+ setHasHashAttr ( Boolean ( tableState . hashAttribute ) ) ;
105
82
}
106
- } , [ tableDescription ] ) ;
83
+ } , [ tableState ] ) ;
107
84
108
85
const validate = ( ) => {
109
86
if ( structure ) {
@@ -146,7 +123,6 @@ function BrowseIndex() {
146
123
147
124
// eslint-disable-next-line
148
125
useEffect ( validate , [ structure , schema , table , compute_stack_id ] ) ;
149
- useEffect ( syncInstanceStructure , [ auth , url , schema , table ] ) ;
150
126
useEffect ( ( ) => {
151
127
const clearTableDescriptionCacheInterval = setInterval ( ( ) => {
152
128
clearTableDescriptionCache ( ) ;
@@ -198,12 +174,7 @@ function BrowseIndex() {
198
174
) : schema && table && action && entities . activeTable ? (
199
175
< JSONEditor newEntityAttributes = { tableState . newEntityAttributes } hashAttribute = { tableState . hashAttribute } />
200
176
) : schema && table && entities . activeTable ? (
201
- < DataTable
202
- activeTable = { entities . activeTable }
203
- tableDescriptionAttributes = { tableDescription ?. attributes }
204
- tableState = { tableState }
205
- setTableState = { setTableState }
206
- />
177
+ < BrowseDatatable activeTable = { entities . activeTable } tableState = { tableState } setTableState = { setTableState } />
207
178
) : schema && table && ! hasHashAttr ? (
208
179
< NoPrimaryKeyMessage />
209
180
) : (
0 commit comments