@@ -25,6 +25,7 @@ import { Submit } from '../Atoms/Submit';
2525import { LoadingContext } from '../Core/Contexts' ;
2626import type { SpecifyResource } from '../DataModel/legacyTypes' ;
2727import { tables } from '../DataModel/tables' ;
28+ import { Tables } from '../DataModel/types' ;
2829import { getSystemInfo } from '../InitialContext/systemInfo' ;
2930import { Dialog , LoadingScreen } from '../Molecules/Dialog' ;
3031import { ResourceLink } from '../Molecules/ResourceLink' ;
@@ -40,6 +41,7 @@ import { nestAllResources } from '../SetupTool/utils';
4041import type { TaxonFileDefaultDefinition } from '../TreeView/CreateTree' ;
4142import { CollapsibleSection } from './CollapsibleSection' ;
4243import type { InstitutionData } from './Utils' ;
44+ import { hasTablePermission } from '../Permissions/helpers' ;
4345
4446type HierarchyNodeKind =
4547 | 'collection'
@@ -392,6 +394,7 @@ const handleEditResource = (
392394 resource : SpecifyResource < any > ,
393395 refreshAllInfo : ( ) => Promise < void >
394396) => (
397+ hasTablePermission ( resource . specifyTable . name , 'update' ) ?
395398 < div className = "flex items-center" >
396399 < ResourceLink
397400 component = { Link . Default }
@@ -409,13 +412,14 @@ const handleEditResource = (
409412 { icons . pencil }
410413 { commonText . edit ( ) }
411414 </ ResourceLink >
412- </ div >
415+ </ div > : null
413416) ;
414417
415418const addButton = (
416419 createResource : ( ) => void ,
417- tableName : string
420+ table : typeof tables [ keyof typeof tables ]
418421) : JSX . Element => (
422+ hasTablePermission ( table . name , 'create' ) ?
419423 < Button . LikeLink
420424 className = "flex items-center gap-2 mb-2"
421425 onClick = { ( ) => {
@@ -424,9 +428,9 @@ const addButton = (
424428 >
425429 < span className = "flex items-center gap-1" >
426430 { icons . plus }
427- { `${ setupToolText . hierarchyAddNew ( ) } ${ tableName } ` }
431+ { `${ setupToolText . hierarchyAddNew ( ) } ${ tableLabel ( table . name ) } ` }
428432 </ span >
429- </ Button . LikeLink >
433+ </ Button . LikeLink > : null
430434) ;
431435
432436export function Hierarchy ( {
@@ -561,7 +565,7 @@ export function Hierarchy({
561565 ) ;
562566 handleNewResource ( ) ;
563567 void refreshAllInfo ( ) ;
564- } , tableLabel ( ' Collection' ) ) }
568+ } , tables . Collection ) }
565569 </ div >
566570 ) }
567571 { /* DISCIPLINE CONFIG DIALOGS */ }
@@ -698,7 +702,7 @@ export function Hierarchy({
698702 openDisciplineCreation ( ) ;
699703 setDisciplineStep ( 0 ) ;
700704 } ,
701- ` ${ tableLabel ( ' Discipline' ) } `
705+ tables . Discipline
702706 ) }
703707 </ div >
704708 </ CollapsibleSection >
@@ -743,7 +747,7 @@ export function Hierarchy({
743747 setNewResource ( new tables . Division . Resource ( ) ) ;
744748 handleNewResource ( ) ;
745749 void refreshAllInfo ( ) ;
746- } , tableLabel ( ' Division' ) ) }
750+ } , tables . Division ) }
747751 </ div >
748752 </ CollapsibleSection >
749753 </ li >
0 commit comments