Commit 4b2ff003 authored by Filipa Lacerda's avatar Filipa Lacerda

Disable try again button while fetching the API

parent 8f189df8
......@@ -197,7 +197,7 @@ export default class Notes {
);
this.$wrapperEl.on('click', '.js-toggle-lazy-diff', this.loadLazyDiff);
this.$wrapperEl.on('click', '.js-toggle-lazy-diff-retry-button', this.loadLazyDiff);
this.$wrapperEl.on('click', '.js-toggle-lazy-diff-retry-button', this.onClickRetryLazyLoad.bind(this));
// fetch notes when tab becomes visible
this.$wrapperEl.on('visibilitychange', this.visibilityChange);
......@@ -1433,6 +1433,17 @@ export default class Notes {
syntaxHighlight(fileHolder);
}
onClickRetryLazyLoad(e) {
const $retryButton = $(e.currentTarget);
$retryButton.prop('disabled', true);
return this.loadLazyDiff(e)
.then(() => {
$retryButton.prop('disabled', false);
});
}
loadLazyDiff(e) {
const $container = $(e.currentTarget).closest('.js-toggle-container');
Notes.renderPlaceholderComponent($container);
......@@ -1453,7 +1464,7 @@ export default class Notes {
* Unresolved discussions don't have an endpoint being provided.
*/
if (url) {
axios
return axios
.get(url)
.then(({ data }) => {
// Reset state in case last request returned error
......@@ -1467,6 +1478,7 @@ export default class Notes {
$errorContainer.removeClass('hidden');
});
}
return Promise.resolve();
}
toggleCommitList(e) {
......
......@@ -762,3 +762,23 @@
max-width: 100%;
}
}
// Hack alert: we've rewritten `btn` class in a way that
// we've broken it and it is not possible to use with `btn-link`
// wich causes a blank button when it's disabled and hovering
// The css in here is the boostrap one
.btn-link-retry {
&[disabled] {
cursor: not-allowed;
filter: alpha(opacity=65);
-webkit-box-shadow: none;
box-shadow: none;
opacity: .65;
&:hover {
color: #777;
text-decoration: none;
}
}
}
\ No newline at end of file
......@@ -31,7 +31,7 @@
%td.line_content.js-success-lazy-load
.js-code-placeholder
%td.line_content.js-error-lazy-load-diff.hidden
- button = button_tag(_("Try again"), class: "btn-link btn-no-padding js-toggle-lazy-diff-retry-button")
- button = button_tag(_("Try again"), class: "btn-link btn-link-retry btn-no-padding js-toggle-lazy-diff-retry-button")
= _("Unable to load the diff. %{button_try_again}").html_safe % { button_try_again: button}
= render "discussions/diff_discussion", discussions: [discussion], expanded: true
- else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment