Skip to content

Commit

Permalink
mep | merge develop into main (#321)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Chris Samory <samorytakougne@gmail.com>
  • Loading branch information
3 people authored Jan 11, 2025
1 parent ed5f911 commit 09a9d32
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 177 deletions.
17 changes: 14 additions & 3 deletions app/Livewire/Components/User/Activities.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,27 @@
use App\Models\Activity;
use App\Models\User;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Livewire\Attributes\Computed;
use Livewire\Component;

final class Activities extends Component
{
public User $user;

#[Computed(persist: true)]
public function activities(): Collection
{
return Cache::remember(
key: 'activities.'.$this->user->id,
ttl: now()->addDays(3),
callback: fn () => Activity::latestFeed($this->user)
);
}

public function render(): View
{
return view('livewire.components.user.activities', [
'activities' => Activity::latestFeed($this->user),
]);
return view('livewire.components.user.activities');
}
}
58 changes: 48 additions & 10 deletions app/Livewire/Pages/Account/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,68 @@

namespace App\Livewire\Pages\Account;

use App\Models\Article;
use App\Models\Discussion;
use App\Models\Thread;
use App\Models\User;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Livewire\Attributes\Computed;
use Livewire\Component;

final class Profile extends Component
{
public User $user;

public function render(): View
#[Computed(persist: true)]
public function articles(): Collection
{
return view('livewire.pages.account.profile', [
'articles' => $this->user->articles() // @phpstan-ignore-line
->recent()
return Cache::remember(
key: 'articles.'.$this->user->id,
ttl: now()->addDays(3),
callback: fn () => Article::with('media', 'tags')
->select('id', 'title', 'slug', 'body', 'published_at')
->whereBelongsTo($this->user)
->published()
->recent()
->limit(5)
->get(),
'threads' => $this->user->threads()
->get()
);
}

#[Computed(persist: true)]
public function threads(): Collection
{
return Cache::remember(
key: 'threads.'.$this->user->id,
ttl: now()->addDays(3),
callback: fn () => Thread::with('channels')
->withCount('replies')
->whereBelongsTo($this->user)
->orderByDesc('created_at')
->limit(5)
->get(),
'discussions' => $this->user->discussions()
->get()
);
}

#[Computed(persist: true)]
public function discussions(): Collection
{
return Cache::remember(
key: 'discussions.'.$this->user->id,
ttl: now()->addDays(3),
callback: fn () => Discussion::with('tags')
->withCount('replies', 'reactions')
->whereBelongsTo($this->user)
->limit(5)
->get(),
])
->get()
);
}

public function render(): View
{
return view('livewire.pages.account.profile')
->title($this->user->username.' ( '.$this->user->name.')');
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"symfony/http-client": "^7.1.8",
"symfony/mailgun-mailer": "^7.1",
"torchlight/torchlight-laravel": "^0.6",
"vormkracht10/filament-mails": "^1.0",
"vormkracht10/filament-mails": "^2.0",
"wire-elements/modal": "^2.0",
"wire-elements/spotlight": "^2.0",
"yarri/link-finder": "^2.7.10",
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion resources/views/components/forum/thread.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<x-forum.thread-channels :thread="$thread" />

<div class="flex items-center gap-4">
<h2 id="question-title-{{ $thread->id }}" class="truncate text-xl font-medium text-gray-900 dark:text-white lg:text-xl">
<h2 id="question-title-{{ $thread->id }}" class="truncate text-lg font-heading/7 font-semibold text-gray-900 dark:text-white lg:text-xl">
<x-link :href="route('forum.show', $thread)" class="hover:underline">
{{ $thread->subject() }}
</x-link>
Expand Down
92 changes: 45 additions & 47 deletions resources/views/components/user/articles.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,54 @@
'articles',
])

<div>
@if ($articles->isNotEmpty())
<div class="-mt-6 divide-y divide-gray-200 dark:divide-white/20">
@foreach ($articles as $article)
<div class="py-6">
<x-articles.card :article="$article" is-summary />
</div>
@endforeach
</div>
@else
<x-empty-state>
@if ($articles->isNotEmpty())
<div class="-mt-6 divide-y divide-gray-200 dark:divide-white/20">
@foreach ($articles as $article)
<div class="py-6">
<x-articles.card :article="$article" is-summary />
</div>
@endforeach
</div>
@else
<x-empty-state>
<div class="relative">
<div class="absolute scale-90 shadow inset-x-0 -top-4 flex items-start -z-10 bg-white gap-3 p-3 rounded-lg ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
</div>
<div class="relative">
<div class="absolute scale-90 shadow inset-x-0 -top-4 flex items-start -z-10 bg-white gap-3 p-3 rounded-lg ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
</div>
<div class="relative">
<div class="absolute -inset-1 bg-gradient-to-r from-flag-green to-flag-red rounded-lg blur opacity-25"></div>
<div class="relative flex items-start z-20 bg-white gap-3 p-3 rounded-lg ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
<div class="w-1/4 h-20 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-lg dark:bg-gray-800"></div>
<div class="w-3/4 pt-2 space-y-2">
<div class="grid grid-cols-3 gap-2 w-2/3">
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
</div>
<div class="h-4 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
<div class="h-6 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
<div class="absolute -inset-1 bg-gradient-to-r from-flag-green to-flag-red rounded-lg blur opacity-25"></div>
<div class="relative flex items-start z-20 bg-white gap-3 p-3 rounded-lg ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
<div class="w-1/4 h-20 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-lg dark:bg-gray-800"></div>
<div class="w-3/4 pt-2 space-y-2">
<div class="grid grid-cols-3 gap-2 w-2/3">
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
</div>
<div class="h-4 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
<div class="h-6 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
</div>
</div>
<div class="absolute scale-[0.8] inset-x-0 -z-10 shadow -bottom-3 flex items-start bg-white gap-3 p-3 rounded-lg ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
</div>
</div>
<div class="mt-8 space-y-4">
<p class="mt-8 text-base text-gray-500 dark:text-gray-400">
<span class="font-medium text-gray-700 dark:text-gray-300">{{ $user->name }}</span>
{{ __('pages/account.activities.empty_articles') }}
</p>

@if ($user->isLoggedInUser())
@can('create', \App\Models\Article::class)
<x-buttons.primary
type="button"
onclick="Livewire.dispatch('openPanel', { component: 'components.slideovers.article-form' })"
>
<x-untitledui-file-06 class="size-5" aria-hidden="true" />
{{ __('global.launch_modal.article_action') }}
</x-buttons.primary>
@endcan
@endif
<div class="absolute scale-[0.8] inset-x-0 -z-10 shadow -bottom-3 flex items-start bg-white gap-3 p-3 rounded-lg ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
</div>
</x-empty-state>
@endif
</div>
</div>
<div class="mt-8 space-y-4">
<p class="mt-8 text-base text-gray-500 dark:text-gray-400">
<span class="font-medium text-gray-700 dark:text-gray-300">{{ $user->name }}</span>
{{ __('pages/account.activities.empty_articles') }}
</p>

@if ($user->isLoggedInUser())
@can('create', \App\Models\Article::class)
<x-buttons.primary
type="button"
onclick="Livewire.dispatch('openPanel', { component: 'components.slideovers.article-form' })"
>
<x-untitledui-file-06 class="size-5" aria-hidden="true" />
{{ __('global.launch_modal.article_action') }}
</x-buttons.primary>
@endcan
@endif
</div>
</x-empty-state>
@endif
88 changes: 43 additions & 45 deletions resources/views/components/user/discussions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,56 @@
'discussions',
])

