Skip to content

Commit 20052ec

Browse files
authored
Merge pull request #4088 from appirio-tech/feature/add_option_for_rendering_internal_intake_forms
Feature/add option for rendering internal intake forms
2 parents b374214 + 9647041 commit 20052ec

File tree

6 files changed

+65
-4
lines changed

6 files changed

+65
-4
lines changed
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 24 additions & 0 deletions
Loading

src/components/ProjectTypeIcon.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import IconSalesforceImplementation from '../assets/icons/v.2.5/project-types/sa
2929
import IconSolutions from '../assets/icons/v.2.5/project-types/solutions.svg'
3030
import IconUserSentimentAnalysis from '../assets/icons/v.2.5/project-types/user-sentiment-analysis.svg'
3131
import IconDefault from '../assets/icons/v.2.5/project-types/default.svg'
32+
import IconTcInternal from '../assets/icons/v.2.5/project-types/tc-internal-2.svg'
33+
//import IconTcInternal from '../assets/icons/ui-rocket-white.svg'
3234

3335
const ProjectTypeIcon = ({ type }) => {
3436
// if type is defined as a relative path to the icon, convert it to icon "id"
@@ -60,6 +62,7 @@ const ProjectTypeIcon = ({ type }) => {
6062
case 'salesforce-implementation': return <IconSalesforceImplementation />
6163
case 'solutions': return <IconSolutions />
6264
case 'user-sentiment-analysis': return <IconUserSentimentAnalysis />
65+
case 'tc-internal': return <IconTcInternal />
6366
default:
6467
// this will be default icon
6568
return <IconDefault />

src/config/constants.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,4 +1000,8 @@ export const CONTENTFUL_SPACE_ID = process.env.CONTENTFUL_SPACE_ID
10001000
*/
10011001
export const CONTENTFUL_NODE_TYPES = {
10021002
HYPERLINK : 'hyperlink',
1003-
}
1003+
}
1004+
export const INTERNAL_PROJECT_URLS=[
1005+
'tc_internal',
1006+
'tc-internal'
1007+
]

src/projects/create/components/ProjectWizard.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import {
2121
SPECIAL_QUERY_PARAMS,
2222
PROJECT_REF_CODE_MAX_LENGTH,
2323
PROJECT_ATTACHMENTS_FOLDER,
24+
MANAGER_ROLES,
25+
INTERNAL_PROJECT_URLS
2426
} from '../../../config/constants'
2527
import {
2628
buildProjectUpdateQueryByQueryParamSelectCondition,
@@ -212,7 +214,7 @@ class ProjectWizard extends Component {
212214
* @return {number} step where wizard should move after parsing the URL param
213215
*/
214216
loadProjectFromURL(urlParams, updateQuery) {
215-
const { projectTemplates, projectTypes } = this.props
217+
const { projectTemplates, projectTypes, userRoles } = this.props
216218
const urlAlias = urlParams && urlParams.project
217219
const statusParam = urlParams && urlParams.status
218220

@@ -233,10 +235,17 @@ class ProjectWizard extends Component {
233235
} else {
234236
// if it is not a project type, it should be a project template
235237
const projectTemplate = getProjectTemplateByAlias(projectTemplates, urlAlias)
238+
const managerRoles = _.filter(MANAGER_ROLES, mgrRole => {
239+
return _.find(userRoles, role => role === mgrRole)
240+
})
241+
const isInternalURL = _.find(INTERNAL_PROJECT_URLS, url => url === urlAlias)
242+
let isValidRole = true
243+
if(isInternalURL)
244+
isValidRole = managerRoles && managerRoles.length > 0
236245

237246
// if we have some project template key in the URL and we can find the project template
238247
// show details step
239-
if (projectTemplate) {
248+
if (isValidRole && projectTemplate) {
240249
updateQuery['type'] = { $set : projectTemplate.category }
241250
updateQuery['templateId'] = { $set : projectTemplate.id }
242251
updateQuery['details'] = {}
@@ -566,6 +575,7 @@ class ProjectWizard extends Component {
566575
onProjectTypeChange={ this.updateProjectType }
567576
projectTemplates={ projectTemplates }
568577
projectTypes={ projectTypes }
578+
userRoles={ userRoles }
569579
/>
570580
<SelectProjectTemplate
571581
onProjectTemplateChange={ this.updateProjectTemplate }

src/projects/create/components/SelectProjectType.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
import React from 'react'
22
import PT from 'prop-types'
3+
import _ from 'lodash'
34

45
import SelectProjectTypeCard from './SelectProjectTypeCard'
56
import { getProjectTemplatesByCategory } from '../../../helpers/templates'
67
import ProjectTypeIcon from '../../../components/ProjectTypeIcon'
78
import IconArrowRight from '../../../assets/icons/arrows-16px-1_tail-right.svg'
89

9-
import { DOMAIN } from '../../../config/constants'
10+
import { DOMAIN, MANAGER_ROLES } from '../../../config/constants'
1011

1112
import './SelectProjectType.scss'
1213

1314
const SelectProjectType = ({
1415
onProjectTypeChange,
1516
projectTypes,
1617
projectTemplates,
18+
userRoles,
1719
}) => {
1820
const cards = []
21+
const managerRoles = _.filter(MANAGER_ROLES, mgrRole => {
22+
return _.find(userRoles, role => role === mgrRole)
23+
})
24+
const isValidRole = managerRoles && managerRoles.length > 0
1925

2026
projectTypes.forEach((projectType) => {
2127

@@ -25,6 +31,10 @@ const SelectProjectType = ({
2531
// don't render hidden items as well, hidden items can be reached via direct link though
2632
if (projectType.disabled || projectType.hidden || visibleProjectTemplates.length === 0) return
2733

34+
// don't render internal projects to customer user roles
35+
if (projectType.metadata && projectType.metadata.isInternal
36+
&& projectType.metadata.isInternal === true && !isValidRole) return
37+
2838
const icon = <ProjectTypeIcon type={projectType.icon} />
2939

3040
cards.push(

0 commit comments

Comments
 (0)