Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/helpers/projectHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export function getNewProjectLink(orgConfigs) {
* @param {Object} project - The project object
* @param {string} projectId - The project id
*/
export function getProjectNavLinks(project, projectId) {
export function getProjectNavLinks(project, projectId, renderFAQs) {
let messagesTab = null
// `Discussions` items can be added as soon as project is loaded
// if discussions are not hidden for it
Expand All @@ -283,12 +283,15 @@ export function getProjectNavLinks(project, projectId) {
// Commented out till it needs to go live.
{ label: 'Reports', to: `/projects/${projectId}/reports`, Icon: ReportsIcon, iconClassName: 'stroke' },
{ label: 'Assets Library', to: `/projects/${projectId}/assets`, Icon: AssetsLibraryIcon, iconClassName: 'stroke' },
{ label: 'FAQ', to: `/projects/${projectId}/faqs`, Icon: FAQIcon, iconClassName: 'fill' },
] : [
{ label: 'Dashboard', to: `/projects/${projectId}`, Icon: DashboardIcon, iconClassName: 'stroke' },
messagesTab,
{ label: 'Specification', to: `/projects/${projectId}/specification`, Icon: ScopeIcon, iconClassName: 'fill' },
]


if (renderFAQs) {
const faqTab = { label: 'FAQ', to: `/projects/${projectId}/faqs`, Icon: FAQIcon, iconClassName: 'fill' }
navLinks.push(faqTab)
}
return navLinks
}
13 changes: 13 additions & 0 deletions src/helpers/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,16 @@ export function getProjectTypeByAlias(projectTypes, alias) {
projectType.aliases[0] === alias
) || null
}



/**
* Finds whether the template supports FAQ or not
*
* @param {Object} projectTemplate a project template object
*
* @return {Boolean} boolean true/false
*/
export function containsFAQ(projectTemplate) {
return projectTemplate && projectTemplate.metadata && !_.isEmpty(projectTemplate.metadata) && projectTemplate.metadata.contentful && projectTemplate.metadata.contentful.projectFaqId
}
10 changes: 9 additions & 1 deletion src/projects/detail/containers/ProjectInfoContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { loadDashboardFeeds, loadProjectMessages } from '../../actions/projectTo
import { loadTopic } from '../../../actions/topics'
import { loadProjectPlan } from '../../actions/projectPlan'
import { getProjectNavLinks } from '../../../helpers/projectHelper'
import { getProjectTemplateByKey, containsFAQ } from '../../../helpers/templates'
import {
PROJECT_ROLE_OWNER,
PROJECT_ROLE_COPILOT,
Expand Down Expand Up @@ -450,7 +451,14 @@ class ProjectInfoContainer extends React.Component {
const notReadPhaseNotifications = filterTopicAndPostChangedNotifications(projectNotReadNotifications, /^phase#\d+$/)
const notReadAssetsNotifications = filterFileAndLinkChangedNotifications(projectNotReadNotifications)

const navLinks = getProjectNavLinks(project, project.id).map((navLink) => {
const projectTemplateId = project.templateId
const projectTemplateKey = _.get(project, 'details.products[0]')
const projectTemplate = projectTemplateId
? _.find(projectTemplates, pt => pt.id === projectTemplateId)
: getProjectTemplateByKey(projectTemplates, projectTemplateKey)

const renderFAQs = containsFAQ(projectTemplate)
const navLinks = getProjectNavLinks(project, project.id, renderFAQs).map((navLink) => {
if (navLink.label === 'Messages') {
navLink.count = notReadMessageNotifications.length
navLink.toolTipText = 'New messages'
Expand Down