Skip to content

Commit 0ffb773

Browse files
committed
add retry button for virtual project metrics
1 parent 8f495cd commit 0ffb773

3 files changed

Lines changed: 43 additions & 2 deletions

File tree

src/components/AdminPane/HOCs/WithCurrentProject/WithCurrentProject.jsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,11 @@ export const WithCurrentProject = function (WrappedComponent, options = {}) {
179179
};
180180

181181
loadChallengeStats = (project) => {
182-
this.setState({ loadingChallengeStats: true, challengeStatsAvailable: true });
182+
this.setState({
183+
loadingChallengeStats: true,
184+
challengeStatsAvailable: true,
185+
challengeStatsError: null
186+
});
183187

184188
// Used for burndown chart
185189
let activityStartDate = new Date(project.created);
@@ -197,7 +201,24 @@ export const WithCurrentProject = function (WrappedComponent, options = {}) {
197201
this.props.fetchLatestProjectChallengeActivity(project.id),
198202
];
199203

200-
return Promise.all(promises).then(() => this.setState({ loadingChallengeStats: false }));
204+
return Promise.all(promises)
205+
.then(() => this.setState({ loadingChallengeStats: false }))
206+
.catch((error) => {
207+
console.error('Error loading challenge stats:', error);
208+
209+
// Check if it's a timeout error
210+
const isTimeout = error?.response?.status === 504 ||
211+
error?.message?.includes('timeout') ||
212+
error?.code === 'QUERY_TIMEOUT';
213+
214+
this.setState({
215+
loadingChallengeStats: false,
216+
challengeStatsAvailable: false,
217+
challengeStatsError: isTimeout ?
218+
'The virtual project is too large and the request timed out. Please try again later or contact support.' :
219+
'An error occurred while loading completion stats. Please try again.'
220+
});
221+
});
201222
} else {
202223
this.setState({
203224
loadingChallengeStats: false,

src/components/Widgets/CompletionProgressWidget/CompletionProgressWidget.jsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ export default class CompletionProgressWidget extends Component {
4141
{window.env.REACT_APP_PROJECT_CHALLENGE_LIMIT} challenges.
4242
</div>
4343
);
44+
} else if (this.props.challengeStatsError) {
45+
content = (
46+
<div>
47+
<div className="mr-text-red mr-mb-4">
48+
{this.props.challengeStatsError}
49+
</div>
50+
<button
51+
type="button"
52+
className="mr-button"
53+
onClick={() => this.props.loadChallengeStats(this.props.project)}
54+
>
55+
<FormattedMessage {...messages.retryLabel} />
56+
</button>
57+
</div>
58+
);
4459
} else if (!this.props.challengeStatsAvailable) {
4560
content = (
4661
<button

src/components/Widgets/CompletionProgressWidget/Messages.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ export default defineMessages({
2323
id: "Widgets.BurndownChartWidget.controls.loadStats.label",
2424
defaultMessage: "Load Completion Stats",
2525
},
26+
27+
retryLabel: {
28+
id: "Widgets.CompletionProgressWidget.controls.retry.label",
29+
defaultMessage: "Retry",
30+
},
2631
});

0 commit comments

Comments
 (0)