feat(SourceManagement): add functionality to change Git source and display current source in the application settings
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user