Skip to content

Commit 5129100

Browse files
author
vikasrohit
authored
Merge pull request #3729 from appirio-tech/hotfix/post-release-2.7.1
[HOTIFX] [PROD] Post release 2.7.1
2 parents 6696d25 + c8be931 commit 5129100

File tree

6 files changed

+85
-38
lines changed

6 files changed

+85
-38
lines changed

src/api/projectMembers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function removeProjectMember(projectId, memberId) {
6868
}
6969

7070
export function getProjectMembers(projectId) {
71-
const fields = 'id,userId,role,isPrimary,deletedAt,createdAt,updatedAt,deletedBy,createdBy,updatedBy,handle,firstName,lastName,photoURL,workingHourStart,workingHourEnd,timeZone'
71+
const fields = 'id,userId,role,isPrimary,deletedAt,createdAt,updatedAt,deletedBy,createdBy,updatedBy,handle,firstName,lastName,email,photoURL,workingHourStart,workingHourEnd,timeZone'
7272
const url = `${PROJECTS_API_URL}/v5/projects/${projectId}/members/?fields=`
7373
+ encodeURIComponent(fields)
7474
return axios.get(url)
@@ -78,7 +78,7 @@ export function getProjectMembers(projectId) {
7878
}
7979

8080
export function getProjectMember(projectId, memberId) {
81-
const fields = 'id,userId,role,isPrimary,deletedAt,createdAt,updatedAt,deletedBy,createdBy,updatedBy,handle,firstName,lastName,photoURL,workingHourStart,workingHourEnd,timeZone'
81+
const fields = 'id,userId,role,isPrimary,deletedAt,createdAt,updatedAt,deletedBy,createdBy,updatedBy,handle,firstName,lastName,email,photoURL,workingHourStart,workingHourEnd,timeZone'
8282
const url = `${PROJECTS_API_URL}/v5/projects/${projectId}/members/${memberId}?fields=`
8383
+ encodeURIComponent(fields)
8484
return axios.get(url)

src/api/projects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { PROJECTS_API_URL, PROJECTS_LIST_PER_PAGE } from '../config/constants'
44

55
export function getProjects(criteria, pageNum) {
66
// add default params
7-
const includeFields = ['id', 'name', 'description', 'members', 'status', 'type', 'actualPrice', 'estimatedPrice', 'createdAt', 'updatedAt', 'createdBy', 'updatedBy', 'details', 'lastActivityAt', 'lastActivityUserId', 'version', 'templateId']
7+
const includeFields = ['id', 'name', 'description', 'members', 'invites', 'status', 'type', 'actualPrice', 'estimatedPrice', 'createdAt', 'updatedAt', 'createdBy', 'updatedBy', 'details', 'lastActivityAt', 'lastActivityUserId', 'version', 'templateId']
88
const params = {
99
fields: includeFields.join(','),
1010
sort: 'updatedAt+desc', // default sort value

src/config/constants.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ export const LOAD_PROJECT_SUMMARY = 'LOAD_PROJECT_SUMMARY'
417417
export const LOAD_PROJECT_SUMMARY_PENDING = 'LOAD_PROJECT_SUMMARY_PENDING'
418418
export const LOAD_PROJECT_SUMMARY_SUCCESS = 'LOAD_PROJECT_SUMMARY_SUCCESS'
419419
export const LOAD_PROJECT_SUMMARY_FAILURE = 'LOAD_PROJECT_SUMMARY_FAILURE'
420-
export const REFRESH_LOOKER_SESSION = 'REFRESH_LOOKER_SESSION'
420+
export const SET_LOOKER_SESSION_EXPIRED = 'SET_LOOKER_SESSION_EXPIRED'
421421

422422
// Product attachments
423423
export const ADD_PRODUCT_ATTACHMENT = 'ADD_PRODUCT_ATTACHMENT'
@@ -962,4 +962,7 @@ export const PROJECT_REPORTS = {
962962
TAAS_MEMBERS : 'taas_members',
963963
}
964964

965-
export const REPORT_SESSION_LENGTH = 1800
965+
/**
966+
* Report session length in seconds
967+
*/
968+
export const REPORT_SESSION_LENGTH = 30 * 60 // 30 minutes

src/projects/actions/projectReports.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
LOAD_PROJECT_SUMMARY,
3-
REFRESH_LOOKER_SESSION,
3+
SET_LOOKER_SESSION_EXPIRED,
44
} from '../../config/constants'
55
import {
66
getProjectSummary,
@@ -33,14 +33,15 @@ export function loadProjectReportsUrls(projectId, reportName) {
3333
}
3434

3535
/**
36-
* Redux action to refresh the looker session. It is aimed to just indicate that there is need
37-
* of refreshing the token. It does not do any thing itself. It is upto the state listner to react.
36+
* Redux action set the flag `lookerSessionExpired`
37+
*
38+
* @param {Boolean} isExpired true to indicate that looker session is expired
3839
*/
39-
export function refreshLookerSession() {
40+
export function setLookerSessionExpired(isExpired) {
4041
return (dispatch) => {
4142
return dispatch({
42-
type: REFRESH_LOOKER_SESSION,
43-
payload: { lookerSessionExpired: true }
43+
type: SET_LOOKER_SESSION_EXPIRED,
44+
payload: { lookerSessionExpired: isExpired }
4445
})
4546
}
4647
}

src/projects/detail/containers/ProjectSummaryReportContainer.jsx

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import PT from 'prop-types'
44
import { connect } from 'react-redux'
55
import { withRouter } from 'react-router-dom'
66
import MediaQuery from 'react-responsive'
7+
import Modal from 'react-modal'
78

89
import {
910
SCREEN_BREAKPOINT_MD,
@@ -17,7 +18,7 @@ import Sticky from '../../../components/Sticky'
1718
import ProjectInfoContainer from './ProjectInfoContainer'
1819
import PERMISSIONS from '../../../config/permissions'
1920
import { checkPermission } from '../../../helpers/permissions'
20-
import { loadProjectSummary, loadProjectReportsUrls, refreshLookerSession } from '../../actions/projectReports'
21+
import { loadProjectReportsUrls, setLookerSessionExpired } from '../../actions/projectReports'
2122
import spinnerWhileLoading from '../../../components/LoadingSpinner'
2223

2324
import './ProjectSummaryReportContainer.scss'
@@ -34,34 +35,60 @@ class ProjectSummaryReportContainer extends React.Component {
3435

3536
constructor(props) {
3637
super(props)
38+
39+
this.state = {
40+
iframeKey: 0, // we would use it to force iframe to reload
41+
}
3742
this.timer = null
3843
this.setLookerSessionTimer = this.setLookerSessionTimer.bind(this)
44+
this.reloadProjectReport = this.reloadProjectReport.bind(this)
45+
}
46+
47+
reloadProjectReport() {
48+
this.props.loadProjectReportsUrls(_.get(this.props, 'project.id'), PROJECT_REPORTS.PROJECT_SUMMARY)
49+
// don't have to set session expire timer here, it would be set of iframe load
50+
}
51+
52+
componentWillMount() {
53+
this.reloadProjectReport()
54+
// don't have to set session expire timer here, it would be set of iframe load
55+
}
56+
57+
componentWillUnmount() {
58+
if (this.timer) {
59+
clearTimeout(this.timer)
60+
}
3961
}
4062

4163
componentWillUpdate(nextProps) {
4264
const nextReportProjectId = _.get(nextProps, 'reportsProjectId')
4365
const nextProjectId = _.get(nextProps, 'project.id')
44-
const lookerSessionExpired = !this.props.lookerSessionExpired && nextProps.lookerSessionExpired
45-
if(lookerSessionExpired || (nextProjectId && nextReportProjectId !== nextProjectId)) {
46-
nextProps.loadProjectReportsUrls(nextProjectId, PROJECT_REPORTS.PROJECT_SUMMARY)
47-
this.setLookerSessionTimer()
66+
67+
if (nextProjectId && nextReportProjectId !== nextProjectId) {
68+
this.props.loadProjectReportsUrls(nextProjectId, PROJECT_REPORTS.PROJECT_SUMMARY)
69+
// don't have to set session expire timer here, it would be set of iframe load
70+
}
71+
72+
// when we get a new URL for report, force iframe to reload, in case the URL stays the same
73+
if (this.props.isLoading && !nextProps.isLoading) {
74+
this.setState({
75+
iframeKey: this.state.iframeKey + 1
76+
})
4877
}
4978
}
5079

5180
setLookerSessionTimer() {
5281
console.log('Setting Looker Session Timer')
82+
5383
if (this.timer) {
5484
clearTimeout(this.timer)
5585
}
56-
let timeoutDuration = 60*1000
57-
if (REPORT_SESSION_LENGTH > 2*60) {
58-
timeoutDuration = REPORT_SESSION_LENGTH*1000 - 2*60*1000
59-
}
60-
// set timeout for raising alert to refresh the token 2 minutes before the session expire
86+
87+
// set timeout for raising alert to refresh the token when session expires
6188
this.timer = setTimeout(() => {
62-
console.log('Calling refresh looker session action')
63-
this.props.refreshLookerSession()
64-
}, (timeoutDuration))
89+
console.log('Looker Session is expired by timer')
90+
this.props.setLookerSessionExpired(true)
91+
}, REPORT_SESSION_LENGTH * 1000)
6592
}
6693

6794
render() {
@@ -78,6 +105,7 @@ class ProjectSummaryReportContainer extends React.Component {
78105
isLoading,
79106
location,
80107
projectSummaryEmbedUrl,
108+
lookerSessionExpired,
81109
} = this.props
82110

83111
const leftArea = (
@@ -111,13 +139,30 @@ class ProjectSummaryReportContainer extends React.Component {
111139
</MediaQuery>
112140
</TwoColsLayout.Sidebar>
113141
<TwoColsLayout.Content>
114-
{
115-
<EnhancedLookerEmbedReport
116-
isLoading={isLoading}
117-
projectSummaryEmbedUrl={projectSummaryEmbedUrl}
118-
onLoad={this.setLookerSessionTimer}
119-
/>
120-
}
142+
<Modal
143+
isOpen={lookerSessionExpired && !isLoading}
144+
className="delete-post-dialog"
145+
overlayClassName="delete-post-dialog-overlay"
146+
contentLabel=""
147+
>
148+
<div className="modal-title">
149+
Report sessions expired
150+
</div>
151+
152+
<div className="modal-body">
153+
To keep the data up to date, please, hit "Refresh" button to reload the report.
154+
</div>
155+
156+
<div className="button-area flex center action-area">
157+
<button className="tc-btn tc-btn-primary tc-btn-sm" onClick={this.reloadProjectReport}>Refresh</button>
158+
</div>
159+
</Modal>
160+
<EnhancedLookerEmbedReport
161+
key={this.state.iframeKey}
162+
isLoading={isLoading}
163+
projectSummaryEmbedUrl={projectSummaryEmbedUrl}
164+
onLoad={this.setLookerSessionTimer}
165+
/>
121166
</TwoColsLayout.Content>
122167
</TwoColsLayout>
123168
)
@@ -154,9 +199,8 @@ const mapStateToProps = ({ projectState, projectTopics, phasesTopics, projectRep
154199
}
155200

156201
const mapDispatchToProps = {
157-
loadProjectSummary,
158202
loadProjectReportsUrls,
159-
refreshLookerSession,
203+
setLookerSessionExpired,
160204
}
161205

162206
export default connect(mapStateToProps, mapDispatchToProps)(withRouter(ProjectSummaryReportContainer))

src/projects/reducers/projectReports.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
LOAD_PROJECT_SUMMARY_PENDING,
33
LOAD_PROJECT_SUMMARY_SUCCESS,
44
LOAD_PROJECT_SUMMARY_FAILURE,
5-
REFRESH_LOOKER_SESSION,
5+
SET_LOOKER_SESSION_EXPIRED,
66
} from '../../config/constants'
77

88
const initialState = {
@@ -22,7 +22,7 @@ export const projectReports = function (state=initialState, action) {
2222
return Object.assign({}, state, {
2323
isLoading: true,
2424
error: false,
25-
projectId: action.meta.projectId
25+
projectId: action.meta.projectId,
2626
})
2727

2828
case LOAD_PROJECT_SUMMARY_SUCCESS:
@@ -41,14 +41,13 @@ export const projectReports = function (state=initialState, action) {
4141
case LOAD_PROJECT_SUMMARY_FAILURE: {
4242
return Object.assign({}, state, {
4343
isLoading: false,
44-
lookerSessionExpired: false,
4544
error: payload
4645
})
4746
}
4847

49-
case REFRESH_LOOKER_SESSION: {
48+
case SET_LOOKER_SESSION_EXPIRED: {
5049
return Object.assign({}, state, {
51-
lookerSessionExpired: true
50+
lookerSessionExpired: payload
5251
})
5352
}
5453

0 commit comments

Comments
 (0)