refactor(previews): streamline preview URL generation by utilizing application method
This commit is contained in:
@@ -7,7 +7,6 @@ use App\Models\Application;
|
|||||||
use App\Models\ApplicationPreview;
|
use App\Models\ApplicationPreview;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Spatie\Url\Url;
|
|
||||||
use Visus\Cuid2\Cuid2;
|
use Visus\Cuid2\Cuid2;
|
||||||
|
|
||||||
class Previews extends Component
|
class Previews extends Component
|
||||||
@@ -87,18 +86,9 @@ class Previews extends Component
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fqdn = generateFqdn($this->application->destination->server, $this->application->uuid);
|
$this->application->generate_preview_fqdn($preview->pull_request_id);
|
||||||
$url = Url::fromString($fqdn);
|
$this->application->refresh();
|
||||||
$template = $this->application->preview_url_template;
|
$this->dispatch('update_links');
|
||||||
$host = $url->getHost();
|
|
||||||
$schema = $url->getScheme();
|
|
||||||
$random = new Cuid2;
|
|
||||||
$preview_fqdn = str_replace('{{random}}', $random, $template);
|
|
||||||
$preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn);
|
|
||||||
$preview_fqdn = str_replace('{{pr_id}}', $preview->pull_request_id, $preview_fqdn);
|
|
||||||
$preview_fqdn = "$schema://$preview_fqdn";
|
|
||||||
$preview->fqdn = $preview_fqdn;
|
|
||||||
$preview->save();
|
|
||||||
$this->dispatch('success', 'Domain generated.');
|
$this->dispatch('success', 'Domain generated.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user