<div>
@if ($discussions->isNotEmpty())
<div class="relative -mt-6 divide-y divide-gray-200 dark:divide-white/20">
@foreach ($discussions as $discussion)
<x-discussions.overview :discussion="$discussion" />
@endforeach
</div>
@else
<x-empty-state>
@if ($discussions->isNotEmpty())
<div class="relative -mt-6 divide-y divide-gray-200 dark:divide-white/20">
@foreach ($discussions as $discussion)
<x-discussions.overview :discussion="$discussion" />
@endforeach
</div>
@else
<x-empty-state>
<div class="relative">
<div class="relative">
<div class="relative">
<div class="absolute -inset-1 bg-gradient-to-r rotate-3 w-72 from-flag-green to-flag-red rounded-lg blur opacity-25"></div>
<div class="relative z-20 bg-white gap-3 rotate-3 p-3 w-72 rounded-lg shadow ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
<div class="space-y-2">
<div class="grid grid-cols-3 gap-2 w-1/3">
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
</div>
<div class="h-4 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
<div class="h-6 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
</div>
</div>
</div>
<div class="absolute transform scale-[0.8] bottom-10 right-2 shadow w-40 -rotate-6 z-20 bg-white gap-3 p-3 rounded-lg ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
<div class="absolute -inset-1 bg-gradient-to-r rotate-3 w-72 from-flag-green to-flag-red rounded-lg blur opacity-25"></div>
<div class="relative z-20 bg-white gap-3 rotate-3 p-3 w-72 rounded-lg shadow ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
<div class="space-y-2">
<div class="grid grid-cols-3 gap-2 w-2/3">
<div class="grid grid-cols-3 gap-2 w-1/3">
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
</div>
<div class="h-2 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
<div class="h-4 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
<div class="h-6 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
</div>
</div>
</div>
<div class="mt-8 space-y-4">
<p class="mt-8 text-base text-gray-500 dark:text-gray-400">
<span class="font-medium text-gray-700 dark:text-gray-300">{{ $user->name }}</span>
{{ __('pages/account.activities.empty_discussions') }}
</p>

@if ($user->isLoggedInUser())
@can('create', \App\Models\Discussion::class)
<x-buttons.primary
type="button"
onclick="Livewire.dispatch('openPanel', { component: 'components.slideovers.thread-form' })"
>
<x-untitledui-message-text-square class="size-5" aria-hidden="true" />
{{ __('global.launch_modal.discussion_action') }}
</x-buttons.primary>
@endcan
@endif
<div class="absolute transform scale-[0.8] bottom-10 right-2 shadow w-40 -rotate-6 z-20 bg-white gap-3 p-3 rounded-lg ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
<div class="space-y-2">
<div class="grid grid-cols-3 gap-2 w-2/3">
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
</div>
<div class="h-2 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
<div class="h-6 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
</div>
</div>
</x-empty-state>
@endif
</div>
</div>
<div class="mt-8 space-y-4">
<p class="mt-8 text-base text-gray-500 dark:text-gray-400">
<span class="font-medium text-gray-700 dark:text-gray-300">{{ $user->name }}</span>
{{ __('pages/account.activities.empty_discussions') }}
</p>

@if ($user->isLoggedInUser())
@can('create', \App\Models\Discussion::class)
<x-buttons.primary
type="button"
onclick="Livewire.dispatch('openPanel', { component: 'components.slideovers.thread-form' })"
>
<x-untitledui-message-text-square class="size-5" aria-hidden="true" />
{{ __('global.launch_modal.discussion_action') }}
</x-buttons.primary>
@endcan
@endif
</div>
</x-empty-state>
@endif
Loading

0 comments on commit 09a9d32

Please sign in to comment.