wip button to sync new app name
This commit is contained in:
@@ -154,16 +154,26 @@ class Change extends Component
|
||||
$github_access_token = generate_github_installation_token($this->github_app);
|
||||
|
||||
$response = Http::withToken($github_access_token)
|
||||
->get("{$this->github_app->api_url}/app");
|
||||
->withHeaders([
|
||||
'Accept' => 'application/vnd.github+json',
|
||||
'X-GitHub-Api-Version' => '2022-11-28',
|
||||
])
|
||||
->get("{$this->github_app->api_url}/installation/repositories");
|
||||
|
||||
if ($response->successful()) {
|
||||
$app_data = $response->json();
|
||||
if ($app_data['name'] !== $this->github_app->name) {
|
||||
$this->github_app->name = $app_data['name'];
|
||||
$app_name = data_get($app_data, 'installation.app_slug');
|
||||
|
||||
if ($app_name && $app_name !== $this->github_app->name) {
|
||||
$this->github_app->name = $app_name;
|
||||
$this->name = str($app_name)->kebab();
|
||||
$this->github_app->save();
|
||||
$this->name = str($this->github_app->name)->kebab();
|
||||
$this->dispatch('success', 'Github App name synchronized.');
|
||||
$this->dispatch('success', 'Github App name synchronized successfully.');
|
||||
} else {
|
||||
$this->dispatch('info', 'Github App name is already up to date.');
|
||||
}
|
||||
} else {
|
||||
$this->dispatch('error', 'Failed to fetch Github App information. Status: '.$response->status());
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
|
@@ -60,6 +60,7 @@
|
||||
<div class="flex gap-2">
|
||||
<div class="flex items-end gap-2 w-full">
|
||||
<x-forms.input id="github_app.name" label="App Name" disabled />
|
||||
<x-forms.button wire:click.prevent="syncGithubAppName">Sync Name</x-forms.button>
|
||||
<a href="{{ $this->getUpdatePath() }}">
|
||||
<x-forms.button>
|
||||
Update
|
||||
|
Reference in New Issue
Block a user