Skip to content

Commit

Permalink
Hide 'Visit URL' button when collection has no route (#3080)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean authored Feb 10, 2021
1 parent a018219 commit 6c6e6e6
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions resources/js/components/entries/BaseCreateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
method="post"
:initial-title="__('Create Entry')"
:collection-handle="collectionHandle"
:collection-has-routes="collectionHasRoutes"
:initial-fieldset="fieldset"
:initial-values="values"
:initial-meta="meta"
Expand All @@ -31,6 +32,7 @@ export default {
props: [
'actions',
'collectionHandle',
'collectionHasRoutes',
'fieldset',
'values',
'meta',
Expand Down
3 changes: 2 additions & 1 deletion resources/js/components/entries/PublishForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
>
<template #actions="{ shouldShowSidebar }">

<div :class="{ 'hi': !shouldShowSidebar }">
<div v-if="collectionHasRoutes" :class="{ 'hi': !shouldShowSidebar }">

<div class="p-2 flex items-center -mx-1">
<button
Expand Down Expand Up @@ -300,6 +300,7 @@ export default {
canManagePublishState: Boolean,
createAnotherUrl: String,
listingUrl: String,
collectionHasRoutes: Boolean,
},
data() {
Expand Down
1 change: 1 addition & 0 deletions resources/views/entries/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<base-entry-create-form
:actions="{{ json_encode($actions) }}"
collection-handle="{{ $collection }}"
:collection-has-routes="{{ Statamic\Support\Str::bool($collectionHasRoutes) }}"
:fieldset="{{ json_encode($blueprint) }}"
:values="{{ json_encode($values) }}"
:meta="{{ json_encode($meta) }}"
Expand Down
1 change: 1 addition & 0 deletions resources/views/entries/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:initial-actions="{{ json_encode($actions) }}"
method="patch"
collection-handle="{{ $collection }}"
:collection-has-routes="{{ Statamic\Support\Str::bool($collectionHasRoutes) }}"
initial-title="{{ $title }}"
initial-reference="{{ $reference }}"
:initial-fieldset="{{ json_encode($blueprint) }}"
Expand Down
1 change: 1 addition & 0 deletions src/Fieldtypes/Entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Entries extends Relationship
'breadcrumbs' => 'breadcrumbs',
'collectionHandle' => 'collection',
'canManagePublishState' => 'canManagePublishState',
'collectionHasRoutes' => 'collectionHasRoutes',
];

protected function configFieldItems(): array
Expand Down
2 changes: 2 additions & 0 deletions src/Http/Controllers/CP/Collections/EntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function edit(Request $request, $collection, $entry)
'values' => array_merge($values, ['id' => $entry->id()]),
'meta' => $meta,
'collection' => $collection->handle(),
'collectionHasRoutes' => ! is_null($collection->route($entry->locale())),
'blueprint' => $blueprint->toPublishArray(),
'readOnly' => User::current()->cant('edit', $entry),
'locale' => $entry->locale(),
Expand Down Expand Up @@ -244,6 +245,7 @@ public function create(Request $request, $collection, $site)
'values' => $values->all(),
'meta' => $fields->meta(),
'collection' => $collection->handle(),
'collectionHasRoutes' => ! is_null($collection->route($site->handle())),
'blueprint' => $blueprint->toPublishArray(),
'published' => $collection->defaultPublishState(),
'locale' => $site->handle(),
Expand Down

0 comments on commit 6c6e6e6

Please sign in to comment.