Skip to content

Commit

Permalink
Merge branch 'statamic:4.x' into feature/group-fieldtype
Browse files Browse the repository at this point in the history
  • Loading branch information
godismyjudge95 authored Nov 11, 2023
2 parents 00f58f5 + 30db081 commit 9669ed4
Show file tree
Hide file tree
Showing 17 changed files with 317 additions and 41 deletions.
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Release Notes

## 4.33.0 (2023-11-10)

### What's new
- Bard supports cmd+k for links. [#8950](https://github.com/statamic/cms/issues/8950) by @o1y
- The Entries fieldtype use columns from preferences in the stack selector. [#8900](https://github.com/statamic/cms/issues/8900) by @duncanmcclean
- Bind `AssetContainerContents` to the service provider. [#8954](https://github.com/statamic/cms/issues/8954) by @ryanmitchell
- Support arrays in wrap modifier [#8942](https://github.com/statamic/cms/issues/8942) by @jacksleight
- Add `mount` to augmented collection. [#8928](https://github.com/statamic/cms/issues/8928) by @duncanmcclean
- Require `pint` in dev. [#8955](https://github.com/statamic/cms/issues/8955) by @ryanmitchell

### What's improved
- French translations. [#8945](https://github.com/statamic/cms/issues/8945) [#8934](https://github.com/statamic/cms/issues/8934) by @ebeauchamps
- German translations. [#8939](https://github.com/statamic/cms/issues/8939) by @doriengr

### What's fixed
- Front-end form asset field php file validation. [#8968](https://github.com/statamic/cms/issues/8968) by @jasonvarga
- Fix entries fieldtype not respecting collection sort column & direction. [#8894](https://github.com/statamic/cms/issues/8894) by @duncanmcclean
- Fix duplicate entry action translation. [#8946](https://github.com/statamic/cms/issues/8946) by @jasonvarga
- Fix SortableList not reacting to disabled prop changes. [#8949](https://github.com/statamic/cms/issues/8949) by @duncanmcclean
- Remove debounce when renaming assets & folders. [#8953](https://github.com/statamic/cms/issues/8953) by @duncanmcclean
- Use translations from fallback locale when primary locale is missing translations. [#8940](https://github.com/statamic/cms/issues/8940) by @duncanmcclean
- Fix missing title on relationship fields in multi-site. [#8936](https://github.com/statamic/cms/issues/8936) by @duncanmcclean
- Prevent ensuring fields on entries if they already exist. [#8926](https://github.com/statamic/cms/issues/8926) by @duncanmcclean
- Fix `statamic.web` middleware not being merged. [#8935](https://github.com/statamic/cms/issues/8935) by @duncanmcclean
- Fix infinite loop on listing table of mounted collection. [#8937](https://github.com/statamic/cms/issues/8937) by @duncanmcclean
- Fix "Always Save" toggle not being saved when used on linked field. [#8927](https://github.com/statamic/cms/issues/8927) by @duncanmcclean
- Fix slug field not targeting sibling fields inside a replicator. [#8929](https://github.com/statamic/cms/issues/8929) by @duncanmcclean



## 4.32.0 (2023-11-03)

### What's new
Expand Down
12 changes: 9 additions & 3 deletions resources/js/components/fieldtypes/bard/Small.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Mark } from '@tiptap/core';
import { Mark, mergeAttributes } from '@tiptap/core';

export const Small = Mark.create({

name: 'small',

addOptions() {
return {
HTMLAttributes: {},
}
},

parseHTML() {
return [
{
Expand All @@ -12,8 +18,8 @@ export const Small = Mark.create({
]
},

renderHTML() {
return ['small', 0]
renderHTML({ HTMLAttributes }) {
return ['small', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
},

addCommands() {
Expand Down
2 changes: 2 additions & 0 deletions resources/js/components/users/ChangePassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</div>
<div class="publish-fields p-4 pb-0 w-96">
<form-group
v-if="requiresCurrentPassword"
handle="password"
:display="__('Current Password')"
v-model="currentPassword"
Expand Down Expand Up @@ -49,6 +50,7 @@ export default {
props: {
saveUrl: String,
requiresCurrentPassword: Boolean,
},
data() {
Expand Down
4 changes: 3 additions & 1 deletion resources/js/components/users/PublishForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<change-password
v-if="canEditPassword"
:save-url="actions.password"
:requires-current-password="requiresCurrentPassword"
class="mr-4"
/>

Expand Down Expand Up @@ -75,7 +76,8 @@ export default {
actions: Object,
method: String,
canEditPassword: Boolean,
canEditBlueprint: Boolean
canEditBlueprint: Boolean,
requiresCurrentPassword: Boolean,
},
data() {
Expand Down
1 change: 1 addition & 0 deletions resources/views/users/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:initial-meta="{{ json_encode($meta) }}"
:can-edit-password="{{ Statamic\Support\Str::bool($canEditPassword) }}"
:can-edit-blueprint="{{ Statamic\Support\Str::bool($user->can('configure fields')) }}"
:requires-current-password="{{ Statamic\Support\Str::bool($requiresCurrentPassword) }}"
></user-publish-form>

@endsection
2 changes: 1 addition & 1 deletion src/Actions/Impersonate.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ public function redirect($users, $values)
return $url;
}

return $users->first()->can('access cp') ? cp_route('dashboard') : '/';
return $users->first()->can('access cp') ? cp_route('index') : '/';
}
}
31 changes: 31 additions & 0 deletions src/Entries/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Statamic\Entries;

use ArrayAccess;
use Closure;
use Facades\Statamic\Entries\InitiatorStack;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Responsable;
Expand Down Expand Up @@ -722,13 +723,43 @@ public function makeLocalization($site)
->published($this->published)
->slug($this->slug());

if ($callback = $this->addToStructure($site, $this->parent())) {
$localization->afterSave($callback);
}

if ($this->collection()->dated()) {
$localization->date($this->date());
}

return $localization;
}

private function addToStructure($site, $parent = null): ?Closure
{
// If it's orderable (linear - a max depth of 1) then don't add it.
if ($this->collection()->orderable()) {
return null;
}

// Collection not structured? Don't add it.
if (! $structure = $this->collection()->structure()) {
return null;
}

$tree = $structure->in($site);
$parent = optional($parent)->in($site);

return function ($entry) use ($parent, $tree) {
if (! $parent || $parent->isRoot()) {
$tree->append($entry);
} else {
$tree->appendTo($parent->id(), $entry);
}

$tree->save();
};
}

public function supplementTaxonomies()
{
// TODO: This is just here to make things work without rewriting a bunch of places.
Expand Down
4 changes: 2 additions & 2 deletions src/Fieldtypes/Bard/ImageNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public function renderHTML($node, $HTMLAttributes = [])

protected function getUrl($id)
{
return optional(Asset::find($id))->url();
return Asset::find($id)?->url();
}

protected function getAlt($id)
{
return optional(Asset::find($id))->data()->get('alt');
return Asset::find($id)?->data()->get('alt');
}
}
16 changes: 14 additions & 2 deletions src/Fieldtypes/Bard/Marks/Small.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
namespace Statamic\Fieldtypes\Bard\Marks;

use Tiptap\Core\Mark;
use Tiptap\Utils\HTML;

class Small extends Mark
{
public static $name = 'small';

public function addOptions()
{
return [
'HTMLAttributes' => [],
];
}

public function parseHTML()
{
return [
Expand All @@ -17,8 +25,12 @@ public function parseHTML()
];
}

public function renderHTML($mark)
public function renderHTML($mark, $HTMLAttributes = [])
{
return ['small', 0];
return [
'small',
HTML::mergeAttributes($this->options['HTMLAttributes'], $HTMLAttributes),
0,
];
}
}
28 changes: 0 additions & 28 deletions src/Http/Controllers/CP/Collections/LocalizeEntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,11 @@ public function __invoke(Request $request, $collection, $entry)

$localized = $entry->makeLocalization($site = $request->site);

$this->addToStructure($collection, $entry, $localized);

$localized->store(['user' => User::fromUser($request->user())]);

return [
'handle' => $site,
'url' => $localized->editUrl(),
];
}

private function addToStructure($collection, $entry, $localized)
{
// If it's orderable (linear - a max depth of 1) then don't add it.
if ($collection->orderable()) {
return;
}

// Collection not structured? Don't add it.
if (! $structure = $collection->structure()) {
return;
}

$tree = $structure->in($localized->locale());
$parent = optional($entry->parent())->in($localized->locale());

$localized->afterSave(function ($localized) use ($parent, $tree) {
if (! $parent || $parent->isRoot()) {
$tree->append($localized);
} else {
$tree->appendTo($parent->id(), $localized);
}

$tree->save();
});
}
}
11 changes: 8 additions & 3 deletions src/Http/Controllers/CP/Users/PasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ public function update(Request $request, $user)

$this->authorize('editPassword', $user);

$request->validate([
'current_password' => ['required', 'current_password'],
$rules = [
'password' => ['required', 'confirmed', Password::default()],
]);
];

if ($request->user()->id === $user) {
$rules['current_password'] = ['required', 'current_password'];
}

$request->validate($rules);

$user->password($request->password)->save();

Expand Down
1 change: 1 addition & 0 deletions src/Http/Controllers/CP/Users/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ public function edit(Request $request, $user)
'editBlueprint' => cp_route('users.blueprint.edit'),
],
'canEditPassword' => User::fromUser($request->user())->can('editPassword', $user),
'requiresCurrentPassword' => $request->user()->id === $user->id(),
];

if ($request->wantsJson()) {
Expand Down
6 changes: 5 additions & 1 deletion src/Http/Controllers/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ protected function extraRules($fields)
return $field->fieldtype()->handle() === 'assets';
})
->mapWithKeys(function ($field) {
return [$field->handle().'.*' => 'file'];
return [$field->handle().'.*' => ['file', function ($attribute, $value, $fail) {
if (in_array(trim(strtolower($value->getClientOriginalExtension())), ['php', 'php3', 'php4', 'php5', 'phtml'])) {
$fail(__('validation.uploaded'));
}
}]];
})
->all();

Expand Down
6 changes: 6 additions & 0 deletions src/View/Antlers/Antlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Statamic\Contracts\View\Antlers\Parser;
use Statamic\View\Antlers\Language\Parser\IdentifierFinder;

class Antlers
{
Expand Down Expand Up @@ -43,4 +44,9 @@ public function parseLoop($content, $data, $supplement = true, $context = [])
{
return new AntlersLoop($this->parser(), $content, $data, $supplement, $context);
}

public function identifiers(string $content): array
{
return (new IdentifierFinder)->getIdentifiers($content);
}
}
Loading

0 comments on commit 9669ed4

Please sign in to comment.