Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Remove container tabs from Asset Manager #10392

Merged
merged 4 commits into from
Jul 9, 2024
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
24 changes: 0 additions & 24 deletions resources/js/components/assets/Browser/Browser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@
<span>{{ __('Drop File to Upload') }}</span>
</div>

<div class="publish-tabs tabs rounded-none rounded-t mb-3 shadow-none" v-if="showContainerTabs">
<button class="tab-button" v-for="item in containers" :key="item.id"
v-text="__(item.title)"
:class="{
active: item.id === container.id,
'border-b border-gray-300': item.id !== container.id
}"
@click="selectContainer(item.id)"
/>
</div>

<data-list
v-if="!initializing"
:rows="assets"
Expand Down Expand Up @@ -321,7 +310,6 @@ export default {
// Either the ID, or the whole container object.
initialContainer: {},
selectedPath: String, // The path to display, determined by a parent component.
restrictContainerNavigation: Boolean, // Whether to restrict to a single container and prevent navigation.
restrictFolderNavigation: Boolean, // Whether to restrict to a single folder and prevent navigation.
selectedAssets: Array,
maxFiles: Number,
Expand Down Expand Up @@ -376,10 +364,6 @@ export default {
return {container: this.selectedContainer};
},

showContainerTabs() {
return !this.restrictContainerNavigation && Object.keys(this.containers).length > 1
},

showAssetEditor() {
return Boolean(this.editedAssetId);
},
Expand Down Expand Up @@ -552,14 +536,6 @@ export default {
this.$emit('navigated', this.container, this.path);
},

selectContainer(id) {
this.container = this.containers[id];
this.path = '/';
this.page = 1;

this.$emit('navigated', this.container, this.path);
},

setMode(mode) {
this.mode = mode;
this.setPreference('mode', mode == 'table' ? null : mode);
Expand Down
7 changes: 0 additions & 7 deletions resources/js/components/assets/Selector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
:initial-per-page="$config.get('paginationSize')"
:selected-path="folder"
:selected-assets="browserSelections"
:restrict-container-navigation="restrictContainerNavigation"
:restrict-folder-navigation="restrictFolderNavigation"
:max-files="maxFiles"
:query-scopes="queryScopes"
Expand Down Expand Up @@ -59,12 +58,6 @@ export default {
selected: Array,
maxFiles: Number,
queryScopes: Array,
restrictContainerNavigation: {
type: Boolean,
default() {
return false;
}
},
restrictFolderNavigation: {
type: Boolean,
default() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
<selector
:container="container"
:folder="folder"
:restrict-container-navigation="true"
:restrict-folder-navigation="restrictNavigation"
:selected="selectedAssets"
:view-mode="selectorViewMode"
Expand Down
1 change: 0 additions & 1 deletion resources/js/components/fieldtypes/bard/Image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<selector
:container="extension.options.bard.config.container"
:folder="extension.options.bard.config.folder || '/'"
:restrict-container-navigation="true"
:restrict-folder-navigation="extension.options.bard.config.restrict_assets"
:selected="selections"
:view-mode="'grid'"
Expand Down
1 change: 0 additions & 1 deletion resources/js/components/fieldtypes/bard/LinkToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@
<asset-selector
:container="config.container"
:folder="config.folder || '/'"
:restrict-container-navigation="true"
:restrict-folder-navigation="config.restrict_assets"
:selected="[]"
:view-mode="'grid'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
:container="container"
:folder="folder"
:selected="selectedAssets"
:restrict-container-navigation="restrictAssetNavigation"
:restrict-folder-navigation="restrictAssetNavigation"
@selected="assetsSelected"
@closed="closeAssetSelector"
Expand Down
11 changes: 11 additions & 0 deletions src/Http/Controllers/CP/Assets/RedirectsToFirstAssetContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@

namespace Statamic\Http\Controllers\CP\Assets;

use Statamic\CP\Navigation\NavItem;
use Statamic\Facades\AssetContainer;
use Statamic\Facades\CP\Nav;
use Statamic\Facades\User;

trait RedirectsToFirstAssetContainer
{
public function redirectToFirstContainer()
{
$firstContainerInNav = Nav::build()->pluck('items')->flatten()
->filter(fn (NavItem $navItem) => $navItem->url() === cp_route('assets.index'))
->map(fn (NavItem $navItem) => $navItem->children()?->first())
->first();

if ($firstContainerInNav) {
abort(redirect($firstContainerInNav->url()));
}

$containers = AssetContainer::all()->sortBy->title()->filter(function ($container) {
return User::current()->can('view', $container);
});
Expand Down
Loading