diff --git a/src/components/manage_dac_table/ManageDacTable.js b/src/components/manage_dac_table/ManageDacTable.js index 05d87e792..722e3f4d0 100644 --- a/src/components/manage_dac_table/ManageDacTable.js +++ b/src/components/manage_dac_table/ManageDacTable.js @@ -154,28 +154,6 @@ export const ManageDacTable = function ManageDacTable(props) { setSelectedDatasets } = props; - useEffect(() => { - recalculateVisibleTable({ - tableSize, - pageCount, - filteredList: processDacRowData({ - dacs, - viewDatasets, - viewMembers, - editDac, - deleteDac, - userRole, - columns - }), - currentPage, - setPageCount: (c) => setPageCount(c), - setCurrentPage: (p) => setCurrentPage(p), - setVisibleList: (l) => setVisibleDacs(l), - sort - }); - }, [dacs, tableSize, pageCount, userRole, currentPage, sort, deleteDac, editDac, viewDatasets, viewMembers]); - - const editDac = useCallback((selectedDac) => { setShowDacModal(true); setSelectedDac(selectedDac); @@ -201,6 +179,27 @@ export const ManageDacTable = function ManageDacTable(props) { setSelectedDatasets(approvedDatasets); }, [setShowDatasetsModal, setSelectedDac, setSelectedDatasets]); + useEffect(() => { + recalculateVisibleTable({ + tableSize, + pageCount, + filteredList: processDacRowData({ + dacs, + viewDatasets, + viewMembers, + editDac, + deleteDac, + userRole, + columns + }), + currentPage, + setPageCount: (c) => setPageCount(c), + setCurrentPage: (p) => setCurrentPage(p), + setVisibleList: (l) => setVisibleDacs(l), + sort + }); + }, [dacs, tableSize, pageCount, userRole, currentPage, sort, deleteDac, editDac, viewDatasets, viewMembers]); + const changeTableSize = useCallback((value) => { if (value > 0 && !isNaN(parseInt(value))) { setTableSize(value); diff --git a/src/pages/manage_dac/ManageDac.js b/src/pages/manage_dac/ManageDac.js index f9b97f00d..8039e9131 100644 --- a/src/pages/manage_dac/ManageDac.js +++ b/src/pages/manage_dac/ManageDac.js @@ -34,6 +34,20 @@ export const ManageDac = function ManageDac() { const [selectedDatasets, setSelectedDatasets] = useState([]); + const reloadUserRole = useCallback(async () => { + setIsLoading(true); + const currentUser = Storage.getCurrentUser(); + const roles = currentUser.roles.map(r => r.name); + const role = contains(ADMIN)(roles) ? ADMIN : CHAIR; + let dacIDs = filter({name: CHAIR})(currentUser.roles); + dacIDs = map('dacId')(dacIDs); + if (role === CHAIR) { + setDacIDs(dacIDs); + } + setUserRole(role); + setIsLoading(false); + }, []); + const reloadDacList = useCallback(async () => { setIsLoading(true); DAC.list().then( @@ -68,20 +82,6 @@ export const ManageDac = function ManageDac() { } }; - const reloadUserRole = useCallback(async () => { - setIsLoading(true); - const currentUser = Storage.getCurrentUser(); - const roles = currentUser.roles.map(r => r.name); - const role = contains(ADMIN)(roles) ? ADMIN : CHAIR; - let dacIDs = filter({name: CHAIR})(currentUser.roles); - dacIDs = map('dacId')(dacIDs); - if (role === CHAIR) { - setDacIDs(dacIDs); - } - setUserRole(role); - setIsLoading(false); - }, []); - const closeViewMembersModal = () => { setShowMembersModal(false); setSelectedDac({});