Skip to content

Commit 9f8cbde

Browse files
[6.x] Show collection tree in navigation page selector (#13643)
1 parent 6f6c234 commit 9f8cbde

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

resources/js/components/structures/PageSelector.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
:can-create="false"
1515
:can-reorder="false"
1616
:max-items="maxItems"
17+
:tree="tree"
1718
@item-data-updated="itemDataUpdated"
1819
/>
1920
</template>
@@ -34,6 +35,10 @@ export default {
3435
type: Number,
3536
required: false,
3637
},
38+
tree: {
39+
type: Object,
40+
required: false,
41+
},
3742
},
3843
3944
data() {

resources/js/pages/navigation/Show.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export default {
5151
canSelectAcrossSites: { type: Boolean, required: true },
5252
canEditBlueprint: { type: Boolean, required: true },
5353
entryQueryScopes: { type: Array, default: () => [] },
54+
collectionTree: { type: Object, required: false },
5455
},
5556
5657
data() {
@@ -540,6 +541,7 @@ export default {
540541
:query-scopes="entryQueryScopes"
541542
:max-items="maxPagesSelection"
542543
:can-select-across-sites="canSelectAcrossSites"
544+
:tree="collectionTree"
543545
@selected="entriesSelected"
544546
/>
545547

src/Http/Controllers/CP/Navigation/NavigationController.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,30 @@ public function show(Request $request, $nav)
9393

9494
$this->authorize('view', $nav->in($site), __('You are not authorized to view navs.'));
9595

96+
$collectionTree = null;
97+
98+
if ($nav->collections()->count() === 1 && $nav->collections()->first()->hasStructure()) {
99+
$collection = $nav->collections()->first();
100+
101+
$collectionBlueprints = $collection
102+
->entryBlueprints()
103+
->reject->hidden()
104+
->map(function ($blueprint) {
105+
return [
106+
'handle' => $blueprint->handle(),
107+
'title' => $blueprint->title(),
108+
];
109+
})->values();
110+
111+
$collectionTree = [
112+
'title' => $collection->title(),
113+
'url' => cp_route('collections.tree.index', $collection),
114+
'showSlugs' => $collection->structure()->showSlugs(),
115+
'expectsRoot' => $collection->structure()->expectsRoot(),
116+
'blueprints' => $collectionBlueprints,
117+
];
118+
}
119+
96120
return Inertia::render('navigation/Show', [
97121
'title' => $nav->title(),
98122
'handle' => $nav->handle(),
@@ -118,6 +142,7 @@ public function show(Request $request, $nav)
118142
'canEdit' => User::current()->can('edit', $nav),
119143
'canSelectAcrossSites' => $nav->canSelectAcrossSites(),
120144
'canEditBlueprint' => User::current()->can('configure fields'),
145+
'collectionTree' => $collectionTree,
121146
]);
122147
}
123148

0 commit comments

Comments
 (0)