Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"spatie/laravel-package-tools": "^1.16"
},
"require-dev": {
"filament/filament": "^3.2",
"filament/filament": "^3.3",
"larastan/larastan": "^2.9",
"laravel/pint": "^1.16",
"nunomaduro/collision": "^8.1.1||^7.10.0",
Expand Down
29 changes: 15 additions & 14 deletions config/filament-activitylog.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

return [
'resources' => [
'label' => 'Activity Log',
'plural_label' => 'Activity Logs',
'hide_restore_action' => false,
'restore_action_label' => 'Restore',
'hide_resource_action' => false,
'resource_action_label' => 'View',
'navigation_item' => true,
'navigation_group' => null,
'navigation_icon' => 'heroicon-o-shield-check',
'navigation_sort' => null,
'default_sort_column' => 'id',
'default_sort_direction' => 'desc',
'navigation_count_badge' => false,
'resource' => \Rmsramos\Activitylog\Resources\ActivitylogResource::class,
'label' => 'Activity Log',
'plural_label' => 'Activity Logs',
'hide_restore_action' => false,
'restore_action_label' => 'Restore',
'hide_resource_action' => false,
'hide_restore_model_action' => true,
'resource_action_label' => 'View',
'navigation_item' => true,
'navigation_group' => null,
'navigation_icon' => 'heroicon-o-shield-check',
'navigation_sort' => null,
'default_sort_column' => 'id',
'default_sort_direction' => 'desc',
'navigation_count_badge' => false,
'resource' => \Rmsramos\Activitylog\Resources\ActivitylogResource::class,
],
'date_format' => 'd/m/Y',
'datetime_format' => 'd/m/Y H:i:s',
Expand Down
11 changes: 8 additions & 3 deletions resources/lang/en/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
'updated' => 'updated',
'restored' => 'restored',
],
'view' => 'View',
'edit' => 'Edit',
'restore' => 'Restore',
'view' => 'View',
'edit' => 'Edit',
'restore' => 'Restore',
'restore_soft_delete' => [
'label' => 'Restore Model',
'modal_heading' => 'Restore Deleted Model',
'modal_description' => 'This will restore the model that was deleted (soft delete).',
],
];
3 changes: 3 additions & 0 deletions resources/lang/en/notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
'activity_restored_successfully' => 'Activity restored successfully.',
'failed_to_restore_activity' => 'Failed to restore activity : :error.',
'subject_not_found' => 'Subject not found.',
'unable_to_restore_this_model' => 'Unable to restore this model',
'model_successfully_restored' => 'Model successfully restored',
'error_restoring_model' => 'Erro ao restaurar modelo',
];
4 changes: 3 additions & 1 deletion resources/lang/en/tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
'label' => 'Event',
],
'subject_type' => [
'label' => 'Subject',
'label' => 'Subject',
'soft_deleted' => ' (Soft Deleted)',
'deleted' => ' (Deleted)',
],
'causer' => [
'label' => 'User',
Expand Down
11 changes: 8 additions & 3 deletions resources/lang/pt_BR/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
'updated' => 'atualizado',
'restored' => 'restaurado',
],
'view' => 'Visualizar',
'edit' => 'Editar',
'restore' => 'Restaurar',
'view' => 'Visualizar',
'edit' => 'Editar',
'restore' => 'Restaurar',
'restore_soft_delete' => [
'label' => 'Restaurar Modelo',
'modal_heading' => 'Restaurar Modelo Excluído',
'modal_description' => 'Isso irá restaurar o modelo que foi excluído (soft delete).',
],
];
2 changes: 1 addition & 1 deletion resources/lang/pt_BR/infolists.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
return [
'components' => [
'created_by_at' => 'O <strong>:subject</strong> foi <strong>:event</strong> por <strong>:causer</strong>. <br><small> Atualizado em: <strong>:update_at</strong></small>',
'updater_updated' => ':causer :event para: <br>:changes',
'updater_updated' => ':causer :event o seguinte: <br>:changes',
'from_oldvalue_to_newvalue' => '- :key de <strong>:old_value</strong> para <strong>:new_value</strong>',
'to_newvalue' => '- :key <strong>:new_value</strong>',
'unknown' => 'Desconhecido',
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/pt_BR/notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
'activity_restored_successfully' => 'Atividade restaurada com sucesso.',
'failed_to_restore_activity' => 'Falha ao restaurar a atividade: :error.',
'subject_not_found' => 'Registro não encontrado.',
'unable_to_restore_this_model' => 'Não é possível restaurar este modelo',
'model_successfully_restored' => 'Modelo restaurado com sucesso',
'error_restoring_model' => 'Erro ao restaurar modelo',
];
4 changes: 3 additions & 1 deletion resources/lang/pt_BR/tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
'label' => 'Evento',
],
'subject_type' => [
'label' => 'Assunto',
'label' => 'Assunto',
'soft_deleted' => ' (Delete suave)',
'deleted' => ' (Deletado)',
],
'causer' => [
'label' => 'Usuário',
Expand Down
17 changes: 15 additions & 2 deletions src/Actions/Concerns/ActionContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ protected function setUp(): void
}

