feat(SourceManagement): add functionality to change Git source and display current source in the application settings

This commit is contained in:
Andras Bacsai
2025-04-11 18:22:42 +02:00
parent 4c8ebe146c
commit ec36825545
2 changed files with 58 additions and 0 deletions

View File

@@ -30,11 +30,15 @@ class Source extends Component
#[Validate(['nullable', 'string'])]
public ?string $gitCommitSha = null;
#[Locked]
public $sources;
public function mount()
{
try {
$this->syncData();
$this->getPrivateKeys();
$this->getSources();
} catch (\Throwable $e) {
handleError($e, $this);
}
@@ -66,6 +70,14 @@ class Source extends Component
});
}
private function getSources()
{
// filter the current source out
$this->sources = currentTeam()->sources()->whereNotNull('app_id')->reject(function ($source) {
return $source->id === $this->application->source_id;
});
}
public function setPrivateKey(int $privateKeyId)
{
try {
@@ -92,4 +104,18 @@ class Source extends Component
return handleError($e, $this);
}
}
public function changeSource($sourceId, $sourceType)
{
try {
$this->application->update([
'source_id' => $sourceId,
'source_type' => $sourceType,
]);
$this->application->refresh();
$this->dispatch('success', 'Source updated!');
} catch (\Throwable $e) {
return handleError($e, $this);
}
}
}