-
Notifications
You must be signed in to change notification settings - Fork 921
[Dashboard] Add tour for dashboard #6301
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
Conversation
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.
Bug: Clipboard Copy Errors: Null Checks and Promise Handling
The copyDashboardCodeBlock function lacks robust error handling. It is missing null checks for DOM element queries (e.g., closest, querySelector), which can lead to TypeError crashes if the expected elements are not found. Additionally, the navigator.clipboard.writeText() call lacks a .catch() block, resulting in unhandled promise rejections if the clipboard operation fails.
sky/dashboard/src/hooks/useTour.js#L23-L36
skypilot/sky/dashboard/src/hooks/useTour.js
Lines 23 to 36 in b604940
| if (typeof window !== 'undefined') { | |
| window['copyDashboardCodeBlock'] = function (button) { | |
| const codeContainer = button.closest('.bg-gray-50').querySelector('pre'); | |
| const codeBlock = codeContainer.querySelector('code.block'); | |
| const text = codeBlock.textContent; | |
| navigator.clipboard.writeText(text).then(() => { | |
| const originalSvg = button.innerHTML; | |
| button.innerHTML = | |
| '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check h-5 w-5 text-green-600"><path d="m9 12 2 2 4-4"/></svg>'; | |
| setTimeout(() => { | |
| button.innerHTML = originalSvg; | |
| }, 2000); | |
| }); | |
| }; |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Tested (run the relevant ones):
bash format.sh/smoke-test(CI) orpytest tests/test_smoke.py(local)/smoke-test -k test_name(CI) orpytest tests/test_smoke.py::test_name(local)/quicktest-core(CI) orpytest tests/smoke_tests/test_backward_compat.py(local)