Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Merge remote-tracking branch 'origin/next' into fix/clipboard-https-secure-context

Andras Bacsaid742b4a67833
diff --cc resources/views/livewire/project/application/deployment/show.blade.php
index a8b24aa9c1,4c1a2f08a8..bbafdd24b8
--- a/resources/views/livewire/project/application/deployment/show.blade.php
+++ b/resources/views/livewire/project/application/deployment/show.blade.php
@@@ -118,6 -181,17 +181,24 @@@
content += text + String.fromCharCode(10);
}
});
+ return content;
+ },
+ copyLogs() {
+ const content = this.collectVisibleLogs();
+ if (!content) return;
- navigator.clipboard.writeText(content);
- Livewire.dispatch('success', ['Logs copied to clipboard.']);
++ if (!navigator.clipboard?.writeText) {
++ Livewire.dispatch('error', ['Clipboard is not available. Please use HTTPS or localhost.']);
++ return;
++ }
++ navigator.clipboard?.writeText(content).then(() => {
++ Livewire.dispatch('success', ['Logs copied to clipboard.']);
++ }).catch(() => {
++ Livewire.dispatch('error', ['Failed to copy logs to clipboard.']);
++ });
+ },
+ downloadLogs() {
+ const content = this.collectVisibleLogs();
+ if (!content) return;
const blob = new Blob([content], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
diff --cc resources/views/livewire/project/shared/get-logs.blade.php
index 4bbd5a28a2,2140e7d2c4..f74ab6dc54
--- a/resources/views/livewire/project/shared/get-logs.blade.php
+++ b/resources/views/livewire/project/shared/get-logs.blade.php
@@@ -314,15 -346,8 +346,17 @@@
<button
x-on:click="
$wire.copyLogs().then(logs => {
- if (!navigator.clipboard) {
- Livewire.dispatch('error', ['Clipboard is not available. Please use HTTPS.']);
- navigator.clipboard.writeText(logs);
- Livewire.dispatch('success', ['Logs copied to clipboard.']);
++ if (!navigator.clipboard?.writeText) {
++ Livewire.dispatch('error', ['Clipboard is not available. Please use HTTPS or localhost.']);
+ return;
+ }
+ navigator.clipboard.writeText(logs).then(() => {
+ Livewire.dispatch('success', ['Logs copied to clipboard.']);
+ }).catch(() => {
+ Livewire.dispatch('error', ['Failed to copy logs to clipboard.']);
+ });
++ }).catch(() => {
++ Livewire.dispatch('error', ['Failed to prepare logs for clipboard.']);
});
"
title="Copy Logs"
diff --cc tests/Feature/LogClipboardHandlerTest.php
index 0000000000,0000000000..1b02733532
new file mode 100644
--- /dev/null
+++ b/tests/Feature/LogClipboardHandlerTest.php
@@@ -1,0 -1,0 +1,39 @@@
++<?php
++
++use Illuminate\Support\Str;
++
++function bladeView(string $path): string
++{
++ return file_get_contents(base_path($path));
++}
++
++it('guards deployment log clipboard writes and reports promise failures', function () {
++ $view = bladeView('resources/views/livewire/project/application/deployment/show.blade.php');
++
++ expect($view)
++ ->toContain('copyLogs()')
++ ->toContain('navigator.clipboard?.writeText')
++ ->toContain("Livewire.dispatch('error', ['Clipboard is not available. Please use HTTPS or localhost.']);")
++ ->toContain("Livewire.dispatch('error', ['Failed to copy logs to clipboard.']);")
++ ->toContain("Livewire.dispatch('success', ['Logs copied to clipboard.']);");
++
++ expect(Str::between($view, 'copyLogs() {', 'downloadLogs()'))
++ ->toContain('navigator.clipboard?.writeText(content).then(() =>')
++ ->not->toContain("navigator.clipboard.writeText(content);\n Livewire.dispatch('success'");
++});
++
++it('guards shared log clipboard writes and handles Livewire preparation failures', function () {
++ $view = bladeView('resources/views/livewire/project/shared/get-logs.blade.php');
++
++ expect($view)
++ ->toContain('navigator.clipboard?.writeText')
++ ->toContain("Livewire.dispatch('error', ['Clipboard is not available. Please use HTTPS or localhost.']);")
++ ->toContain("Livewire.dispatch('error', ['Failed to copy logs to clipboard.']);")
++ ->toContain("Livewire.dispatch('error', ['Failed to prepare logs for clipboard.']);")
++ ->toContain("Livewire.dispatch('success', ['Logs copied to clipboard.']);");
++
++ expect($view)
++ ->toContain('$wire.copyLogs().then(logs =>')
++ ->toContain('}).catch(() => {')
++ ->not->toContain('navigator.clipboard.writeText(logs);');
++});