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

Hide 'Visit URL' button when collection has no route #3080

Merged
merged 6 commits into from
Feb 10, 2021
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
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