diff --git a/src/api.js b/src/api.js
index 475ec447f..b5e0a3777 100644
--- a/src/api.js
+++ b/src/api.js
@@ -4,7 +4,7 @@ import { toast } from 'react-toastify';
import Toast from './components/Toast';
-import { DEFAULT_ERROR_TOAST_MSG } from './utils';
+import { DEFAULT_ERROR_TOAST_MSG, parseDirectoryFile, getNavFolderDropdownFromFolderOrder } from './utils';
import elementStyles from './styles/isomer-cms/Elements.module.scss';
@@ -44,16 +44,28 @@ const getFolderContents = async (siteName, folderName, subfolderName) => {
// EditNavBar
const getEditNavBarData = async(siteName) => {
- let navContent, collectionContent, resourceContent, navSha
+ let navContent, collectionContent, foldersContent, resourceContent, navSha
try {
const resp = await axios.get(`${BACKEND_URL}/sites/${siteName}/navigation`);
const { content, sha } = resp.data;
navContent = content
navSha = sha
- const collectionResp = await axios.get(`${BACKEND_URL}/sites/${siteName}/collections`)
- collectionContent = collectionResp.data
const resourceResp = await axios.get(`${BACKEND_URL}/sites/${siteName}/resources`)
resourceContent = resourceResp.data
+ const foldersResp = await axios.get(`${BACKEND_URL}/sites/${siteName}/folders/all`)
+
+ if (foldersResp.data && foldersResp.data.allFolderContent) {
+ // parse directory files
+ foldersContent = foldersResp.data.allFolderContent.reduce((acc, currFolder) => {
+ const folderOrder = parseDirectoryFile(currFolder.content)
+ acc[currFolder.name] = getNavFolderDropdownFromFolderOrder(folderOrder)
+ return acc
+ }, {})
+
+ collectionContent = {
+ collections: foldersResp.data.allFolderContent.map((folder) => folder.name),
+ }
+ }
if (!navContent) return
@@ -61,6 +73,7 @@ const getEditNavBarData = async(siteName) => {
navContent,
navSha,
collectionContent,
+ foldersContent,
resourceContent,
}
} catch (err) {
diff --git a/src/hooks/useSiteColorsHook.jsx b/src/hooks/useSiteColorsHook.jsx
index c990c9719..445d7437f 100644
--- a/src/hooks/useSiteColorsHook.jsx
+++ b/src/hooks/useSiteColorsHook.jsx
@@ -16,7 +16,6 @@ const useSiteColorsHook = () => {
const retrieveSiteColors = async (siteName) => {
const siteColors = getLocalStorageSiteColors()
- console.log(siteColors, 'test')
// if (!siteColors[siteName]) {
if (!siteColors || !siteColors[siteName]) {
diff --git a/src/layouts/EditNavBar.jsx b/src/layouts/EditNavBar.jsx
index 67c4a67d5..5dd45644b 100644
--- a/src/layouts/EditNavBar.jsx
+++ b/src/layouts/EditNavBar.jsx
@@ -35,6 +35,7 @@ const EditNavBar = ({ match }) => {
const [links, setLinks] = useState([])
const [originalNav, setOriginalNav] = useState()
const [collections, setCollections] = useState([])
+ const [folderDropdowns, setFolderDropdowns] = useState({})
const [options, setOptions] = useState([])
const [displayLinks, setDisplayLinks] = useState([])
const [displaySublinks, setDisplaySublinks] = useState([])
@@ -141,6 +142,7 @@ const EditNavBar = ({ match }) => {
navContent,
navSha,
collectionContent,
+ foldersContent,
resourceContent,
} = navigationContents
@@ -178,6 +180,7 @@ const EditNavBar = ({ match }) => {
setDisplayLinks(initialDisplayLinks)
setDisplaySublinks(initialDisplaySublinks)
setCollections(initialCollections)
+ setFolderDropdowns(foldersContent)
setOptions(initialOptions)
setResources(initialResource.map(resource => deslugifyDirectory(resource.dirName)))
setOriginalNav(navContent)
@@ -609,7 +612,7 @@ const EditNavBar = ({ match }) => {
{/* TODO: update collectionInfo */}