refactor(previews): streamline preview URL generation by utilizing application method
This commit is contained in:
parent
085529dc63
commit
6d94aaf0f8
1 changed files with 3 additions and 13 deletions
|
|
@ -7,7 +7,6 @@
|
||||||
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 @@ public function generate_preview($preview_id)
|
||||||
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.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue