Skip to content

Commit 071ec4c

Browse files
Merge pull request #6 from appirio-tech/cf19
Cf19
2 parents 1f9e422 + da301d5 commit 071ec4c

File tree

16 files changed

+234
-36
lines changed

16 files changed

+234
-36
lines changed

src/components/MobilePage/MobilePage.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
overflow: hidden;
1212
overflow-y: scroll;
1313
}
14+
15+
.mobile-page-gateway {
16+
z-index: 10000;
17+
position: absolute;
18+
top: 0;
19+
left: 0;
20+
width: 100%;
21+
}
1422
}
1523

1624
.container {
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
@import '~tc-ui/src/styles/tc-includes';
22

33
.badge {
4-
display: inline-flex;
5-
background: $tc-red-70;
6-
color: white;
7-
@include roboto-bold;
8-
border-radius: 100%;
9-
height: 17px;
10-
line-height: 17px;
11-
justify-content: center;
12-
align-items: center;
13-
width: 17px;
14-
font-size: 11px;
15-
}
4+
display: inline-flex;
5+
background: $tc-red-70;
6+
color: white;
7+
@include roboto-bold;
8+
border-radius: 100%;
9+
line-height: 17px;
10+
justify-content: center;
11+
align-items: center;
12+
min-width: 17px;
13+
min-height: 17px;
14+
padding: 0 2px;
15+
font-size: 11px;
16+
}

src/components/ProjectInfo/ProjectInfo.jsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import MobileExpandable from '../MobileExpandable/MobileExpandable'
99
import MediaQuery from 'react-responsive'
1010
import { SCREEN_BREAKPOINT_MD, PROJECT_STATUS_ACTIVE, PHASE_STATUS_ACTIVE, PHASE_STATUS_REVIEWED, PROJECT_ROLE_OWNER, PROJECT_ROLE_CUSTOMER } from '../../config/constants'
1111
import ReviewProjectButton from '../../projects/detail/components/ReviewProjectButton'
12+
import Tooltip from 'appirio-tech-react-components/components/Tooltip/Tooltip'
13+
import { TOOLTIP_DEFAULT_DELAY } from '../../config/constants'
1214

1315
import './ProjectInfo.scss'
1416

