-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ErrorHandler] Add button to copy the path where error is thrown #40052
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,15 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') { | |
}; | ||
} | ||
|
||
if (navigator.clipboard) { | ||
document.querySelectorAll('[data-clipboard-text]').forEach(function(element) { | ||
removeClass(element, 'hidden'); | ||
element.addEventListener('click', function() { | ||
navigator.clipboard.writeText(element.getAttribute('data-clipboard-text')); | ||
}) | ||
}); | ||
} | ||
|
||
var request = function(url, onSuccess, onError, payload, options, tries) { | ||
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); | ||
options = options || {}; | ||
|
@@ -705,6 +714,14 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') { | |
}); | ||
} | ||
|
||
/* Prevents from disallowing clicks on "copy to clipboard" elements inside toggles */ | ||
var copyToClipboardElements = toggles[i].querySelectorAll('span[data-clipboard-text]') | ||
for (var k = 0; k < copyToClipboardElements.length; k++) { | ||
addEventListener(copyToClipboardElements[k], 'click', function(e) { | ||
e.stopPropagation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO we could always stopPropagation (and not ONLY for items in SPAN/toggle). And moving this logic at line 44 |
||
}); | ||
} | ||
|
||
toggles[i].setAttribute('data-processed', 'true'); | ||
} | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,9 @@ | |
<span class="trace-method"><?= $trace['function']; ?></span> | ||
<?php } ?> | ||
(line <?= $lineNumber; ?>) | ||
<span class="icon icon-copy hidden" data-clipboard-text="<?php echo implode(\DIRECTORY_SEPARATOR, $filePathParts).':'.$lineNumber; ?>"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about that... when running app in docker, absolute path is useless, while relative pat works in IDE, and console (when CWD=root of project) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, you're right. We do have a way to map paths from docker to host, but it is bound to the IDE URLs. Can't we use that map somehow to compute absolute paths for the host? |
||
<?php echo $this->include('assets/images/icon-copy.svg'); ?> | ||
</span> | ||
</span> | ||
<?php } ?> | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why using
for (...)
here and.forEach
at line 40.Same for
addEventListener(element
vselement.addEventListener
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be even better to use event delegation instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this code is actually useless because the click listener for toggle it is not attached to span elements. What do you think?