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
63 changes: 0 additions & 63 deletions src/api/projectReports.js

This file was deleted.

28 changes: 0 additions & 28 deletions src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,19 +462,6 @@ export const UPDATE_PROJECT_ATTACHMENT_FAILURE = 'UPDATE_PROJECT_ATTACHMENT_FAIL
export const REMOVE_PENDING_ATTACHMENT = 'REMOVE_PENDING_ATTACHMENT'
export const UPDATE_PENDING_ATTACHMENT = 'UPDATE_PENDING_ATTACHMENT'

// Project summary
export const LOAD_PROJECT_SUMMARY = 'LOAD_PROJECT_SUMMARY'
export const LOAD_PROJECT_SUMMARY_PENDING = 'LOAD_PROJECT_SUMMARY_PENDING'
export const LOAD_PROJECT_SUMMARY_SUCCESS = 'LOAD_PROJECT_SUMMARY_SUCCESS'
export const LOAD_PROJECT_SUMMARY_FAILURE = 'LOAD_PROJECT_SUMMARY_FAILURE'
export const SET_LOOKER_SESSION_EXPIRED = 'SET_LOOKER_SESSION_EXPIRED'

// User Reports
export const LOAD_USER_REPORTS = 'LOAD_USER_REPORTS'
export const LOAD_USER_REPORTS_PENDING = 'LOAD_USER_REPORTS_PENDING'
export const LOAD_USER_REPORTS_SUCCESS = 'LOAD_USER_REPORTS_SUCCESS'
export const LOAD_USER_REPORTS_FAILURE = 'LOAD_USER_REPORTS_FAILURE'

// Product attachments
export const ADD_PRODUCT_ATTACHMENT = 'ADD_PRODUCT_ATTACHMENT'
export const ADD_PRODUCT_ATTACHMENT_PENDING = 'ADD_PRODUCT_ATTACHMENT_PENDING'
Expand Down Expand Up @@ -1055,21 +1042,6 @@ export const PROJECT_ASSETS_SHARED_WITH_TOPCODER_MEMBERS = 'Only Topcoder Member
export const PROJECT_ASSETS_SHARED_WITH_ADMIN = 'Only Admins'



/**
* REPORTS
*/
export const PROJECT_REPORTS = {
PROJECT_SUMMARY : 'summary',
TAAS_MEMBERS : 'taas_members',
}

/**
* Report session length in seconds
*/
export const REPORT_SESSION_LENGTH = 25 * 60 // 25 minutes (5 minutes less than the report session)


/**
* Contentful Content Ids
*/
Expand Down
47 changes: 0 additions & 47 deletions src/projects/actions/projectReports.js

This file was deleted.

120 changes: 22 additions & 98 deletions src/projects/detail/containers/ProjectSummaryReportContainer.jsx
Original file line number Diff line number Diff line change
@@ -1,85 +1,25 @@
import _ from 'lodash'
import React from 'react'
import PT from 'prop-types'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import MediaQuery from 'react-responsive'
import Modal from 'react-modal'

import {
SCREEN_BREAKPOINT_MD,
PROJECT_FEED_TYPE_PRIMARY,
PROJECT_FEED_TYPE_MESSAGES,
PROJECT_REPORTS,
REPORT_SESSION_LENGTH,
} from '../../../config/constants'
import TwoColsLayout from '../../../components/TwoColsLayout'
import Sticky from '../../../components/Sticky'
import ProjectInfoContainer from './ProjectInfoContainer'
import { PERMISSIONS } from '../../../config/permissions'
import { hasPermission } from '../../../helpers/permissions'
import { loadProjectReportsUrls, setLookerSessionExpired } from '../../actions/projectReports'
import spinnerWhileLoading from '../../../components/LoadingSpinner'

import './ProjectSummaryReportContainer.scss'

const LookerEmbedReport = (props) => {
return (<iframe width="100%" src={props.projectSummaryEmbedUrl} onLoad={props.onLoad} />)
}

const EnhancedLookerEmbedReport = spinnerWhileLoading(props => {
return !props.isLoading
})(LookerEmbedReport)