@@ -51,24 +53,39 @@ class ProjectInfo extends Component {
5153
return (
5254
<div className="project-info">
5355
<div className="project-status">
54-
<div>
55-
<div styleName="project-name">{_.unescape(project.name)}</div>
56-
<div className="project-status-time">Created {moment(project.createdAt).format('MMM DD, YYYY')}</div>
57-
{!!code && <div className="project-status-ref">{_.unescape(code)}</div>}
56+
<div styleName="project-name">{_.unescape(project.name)}</div>
57+
58+
<div styleName="project-status-bottom">
59+
<div className="project-status-time">
60+
Created {moment(project.createdAt).format('MMM DD, YYYY')}
61+
</div>
62+
{!!code &&
63+
<div styleName="tooltip-target-container">
64+
<Tooltip styleName="tooltip" theme="light" tooltipDelay={TOOLTIP_DEFAULT_DELAY}>
65+
<div className="tooltip-target">
66+
<div className="project-status-ref">{_.unescape(code)}</div>
67+
</div>
68+
<div className="tooltip-body">
69+
<span>{_.unescape(code)}</span>
70+
</div>
71+
</Tooltip>
72+
</div>
73+
74+
}
5875
</div>
5976
</div>
60-
{showDeleteConfirm &&
77+
{showDeleteConfirm && (
6178
<DeleteProjectModal
6279
onCancel={toggleProjectDelete}
6380
onConfirm={onConfirmDelete}
6481
/>
65-
}
82+
)}
6683
{showReviewBtn ? (
6784
reviewButtonSection
6885
) : (
6986
<MobileExpandable title="DESCRIPTION" defaultOpen>
7087
<MediaQuery minWidth={SCREEN_BREAKPOINT_MD}>
71-
{(matches) => (
88+
{matches => (
7289
<ProjectCardBody
7390
project={project}
7491
projectCanBeActive={projectCanBeActive}

src/components/ProjectInfo/ProjectInfo.scss

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
@import '~tc-ui/src/styles/tc-includes';
22

33
:global {
4+
.sticky-inner-wrapper {
5+
z-index: 1;
6+
}
7+
48
.project-info {
59
display: flex;
610
flex-direction: column;
@@ -40,6 +44,8 @@
4044
margin-bottom: 10px;
4145
padding-left: 4 * $base_unit;
4246
padding-right: 4 * $base_unit;
47+
display: flex;
48+
flex-direction: column;
4349
}
4450

4551
.project-status-header {
@@ -60,6 +66,7 @@
6066
text-transform: uppercase;
6167
white-space: nowrap;
6268
float: left;
69+
margin-right: 10px;
6370
}
6471

6572
.project-status-ref {
@@ -74,6 +81,9 @@
7481
margin-top: $base-unit;
7582
white-space: nowrap;
7683
float: right;
84+
overflow: hidden;
85+
text-overflow: ellipsis;
86+
max-width: 100%;
7787
}
7888

7989
.project-card-body {
@@ -110,3 +120,37 @@
110120
text-overflow: ellipsis;
111121
overflow: hidden;
112122
}
123+
124+
.project-status-bottom {
125+
display: flex;
126+
justify-content: space-between;
127+
}
128+
129+
.tooltip-target-container {
130+
flex: 1;
131+
width: 0;
132+
display: flex;
133+
justify-content: flex-end;
134+
135+
:global {
136+
.tooltip-target {
137+
height: 100%;
138+
}
139+
140+
.tooltip-body {
141+
display: flex;
142+
143+
span {
144+
width: 200px;
145+
white-space: normal;
146+
display: flex;
147+
justify-content: center;
148+
}
149+
}
150+
}
151+
}
152+
153+
.tooltip {
154+
max-width: 100%;
155+
height: 100%;
156+
}

src/components/TopicDrawer/TopicDrawer.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import Drawer from 'appirio-tech-react-components/components/Drawer/Drawer'
44

55
import FeedContainer from '../../projects/detail/containers/FeedContainer'
66

7+
import './TopicDrawer.scss'
8+
79
/**
810
* A drawer that shows the posts under the selected topic
911
*/
@@ -18,6 +20,7 @@ const TopicDrawer = ({
1820
return (
1921
<Drawer
2022
open={open}
23+
styleName="drawer-container"
2124
containerStyle={{
2225
top: '60px',
2326
height: 'calc(100% - 60px)',
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@import '~tc-ui/src/styles/tc-includes';
2+
3+
.drawer-container {
4+
> div:nth-child(2) {
5+
@media screen and (max-width: $screen-md - 1px) {
6+
width: 100% !important;
7+
top: 0 !important;
8+
height: 100% !important;
9+
}
10+
}
11+
}

src/components/UserSidebar/UserSidebar.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ const UserSidebar = ({user}) => {
4444
<div className="sideAreaWrapper">
4545
<UserSummary user={user}/>
4646
<hr styleName="separator"/>
47-
<div styleName="section-title">
48-
SYSTEM
49-
</div>
5047
<MenuList navLinks={navLinks}/>
5148
</div>
5249
</div>

src/config/constants.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,13 +643,15 @@ export const ROLE_CONNECT_ADMIN = 'Connect Admin'
643643
export const ROLE_ADMINISTRATOR = 'administrator'
644644
export const ROLE_CONNECT_COPILOT_MANAGER = 'Connect Copilot Manager'
645645

646+
// to be able to start the Connect App we should pass at least the dummy value for `FILE_PICKER_API_KEY`
647+
// but if we want to test file uploading we should provide the real value in `FILE_PICKER_API_KEY` env variable
648+
export const FILE_PICKER_API_KEY = process.env.FILE_PICKER_API_KEY || 'DUMMY'
646649
// FIXME .. remove defaults
647-
export const FILE_PICKER_API_KEY = process.env.FILE_PICKER_API_KEY || ''
648650
export const FILE_PICKER_SUBMISSION_CONTAINER_NAME = process.env.FILE_PICKER_SUBMISSION_CONTAINER_NAME || 'submission-staging-dev'
649651
export const FILE_PICKER_CNAME = process.env.FILE_PICKER_CNAME || 'fs.topcoder.com'
650652
export const FILE_PICKER_FROM_SOURCES = process.env.FILE_PICKER_FROM_SOURCES || ['local_file_system', 'googledrive', 'dropbox']
651653
export const PROJECT_ATTACHMENTS_FOLDER = process.env.PROJECT_ATTACHMENTS_FOLDER || 'PROJECT_ATTACHMENTS'
652-
export const FILE_PICKER_ACCEPT = process.env.FILE_PICKER_ACCEPT || ['.bmp', '.gif', '.jpg', '.tex', '.xls', '.xlsx', '.doc', '.docx', '.zip', '.txt', '.pdf', '.png', '.ppt', '.pptx', '.rtf']
654+
export const FILE_PICKER_ACCEPT = process.env.FILE_PICKER_ACCEPT || ['.bmp', '.gif', '.jpg', '.tex', '.xls', '.xlsx', '.doc', '.docx', '.zip', '.txt', '.pdf', '.png', '.ppt', '.pptx', '.rtf', '.csv']
653655

654656
export const SEGMENT_KEY = process.env.CONNECT_SEGMENT_KEY
655657
/*

src/helpers/wizardHelper.js

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import _ from 'lodash'
2323
import update from 'react-addons-update'
2424
import { evaluate, getFieldNamesFromExpression, populatePreparedConditions } from 'expression-evaluator'
2525
import { flatten, unflatten } from 'flat'
26+
import { checkPermission } from './permissions'
2627

2728
/**
2829
* @typedef {Object} NodeObject
@@ -392,6 +393,13 @@ export const initWizard = (template, project, productTemplates, incompleteWizard
392393
node
393394
}
394395

396+
// precalculate the result for `userPermissionCondition`
397+
if (nodeObject.userPermissionCondition && !checkPermission(nodeObject.userPermissionCondition)) {
398+
// we calculate this value once as user permissions cannot be changed
399+
// and we would use this value to calculate value of `hiddenByCondition`
400+
nodeObject.__wizard.hiddenByPermission = true
401+
}
402+
395403
// add all found variables from condition to the list of dependant fields of the template
396404
if (nodeObject.condition) {
397405
wizardTemplate.__wizard.dependantFields = _.uniq([
@@ -426,6 +434,11 @@ export const initWizard = (template, project, productTemplates, incompleteWizard
426434
prevWizardStep = getPrevStepToShow(wizardTemplate, lastWizardStep)
427435
}
428436

437+
// if the first step we found is hidden, then search for the next step which is not hidden
438+
if (!isNodeVisible(wizardTemplate, currentWizardStep)) {
439+
currentWizardStep = getStepToShowByDir(wizardTemplate, currentWizardStep, NODE_DIR.NEXT)
440+
}
441+
// use provided `lastWizardStep` or use the first non-hidden step
429442
currentWizardStep = lastWizardStep || currentWizardStep
430443
}
431444

@@ -880,7 +893,9 @@ const getParentNode = (node) => {
880893
...node,
881894
subSectionIndex: -1
882895
}
883-
} else if (node.sectionIndex !== -1) {
896+
// we shouldn't return parent node with all indexes as `-1`
897+
// that's why if we reach this point and `node.sectionIndex === 0` we should also return `null`
898+
} else if (node.sectionIndex !== -1 && node.sectionIndex !== 0) {
884899
return {
885900
...node,
886901
sectionIndex: -1
@@ -1095,8 +1110,10 @@ const getNodeWhichMustBeUpdatedByCondition = (template, flatProjectData) => {
10951110
}
10961111

10971112
forEachNode(template, (nodeObject, node) => {
1098-
if (nodeObject.condition) {
1099-
const hiddenByCondition = !evaluate(nodeObject.condition, flatProjectData)
1113+
if (nodeObject.condition || nodeObject.userPermissionCondition) {
1114+
// take into account the result of `userPermissionCondition` which we keep in `hiddenByPermission`
1115+
const hiddenByCondition = nodeObject.__wizard.hiddenByPermission
1116+
|| nodeObject.condition && !evaluate(nodeObject.condition, flatProjectData)
11001117

11011118
// only update if the condition result has changed
11021119
if (hiddenByCondition !== nodeObject.__wizard.hiddenByCondition) {
@@ -1194,4 +1211,24 @@ export const buildProjectUpdateQueryByQueryParamSelectCondition = (template, que
11941211
})
11951212

11961213
return updateQuery
1214+
}
1215+
1216+
/**
1217+
* Check if node is visible taking into account parent nodes.
1218+
* If any parent node or node itself is hidden, then the node is treated as hidden.
1219+
*
1220+
* @param {Object} template template
1221+
* @param {Node} node node
1222+
*
1223+
* @returns {Boolean} true if node is visible
1224+
*/
1225+
const isNodeVisible = (template, node) => {
1226+
let isVisible = !_.get(getNodeObject(template, node), '__wizard.hiddenByCondition')
1227+
1228+
let tempNode = node
1229+
while (isVisible && (tempNode = getParentNode(tempNode))) {
1230+
isVisible = isVisible && !_.get(getNodeObject(template, tempNode), '__wizard.hiddenByCondition')
1231+
}
1232+
1233+
return isVisible
11971234
}

src/projects/detail/components/PortalSubSection.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,22 @@ const PortalSubSection = ({
2626
removeAttachment,
2727
canManageAttachments,
2828
attachmentsStorePath,
29+
isCreation,
2930
}) => (
3031
<div>
3132
{content.map(({ sectionIndex }) => {
32-
if (sectionIndex && sectionIndex !== -1 && template && template.sections[sectionIndex]) {
33+
if (sectionIndex !== -1 && template && template.sections[sectionIndex]) {
3334
const section = template.sections[sectionIndex]
35+
36+
if (
37+
// hide if section is hidden by condition
38+
_.get(section, '__wizard.hiddenByCondition') ||
39+
// hide section in edit mode, if it should be hidden on edit
40+
!isCreation && section.hiddenOnEdit
41+
) {
42+
return null
43+
}
44+
3445
return (
3546
<SpecSection
3647
key={'portal-' + (section.id || `section-${sectionIndex}`)}

0 commit comments

Comments
 (0)