From 41f6abc087d48ae5811238f76cec78ca978a1da7 Mon Sep 17 00:00:00 2001 From: Phan An Date: Tue, 18 Oct 2022 16:07:41 +0200 Subject: [PATCH] feat: tabs for Artist/Album screens (#1532) --- .../V6/API/ArtistAlbumController.php | 20 ++++ app/Repositories/AlbumRepository.php | 11 ++ .../assets/js/components/album/AlbumCard.vue | 1 - .../js/components/album/AlbumInfo.spec.ts | 14 ++- .../assets/js/components/album/AlbumInfo.vue | 10 +- .../__snapshots__/AlbumCard.spec.ts.snap | 2 +- .../js/components/artist/ArtistCard.vue | 1 - .../js/components/artist/ArtistInfo.spec.ts | 13 ++- .../js/components/artist/ArtistInfo.vue | 6 +- .../__snapshots__/ArtistCard.spec.ts.snap | 2 +- .../layout/main-wrapper/ExtraPanel.vue | 3 +- .../layout/main-wrapper/MainContent.vue | 11 +- .../layout/main-wrapper/Sidebar.vue | 1 + .../__snapshots__/AboutKoelModal.spec.ts.snap | 2 +- .../js/components/screens/AlbumScreen.spec.ts | 39 ++++--- .../js/components/screens/AlbumScreen.vue | 104 +++++++++++++++--- .../components/screens/ArtistScreen.spec.ts | 21 ++-- .../js/components/screens/ArtistScreen.vue | 95 +++++++++++++--- .../js/components/screens/PlaylistScreen.vue | 26 ++--- .../screens/RecentlyPlayedScreen.vue | 1 + .../js/components/screens/UploadScreen.vue | 4 +- .../js/components/screens/YouTubeScreen.vue | 5 +- .../assets/js/components/song/SongList.vue | 3 +- .../song/__snapshots__/SongList.spec.ts.snap | 2 +- .../components/ui/ArtistAlbumScreenTabs.vue | 60 ++++++++++ .../js/components/ui/FooterPlayButton.vue | 2 +- .../js/components/ui/ScreenEmptyState.vue | 3 +- .../assets/js/components/ui/ScreenHeader.vue | 1 + resources/assets/js/stores/albumStore.ts | 8 ++ resources/assets/sass/partials/_mixins.scss | 24 +++- resources/assets/sass/partials/_vars.scss | 2 +- routes/api.v6.php | 2 + tests/Feature/V6/ArtistAlbumTest.php | 20 ++++ 33 files changed, 402 insertions(+), 117 deletions(-) create mode 100644 app/Http/Controllers/V6/API/ArtistAlbumController.php create mode 100644 resources/assets/js/components/ui/ArtistAlbumScreenTabs.vue create mode 100644 tests/Feature/V6/ArtistAlbumTest.php diff --git a/app/Http/Controllers/V6/API/ArtistAlbumController.php b/app/Http/Controllers/V6/API/ArtistAlbumController.php new file mode 100644 index 00000000..59869b68 --- /dev/null +++ b/app/Http/Controllers/V6/API/ArtistAlbumController.php @@ -0,0 +1,20 @@ +albumRepository->getByArtist($artist)); + } +} diff --git a/app/Repositories/AlbumRepository.php b/app/Repositories/AlbumRepository.php index b420e875..7ec385f6 100644 --- a/app/Repositories/AlbumRepository.php +++ b/app/Repositories/AlbumRepository.php @@ -3,6 +3,7 @@ namespace App\Repositories; use App\Models\Album; +use App\Models\Artist; use App\Models\User; use App\Repositories\Traits\Searchable; use Illuminate\Contracts\Pagination\Paginator; @@ -52,6 +53,16 @@ class AlbumRepository extends Repository ->get(); } + /** @return Collection|array */ + public function getByArtist(Artist $artist): Collection + { + return Album::query() + ->where('artist_id', $artist->id) + ->orWhereIn('id', $artist->songs()->pluck('album_id')) + ->orderBy('name') + ->get(); + } + public function paginate(): Paginator { return Album::query() diff --git a/resources/assets/js/components/album/AlbumCard.vue b/resources/assets/js/components/album/AlbumCard.vue index cd93980e..0042b581 100644 --- a/resources/assets/js/components/album/AlbumCard.vue +++ b/resources/assets/js/components/album/AlbumCard.vue @@ -28,7 +28,6 @@ > Shuffle - • ([['aside'], ['full']])('renders in %s mode', async (mode) => { - const { getByTestId } = await this.renderComponent(mode) + const { getByTestId, queryByTestId } = await this.renderComponent(mode) - getByTestId('album-artist-thumbnail') getByTestId('album-info-tracks') + if (mode === 'aside') { + getByTestId('thumbnail') + } else { + expect(queryByTestId('thumbnail')).toBeNull() + } + expect(getByTestId('album-info').classList.contains(mode)).toBe(true) }) diff --git a/resources/assets/js/components/album/AlbumInfo.vue b/resources/assets/js/components/album/AlbumInfo.vue index 87a57321..ecfe1cee 100644 --- a/resources/assets/js/components/album/AlbumInfo.vue +++ b/resources/assets/js/components/album/AlbumInfo.vue @@ -1,6 +1,6 @@