class ProjectSummaryReportContainer extends React.Component {

constructor(props) {
super(props)

this.timer = null
this.setLookerSessionTimer = this.setLookerSessionTimer.bind(this)
this.reloadProjectReport = this.reloadProjectReport.bind(this)
}

reloadProjectReport() {
this.props.loadProjectReportsUrls(_.get(this.props, 'project.id'), PROJECT_REPORTS.PROJECT_SUMMARY)
// don't have to set session expire timer here, it would be set of iframe load
}

componentWillMount() {
this.reloadProjectReport()
// don't have to set session expire timer here, it would be set of iframe load
}

componentWillUnmount() {
if (this.timer) {
clearTimeout(this.timer)
}
}

componentWillUpdate(nextProps) {
const nextReportProjectId = _.get(nextProps, 'reportsProjectId')
const nextProjectId = _.get(nextProps, 'project.id')

if (nextProjectId && nextReportProjectId !== nextProjectId) {
this.props.loadProjectReportsUrls(nextProjectId, PROJECT_REPORTS.PROJECT_SUMMARY)
// don't have to set session expire timer here, it would be set of iframe load
}
}

setLookerSessionTimer() {
console.log('Setting Looker Session Timer')

if (this.timer) {
clearTimeout(this.timer)
}

// set timeout for raising alert to refresh the token when session expires
this.timer = setTimeout(() => {
console.log('Looker Session is expired by timer')
this.props.setLookerSessionExpired(true)
window.analytics && window.analytics.track('Looker Session Expired')
}, REPORT_SESSION_LENGTH * 1000)
}

render() {
Expand All @@ -92,8 +32,6 @@ class ProjectSummaryReportContainer extends React.Component {
phasesTopics,
isLoading,
location,
projectSummaryEmbedUrl,
lookerSessionExpired,
} = this.props

const leftArea = (
Expand All @@ -116,37 +54,25 @@ class ProjectSummaryReportContainer extends React.Component {
<MediaQuery minWidth={SCREEN_BREAKPOINT_MD}>
{(matches) => {
if (matches) {
return <Sticky top={60} bottomBoundary="#wrapper-main">{leftArea}</Sticky>
return (
<Sticky top={60} bottomBoundary="#wrapper-main">
{leftArea}
</Sticky>
)
} else {
return leftArea
}
}}
</MediaQuery>
</TwoColsLayout.Sidebar>
<TwoColsLayout.Content>
<Modal
isOpen={lookerSessionExpired && !isLoading}
className="delete-post-dialog"
overlayClassName="delete-post-dialog-overlay"
contentLabel=""
>
<div className="modal-title">
Report sessions expired
</div>

<div className="modal-body">
To keep the data up to date, please, hit "Refresh" button to reload the report.
</div>

<div className="button-area flex center action-area">
<button className="tc-btn tc-btn-primary tc-btn-sm" onClick={this.reloadProjectReport}>Refresh</button>
</div>
</Modal>
<EnhancedLookerEmbedReport
isLoading={isLoading}
projectSummaryEmbedUrl={projectSummaryEmbedUrl}
onLoad={this.setLookerSessionTimer}
/>
<div styleName="container">
<p>
This content has been moved. Please contact{' '}
<a href="mailto:support@topcoder.com">support@topcoder.com</a> to
receive an emailed copy of your report.
</p>
</div>
</TwoColsLayout.Content>
</TwoColsLayout>
)
Expand All @@ -158,30 +84,28 @@ ProjectSummaryReportContainer.propTypes = {
project: PT.object.isRequired,
phases: PT.array.isRequired,
productsTimelines: PT.object.isRequired,
reportsProjectId: PT.number,
}

const mapStateToProps = ({ projectState, projectTopics, phasesTopics, projectReports }) => {
const mapStateToProps = ({ projectState, projectTopics, phasesTopics }) => {
// all feeds includes primary as well as private topics if user has access to private topics
let allFeed = projectTopics.feeds[PROJECT_FEED_TYPE_PRIMARY].topics
if (hasPermission(PERMISSIONS.ACCESS_PRIVATE_POST)) {
allFeed = [...allFeed, ...projectTopics.feeds[PROJECT_FEED_TYPE_MESSAGES].topics]
allFeed = [
...allFeed,
...projectTopics.feeds[PROJECT_FEED_TYPE_MESSAGES].topics,
]
}

return {
phases: projectState.phases,
feeds: allFeed,
phasesTopics,
isLoading: projectReports.isLoading,
reportsProjectId: projectReports.projectId,
lookerSessionExpired: projectReports.lookerSessionExpired,
projectSummaryEmbedUrl: projectReports.projectSummaryEmbedUrl,
}
}

const mapDispatchToProps = {
loadProjectReportsUrls,
setLookerSessionExpired,
}
const mapDispatchToProps = {}

export default connect(mapStateToProps, mapDispatchToProps)(withRouter(ProjectSummaryReportContainer))
export default connect(
mapStateToProps,
mapDispatchToProps
)(withRouter(ProjectSummaryReportContainer))
37 changes: 34 additions & 3 deletions src/projects/detail/containers/ProjectSummaryReportContainer.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
iframe {
height: calc(100vh - 60px);
}
@import '~tc-ui/src/styles/tc-includes';
@import '../../../styles/includes';

.container {
@include stand-alone-item-shadow;
background-color: $tc-white;
border-radius: $card-border-radius;
margin-top: 4 * $base-unit;
padding: 4 * $base-unit;
margin: 0 auto;
max-width: 760px;

@media screen and (min-width: $screen-md) {
margin-top: 30px;
}

@media screen and (max-width: $screen-md - 1px) {
border-radius: 0;
}

p {
@include roboto;
font-size: 15px;
line-height: 25px;

a {
color: $tc-dark-blue;

&:hover {
text-decoration: underline;
}
}
}
}
Loading