return Activity::query()
->with(['subject', 'causer'])
->with([
'subject' => function ($query) {
if (method_exists($query, 'withTrashed')) {
$query->withTrashed();
}
},
'causer',
])
->where(function (Builder $query) use ($record) {
$query->where('subject_type', $record->getMorphClass())
->where('subject_id', $record->getKey());
Expand All @@ -91,14 +98,14 @@ protected function setUp(): void
});
}
} catch (\Exception $e) {
// Ignore errors
}
}
}
}
});
};
}

private function configureInfolist(): void
{
$this->infolist(function (?Model $record, Infolist $infolist) {
Expand Down Expand Up @@ -295,6 +302,12 @@ protected function formatActivityData($activity): array
}
}

if ($activity->event === 'restored') {
if (empty($properties) && $activity->description !== 'restored') {
$properties['description'] = $activity->description;
}
}

return [
'log_name' => $activity->log_name,
'description' => $activity->description,
Expand Down
14 changes: 14 additions & 0 deletions src/ActivitylogPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class ActivitylogPlugin implements Plugin

protected bool|Closure|null $isRestoreActionHidden = null;

protected bool|Closure|null $isRestoreModelActionHidden = null;

protected Closure|bool $navigationItem = true;

protected string|Closure|null $navigationGroup = null;
Expand Down Expand Up @@ -101,6 +103,11 @@ public function getIsRestoreActionHidden(): bool
return $this->evaluate($this->isRestoreActionHidden) ?? config('filament-activitylog.resources.hide_restore_action');
}

public function getIsRestoreModelActionHidden(): bool
{
return $this->evaluate($this->isRestoreModelActionHidden) ?? config('filament-activitylog.resources.hide_restore_model_action');
}

public function getPluralLabel(): string
{
return $this->evaluate($this->pluralLabel) ?? config('filament-activitylog.resources.plural_label');
Expand Down Expand Up @@ -202,6 +209,13 @@ public function isRestoreActionHidden(bool|Closure $isHidden): static
return $this;
}

public function isRestoreModelActionHidden(bool|Closure $isHidden): static
{
$this->isRestoreModelActionHidden = $isHidden;

return $this;
}

public function pluralLabel(string|Closure $label): static
{
$this->pluralLabel = $label;
Expand Down
2 changes: 2 additions & 0 deletions src/Infolists/Components/TimeLinePropertiesEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ private function getPropertyChanges(array $properties): array
$changes = $this->compareOldAndNewValues($properties['old'], $properties['attributes']);
} elseif (isset($properties['attributes'])) {
$changes = $this->getNewValues($properties['attributes']);
} elseif (isset($properties['old'])) {
$changes = $this->getNewValues($properties['old']);
}

return $changes;
Expand Down
2 changes: 1 addition & 1 deletion src/Infolists/Components/TimeLineTitleEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private function modifiedTitle($state): string|HtmlString|Closure
if ($this->configureTitleUsing !== null && $this->shouldConfigureTitleUsing !== null && $this->evaluate($this->shouldConfigureTitleUsing)) {
return $this->evaluate($this->configureTitleUsing, ['state' => $state]);
} else {
if ($state['description'] == $state['event']) {
if ($state['description'] == $state['event'] || $state['event'] === 'restored') {
$className = property_exists($state['subject'], 'activityTitleName') && ! empty($state['subject']::$activityTitleName)
? $state['subject']::$activityTitleName
: Str::lower(Str::snake(class_basename($state['subject']), ' '));
Expand Down
Loading