Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse generic error handling mechanism of overlay #699

Merged
merged 1 commit into from May 18, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app/static/js/app.js
Expand Up @@ -342,6 +342,7 @@ const errorEvents = [
"change-hostname-failure",
"shutdown-failure",
"video-settings-failure",
"debug-logs-failure",
];
errorEvents.forEach((name) => {
document.addEventListener(name, (evt) => {
Expand Down
54 changes: 21 additions & 33 deletions app/templates/custom-elements/debug-dialog.html
Expand Up @@ -5,19 +5,15 @@

#logs-loading,
#logs-success,
#logs-fail,
#url-loading,
#url-success,
#url-fail {
#url-success {
display: none;
}

:host([state="logs-loading"]) #logs-loading,
:host([state="logs-success"]) #logs-success,
:host([state="logs-fail"]) #logs-fail,
:host([state="url-loading"]) #url-loading,
:host([state="url-success"]) #url-success,
:host([state="url-fail"]) #url-fail {
:host([state="url-success"]) #url-success {
display: block;
}

Expand All @@ -41,13 +37,6 @@
background: #bdbdbd;
padding: 1rem 2rem;
}

.error {
color: var(--brand-red);
font-weight: bold;
user-select: text;
white-space: pre-wrap;
}
</style>

<!-- Get Debug Logs -->
Expand All @@ -68,12 +57,6 @@ <h3>Debug Logs</h3>
<button class="close-btn" type="button">Close</button>
</div>

<div id="logs-fail">
<h3>Error Retrieving Debug Logs</h3>
<p class="error"></p>
<button class="close-btn" type="button">Close</button>
</div>

<!-- Get Shareable URL -->
<div id="url-loading">
<h3>Retrieving Shareable URL</h3>
Expand All @@ -90,12 +73,6 @@ <h3>Debug Logs</h3>
</button>
<button class="close-btn" type="button">Close</button>
</div>

<div id="url-fail">
<h3>Error Retrieving Shareable URL</h3>
<p class="error"></p>
<button class="close-btn" type="button">Close</button>
</div>
</template>

<script src="/js/util/clipboard.js"></script>
Expand Down Expand Up @@ -167,10 +144,10 @@ <h3>Error Retrieving Shareable URL</h3>
this.state = "logs-success";
})
.catch((error) => {
this.shadowRoot.querySelector(
"#logs-fail .error"
).textContent = error;
this.state = "logs-fail";
this._handleFailure({
title: "Error Retrieving Debug Logs",
details: error,
});
});
}

Expand Down Expand Up @@ -203,17 +180,28 @@ <h3>Error Retrieving Shareable URL</h3>
this.state = "url-success";
})
.catch((error) => {
this.shadowRoot.querySelector(
"#url-fail .error"
).textContent = error;
this.state = "url-fail";
this._handleFailure({
title: "Error Retrieving Shareable URL",
details: error,
});
});
}

onPushCopyButton(buttonElement, sourceElement) {
copyElementTextToClipboard(sourceElement);
buttonElement.innerText = "Copied!";
}

_handleFailure(errorInfo) {
this._close();
this.dispatchEvent(
new CustomEvent("debug-logs-failure", {
detail: errorInfo,
bubbles: true,
composed: true,
})
);
}
}
);
})();
Expand Down