Skip to content

Commit 736fad4

Browse files
committed
fix: optimize code for github view templates
1 parent ff5fdd4 commit 736fad4

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

resources/views/events/github/workflow_run/completed.blade.php

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,17 @@
22
/**
33
* @var $payload object
44
*/
5-
?>
6-
7-
@switch($payload->workflow_run->conclusion)
8-
@case('success')
9-
{!! __('tg-notifier::events/github/workflow_run.completed.success.title', ['user' => "<a href='{$payload->repository->html_url}'>{$payload->repository->full_name}</a>"]) !!}
105
11-
{!! __('tg-notifier::events/github/workflow_run.completed.success.body', ['name' => $payload->workflow_run->name]) !!}
12-
@break
13-
@case('failure')
14-
{!! __('tg-notifier::events/github/workflow_run.completed.failure.title', ['user' => "<a href='{$payload->repository->html_url}'>{$payload->repository->full_name}</a>"]) !!}
15-
16-
{!! __('tg-notifier::events/github/workflow_run.completed.failure.body', ['name' => $payload->workflow_run->name]) !!}
17-
@break
18-
@case('cancelled')
19-
{!! __('tg-notifier::events/github/workflow_run.completed.cancelled.title', ['user' => "<a href='{$payload->repository->html_url}'>{$payload->repository->full_name}</a>"]) !!}
6+
match ($payload->workflow_run->conclusion) {
7+
'success' => $status = 'success',
8+
'failure' => $status = 'failure',
9+
'cancelled' => $status = 'cancelled',
10+
default => $status = 'default',
11+
};
12+
?>
2013

21-
{!! __('tg-notifier::events/github/workflow_run.completed.cancelled.body', ['name' => $payload->workflow_run->name]) !!}
22-
@break
23-
@default
24-
{!! __('tg-notifier::events/github/workflow_run.completed.default.title', ['user' => "<a href='{$payload->repository->html_url}'>{$payload->repository->full_name}</a>"]) !!}
14+
{!! __("tg-notifier::events/github/workflow_run.completed.$status.title", ['user' => "<a href='{$payload->repository->html_url}'>{$payload->repository->full_name}</a>"]) !!}
2515

26-
{!! __('tg-notifier::events/github/workflow_run.completed.default.body', ['name' => $payload->workflow_run->name]) !!}
27-
@break
28-
@endswitch
16+
{!! __("tg-notifier::events/github/workflow_run.completed.$status.body", ['name' => $payload->workflow_run->name]) !!}
2917

3018
{!! __('tg-notifier::events/github/workflow_run.link', ['link' => "<a href='{$payload->workflow_run->html_url}'>{$payload->workflow_run->event} - {$payload->workflow_run->name}</a>"]) !!}

0 commit comments

Comments
 (0)