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.

refactor(deployment): move copyLogs to client-side and hide refund when ineligible

Andras Bacsaie89820b46552
diff --git a/app/Livewire/Project/Application/Deployment/Show.php b/app/Livewire/Project/Application/Deployment/Show.php
index 954670582a..c9f818e2cd 100644
--- a/app/Livewire/Project/Application/Deployment/Show.php
+++ b/app/Livewire/Project/Application/Deployment/Show.php
@@ -108,19 +108,6 @@ class Show extends Component
return decode_remote_command_output($this->application_deployment_queue);
}
- public function copyLogs(): string
- {
- $logs = decode_remote_command_output($this->application_deployment_queue)
- ->map(function ($line) {
- return $line['timestamp'].' '.
- (isset($line['command']) && $line['command'] ? '[CMD]: ' : '').
- trim($line['line']);
- })
- ->join("\n");
-
- return sanitizeLogsForExport($logs);
- }
-
public function downloadAllLogs(): string
{
$logs = decode_remote_command_output($this->application_deployment_queue, includeAll: true)
diff --git a/resources/views/livewire/project/application/deployment/show.blade.php b/resources/views/livewire/project/application/deployment/show.blade.php
index 8618872f51..8ef2c3f516 100644
--- a/resources/views/livewire/project/application/deployment/show.blade.php
+++ b/resources/views/livewire/project/application/deployment/show.blade.php
@@ -155,9 +155,9 @@
this.matchCount = query ? count : 0;
},
- downloadLogs() {
+ collectVisibleLogs() {
const logs = document.getElementById('logs');
- if (!logs) return;
+ if (!logs) return '';
const visibleLines = logs.querySelectorAll('[data-log-line]:not(.hidden)');
let content = '';
visibleLines.forEach(line => {
@@ -166,6 +166,17 @@
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.']);
+ },
+ 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');
@@ -258,12 +269,7 @@
</div>
<div class="flex flex-wrap items-center gap-1">
<button
- x-on:click="
- $wire.copyLogs().then(logs => {
- navigator.clipboard.writeText(logs);
- Livewire.dispatch('success', ['Logs copied to clipboard.']);
- });
- "
+ x-on:click="copyLogs()"
title="Copy Logs"
class="p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200">
<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
diff --git a/resources/views/livewire/subscription/actions.blade.php b/resources/views/livewire/subscription/actions.blade.php
index aa129043b0..1b622285ab 100644
--- a/resources/views/livewire/subscription/actions.blade.php
+++ b/resources/views/livewire/subscription/actions.blade.php
@@ -249,23 +249,23 @@
{{-- Refund --}}
<section>
<h3 class="pb-2">Refund</h3>
- <div class="flex flex-wrap items-center gap-2">
- @if ($refundCheckLoading)
- <x-forms.button disabled>Request Full Refund</x-forms.button>
- @elseif ($isRefundEligible && !currentTeam()->subscription->stripe_cancel_at_period_end)
- <x-modal-confirmation title="Request Full Refund?" buttonTitle="Request Full Refund"
- isErrorButton submitAction="refundSubscription"
- :actions="[
- 'Your latest payment will be fully refunded.',
- 'Your subscription will be cancelled immediately.',
- 'All servers will be deactivated.',
- ]" confirmationText="{{ currentTeam()->name }}"
- confirmationLabel="Enter your team name to confirm" shortConfirmationLabel="Team Name"
- step2ButtonText="Confirm Refund & Cancel" />
- @else
- <x-forms.button disabled>Request Full Refund</x-forms.button>
- @endif
- </div>
+ @if ($refundCheckLoading || ($isRefundEligible && !currentTeam()->subscription->stripe_cancel_at_period_end))
+ <div class="flex flex-wrap items-center gap-2">
+ @if ($refundCheckLoading)
+ <x-forms.button disabled>Request Full Refund</x-forms.button>
+ @else
+ <x-modal-confirmation title="Request Full Refund?" buttonTitle="Request Full Refund"
+ isErrorButton submitAction="refundSubscription"
+ :actions="[
+ 'Your latest payment will be fully refunded.',
+ 'Your subscription will be cancelled immediately.',
+ 'All servers will be deactivated.',
+ ]" confirmationText="{{ currentTeam()->name }}"
+ confirmationLabel="Enter your team name to confirm" shortConfirmationLabel="Team Name"
+ step2ButtonText="Confirm Refund & Cancel" />
+ @endif
+ </div>
+ @endif
<p class="mt-2 text-sm text-neutral-500">
@if ($refundCheckLoading)
Checking refund eligibility...