Skip to content

Commit

Permalink
RavenDB-19578 Provide copy button in error dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbartosik authored and arekpalinski committed Jun 25, 2024
1 parent 28c5107 commit bf79035
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import abstractNotification = require("common/notifications/models/abstractNotif
import notificationCenter = require("common/notifications/notificationCenter");
import recentError = require("common/notifications/models/recentError");
import dialogViewModelBase = require("viewmodels/dialogViewModelBase");
import copyToClipboard from "common/copyToClipboard";

class recentErrorDetails extends dialogViewModelBase {

Expand All @@ -13,7 +14,7 @@ class recentErrorDetails extends dialogViewModelBase {

constructor(recentError: recentError, notificationCenter: notificationCenter) {
super();
this.bindToCurrentInstance("close", "dismiss");
this.bindToCurrentInstance("close", "dismiss", "copyErrorDetails");

this.recentError = recentError;
this.dismissFunction = () => notificationCenter.dismiss(recentError);
Expand All @@ -24,6 +25,11 @@ class recentErrorDetails extends dialogViewModelBase {
this.close();
}

copyErrorDetails(): void {
const errorDetails = this.recentError.details();
copyToClipboard.copy(errorDetails, "Error has been copied to clipboard");
}

static supportsDetailsFor(notification: abstractNotification) {
return notification instanceof recentError;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ <h3 class="modal-title" id="myModalLabel" data-bind="text: title, attr: { class:
</div>
<div class="modal-body" data-bind="with: recentError">
<div data-bind="html: longerMessage"></div>
<pre class="margin-top error-messages" data-bind="visible: details"><code data-bind="text: details"></code></pre>
<div class="d-flex margin-top" data-bind="visible: details">
<div class="flex-grow"></div>
<button class="btn btn-default btn-sm" data-bind="click: $parent.copyErrorDetails"><i class="icon-copy-to-clipboard"></i><span>Copy error message</span></button>
</div>
<pre class="d-flex error-messages position-relative" data-bind="visible: details">
<code data-bind="text: details"></code>
</pre>
</div>
<div class="modal-footer">
<div class="flex-horizontal">
Expand Down

0 comments on commit bf79035

Please sign in to comment.