Skip to content

Commit c8be931

Browse files
committed
fix: don't use random for report URL
ref issue #3727
1 parent 29f0a73 commit c8be931

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/projects/detail/containers/ProjectSummaryReportContainer.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class ProjectSummaryReportContainer extends React.Component {
3636
constructor(props) {
3737
super(props)
3838

39+
this.state = {
40+
iframeKey: 0, // we would use it to force iframe to reload
41+
}
3942
this.timer = null
4043
this.setLookerSessionTimer = this.setLookerSessionTimer.bind(this)
4144
this.reloadProjectReport = this.reloadProjectReport.bind(this)
@@ -65,6 +68,13 @@ class ProjectSummaryReportContainer extends React.Component {
6568
this.props.loadProjectReportsUrls(nextProjectId, PROJECT_REPORTS.PROJECT_SUMMARY)
6669
// don't have to set session expire timer here, it would be set of iframe load
6770
}
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+
})
77+
}
6878
}
6979

7080
setLookerSessionTimer() {
@@ -148,6 +158,7 @@ class ProjectSummaryReportContainer extends React.Component {
148158
</div>
149159
</Modal>
150160
<EnhancedLookerEmbedReport
161+
key={this.state.iframeKey}
151162
isLoading={isLoading}
152163
projectSummaryEmbedUrl={projectSummaryEmbedUrl}
153164
onLoad={this.setLookerSessionTimer}

src/projects/reducers/projectReports.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,6 @@ const initialState = {
1414
lookerSessionExpired: false,
1515
}
1616

17-
/**
18-
* Adds a `random` query param to the URL so browser could treat such a URL as different.
19-
*
20-
* @param {String} url URL string to augment
21-
*
22-
* @returns {String} URL with `random` query param
23-
*/
24-
function addRandomParamToUrl(url) {
25-
const randomParam = `random=${Math.random().toString().slice(2)}`
26-
27-
return url + (url.indexOf('?') > -1 ? '&' : '?') + randomParam
28-
}
29-
3017
export const projectReports = function (state=initialState, action) {
3118
const payload = action.payload
3219

@@ -43,7 +30,7 @@ export const projectReports = function (state=initialState, action) {
4330
return Object.assign({}, state, {
4431
isLoading: false,
4532
error: false,
46-
projectSummaryEmbedUrl: addRandomParamToUrl(payload),
33+
projectSummaryEmbedUrl: payload,
4734
lookerSessionExpired: false,
4835
// projectSummary: payload
4936
})

0 commit comments

Comments
 (0)