Merge branch 'main' into #134-fill-users-data-for-resume

This commit is contained in:
Adrian Hopek 2022-05-17 15:21:00 +02:00 committed by GitHub
commit 07ed41223a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 183 additions and 56 deletions

View File

@ -27,9 +27,10 @@ class VacationRequestCreatedNotification extends Notification
public function toSlack(): SlackMessage
{
$url = route("vacation.requests.show", ["vacationRequest" => $this->vacationRequest->id]);
$seeDetails = __("See details");
return (new SlackMessage())
->text("{$this->buildDescription()}\n <${url}|Zobacz szczegóły>");
->text("{$this->buildDescription()}\n <${url}|${seeDetails}>");
}
/**
@ -97,8 +98,8 @@ class VacationRequestCreatedNotification extends Notification
$name = $this->vacationRequest->name;
if ($this->vacationRequest->creator()->is($this->vacationRequest->user)) {
return __("The vacation request :title from user :user has been created successfully.", [
"user" => $this->vacationRequest->user->profile->full_name,
return __("The vacation request :title has been created successfully.", [
"requester" => $this->vacationRequest->user->profile->full_name,
"title" => $name,
]);
}

View File

@ -29,9 +29,10 @@ class VacationRequestStatusChangedNotification extends Notification
public function toSlack(): SlackMessage
{
$url = route("vacation.requests.show", ["vacationRequest" => $this->vacationRequest->id]);
$seeDetails = __("See details");
return (new SlackMessage())
->text("{$this->buildDescription()}\n <${url}|Zobacz szczegóły>");
->text("{$this->buildDescription()}\n <${url}|${seeDetails}>");
}
/**

View File

@ -30,9 +30,10 @@ class VacationRequestWaitsForApprovalNotification extends Notification
public function toSlack(): SlackMessage
{
$url = route("vacation.requests.show", ["vacationRequest" => $this->vacationRequest->id]);
$seeDetails = __("See details");
return (new SlackMessage())
->text("{$this->buildDescription()}\n <${url}|Zobacz szczegóły>");
->text("{$this->buildDescription()}\n <${url}|${seeDetails}>");
}
/**

View File

@ -29,7 +29,7 @@ class VacationRequestsSummaryNotification extends Notification
public function toSlack(): SlackMessage
{
return (new SlackMessage())
->text("Wnioski oczekujące na Twoją akcję - stan na dzień {$this->day->toDisplayString()}:")
->text(__("Requests wait for your approval - status for day :date:", ["date" => $this->day->toDisplayString()]))
->withAttachment(new VacationRequestsAttachment($this->vacationRequests));
}
@ -55,16 +55,18 @@ class VacationRequestsSummaryNotification extends Notification
"user" => $user,
]),
)
->line("Lista wniosków oczekujących na Twoją akcję - stan na dzień {$this->day->toDisplayString()}:")
->subject("Wnioski oczekujące na akcje - stan na dzień {$this->day->toDisplayString()}");
->line (__("Requests list waits for your approval - status for day :date:", ["date" => $this->day->toDisplayString()]))
->subject(__("Requests wait for your approval - status for day :date:", ["date" => $this->day->toDisplayString()]));
foreach ($this->vacationRequests as $request) {
$url = route("vacation.requests.show", ["vacationRequest" => $request->id]);
$message->line(
"Wniosek nr {$request->name} użytkownika {$request->user->profile->full_name} ({$request->from->toDisplayString()} - {$request->to->toDisplayString()})",
__("- [request no. :request](:url) of user :user (:startDate - :endDate)", ["request" => $request->name, "url" => $url, "user" => $request->user->profile->full_name, "startDate" => $request->from->toDisplayString(), "endDate" => $request->to->toDisplayString()]),
);
}
return $message
->action("Przejdź do wniosków", $url);
->action(__("Go to requests"), $url);
}
}

View File

@ -18,7 +18,7 @@ use Toby\Infrastructure\Slack\Elements\RemotesAttachment;
class SendDailySummaryToSlack extends Command
{
protected $signature = "toby:slack:daily-summary {--f|force}";
protected $description = "Sent daily summary to slack";
protected $description = "Sent daily summary to Slack";
public function handle(DailySummaryRetriever $dailySummaryRetriever): void
{
@ -37,7 +37,7 @@ class SendDailySummaryToSlack extends Command
Http::withToken($this->getSlackClientToken())
->post($this->getUrl(), [
"channel" => $this->getSlackChannel(),
"text" => "Podsumowanie dla dnia {$now->toDisplayString()}",
"text" => __("Daily summary for day :day", ["day" => $now->toDisplayString()]),
"attachments" => $attachments,
]);
}

View File

@ -92,19 +92,16 @@ class VacationRequestController extends Controller
}
$yearPeriod = $yearPeriodRetriever->selected();
$status = $request->get("status");
$status = $request->get("status", "all");
$user = $request->get("user");
$type = $request->get("type");
$vacationRequests = VacationRequest::query()
->with(["user", "vacations"])
->whereBelongsTo($yearPeriod)
->when($user !== null, fn(Builder $query): Builder => $query->where("user_id", $user))
->when(
$status !== null,
fn(Builder $query): Builder => $query->states(
VacationRequestStatesRetriever::filterByStatusGroup($status, $request->user()),
),
)
->when($type !== null, fn(Builder $query): Builder => $query->where("type", $type))
->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $request->user()))
->latest()
->paginate();
@ -116,9 +113,11 @@ class VacationRequestController extends Controller
return inertia("VacationRequest/IndexForApprovers", [
"requests" => VacationRequestResource::collection($vacationRequests),
"users" => SimpleUserResource::collection($users),
"types" => VacationType::casesToSelect(),
"filters" => [
"status" => $status,
"user" => (int)$user,
"type" => $type,
],
]);
}

View File

@ -19,6 +19,6 @@ class YearPeriodExists implements Rule
public function message(): string
{
return "The year period for given year doesn't exist.";
return __("The year period for given year does not exist.");
}
}

View File

@ -14,9 +14,9 @@ class AbsencesAttachment extends ListAttachment
parent::__construct();
$this
->setTitle("Nieobecności :palm_tree:")
->setTitle(__("Absences :palm_tree:"))
->setColor("#eab308")
->setItems($absences->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name))
->setEmptyText("Wszyscy dzisiaj pracują :muscle:");
->setEmptyText(__("Everybody works today :muscle:"));
}
}

View File

@ -14,9 +14,9 @@ class BirthdaysAttachment extends ListAttachment
parent::__construct();
$this
->setTitle("Urodziny :birthday:")
->setTitle(__("Birthdays :birthday:"))
->setColor("#3c5f97")
->setItems($birthdays->map(fn(User $user): string => $user->profile->full_name))
->setEmptyText("Dzisiaj nikt nie ma urodzin :cry:");
->setEmptyText(__("Nobody has a birthday today :cry:"));
}
}

View File

@ -16,6 +16,6 @@ class KeysAttachment extends ListAttachment
$this
->setColor("#3c5f97")
->setItems($keys->map(fn(Key $key): string => "Klucz nr {$key->id} - <@{$key->user->profile->slack_id}>"))
->setEmptyText("Nie ma żadnych kluczy w tobym");
->setEmptyText(__("There are no keys in toby"));
}
}

View File

@ -14,9 +14,9 @@ class RemotesAttachment extends ListAttachment
parent::__construct();
$this
->setTitle("Praca zdalna :house_with_garden:")
->setTitle(__("Remote work :house_with_garden:"))
->setColor("#527aba")
->setItems($remoteDays->map(fn(Vacation $vacation): string => $vacation->user->profile->full_name))
->setEmptyText("Wszyscy dzisiaj są w biurze :boom:");
->setEmptyText(__("Everybody is in the office :boom:"));
}
}

View File

@ -27,7 +27,12 @@ class VacationRequestsAttachment extends ListAttachment
? "{$request->from->toDisplayString()}"
: "{$request->from->toDisplayString()} - {$request->to->toDisplayString()}";
return "<{$url}|Wniosek nr {$request->name}> użytkownika {$request->user->profile->full_name} ({$date})";
return __("<:url|Request no. :request> for user :user (:date)", [
"url" => $url,
"request" => $request->name,
"user" => $request->user->profile->full_name,
"date" => $date,
]);
});
}
}

View File

@ -24,7 +24,7 @@ class CatchAll extends BaseHandler
$handlers = $this->findAvailableHandlers();
$attachmentFields = $this->mapHandlersToAttachments($handlers);
return $this->respondToSlack(":x: Nie rozpoznaję polecenia. Lista wszystkich poleceń:")
return $this->respondToSlack(__(":x: I don't recognize the command. List of all commands:"))
->withAttachment(
Attachment::create()
->setColor("danger")

View File

@ -16,7 +16,7 @@ use Toby\Infrastructure\Slack\Elements\RemotesAttachment;
class DailySummary extends SignatureHandler
{
protected $signature = "toby dzisiaj";
protected $description = "Codzienne podsumowanie";
protected $description = "Daily summary";
public function handle(Request $request): Response
{
@ -30,7 +30,7 @@ class DailySummary extends SignatureHandler
new BirthdaysAttachment($dailySummaryRetriever->getBirthdays($now)),
]);
return $this->respondToSlack("Podsumowanie dla dnia {$now->toDisplayString()}")
return $this->respondToSlack(__("Summary for the day :day", ["day" => $now->toDisplayString()]))
->withAttachments($attachments->all());
}
}

View File

@ -18,7 +18,7 @@ class GiveKeysTo extends SignatureHandler
use FindsUserBySlackId;
protected $signature = "toby klucze:dla {user}";
protected $description = "Przekaż klucze wskazanemu użytkownikowi";
protected $description = "Give the keys to the specified user";
/**
* @throws UserNotFoundException
@ -35,12 +35,12 @@ class GiveKeysTo extends SignatureHandler
$key = $authUser->keys()->first();
if (!$key) {
throw ValidationException::withMessages(["key" => "Nie masz żadnego klucza do przekazania"]);
throw ValidationException::withMessages(["key" => __("You don't have any key to give")]);
}
if ($user->is($authUser)) {
throw ValidationException::withMessages([
"key" => "Nie możesz przekazać sobie kluczy :dzban:",
"key" => __("You can't give the keys to yourself :dzban:"),
]);
}
@ -51,7 +51,7 @@ class GiveKeysTo extends SignatureHandler
$key->notify(new KeyHasBeenGivenNotification($authUser, $user));
return $this->respondToSlack(
":white_check_mark: Klucz nr {$key->id} został przekazany użytkownikowi <@{$user->profile->slack_id}>",
__(":white_check_mark: Key no. :key has been given to <@:user>", ["key" => $key->id, "user" => $user->profile->slack_id]),
);
}
@ -65,7 +65,7 @@ class GiveKeysTo extends SignatureHandler
protected function getMessages(): array
{
return [
"user.required" => "Musisz podać użytkownika, któremu chcesz przekazać klucze",
"user.required" => "You must specified the user to whom you want to give the keys",
];
}
}

View File

@ -14,7 +14,7 @@ class Help extends SignatureHandler
use ListsHandlers;
protected $signature = "toby pomoc";
protected $description = "Wyświetl wszystkie dostępne polecenia";
protected $description = "Show all available commands";
public function handle(Request $request): Response
{
@ -22,7 +22,7 @@ class Help extends SignatureHandler
$attachmentFields = $this->mapHandlersToAttachments($handlers);
return $this->respondToSlack("Dostępne polecenia:")
return $this->respondToSlack(__("Available commands:"))
->withAttachment(
Attachment::create()
->setColor("good")

View File

@ -18,18 +18,18 @@ class HomeOffice extends SignatureHandler
use FindsUserBySlackId;
protected $signature = "toby zdalnie";
protected $description = "Pracuj dzisiaj zdalnie";
protected $description = "Work remotely today";
public function handle(Request $request): Response
{
$user = $this->findUserBySlackId($request->userId);
$this->createRemoteday($user, Carbon::today());
$this->createRemoteDay($user, Carbon::today());
return $this->respondToSlack(":white_check_mark: Pracujesz dzisiaj zdalnie");
return $this->respondToSlack(__(":white_check_mark: You work remotely today"));
}
protected function createRemoteday(User $user, Carbon $date): void
protected function createRemoteDay(User $user, Carbon $date): void
{
$yearPeriod = YearPeriod::findByYear($date->year);

View File

@ -12,7 +12,7 @@ use Toby\Infrastructure\Slack\Elements\KeysAttachment;
class KeyList extends SignatureHandler
{
protected $signature = "toby klucze";
protected $description = "Lista wszystkich kluczy";
protected $description = "List of all keys";
public function handle(Request $request): Response
{
@ -20,7 +20,7 @@ class KeyList extends SignatureHandler
->orderBy("id")
->get();
return $this->respondToSlack("Lista kluczy :key:")
return $this->respondToSlack(__("Keys list :key:"))
->withAttachment(new KeysAttachment($keys));
}
}

View File

@ -18,7 +18,7 @@ class TakeKeysFrom extends SignatureHandler
use FindsUserBySlackId;
protected $signature = "toby klucze:od {user}";
protected $description = "Zabierz klucze wskazanemu użytkownikowi";
protected $description = "Take keys from specified user";
/**
* @throws UserNotFoundException|ValidationException
@ -35,13 +35,13 @@ class TakeKeysFrom extends SignatureHandler
if (!$key) {
throw ValidationException::withMessages([
"key" => "Użytkownik <@{$user->profile->slack_id}> nie ma żadnych kluczy",
"key" => __("User <@:user> does not have any keys", ["user" => $user->profile->slack_id]),
]);
}
if ($key->user()->is($authUser)) {
throw ValidationException::withMessages([
"key" => "Nie możesz zabrać sobie kluczy :dzban:",
"key" => __("You can't take the keys from yourself :dzban:"),
]);
}
@ -51,7 +51,7 @@ class TakeKeysFrom extends SignatureHandler
$key->notify(new KeyHasBeenTakenNotification($authUser, $user));
return $this->respondToSlack(":white_check_mark: Klucz nr {$key->id} został zabrany użytkownikowi <@{$user->profile->slack_id}>");
return $this->respondToSlack(__(":white_check_mark: Key no. :key has been taken from user <@:user>", ["key" => $key->id, "user" => $user->profile->slack_id]));
}
protected function getRules(): array
@ -64,7 +64,7 @@ class TakeKeysFrom extends SignatureHandler
protected function getMessages(): array
{
return [
"user.required" => "Musisz podać użytkownika, któremu chcesz zabrać klucze",
"user.required" => __("You must specified the user you want to take the keys from"),
];
}
}

View File

@ -19,6 +19,6 @@ class SlackUserExistsRule implements Rule
public function message(): string
{
return "Użytkownik :input nie istnieje w tobym";
return __("User :input does not exist in toby");
}
}

View File

@ -30,7 +30,7 @@ trait FindsUserBySlackId
$user = $this->findUserBySlackId($slackId);
if (!$user) {
throw new UserNotFoundException("Użytkownik {$slackId} nie istnieje w tobym");
throw new UserNotFoundException(__("User :input does not exist in toby", ["input" => $slackId]));
}
return $user;

View File

@ -37,7 +37,7 @@ trait ListsHandlers
)
->map(
fn(SignatureHandler $handler): AttachmentField => AttachmentField::create(
$handler->getDescription(),
__($handler->getDescription()),
"`/{$handler->getSignature()}`",
),
)

View File

@ -17,7 +17,7 @@
</div>
</div>
<div class="border-t border-gray-200">
<div class="grid grid-cols-1 gap-2 p-4 md:grid-cols-2 md:gap-4">
<div class="grid grid-cols-1 gap-2 p-4 md:grid-cols-3 md:gap-4">
<Listbox
v-model="form.user"
as="div"
@ -159,6 +159,82 @@
</transition>
</div>
</Listbox>
<Listbox
v-model="form.type"
as="div"
>
<ListboxLabel class="block mb-2 text-sm font-medium text-gray-700">
Rodzaj wniosku
</ListboxLabel>
<div class="relative mt-1 sm:mt-0">
<ListboxButton
class="relative py-2 pr-10 pl-3 w-full max-w-lg h-10 text-left bg-white rounded-md border border-gray-300 focus:border-blumilk-500 focus:outline-none focus:ring-1 focus:ring-blumilk-500 shadow-sm cursor-default sm:text-sm"
>
<VacationType
v-if="form.type"
:type="form.type.value"
/>
<span
v-else
class="flex items-center"
>
Wszystkie
</span>
<span class="flex absolute inset-y-0 right-0 items-center pr-2 pointer-events-none">
<SelectorIcon class="w-5 h-5 text-gray-400" />
</span>
</ListboxButton>
<transition
leave-active-class="transition ease-in duration-100"
leave-from-class="opacity-100"
leave-to-class="opacity-0"
>
<ListboxOptions
class="overflow-auto absolute z-10 py-1 mt-1 w-full max-w-lg max-h-60 text-base bg-white rounded-md focus:outline-none ring-1 ring-black ring-opacity-5 shadow-lg sm:text-sm"
>
<ListboxOption
v-slot="{ active, selected }"
as="template"
:value="null"
>
<li
:class="[active ? 'bg-gray-100' : 'text-gray-900', 'cursor-default truncate select-none relative py-2 pl-3 pr-9']"
>
Wszystkie
<span
v-if="selected"
:class="['text-blumilk-600 absolute inset-y-0 right-0 flex items-center pr-4']"
>
<CheckIcon class="w-5 h-5" />
</span>
</li>
</ListboxOption>
<ListboxOption
v-for="type in types"
:key="type.value"
v-slot="{ active }"
as="template"
:value="type"
>
<li
:class="[active ? 'bg-gray-100' : 'text-gray-900', 'cursor-default truncate select-none relative py-2 pl-3 pr-9']"
>
<VacationType :type="type.value" />
<span
v-if="form.type?.value === type.value"
:class="['text-blumilk-600 absolute inset-y-0 right-0 flex items-center pr-4']"
>
<CheckIcon class="w-5 h-5" />
</span>
</li>
</ListboxOption>
</ListboxOptions>
</transition>
</div>
</Listbox>
</div>
</div>
<div class="overflow-auto xl:overflow-visible">
@ -294,6 +370,7 @@ const props = defineProps({
requests: Object,
users: Object,
filters: Object,
types: Object,
})
const statuses = [
@ -322,12 +399,17 @@ const statuses = [
const form = reactive({
user: props.users.data.find(user => user.id === props.filters.user) ?? null,
status: statuses.find(status => status.value === props.filters.status) ?? statuses[0],
type: props.types.find(type => type.value === props.filters.type) ?? null,
})
watch(form, debounce(() => {
Inertia.get('/vacation/requests', { user: form.user?.id, status: form.status.value }, {
Inertia.get('/vacation/requests', {
user: form.user?.id,
status: form.status.value,
type: form.type?.value,
}, {
preserveState: true,
replace: true,
})
}, 300))
}, 150))
</script>

View File

@ -78,5 +78,41 @@
"Resume has been deleted.": "CV zostało usunięte.",
"Resume has been created.": "CV zostało utworzone.",
"Technology :name has been created.": "Technologia :name została utworzona.",
"Technology :name has been deleted.": "Technologia :name została usunięta."
"Technology :name has been deleted.": "Technologia :name została usunięta.",
"The vacation request :title has been created successfully.": "Wniosek urlopowy :title został utworzony pomyślnie.",
":x: I don't recognize the command. List of all commands:": ":x: Nie rozpoznaję polecenia. Lista wszystkich poleceń:",
"Summary for the day :day": "Podsumowanie dla dnia :day",
"Daily summary": "Podsumowanie dnia",
"Give the keys to the specified user": "Przekaż klucze wskazanemu użytkownikowi",
"You don't have any key to give": "Nie masz żadnego klucza do przekazania",
"You can't give the keys to yourself :dzban:": "Nie możesz przekazać sobie kluczy :dzban:",
":white_check_mark: Key no. :key has been given to <@:user>": ":white_check_mark: Klucz nr :key został przekazany użytkownikowi <@:user>",
"You must specified the user to whom you want to give the keys": "Musisz podać użytkownika, któremu chcesz przekazać klucze",
"Show all available commands": "Wyświetl wszystkie dostępne polecenia",
"Available commands:": "Dostępne polecenia:",
"Work remotely today": "Pracuj dzisiaj zdalnie",
":white_check_mark: You work remotely today": ":white_check_mark: Pracujesz dzisiaj zdalnie",
"List of all keys": "Lista wszystkich kluczy",
"Keys list :key:": "Lista kluczy :key:",
"Take keys from specified user": "Zabierz klucze wskazanemu użytkownikowi",
"User <@:user> does not have any keys": "Użytkownik <@:user> nie ma żadnych kluczy",
"You can't take the keys from yourself :dzban:": "Nie możesz zabrać sobie kluczy :dzban:",
"You must specified the user you want to take the keys from": "Musisz podać użytkownika, któremu chcesz zabrać klucze",
"User :input does not exist in toby": "Użytkownik :input nie istnieje w tobym",
":white_check_mark: Key no. :key has been taken from user <@:user>": ":white_check_mark: Klucz nr :key został zabrany użytkownikowi <@:user>",
"Absences :palm_tree:": "Nieobecności :palm_tree:",
"Everybody works today :muscle:": "Wszyscy dzisiaj pracują :muscle:",
"Birthdays :birthday:": "Urodziny :birthday:",
"Nobody has a birthday today :cry:": "Dzisiaj nikt nie ma urodzin :cry:",
"Remote work :house_with_garden:": "Praca zdalna :house_with_garden:",
"Everybody is in the office :boom:": "Wszyscy dzisiaj są w biurze :boom:",
"There are no keys in toby": "Nie ma żadnych kluczy w tobym",
"<:url|Request no. :request> for user :user (:date)": "<:url Wniosek urlopowy nr :request użytkownika :user (:date)",
"The year period for given year does not exist.": "Okres roczny dla danego roku nie istnieje",
"Daily summary for day :day": "Podsumowanie dla dnia :day",
"Requests wait for your approval - status for day :date:": "Wnioski oczekujące na Twoją akcję - stan na dzień :date:",
"Requests list waits for your approval - status for day :date:": "Lista wniosków oczekujących na Twoją akcję - stan na dzień :date:",
"- [request no. :request](:url) of user :user (:startDate - :endDate)": "- [wniosek nr :request](:url) użytkownika :user (:startDate - :endDate)",
"Go to requests": "Przejdź do wniosków",
"See details": "Zobacz szczegóły"
}