Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
80dbb06
This is now normalized by UserNavConfig.
jesseleite Sep 12, 2022
8165a66
Process newly created child items the same way we process regular items.
jesseleite Sep 12, 2022
16924bb
Can't do that in PHP 7.4 my dear boy.
jesseleite Sep 13, 2022
2ec1918
Use `whenNotEmpty()`, but still apparently can't shorthand `fn()` it.
jesseleite Sep 13, 2022
90e4bf3
Refactor to separate params.
jesseleite Sep 13, 2022
a781a9a
Ensure we can rebuild nav from fresh slate.
jesseleite Nov 30, 2022
58be4f9
Support tracking preference manipulations on each NavItem instance fo…
jesseleite Nov 30, 2022
49d35c6
Track preference manipulations.
jesseleite Nov 30, 2022
4542c42
Allow passing of different preferences into `Nav::build()`.
jesseleite Nov 30, 2022
5e87094
Rename `UserNavConfig` to `NavPreferencesConfig`.
jesseleite Nov 30, 2022
6d8cfd9
Lots of front end.
jesseleite Nov 30, 2022
429e06a
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Nov 30, 2022
63093d8
The Nav and NavItem JSON resources used by the builder.
jesseleite Nov 30, 2022
84bd7e3
Hardcode link to nav.
jesseleite Nov 30, 2022
518a6da
Hide breadcrumb, because there is no preferences section yet (maybe l…
jesseleite Nov 30, 2022
6429bde
Normalize `original` for simpler logic in back end.
jesseleite Nov 30, 2022
61e2823
Wire up discard changes behaviour.
jesseleite Nov 30, 2022
088b26a
Icons.
jesseleite Nov 30, 2022
c6acbb7
Fix issue with new item IDs.
jesseleite Nov 30, 2022
e108e5f
Route and controller.
jesseleite Nov 30, 2022
4a438be
Add Nav Pref index and icon
jackmcdade Dec 6, 2022
3d7dcf4
Move `PreferenceController` and fix destroy route to actually use del…
jesseleite Dec 6, 2022
814e920
Wire up routes and controllers for default, role, and user nav prefer…
jesseleite Dec 6, 2022
a517164
Move into `CoreNav`.
jesseleite Dec 6, 2022
2629fd1
Add `buildDefault()` alias.
jesseleite Dec 6, 2022
b2b7ffe
Update front end.
jesseleite Dec 6, 2022
f273d75
Update tests.
jesseleite Dec 6, 2022
1b4bef9
Only show section if roles exist.
jesseleite Dec 6, 2022
41f2713
Add test coverage for new `Preference::preventMergingChildren()` method.
jesseleite Dec 8, 2022
336a22d
Implement `preventMergingChildren()`.
jesseleite Dec 8, 2022
aa73758
Prevent merging of children in nav preferences.
jesseleite Dec 8, 2022
74c4a79
Alias `get()` to `getPreference()`, like we do with `set()`.
jesseleite Dec 8, 2022
31c0c3e
Ensure we’re loading default preferences nav in editor.
jesseleite Dec 8, 2022
dd2ff77
Ensure we’re loading role preferences nav in editor.
jesseleite Dec 8, 2022
678921e
Alias `remove()` to `removePreference()`, like we do with `set()` and…
jesseleite Dec 8, 2022
8f389bf
Scope `Statamic.$preferences` api endpoints to prevent conflicts with…
jesseleite Dec 8, 2022
4198e51
Rename `buildDefault()` to `buildWithoutPreferences()` to avoid confu…
jesseleite Dec 8, 2022
8e7e0f8
Fix resetting of nav prefs, nav precedence on load, and clean up rout…
jesseleite Dec 8, 2022
099819a
Require pro to edit anything other than your own user preferences.
jesseleite Dec 8, 2022
71d92a4
Show confirmation modal when resetting.
jesseleite Dec 8, 2022
fa299a7
Add test to prove that first assigned user role takes precedence.
jesseleite Dec 8, 2022
d3a0d65
Fix discard changes regression.
jesseleite Dec 8, 2022
5f09b9f
Handle `.disabled` class on `.btn-group` buttons.
jesseleite Dec 8, 2022
1c4dbd2
Show reset option as warning.
jesseleite Dec 8, 2022
9c93d20
Handle ‘save as’ dropdown options.
jesseleite Dec 8, 2022
836e19f
Make index messaging a bit more consistent with other pages.
jesseleite Dec 8, 2022
cbcf4d9
Intelligently output save as options for nav builder.
jesseleite Dec 8, 2022
96d9a5d
Fix pro/super check.
jesseleite Dec 8, 2022
7255ae2
run npm install
jasonvarga Dec 9, 2022
2c391d3
add override
jasonvarga Dec 9, 2022
6629232
Merge branch 'fix-package-lock' of https://github.com/statamic/cms in…
jesseleite Dec 9, 2022
341c32d
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Dec 9, 2022
826f327
Rename to ‘CP Nav’ to avoid confusion with ‘Navigation’.
jesseleite Dec 9, 2022
328556e
Fix unique key on v-for warning.
jesseleite Dec 9, 2022
cab8390
Misc cleanup.
jesseleite Dec 9, 2022
bcbd31c
Vue payload to yaml transformation logic.
jesseleite Dec 10, 2022
b3340fd
Fix missing `display` and `url` on newly created items.
jesseleite Dec 10, 2022
3d52925
Allow removing of `@create`’d items (instead of hiding via `@remove` …
jesseleite Dec 10, 2022
7d2b40c
If there’s nothing to save, remove preference instead of saving `nav:…
jesseleite Dec 10, 2022
d9322b7
Fix overzealous `@inherit` minification when reordering.
jesseleite Dec 11, 2022
f6c8c94
Avoid submitting custom sections that have no items.
jesseleite Dec 11, 2022
1bbb1f8
Cmd+s to save.
jesseleite Dec 12, 2022
e907c10
Handle section `action: ‘@remove’` in config normalizer.
jesseleite Dec 12, 2022
af1ffc8
This shouldn’t be needed anymore, since the `normalize()` method abov…
jesseleite Dec 13, 2022
bf2a1c3
Add section manipulations into `build()` output.
jesseleite Dec 13, 2022
72bc6f9
Pluck `items` and `display` so that nav sidebar views continue to wor…
jesseleite Dec 13, 2022
08ce16a
Ensure front end merges whole section config in with items, not just …
jesseleite Dec 13, 2022
463c338
Refactor for new initial nav format on load.
jesseleite Dec 14, 2022
cf4e147
Ensure proper fallbacks.
jesseleite Dec 14, 2022
6b0c96a
Should use `NavItem::snakeCase()` for consistency.
jesseleite Dec 14, 2022
33e7857
Refactor payload to account for new `display_original` section changes.
jesseleite Dec 14, 2022
e67a60b
Improve section minification.
jesseleite Dec 14, 2022
8f33987
Ensure we also pass action to server.
jesseleite Dec 14, 2022
048d8ce
`Nav::build()` was always returning a collection, so this should too.
jesseleite Dec 14, 2022
c45acdd
Pass tests again.
jesseleite Dec 14, 2022
56a80b1
Actually, let’s avoid this `pluck()` and just fix the views.
jesseleite Dec 14, 2022
8210108
Rely on `display_original` for more consistent `itemsAreReordered` lo…
jesseleite Dec 14, 2022
474f565
Only ever show `@inherit` action when section config is empty, for re…
jesseleite Dec 14, 2022
4200a32
Ensure user can still see hidden items in builder on reload.
jesseleite Dec 14, 2022
c0e1b17
Properly handle `withHidden()` state when rebuilding.
jesseleite Dec 14, 2022
359ab19
Reload on save in order to see changes on save.
jesseleite Dec 14, 2022
fc6a8f9
This shoulda been in data.
jesseleite Dec 14, 2022
a831b26
Rename isNew to isCustom and use a new icon
jackmcdade Dec 14, 2022
5e32408
Autofocus first field in stacks, support a plain "enter" key binding
jackmcdade Dec 14, 2022
6a3811b
Use the proper prop data type
jackmcdade Dec 14, 2022
5fe9a23
Prevent hiding `CP Nav` item, so user can always access it.
jesseleite Dec 14, 2022
18233f7
Simplify that last commit.
jesseleite Dec 14, 2022
1b6d7f2
Hook up Expand All and Collapse All controls
jackmcdade Dec 14, 2022
56c784f
Don't need depth here.
jackmcdade Dec 14, 2022
981e6b2
Fix `isSectionNode()` for top level tree items.
jesseleite Dec 14, 2022
de3f29e
Clean up a few JS errors.
jesseleite Dec 14, 2022
db6252a
Make `prevent_hiding` work at section level.
jesseleite Dec 14, 2022
895a661
Prevent user from accidentally hiding CP Nav by dragging into hidden …
jesseleite Dec 14, 2022
e34415a
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
d8b43dd
Snip snap ✂️
jesseleite Dec 14, 2022
a378c98
Preferences Dropdown in the Global Header
jackmcdade Dec 14, 2022
f7b663e
Add `configure cp nav` permission.
jesseleite Dec 14, 2022
1290562
Rename/fix `Statamic.$preferences` endpoints.
jesseleite Dec 14, 2022
14af432
Wrap these routes with pro/permission checks.
jesseleite Dec 14, 2022
b1e3f73
Hook up redirect at controller level.
jesseleite Dec 14, 2022
5179f8c
Update permission check for nav builder breadcrumb link.
jesseleite Dec 14, 2022
f45d787
Remove from core nav, since Jack is adding cool gear in top nav.
jesseleite Dec 14, 2022
2eede65
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
e5e54b9
Pass tests.
jesseleite Dec 14, 2022
7eaebe5
Forgot to snip snap ✂️
jesseleite Dec 15, 2022
d3ecb7e
Improve styling for hidden sections.
jesseleite Dec 15, 2022
b716bcd
Ensure we properly minify section hide action.
jesseleite Dec 15, 2022
b691367
Expand and collapse items in top level tree as well.
jesseleite Dec 15, 2022
fa38a80
Hide hidden sections in built navs.
jesseleite Dec 15, 2022
82a1245
Fix JS errors.
jesseleite Dec 15, 2022
b946954
Ensure section level manipulations get properly set on load.
jesseleite Dec 15, 2022
f1848e3
Fix string replace.
jesseleite Dec 15, 2022
b1d6528
Return `$items` directly.
jesseleite Dec 15, 2022
2fbf6e6
Fix action handling in section minification.
jesseleite Dec 15, 2022
43bd885
Confirm removal of custom section when it contains items.
jesseleite Dec 15, 2022
f066f18
initial preferences ui
jasonvarga Dec 15, 2022
9d3e9cd
Apply fixes from StyleCI
StyleCIBot Dec 15, 2022
4458c04
Remove preferences if form field is set to the default value
jasonvarga Dec 15, 2022
36393f8
Flesh out allowed section actions and modifications as constants.
jesseleite Dec 15, 2022
a0b9711
add prop to allow publish form to reload on save
jasonvarga Dec 15, 2022
38428e2
Make permission more generic
jasonvarga Dec 15, 2022
c986eec
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 15, 2022
e99ae57
Wire up user/default/role forms
jasonvarga Dec 15, 2022
f09bfdc
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 16, 2022
f7a9a9e
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Dec 16, 2022
e28020b
Remove section `@inherit`s from config after processing reordering.
jesseleite Dec 16, 2022
793992c
Fix removing of sections and items after last sections overhaul.
jesseleite Dec 16, 2022
20ff852
Refactor `@remove` to `@hide`.
jesseleite Dec 16, 2022
11e356f
Fix undoing and saving ‘default’ level changes at user level, so that…
jesseleite Dec 16, 2022
57470dc
Apply the same fix at the role level.
jesseleite Dec 16, 2022
8156b53
Allow nulling/removing at default preferences level though.
jesseleite Dec 16, 2022
40e9b5d
Fix `@create` custom section items.
jesseleite Dec 17, 2022
e6eb308
Prevent adding item children to item children.
jesseleite Dec 17, 2022
b3cecce
Pass tests again, ensuring we don’t duplicate modified items in place.
jesseleite Dec 17, 2022
d23aa59
Rename to `NavPreferencesNormalizer::fromPreferences()` for clarity.
jesseleite Dec 17, 2022
878aa4b
Move all nav building logic out into a `NavBuilder` class so that we …
jesseleite Dec 17, 2022
15167da
Clarify why `Nav::extend()` is needed in test.
jesseleite Dec 17, 2022
9edab4d
Show custom section as ‘Custom Section’.
jesseleite Dec 17, 2022
fc1aad7
Misc cleanup.
jesseleite Dec 18, 2022
2a4dae0
Add support for `reorder` on item children.
jesseleite Dec 18, 2022
702f26a
Fix `@move` action when moving a parent item into the children of ano…
jesseleite Dec 18, 2022
93bb5c1
Ensure aliased items have no children unless explicitly set.
jesseleite Dec 18, 2022
4128730
Show configured `children` on aliased items, etc.
jesseleite Dec 18, 2022
e83fb1c
Show moved item icon (WIP).
jesseleite Dec 18, 2022
71a2e9e
Fix `@create`’d children within `@alias`’d items.
jesseleite Dec 18, 2022
ef88276
Pass tests again and cleanup todo’s.
jesseleite Dec 18, 2022
43387ef
Flesh out builder test coverage for recent fixes.
jesseleite Dec 18, 2022
a01291d
Add `syncOriginal()` functionality to `NavItem` class so we can detec…
jesseleite Dec 19, 2022
390dce0
Sync original on each item just before applying nav preference manipu…
jesseleite Dec 19, 2022
9cd1297
Pass original nav item state to tree data in front end builder.
jesseleite Dec 19, 2022
3382d44
Show icon and tooltip for renamed sections.
jesseleite Dec 19, 2022
35458d9
Ensure newly resolved child items sync their original state as well.
jesseleite Dec 19, 2022
b3a55e5
Ensure we can get current section from original children.
jesseleite Dec 19, 2022
624bd04
Fix updating of item manipulations when dragging or updating items.
jesseleite Dec 19, 2022
7d8594e
Fix JS error.
jesseleite Dec 19, 2022
8bff1ea
Fix regression since adding ‘section’ data to nested child items.
jesseleite Dec 19, 2022
a68025b
Fix overzealous `@move` action in front end.
jesseleite Dec 19, 2022
069c80f
Collapse top level items by default, to be consistent with the rest o…
jesseleite Dec 19, 2022
e289921
Fix ordering error on PHP 7.4.
jesseleite Dec 19, 2022
c743756
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 19, 2022
4afb33f
Fix duplicate hidden items regression.
jesseleite Dec 19, 2022
767ab26
Clean up `updateItemAction()` method using more readable switch case.
jesseleite Dec 19, 2022
22483cd
Get and pass clean editable nav item urls to nav builder.
jesseleite Dec 19, 2022
06fbbee
Transform on save, so that we don’t store local domain or configurabl…
jesseleite Dec 19, 2022
a5e20da
Move modified children `action` check to JS, where we handle the rest…
jesseleite Dec 19, 2022
25b2045
Fix reordering on child items payload on save.
jesseleite Dec 19, 2022
5deff45
Fix inability to move item out of an item’s children within the same …
jesseleite Dec 19, 2022
77bf587
Pass tests again.
jesseleite Dec 19, 2022
499072b
Fix disappearing of moved/aliased items by using item’s original ID w…
jesseleite Dec 20, 2022
9afd1aa
Whoops, not inherit.
jesseleite Dec 20, 2022
5ec4135
Improve reorder detection logic.
jesseleite Dec 20, 2022
57ef831
TIL, we cannot use our `Arr::get()` to get `some::id` with double col…
jesseleite Dec 20, 2022
1b18a4e
If `withHidden`, resolve/build all children, to fix cloned IDs bug in…
jesseleite Dec 21, 2022
503ce64
Fix action detection bug.
jesseleite Dec 21, 2022
4dc88ae
Handle empty sections.
jesseleite Dec 21, 2022
ba65452
Make sure we also update action on the parent node they dragged out of.
jesseleite Dec 21, 2022
8ec2f3d
Fix bug when trying to drag newly created/aliased item into another s…
jesseleite Dec 21, 2022
311a5e5
Builder doesn’t need children in manipulations.
jesseleite Dec 21, 2022
151984e
Handle tracking of renamed core sections.
jesseleite Dec 21, 2022
7cd8417
Fix and clean up drag level logic.
jesseleite Dec 21, 2022
413ae4f
Fix more JS errors.
jesseleite Dec 21, 2022
44a027a
Fix a whole bunch of moved/aliased/hidden item issues.
jesseleite Dec 21, 2022
2096ed0
Fix section reordering bug when core section has no items.
jesseleite Dec 22, 2022
f8324a0
Require both display and url.
jesseleite Dec 22, 2022
156e7aa
Remove console.log
jesseleite Dec 22, 2022
693af81
Whoops!
jesseleite Jan 3, 2023
fab9fa0
Removing flex fixes icons not showing in safari
jasonvarga Jan 3, 2023
09d068b
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Jan 3, 2023
5061db1
Never delete from manipulations for `@create`’d items, since there is…
jesseleite Jan 3, 2023
0f72eca
Never `@alias` a `@create`’d item.
jesseleite Jan 3, 2023
12f658a
Magic section setter should never look at nav item children.
jesseleite Jan 3, 2023
433e5c6
Allow overriding of preferences using `[]` when using `preventMerging…
jesseleite Jan 3, 2023
2ecd30d
Remove `nav: @override` in favour of `nav: []` for overriding of nav …
jesseleite Jan 3, 2023
8484154
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b0bae04
Add 'save as' functionality ...
jasonvarga Jan 4, 2023
a8d1ede
Validate
jasonvarga Jan 4, 2023
20cb443
Prevent "are you sure you want to navigate away" dialog when saving
jasonvarga Jan 4, 2023
d75bd14
Remove redundant `Customize` link in favour of `Modified` status.
jesseleite Jan 4, 2023
ba6889b
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b6868b5
Always touchdown for Jason 🏈
jesseleite Jan 4, 2023
160c3ad
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
ed2532b
Show modified text instead of customize link
jasonvarga Jan 4, 2023
04e990e
translate
jasonvarga Jan 4, 2023
a92d780
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
31d6aba
translate
jasonvarga Jan 4, 2023
e8caaf6
Adjust for translations
jasonvarga Jan 4, 2023
181bfba
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
5e12a53
make consistent with navs
jasonvarga Jan 4, 2023
277a45f
Remove 'Global' here, since we don't say this in page titles / save d…
jesseleite Jan 4, 2023
57a41ba
Remove redundant heading
jasonvarga Jan 4, 2023
7107063
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
9aea2c4
consistency
jasonvarga Jan 4, 2023
3470d51
Make sure Save To... dropdown doesn't clip or shrink child content
jackmcdade Jan 5, 2023
3006d22
Small improvements to make `NavTransformer` easier to test.
jesseleite Jan 5, 2023
b9bc2e5
Add whole bunch of `NavTransformer` test coverage.
jesseleite Jan 6, 2023
9066391
Add test coverage for intelligent url handling on save.
jesseleite Jan 6, 2023
a08b5d9
Add test coverage for complex json payload copied from actual vue sub…
jesseleite Jan 6, 2023
d65e105
delete method requires putting data into config
jasonvarga Jan 10, 2023
4de36c0
unused
jasonvarga Jan 10, 2023
fe03ebb
inline
jasonvarga Jan 10, 2023
edba03e
prevent saving through save button dropdown when unchanged
jasonvarga Jan 10, 2023
881e162
disable the dropdown when unchanged
jasonvarga Jan 10, 2023
bb4bb92
*slaps own wrist*
jasonvarga Jan 10, 2023
233cbd0
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 10, 2023
994e0c1
Fix issue with preferences property cache ...
jasonvarga Jan 10, 2023
5058985
CP locale can fall back to role and default preferences
jasonvarga Jan 10, 2023
5c470dc
remove comma for diff
jasonvarga Jan 11, 2023
e05d3fd
make save as dropdown consistent with nav
jasonvarga Jan 11, 2023
db6afcb
localize preference display and instructions
jasonvarga Jan 11, 2023
49c4334
Add preference extend and middleware to allow translations to be used…
jasonvarga Jan 11, 2023
e366c16
ability to defer permission registration until after locale has been …
jasonvarga Jan 11, 2023
a35f750
Apply similar changes to utilities
jasonvarga Jan 11, 2023
398da66
Might as well avoid using deprecated code now
jasonvarga Jan 11, 2023
5f81ff7
Pass preferences into section closure
jasonvarga Jan 12, 2023
efa60e6
Add simpler syntax for registering preferences
jasonvarga Jan 12, 2023
e652e7a
avoid facade
jasonvarga Jan 12, 2023
93329f9
prevent overriding section display names
jasonvarga Jan 12, 2023
6d9416b
Add test coverage for `Nav::extend()`’d sections that don’t follow ti…
jesseleite Jan 12, 2023
c2b3098
Only pass along `display` if it’s explicitly configured for renaming …
jesseleite Jan 12, 2023
6eefad5
Pass failing tests by moving section display and rename logic into `N…
jesseleite Jan 12, 2023
666c723
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Jan 12, 2023
ddf695a
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 13, 2023
d5261cd
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
95a4b3b
Merge branch 'master' into feature/preferences-ui
jasonvarga Jan 13, 2023
f9673de
Disable save part of button and leave dropdown active
jasonvarga Jan 13, 2023
77c3115
Leave dropdown active
jasonvarga Jan 13, 2023
421e81e
Add heading
jasonvarga Jan 13, 2023
01e883e
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
1f56155
Merge branch 'master' into permission-translations
jasonvarga Jan 13, 2023
f2fa807
unnecessary
jasonvarga Jan 13, 2023
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
22 changes: 22 additions & 0 deletions src/Auth/Permissions.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,34 @@

namespace Statamic\Auth;

use Facades\Statamic\Auth\CorePermissions;

class Permissions
{
protected $extensions = [];
protected $permissions = [];
protected $groups = [];
protected $pendingGroup = null;

public function boot()
{
$early = $this->permissions;
$this->permissions = [];

CorePermissions::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}

$this->permissions = array_merge($this->permissions, $early);
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make(string $value)
{
$permission = (new Permission)->value($value);
Expand Down
30 changes: 12 additions & 18 deletions src/CP/Utilities/CoreUtilities.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,7 @@ class CoreUtilities
{
public static function boot()
{
Utility::make('cache')
Utility::register('cache')
->action([CacheController::class, 'index'])
->title(__('Cache Manager'))
->icon('cache')
Expand All@@ -26,60 +26,54 @@ public static function boot()
->routes(function ($router) {
$router->post('cache/{cache}', [CacheController::class, 'clear'])->name('clear');
$router->post('cache/{cache}/warm', [CacheController::class, 'warm'])->name('warm');
})
->register();
});

Utility::make('phpinfo')
Utility::register('phpinfo')
->action(PhpInfoController::class)
->title(__('PHP Info'))
->icon('php')
->description(__('statamic::messages.phpinfo_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/phpinfo'))
->register();
->docsUrl(Statamic::docsUrl('utilities/phpinfo'));

Utility::make('search')
Utility::register('search')
->view('statamic::utilities.search')
->title(__('Search'))
->icon('search-utility')
->description(__('statamic::messages.search_utility_description'))
->routes(function ($router) {
$router->post('/', [UpdateSearchController::class, 'update'])->name('update');
})
->register();
});

Utility::make('email')
Utility::register('email')
->view('statamic::utilities.email')
->title(__('Email'))
->icon('email-utility')
->description(__('statamic::messages.email_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/email'))
->routes(function ($router) {
$router->post('/', [EmailController::class, 'send']);
})
->register();
});

Utility::make('licensing')
Utility::register('licensing')
->action([LicensingController::class, 'show'])
->title(__('Licensing'))
->icon('licensing')
->description(__('statamic::messages.licensing_utility_description'))
->docsUrl(Statamic::docsUrl('licensing'))
->routes(function ($router) {
$router->get('refresh', [LicensingController::class, 'refresh'])->name('refresh');
})
->register();
});

if (config('statamic.git.enabled') && Statamic::pro()) {
Utility::make('git')
Utility::register('git')
->action([GitController::class, 'index'])
->title('Git')
->icon('git')
->description(__('statamic::messages.git_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/git'))
->routes(function ($router) {
$router->post('/', [GitController::class, 'commit'])->name('commit');
})
->register();
});
}
}
}
1 change: 1 addition & 0 deletions src/CP/Utilities/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,6 +104,7 @@ public function routes(Closure $routes = null)
return $this->fluentlyGetOrSet('routes')->args(func_get_args());
}

/** @deprecated */
public function register()
{
\Statamic\Facades\Utility::push($this);
Expand Down
32 changes: 31 additions & 1 deletion src/CP/Utilities/UtilityRepository.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,27 +2,55 @@

namespace Statamic\CP\Utilities;

use Facades\Statamic\CP\Utilities\CoreUtilities;
use Illuminate\Support\Facades\Route;
use Statamic\Facades\User;

class UtilityRepository
{
protected $utilities;
protected $extensions = [];

public function __construct()
{
$this->utilities = collect([]);
}

public function boot()
{
CoreUtilities::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make($handle)
{
return (new Utility)->handle($handle);
}

public function push(Utility $utility)
public function register($utility)
{
if (! $utility instanceof Utility) {
$utility = $this->make($utility);
}

$this->utilities[$utility->handle()] = $utility;

return $utility;
}

/** @deprecated */
public function push(Utility $utility)
{
$this->register($utility);

return $this;
}

Expand All@@ -45,6 +73,8 @@ public function find($handle)

public function routes()
{
$this->boot();

Route::namespace('\\')->prefix('utilities')->name('utilities.')->group(function () {
$this->all()->each(function ($utility) {
if ($utility->action()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

/**
* @method static mixed|null make($handle)
* @method static self push(Utility $utility)
* @method static \Statamic\CP\Utilities\Utility register($utility)
* @method static mixed all()
* @method static mixed authorized()
* @method static mixed find($handle)
Expand Down
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootPermissions.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Permission;

class BootPermissions
{
public function handle($request, Closure $next)
{
Permission::boot();

return $next($request);
}
}
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootUtilities.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Utility;

class BootUtilities
{
public function handle($request, Closure $next)
{
Utility::boot();

return $next($request);
}
}
2 changes: 1 addition & 1 deletion src/Preferences/Preferences.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -230,7 +230,7 @@ public function section($handle, $label, $permissions = null)

$this->pendingSection = $handle;

$permissions();
$permissions($this);

$this->pendingSection = null;
}
Expand Down
5 changes: 0 additions & 5 deletions src/Providers/AuthServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@

namespace Statamic\Providers;

use Facades\Statamic\Auth\CorePermissions;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
Expand DownExpand Up@@ -90,10 +89,6 @@ public function boot()
return optional(User::fromUser($user))->hasPermission($ability) === true ? true : null;
});

$this->app->booted(function () {
CorePermissions::boot();
});

foreach ($this->policies as $key => $policy) {
Gate::policy($key, $policy);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Providers/CpServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Statamic\CP\Utilities\CoreUtilities;
use Statamic\CP\Utilities\UtilityRepository;
use Statamic\Extensions\Translation\Loader;
use Statamic\Extensions\Translation\Translator;
Expand All@@ -33,8 +32,6 @@ public function boot()
View::composer(NavComposer::VIEWS, NavComposer::class);
View::composer(CustomLogoComposer::VIEWS, CustomLogoComposer::class);

CoreUtilities::boot();

Blade::directive('cp_svg', function ($expression) {
return "<?php echo Statamic::svg({$expression}) ?>";
});
Expand DownExpand Up@@ -83,7 +80,9 @@ protected function registerMiddlewareGroups()
$router->middlewareGroup('statamic.cp.authenticated', [
\Statamic\Http\Middleware\CP\Authorize::class,
\Statamic\Http\Middleware\CP\Localize::class,
\Statamic\Http\Middleware\CP\BootPermissions::class,
\Statamic\Http\Middleware\CP\BootPreferences::class,
\Statamic\Http\Middleware\CP\BootUtilities::class,
\Statamic\Http\Middleware\CP\CountUsers::class,
\Statamic\Http\Middleware\DeleteTemporaryFileUploads::class,
]);
Expand Down
96 changes: 96 additions & 0 deletions tests/CP/Utilities/UtilityRepositoryTest.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
<?php

namespace Tests\CP\Utilities;

use Illuminate\Support\Collection;
use Statamic\CP\Utilities\Utility;
use Statamic\CP\Utilities\UtilityRepository;
use Tests\TestCase;

class UtilityRepositoryTest extends TestCase
{
/**
* @test
*
* @dataProvider registerMethodProvider
*/
public function it_registers_a_utility($registerMethod)
{
$utilities = new UtilityRepository;
$this->assertInstanceOf(Collection::class, $utilities->all());
$this->assertCount(0, $utilities->all());

$utility = $utilities->make('one');
$this->assertCount(0, $utilities->all());

$utilities->$registerMethod($utility);
$this->assertEquals(['one' => $utility], $utilities->all()->all());
$this->assertEquals($utility, $utilities->find('one'));
}

public function registerMethodProvider()
{
return [
'register' => ['register'],
'push' => ['push'], // @deprecated
];
}

/** @test */
public function it_registers_a_utility_via_a_string()
{
$utilities = new UtilityRepository;

$utility = $utilities->register('one');

$this->assertInstanceOf(Utility::class, $utility);
$this->assertEquals('one', $utility->handle());
$this->assertCount(1, $utilities->all());
$this->assertEquals(['one' => $utility], $utilities->all()->all());
}

/** @test */
public function it_defers_registration_until_boot_using_extend_method()
{
$utilities = new UtilityRepository;
$callbackRan = false;

$utilities->extend(function ($arg) use ($utilities, &$callbackRan) {
$this->assertEquals($utilities, $arg);
$callbackRan = true;
});

$this->assertFalse($callbackRan);

$utilities->boot();

$this->assertTrue($callbackRan);
}

/** @test */
public function booting_more_than_once_just_updates_the_utilities()
{
// This makes sure that booting a second time doesn't duplicate
// any utilities. It should just update/replace the existing ones.
// We boot once early so that routes can get registered, and
// then again after the user's locale preference is set so
// that the translations for labels etc use the right language.

$utilities = new UtilityRepository;

$utilities->extend(function ($utilities) {
$utilities->register('test')
->title(__('and')); // using a translation that will likely never change.
});

$utilities->boot();

$this->assertEquals(['and'], $utilities->all()->map->title()->values()->all());

app()->setLocale('fr');

$utilities->boot();

$this->assertEquals(['et'], $utilities->all()->map->title()->values()->all());
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
80dbb06
This is now normalized by UserNavConfig.
jesseleite Sep 12, 2022
8165a66
Process newly created child items the same way we process regular items.
jesseleite Sep 12, 2022
16924bb
Can't do that in PHP 7.4 my dear boy.
jesseleite Sep 13, 2022
2ec1918
Use `whenNotEmpty()`, but still apparently can't shorthand `fn()` it.
jesseleite Sep 13, 2022
90e4bf3
Refactor to separate params.
jesseleite Sep 13, 2022
a781a9a
Ensure we can rebuild nav from fresh slate.
jesseleite Nov 30, 2022
58be4f9
Support tracking preference manipulations on each NavItem instance fo…
jesseleite Nov 30, 2022
49d35c6
Track preference manipulations.
jesseleite Nov 30, 2022
4542c42
Allow passing of different preferences into `Nav::build()`.
jesseleite Nov 30, 2022
5e87094
Rename `UserNavConfig` to `NavPreferencesConfig`.
jesseleite Nov 30, 2022
6d8cfd9
Lots of front end.
jesseleite Nov 30, 2022
429e06a
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Nov 30, 2022
63093d8
The Nav and NavItem JSON resources used by the builder.
jesseleite Nov 30, 2022
84bd7e3
Hardcode link to nav.
jesseleite Nov 30, 2022
518a6da
Hide breadcrumb, because there is no preferences section yet (maybe l…
jesseleite Nov 30, 2022
6429bde
Normalize `original` for simpler logic in back end.
jesseleite Nov 30, 2022
61e2823
Wire up discard changes behaviour.
jesseleite Nov 30, 2022
088b26a
Icons.
jesseleite Nov 30, 2022
c6acbb7
Fix issue with new item IDs.
jesseleite Nov 30, 2022
e108e5f
Route and controller.
jesseleite Nov 30, 2022
4a438be
Add Nav Pref index and icon
jackmcdade Dec 6, 2022
3d7dcf4
Move `PreferenceController` and fix destroy route to actually use del…
jesseleite Dec 6, 2022
814e920
Wire up routes and controllers for default, role, and user nav prefer…
jesseleite Dec 6, 2022
a517164
Move into `CoreNav`.
jesseleite Dec 6, 2022
2629fd1
Add `buildDefault()` alias.
jesseleite Dec 6, 2022
b2b7ffe
Update front end.
jesseleite Dec 6, 2022
f273d75
Update tests.
jesseleite Dec 6, 2022
1b4bef9
Only show section if roles exist.
jesseleite Dec 6, 2022
41f2713
Add test coverage for new `Preference::preventMergingChildren()` method.
jesseleite Dec 8, 2022
336a22d
Implement `preventMergingChildren()`.
jesseleite Dec 8, 2022
aa73758
Prevent merging of children in nav preferences.
jesseleite Dec 8, 2022
74c4a79
Alias `get()` to `getPreference()`, like we do with `set()`.
jesseleite Dec 8, 2022
31c0c3e
Ensure we’re loading default preferences nav in editor.
jesseleite Dec 8, 2022
dd2ff77
Ensure we’re loading role preferences nav in editor.
jesseleite Dec 8, 2022
678921e
Alias `remove()` to `removePreference()`, like we do with `set()` and…
jesseleite Dec 8, 2022
8f389bf
Scope `Statamic.$preferences` api endpoints to prevent conflicts with…
jesseleite Dec 8, 2022
4198e51
Rename `buildDefault()` to `buildWithoutPreferences()` to avoid confu…
jesseleite Dec 8, 2022
8e7e0f8
Fix resetting of nav prefs, nav precedence on load, and clean up rout…
jesseleite Dec 8, 2022
099819a
Require pro to edit anything other than your own user preferences.
jesseleite Dec 8, 2022
71d92a4
Show confirmation modal when resetting.
jesseleite Dec 8, 2022
fa299a7
Add test to prove that first assigned user role takes precedence.
jesseleite Dec 8, 2022
d3a0d65
Fix discard changes regression.
jesseleite Dec 8, 2022
5f09b9f
Handle `.disabled` class on `.btn-group` buttons.
jesseleite Dec 8, 2022
1c4dbd2
Show reset option as warning.
jesseleite Dec 8, 2022
9c93d20
Handle ‘save as’ dropdown options.
jesseleite Dec 8, 2022
836e19f
Make index messaging a bit more consistent with other pages.
jesseleite Dec 8, 2022
cbcf4d9
Intelligently output save as options for nav builder.
jesseleite Dec 8, 2022
96d9a5d
Fix pro/super check.
jesseleite Dec 8, 2022
7255ae2
run npm install
jasonvarga Dec 9, 2022
2c391d3
add override
jasonvarga Dec 9, 2022
6629232
Merge branch 'fix-package-lock' of https://github.com/statamic/cms in…
jesseleite Dec 9, 2022
341c32d
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Dec 9, 2022
826f327
Rename to ‘CP Nav’ to avoid confusion with ‘Navigation’.
jesseleite Dec 9, 2022
328556e
Fix unique key on v-for warning.
jesseleite Dec 9, 2022
cab8390
Misc cleanup.
jesseleite Dec 9, 2022
bcbd31c
Vue payload to yaml transformation logic.
jesseleite Dec 10, 2022
b3340fd
Fix missing `display` and `url` on newly created items.
jesseleite Dec 10, 2022
3d52925
Allow removing of `@create`’d items (instead of hiding via `@remove` …
jesseleite Dec 10, 2022
7d2b40c
If there’s nothing to save, remove preference instead of saving `nav:…
jesseleite Dec 10, 2022
d9322b7
Fix overzealous `@inherit` minification when reordering.
jesseleite Dec 11, 2022
f6c8c94
Avoid submitting custom sections that have no items.
jesseleite Dec 11, 2022
1bbb1f8
Cmd+s to save.
jesseleite Dec 12, 2022
e907c10
Handle section `action: ‘@remove’` in config normalizer.
jesseleite Dec 12, 2022
af1ffc8
This shouldn’t be needed anymore, since the `normalize()` method abov…
jesseleite Dec 13, 2022
bf2a1c3
Add section manipulations into `build()` output.
jesseleite Dec 13, 2022
72bc6f9
Pluck `items` and `display` so that nav sidebar views continue to wor…
jesseleite Dec 13, 2022
08ce16a
Ensure front end merges whole section config in with items, not just …
jesseleite Dec 13, 2022
463c338
Refactor for new initial nav format on load.
jesseleite Dec 14, 2022
cf4e147
Ensure proper fallbacks.
jesseleite Dec 14, 2022
6b0c96a
Should use `NavItem::snakeCase()` for consistency.
jesseleite Dec 14, 2022
33e7857
Refactor payload to account for new `display_original` section changes.
jesseleite Dec 14, 2022
e67a60b
Improve section minification.
jesseleite Dec 14, 2022
8f33987
Ensure we also pass action to server.
jesseleite Dec 14, 2022
048d8ce
`Nav::build()` was always returning a collection, so this should too.
jesseleite Dec 14, 2022
c45acdd
Pass tests again.
jesseleite Dec 14, 2022
56a80b1
Actually, let’s avoid this `pluck()` and just fix the views.
jesseleite Dec 14, 2022
8210108
Rely on `display_original` for more consistent `itemsAreReordered` lo…
jesseleite Dec 14, 2022
474f565
Only ever show `@inherit` action when section config is empty, for re…
jesseleite Dec 14, 2022
4200a32
Ensure user can still see hidden items in builder on reload.
jesseleite Dec 14, 2022
c0e1b17
Properly handle `withHidden()` state when rebuilding.
jesseleite Dec 14, 2022
359ab19
Reload on save in order to see changes on save.
jesseleite Dec 14, 2022
fc6a8f9
This shoulda been in data.
jesseleite Dec 14, 2022
a831b26
Rename isNew to isCustom and use a new icon
jackmcdade Dec 14, 2022
5e32408
Autofocus first field in stacks, support a plain "enter" key binding
jackmcdade Dec 14, 2022
6a3811b
Use the proper prop data type
jackmcdade Dec 14, 2022
5fe9a23
Prevent hiding `CP Nav` item, so user can always access it.
jesseleite Dec 14, 2022
18233f7
Simplify that last commit.
jesseleite Dec 14, 2022
1b6d7f2
Hook up Expand All and Collapse All controls
jackmcdade Dec 14, 2022
56c784f
Don't need depth here.
jackmcdade Dec 14, 2022
981e6b2
Fix `isSectionNode()` for top level tree items.
jesseleite Dec 14, 2022
de3f29e
Clean up a few JS errors.
jesseleite Dec 14, 2022
db6252a
Make `prevent_hiding` work at section level.
jesseleite Dec 14, 2022
895a661
Prevent user from accidentally hiding CP Nav by dragging into hidden …
jesseleite Dec 14, 2022
e34415a
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
d8b43dd
Snip snap ✂️
jesseleite Dec 14, 2022
a378c98
Preferences Dropdown in the Global Header
jackmcdade Dec 14, 2022
f7b663e
Add `configure cp nav` permission.
jesseleite Dec 14, 2022
1290562
Rename/fix `Statamic.$preferences` endpoints.
jesseleite Dec 14, 2022
14af432
Wrap these routes with pro/permission checks.
jesseleite Dec 14, 2022
b1e3f73
Hook up redirect at controller level.
jesseleite Dec 14, 2022
5179f8c
Update permission check for nav builder breadcrumb link.
jesseleite Dec 14, 2022
f45d787
Remove from core nav, since Jack is adding cool gear in top nav.
jesseleite Dec 14, 2022
2eede65
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
e5e54b9
Pass tests.
jesseleite Dec 14, 2022
7eaebe5
Forgot to snip snap ✂️
jesseleite Dec 15, 2022
d3ecb7e
Improve styling for hidden sections.
jesseleite Dec 15, 2022
b716bcd
Ensure we properly minify section hide action.
jesseleite Dec 15, 2022
b691367
Expand and collapse items in top level tree as well.
jesseleite Dec 15, 2022
fa38a80
Hide hidden sections in built navs.
jesseleite Dec 15, 2022
82a1245
Fix JS errors.
jesseleite Dec 15, 2022
b946954
Ensure section level manipulations get properly set on load.
jesseleite Dec 15, 2022
f1848e3
Fix string replace.
jesseleite Dec 15, 2022
b1d6528
Return `$items` directly.
jesseleite Dec 15, 2022
2fbf6e6
Fix action handling in section minification.
jesseleite Dec 15, 2022
43bd885
Confirm removal of custom section when it contains items.
jesseleite Dec 15, 2022
f066f18
initial preferences ui
jasonvarga Dec 15, 2022
9d3e9cd
Apply fixes from StyleCI
StyleCIBot Dec 15, 2022
4458c04
Remove preferences if form field is set to the default value
jasonvarga Dec 15, 2022
36393f8
Flesh out allowed section actions and modifications as constants.
jesseleite Dec 15, 2022
a0b9711
add prop to allow publish form to reload on save
jasonvarga Dec 15, 2022
38428e2
Make permission more generic
jasonvarga Dec 15, 2022
c986eec
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 15, 2022
e99ae57
Wire up user/default/role forms
jasonvarga Dec 15, 2022
f09bfdc
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 16, 2022
f7a9a9e
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Dec 16, 2022
e28020b
Remove section `@inherit`s from config after processing reordering.
jesseleite Dec 16, 2022
793992c
Fix removing of sections and items after last sections overhaul.
jesseleite Dec 16, 2022
20ff852
Refactor `@remove` to `@hide`.
jesseleite Dec 16, 2022
11e356f
Fix undoing and saving ‘default’ level changes at user level, so that…
jesseleite Dec 16, 2022
57470dc
Apply the same fix at the role level.
jesseleite Dec 16, 2022
8156b53
Allow nulling/removing at default preferences level though.
jesseleite Dec 16, 2022
40e9b5d
Fix `@create` custom section items.
jesseleite Dec 17, 2022
e6eb308
Prevent adding item children to item children.
jesseleite Dec 17, 2022
b3cecce
Pass tests again, ensuring we don’t duplicate modified items in place.
jesseleite Dec 17, 2022
d23aa59
Rename to `NavPreferencesNormalizer::fromPreferences()` for clarity.
jesseleite Dec 17, 2022
878aa4b
Move all nav building logic out into a `NavBuilder` class so that we …
jesseleite Dec 17, 2022
15167da
Clarify why `Nav::extend()` is needed in test.
jesseleite Dec 17, 2022
9edab4d
Show custom section as ‘Custom Section’.
jesseleite Dec 17, 2022
fc1aad7
Misc cleanup.
jesseleite Dec 18, 2022
2a4dae0
Add support for `reorder` on item children.
jesseleite Dec 18, 2022
702f26a
Fix `@move` action when moving a parent item into the children of ano…
jesseleite Dec 18, 2022
93bb5c1
Ensure aliased items have no children unless explicitly set.
jesseleite Dec 18, 2022
4128730
Show configured `children` on aliased items, etc.
jesseleite Dec 18, 2022
e83fb1c
Show moved item icon (WIP).
jesseleite Dec 18, 2022
71a2e9e
Fix `@create`’d children within `@alias`’d items.
jesseleite Dec 18, 2022
ef88276
Pass tests again and cleanup todo’s.
jesseleite Dec 18, 2022
43387ef
Flesh out builder test coverage for recent fixes.
jesseleite Dec 18, 2022
a01291d
Add `syncOriginal()` functionality to `NavItem` class so we can detec…
jesseleite Dec 19, 2022
390dce0
Sync original on each item just before applying nav preference manipu…
jesseleite Dec 19, 2022
9cd1297
Pass original nav item state to tree data in front end builder.
jesseleite Dec 19, 2022
3382d44
Show icon and tooltip for renamed sections.
jesseleite Dec 19, 2022
35458d9
Ensure newly resolved child items sync their original state as well.
jesseleite Dec 19, 2022
b3a55e5
Ensure we can get current section from original children.
jesseleite Dec 19, 2022
624bd04
Fix updating of item manipulations when dragging or updating items.
jesseleite Dec 19, 2022
7d8594e
Fix JS error.
jesseleite Dec 19, 2022
8bff1ea
Fix regression since adding ‘section’ data to nested child items.
jesseleite Dec 19, 2022
a68025b
Fix overzealous `@move` action in front end.
jesseleite Dec 19, 2022
069c80f
Collapse top level items by default, to be consistent with the rest o…
jesseleite Dec 19, 2022
e289921
Fix ordering error on PHP 7.4.
jesseleite Dec 19, 2022
c743756
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 19, 2022
4afb33f
Fix duplicate hidden items regression.
jesseleite Dec 19, 2022
767ab26
Clean up `updateItemAction()` method using more readable switch case.
jesseleite Dec 19, 2022
22483cd
Get and pass clean editable nav item urls to nav builder.
jesseleite Dec 19, 2022
06fbbee
Transform on save, so that we don’t store local domain or configurabl…
jesseleite Dec 19, 2022
a5e20da
Move modified children `action` check to JS, where we handle the rest…
jesseleite Dec 19, 2022
25b2045
Fix reordering on child items payload on save.
jesseleite Dec 19, 2022
5deff45
Fix inability to move item out of an item’s children within the same …
jesseleite Dec 19, 2022
77bf587
Pass tests again.
jesseleite Dec 19, 2022
499072b
Fix disappearing of moved/aliased items by using item’s original ID w…
jesseleite Dec 20, 2022
9afd1aa
Whoops, not inherit.
jesseleite Dec 20, 2022
5ec4135
Improve reorder detection logic.
jesseleite Dec 20, 2022
57ef831
TIL, we cannot use our `Arr::get()` to get `some::id` with double col…
jesseleite Dec 20, 2022
1b18a4e
If `withHidden`, resolve/build all children, to fix cloned IDs bug in…
jesseleite Dec 21, 2022
503ce64
Fix action detection bug.
jesseleite Dec 21, 2022
4dc88ae
Handle empty sections.
jesseleite Dec 21, 2022
ba65452
Make sure we also update action on the parent node they dragged out of.
jesseleite Dec 21, 2022
8ec2f3d
Fix bug when trying to drag newly created/aliased item into another s…
jesseleite Dec 21, 2022
311a5e5
Builder doesn’t need children in manipulations.
jesseleite Dec 21, 2022
151984e
Handle tracking of renamed core sections.
jesseleite Dec 21, 2022
7cd8417
Fix and clean up drag level logic.
jesseleite Dec 21, 2022
413ae4f
Fix more JS errors.
jesseleite Dec 21, 2022
44a027a
Fix a whole bunch of moved/aliased/hidden item issues.
jesseleite Dec 21, 2022
2096ed0
Fix section reordering bug when core section has no items.
jesseleite Dec 22, 2022
f8324a0
Require both display and url.
jesseleite Dec 22, 2022
156e7aa
Remove console.log
jesseleite Dec 22, 2022
693af81
Whoops!
jesseleite Jan 3, 2023
fab9fa0
Removing flex fixes icons not showing in safari
jasonvarga Jan 3, 2023
09d068b
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Jan 3, 2023
5061db1
Never delete from manipulations for `@create`’d items, since there is…
jesseleite Jan 3, 2023
0f72eca
Never `@alias` a `@create`’d item.
jesseleite Jan 3, 2023
12f658a
Magic section setter should never look at nav item children.
jesseleite Jan 3, 2023
433e5c6
Allow overriding of preferences using `[]` when using `preventMerging…
jesseleite Jan 3, 2023
2ecd30d
Remove `nav: @override` in favour of `nav: []` for overriding of nav …
jesseleite Jan 3, 2023
8484154
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b0bae04
Add 'save as' functionality ...
jasonvarga Jan 4, 2023
a8d1ede
Validate
jasonvarga Jan 4, 2023
20cb443
Prevent "are you sure you want to navigate away" dialog when saving
jasonvarga Jan 4, 2023
d75bd14
Remove redundant `Customize` link in favour of `Modified` status.
jesseleite Jan 4, 2023
ba6889b
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b6868b5
Always touchdown for Jason 🏈
jesseleite Jan 4, 2023
160c3ad
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
ed2532b
Show modified text instead of customize link
jasonvarga Jan 4, 2023
04e990e
translate
jasonvarga Jan 4, 2023
a92d780
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
31d6aba
translate
jasonvarga Jan 4, 2023
e8caaf6
Adjust for translations
jasonvarga Jan 4, 2023
181bfba
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
5e12a53
make consistent with navs
jasonvarga Jan 4, 2023
277a45f
Remove 'Global' here, since we don't say this in page titles / save d…
jesseleite Jan 4, 2023
57a41ba
Remove redundant heading
jasonvarga Jan 4, 2023
7107063
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
9aea2c4
consistency
jasonvarga Jan 4, 2023
3470d51
Make sure Save To... dropdown doesn't clip or shrink child content
jackmcdade Jan 5, 2023
3006d22
Small improvements to make `NavTransformer` easier to test.
jesseleite Jan 5, 2023
b9bc2e5
Add whole bunch of `NavTransformer` test coverage.
jesseleite Jan 6, 2023
9066391
Add test coverage for intelligent url handling on save.
jesseleite Jan 6, 2023
a08b5d9
Add test coverage for complex json payload copied from actual vue sub…
jesseleite Jan 6, 2023
d65e105
delete method requires putting data into config
jasonvarga Jan 10, 2023
4de36c0
unused
jasonvarga Jan 10, 2023
fe03ebb
inline
jasonvarga Jan 10, 2023
edba03e
prevent saving through save button dropdown when unchanged
jasonvarga Jan 10, 2023
881e162
disable the dropdown when unchanged
jasonvarga Jan 10, 2023
bb4bb92
*slaps own wrist*
jasonvarga Jan 10, 2023
233cbd0
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 10, 2023
994e0c1
Fix issue with preferences property cache ...
jasonvarga Jan 10, 2023
5058985
CP locale can fall back to role and default preferences
jasonvarga Jan 10, 2023
5c470dc
remove comma for diff
jasonvarga Jan 11, 2023
e05d3fd
make save as dropdown consistent with nav
jasonvarga Jan 11, 2023
db6afcb
localize preference display and instructions
jasonvarga Jan 11, 2023
49c4334
Add preference extend and middleware to allow translations to be used…
jasonvarga Jan 11, 2023
e366c16
ability to defer permission registration until after locale has been …
jasonvarga Jan 11, 2023
a35f750
Apply similar changes to utilities
jasonvarga Jan 11, 2023
398da66
Might as well avoid using deprecated code now
jasonvarga Jan 11, 2023
5f81ff7
Pass preferences into section closure
jasonvarga Jan 12, 2023
efa60e6
Add simpler syntax for registering preferences
jasonvarga Jan 12, 2023
e652e7a
avoid facade
jasonvarga Jan 12, 2023
93329f9
prevent overriding section display names
jasonvarga Jan 12, 2023
6d9416b
Add test coverage for `Nav::extend()`’d sections that don’t follow ti…
jesseleite Jan 12, 2023
c2b3098
Only pass along `display` if it’s explicitly configured for renaming …
jesseleite Jan 12, 2023
6eefad5
Pass failing tests by moving section display and rename logic into `N…
jesseleite Jan 12, 2023
666c723
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Jan 12, 2023
ddf695a
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 13, 2023
d5261cd
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
95a4b3b
Merge branch 'master' into feature/preferences-ui
jasonvarga Jan 13, 2023
f9673de
Disable save part of button and leave dropdown active
jasonvarga Jan 13, 2023
77c3115
Leave dropdown active
jasonvarga Jan 13, 2023
421e81e
Add heading
jasonvarga Jan 13, 2023
01e883e
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
1f56155
Merge branch 'master' into permission-translations
jasonvarga Jan 13, 2023
f2fa807
unnecessary
jasonvarga Jan 13, 2023
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
22 changes: 22 additions & 0 deletions src/Auth/Permissions.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,34 @@

namespace Statamic\Auth;

use Facades\Statamic\Auth\CorePermissions;

class Permissions
{
protected $extensions = [];
protected $permissions = [];
protected $groups = [];
protected $pendingGroup = null;

public function boot()
{
$early = $this->permissions;
$this->permissions = [];

CorePermissions::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}

$this->permissions = array_merge($this->permissions, $early);
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make(string $value)
{
$permission = (new Permission)->value($value);
Expand Down
30 changes: 12 additions & 18 deletions src/CP/Utilities/CoreUtilities.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,7 @@ class CoreUtilities
{
public static function boot()
{
Utility::make('cache')
Utility::register('cache')
->action([CacheController::class, 'index'])
->title(__('Cache Manager'))
->icon('cache')
Expand All@@ -26,60 +26,54 @@ public static function boot()
->routes(function ($router) {
$router->post('cache/{cache}', [CacheController::class, 'clear'])->name('clear');
$router->post('cache/{cache}/warm', [CacheController::class, 'warm'])->name('warm');
})
->register();
});

Utility::make('phpinfo')
Utility::register('phpinfo')
->action(PhpInfoController::class)
->title(__('PHP Info'))
->icon('php')
->description(__('statamic::messages.phpinfo_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/phpinfo'))
->register();
->docsUrl(Statamic::docsUrl('utilities/phpinfo'));

Utility::make('search')
Utility::register('search')
->view('statamic::utilities.search')
->title(__('Search'))
->icon('search-utility')
->description(__('statamic::messages.search_utility_description'))
->routes(function ($router) {
$router->post('/', [UpdateSearchController::class, 'update'])->name('update');
})
->register();
});

Utility::make('email')
Utility::register('email')
->view('statamic::utilities.email')
->title(__('Email'))
->icon('email-utility')
->description(__('statamic::messages.email_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/email'))
->routes(function ($router) {
$router->post('/', [EmailController::class, 'send']);
})
->register();
});

Utility::make('licensing')
Utility::register('licensing')
->action([LicensingController::class, 'show'])
->title(__('Licensing'))
->icon('licensing')
->description(__('statamic::messages.licensing_utility_description'))
->docsUrl(Statamic::docsUrl('licensing'))
->routes(function ($router) {
$router->get('refresh', [LicensingController::class, 'refresh'])->name('refresh');
})
->register();
});

if (config('statamic.git.enabled') && Statamic::pro()) {
Utility::make('git')
Utility::register('git')
->action([GitController::class, 'index'])
->title('Git')
->icon('git')
->description(__('statamic::messages.git_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/git'))
->routes(function ($router) {
$router->post('/', [GitController::class, 'commit'])->name('commit');
})
->register();
});
}
}
}
1 change: 1 addition & 0 deletions src/CP/Utilities/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,6 +104,7 @@ public function routes(Closure $routes = null)
return $this->fluentlyGetOrSet('routes')->args(func_get_args());
}

/** @deprecated */
public function register()
{
\Statamic\Facades\Utility::push($this);
Expand Down
32 changes: 31 additions & 1 deletion src/CP/Utilities/UtilityRepository.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,27 +2,55 @@

namespace Statamic\CP\Utilities;

use Facades\Statamic\CP\Utilities\CoreUtilities;
use Illuminate\Support\Facades\Route;
use Statamic\Facades\User;

class UtilityRepository
{
protected $utilities;
protected $extensions = [];

public function __construct()
{
$this->utilities = collect([]);
}

public function boot()
{
CoreUtilities::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make($handle)
{
return (new Utility)->handle($handle);
}

public function push(Utility $utility)
public function register($utility)
{
if (! $utility instanceof Utility) {
$utility = $this->make($utility);
}

$this->utilities[$utility->handle()] = $utility;

return $utility;
}

/** @deprecated */
public function push(Utility $utility)
{
$this->register($utility);

return $this;
}

Expand All@@ -45,6 +73,8 @@ public function find($handle)

public function routes()
{
$this->boot();

Route::namespace('\\')->prefix('utilities')->name('utilities.')->group(function () {
$this->all()->each(function ($utility) {
if ($utility->action()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

/**
* @method static mixed|null make($handle)
* @method static self push(Utility $utility)
* @method static \Statamic\CP\Utilities\Utility register($utility)
* @method static mixed all()
* @method static mixed authorized()
* @method static mixed find($handle)
Expand Down
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootPermissions.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Permission;

class BootPermissions
{
public function handle($request, Closure $next)
{
Permission::boot();

return $next($request);
}
}
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootUtilities.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Utility;

class BootUtilities
{
public function handle($request, Closure $next)
{
Utility::boot();

return $next($request);
}
}
2 changes: 1 addition & 1 deletion src/Preferences/Preferences.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -230,7 +230,7 @@ public function section($handle, $label, $permissions = null)

$this->pendingSection = $handle;

$permissions();
$permissions($this);

$this->pendingSection = null;
}
Expand Down
5 changes: 0 additions & 5 deletions src/Providers/AuthServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@

namespace Statamic\Providers;

use Facades\Statamic\Auth\CorePermissions;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
Expand DownExpand Up@@ -90,10 +89,6 @@ public function boot()
return optional(User::fromUser($user))->hasPermission($ability) === true ? true : null;
});

$this->app->booted(function () {
CorePermissions::boot();
});

foreach ($this->policies as $key => $policy) {
Gate::policy($key, $policy);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Providers/CpServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Statamic\CP\Utilities\CoreUtilities;
use Statamic\CP\Utilities\UtilityRepository;
use Statamic\Extensions\Translation\Loader;
use Statamic\Extensions\Translation\Translator;
Expand All@@ -33,8 +32,6 @@ public function boot()
View::composer(NavComposer::VIEWS, NavComposer::class);
View::composer(CustomLogoComposer::VIEWS, CustomLogoComposer::class);

CoreUtilities::boot();

Blade::directive('cp_svg', function ($expression) {
return "<?php echo Statamic::svg({$expression}) ?>";
});
Expand DownExpand Up@@ -83,7 +80,9 @@ protected function registerMiddlewareGroups()
$router->middlewareGroup('statamic.cp.authenticated', [
\Statamic\Http\Middleware\CP\Authorize::class,
\Statamic\Http\Middleware\CP\Localize::class,
\Statamic\Http\Middleware\CP\BootPermissions::class,
\Statamic\Http\Middleware\CP\BootPreferences::class,
\Statamic\Http\Middleware\CP\BootUtilities::class,
\Statamic\Http\Middleware\CP\CountUsers::class,
\Statamic\Http\Middleware\DeleteTemporaryFileUploads::class,
]);
Expand Down
96 changes: 96 additions & 0 deletions tests/CP/Utilities/UtilityRepositoryTest.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
<?php

namespace Tests\CP\Utilities;

use Illuminate\Support\Collection;
use Statamic\CP\Utilities\Utility;
use Statamic\CP\Utilities\UtilityRepository;
use Tests\TestCase;

class UtilityRepositoryTest extends TestCase
{
/**
* @test
*
* @dataProvider registerMethodProvider
*/
public function it_registers_a_utility($registerMethod)
{
$utilities = new UtilityRepository;
$this->assertInstanceOf(Collection::class, $utilities->all());
$this->assertCount(0, $utilities->all());

$utility = $utilities->make('one');
$this->assertCount(0, $utilities->all());

$utilities->$registerMethod($utility);
$this->assertEquals(['one' => $utility], $utilities->all()->all());
$this->assertEquals($utility, $utilities->find('one'));
}

public function registerMethodProvider()
{
return [
'register' => ['register'],
'push' => ['push'], // @deprecated
];
}

/** @test */
public function it_registers_a_utility_via_a_string()
{
$utilities = new UtilityRepository;

$utility = $utilities->register('one');

$this->assertInstanceOf(Utility::class, $utility);
$this->assertEquals('one', $utility->handle());
$this->assertCount(1, $utilities->all());
$this->assertEquals(['one' => $utility], $utilities->all()->all());
}

/** @test */
public function it_defers_registration_until_boot_using_extend_method()
{
$utilities = new UtilityRepository;
$callbackRan = false;

$utilities->extend(function ($arg) use ($utilities, &$callbackRan) {
$this->assertEquals($utilities, $arg);
$callbackRan = true;
});

$this->assertFalse($callbackRan);

$utilities->boot();

$this->assertTrue($callbackRan);
}

/** @test */
public function booting_more_than_once_just_updates_the_utilities()
{
// This makes sure that booting a second time doesn't duplicate
// any utilities. It should just update/replace the existing ones.
// We boot once early so that routes can get registered, and
// then again after the user's locale preference is set so
// that the translations for labels etc use the right language.

$utilities = new UtilityRepository;

$utilities->extend(function ($utilities) {
$utilities->register('test')
->title(__('and')); // using a translation that will likely never change.
});

$utilities->boot();

$this->assertEquals(['and'], $utilities->all()->map->title()->values()->all());

app()->setLocale('fr');

$utilities->boot();

$this->assertEquals(['et'], $utilities->all()->map->title()->values()->all());
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
80dbb06
This is now normalized by UserNavConfig.
jesseleite Sep 12, 2022
8165a66
Process newly created child items the same way we process regular items.
jesseleite Sep 12, 2022
16924bb
Can't do that in PHP 7.4 my dear boy.
jesseleite Sep 13, 2022
2ec1918
Use `whenNotEmpty()`, but still apparently can't shorthand `fn()` it.
jesseleite Sep 13, 2022
90e4bf3
Refactor to separate params.
jesseleite Sep 13, 2022
a781a9a
Ensure we can rebuild nav from fresh slate.
jesseleite Nov 30, 2022
58be4f9
Support tracking preference manipulations on each NavItem instance fo…
jesseleite Nov 30, 2022
49d35c6
Track preference manipulations.
jesseleite Nov 30, 2022
4542c42
Allow passing of different preferences into `Nav::build()`.
jesseleite Nov 30, 2022
5e87094
Rename `UserNavConfig` to `NavPreferencesConfig`.
jesseleite Nov 30, 2022
6d8cfd9
Lots of front end.
jesseleite Nov 30, 2022
429e06a
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Nov 30, 2022
63093d8
The Nav and NavItem JSON resources used by the builder.
jesseleite Nov 30, 2022
84bd7e3
Hardcode link to nav.
jesseleite Nov 30, 2022
518a6da
Hide breadcrumb, because there is no preferences section yet (maybe l…
jesseleite Nov 30, 2022
6429bde
Normalize `original` for simpler logic in back end.
jesseleite Nov 30, 2022
61e2823
Wire up discard changes behaviour.
jesseleite Nov 30, 2022
088b26a
Icons.
jesseleite Nov 30, 2022
c6acbb7
Fix issue with new item IDs.
jesseleite Nov 30, 2022
e108e5f
Route and controller.
jesseleite Nov 30, 2022
4a438be
Add Nav Pref index and icon
jackmcdade Dec 6, 2022
3d7dcf4
Move `PreferenceController` and fix destroy route to actually use del…
jesseleite Dec 6, 2022
814e920
Wire up routes and controllers for default, role, and user nav prefer…
jesseleite Dec 6, 2022
a517164
Move into `CoreNav`.
jesseleite Dec 6, 2022
2629fd1
Add `buildDefault()` alias.
jesseleite Dec 6, 2022
b2b7ffe
Update front end.
jesseleite Dec 6, 2022
f273d75
Update tests.
jesseleite Dec 6, 2022
1b4bef9
Only show section if roles exist.
jesseleite Dec 6, 2022
41f2713
Add test coverage for new `Preference::preventMergingChildren()` method.
jesseleite Dec 8, 2022
336a22d
Implement `preventMergingChildren()`.
jesseleite Dec 8, 2022
aa73758
Prevent merging of children in nav preferences.
jesseleite Dec 8, 2022
74c4a79
Alias `get()` to `getPreference()`, like we do with `set()`.
jesseleite Dec 8, 2022
31c0c3e
Ensure we’re loading default preferences nav in editor.
jesseleite Dec 8, 2022
dd2ff77
Ensure we’re loading role preferences nav in editor.
jesseleite Dec 8, 2022
678921e
Alias `remove()` to `removePreference()`, like we do with `set()` and…
jesseleite Dec 8, 2022
8f389bf
Scope `Statamic.$preferences` api endpoints to prevent conflicts with…
jesseleite Dec 8, 2022
4198e51
Rename `buildDefault()` to `buildWithoutPreferences()` to avoid confu…
jesseleite Dec 8, 2022
8e7e0f8
Fix resetting of nav prefs, nav precedence on load, and clean up rout…
jesseleite Dec 8, 2022
099819a
Require pro to edit anything other than your own user preferences.
jesseleite Dec 8, 2022
71d92a4
Show confirmation modal when resetting.
jesseleite Dec 8, 2022
fa299a7
Add test to prove that first assigned user role takes precedence.
jesseleite Dec 8, 2022
d3a0d65
Fix discard changes regression.
jesseleite Dec 8, 2022
5f09b9f
Handle `.disabled` class on `.btn-group` buttons.
jesseleite Dec 8, 2022
1c4dbd2
Show reset option as warning.
jesseleite Dec 8, 2022
9c93d20
Handle ‘save as’ dropdown options.
jesseleite Dec 8, 2022
836e19f
Make index messaging a bit more consistent with other pages.
jesseleite Dec 8, 2022
cbcf4d9
Intelligently output save as options for nav builder.
jesseleite Dec 8, 2022
96d9a5d
Fix pro/super check.
jesseleite Dec 8, 2022
7255ae2
run npm install
jasonvarga Dec 9, 2022
2c391d3
add override
jasonvarga Dec 9, 2022
6629232
Merge branch 'fix-package-lock' of https://github.com/statamic/cms in…
jesseleite Dec 9, 2022
341c32d
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Dec 9, 2022
826f327
Rename to ‘CP Nav’ to avoid confusion with ‘Navigation’.
jesseleite Dec 9, 2022
328556e
Fix unique key on v-for warning.
jesseleite Dec 9, 2022
cab8390
Misc cleanup.
jesseleite Dec 9, 2022
bcbd31c
Vue payload to yaml transformation logic.
jesseleite Dec 10, 2022
b3340fd
Fix missing `display` and `url` on newly created items.
jesseleite Dec 10, 2022
3d52925
Allow removing of `@create`’d items (instead of hiding via `@remove` …
jesseleite Dec 10, 2022
7d2b40c
If there’s nothing to save, remove preference instead of saving `nav:…
jesseleite Dec 10, 2022
d9322b7
Fix overzealous `@inherit` minification when reordering.
jesseleite Dec 11, 2022
f6c8c94
Avoid submitting custom sections that have no items.
jesseleite Dec 11, 2022
1bbb1f8
Cmd+s to save.
jesseleite Dec 12, 2022
e907c10
Handle section `action: ‘@remove’` in config normalizer.
jesseleite Dec 12, 2022
af1ffc8
This shouldn’t be needed anymore, since the `normalize()` method abov…
jesseleite Dec 13, 2022
bf2a1c3
Add section manipulations into `build()` output.
jesseleite Dec 13, 2022
72bc6f9
Pluck `items` and `display` so that nav sidebar views continue to wor…
jesseleite Dec 13, 2022
08ce16a
Ensure front end merges whole section config in with items, not just …
jesseleite Dec 13, 2022
463c338
Refactor for new initial nav format on load.
jesseleite Dec 14, 2022
cf4e147
Ensure proper fallbacks.
jesseleite Dec 14, 2022
6b0c96a
Should use `NavItem::snakeCase()` for consistency.
jesseleite Dec 14, 2022
33e7857
Refactor payload to account for new `display_original` section changes.
jesseleite Dec 14, 2022
e67a60b
Improve section minification.
jesseleite Dec 14, 2022
8f33987
Ensure we also pass action to server.
jesseleite Dec 14, 2022
048d8ce
`Nav::build()` was always returning a collection, so this should too.
jesseleite Dec 14, 2022
c45acdd
Pass tests again.
jesseleite Dec 14, 2022
56a80b1
Actually, let’s avoid this `pluck()` and just fix the views.
jesseleite Dec 14, 2022
8210108
Rely on `display_original` for more consistent `itemsAreReordered` lo…
jesseleite Dec 14, 2022
474f565
Only ever show `@inherit` action when section config is empty, for re…
jesseleite Dec 14, 2022
4200a32
Ensure user can still see hidden items in builder on reload.
jesseleite Dec 14, 2022
c0e1b17
Properly handle `withHidden()` state when rebuilding.
jesseleite Dec 14, 2022
359ab19
Reload on save in order to see changes on save.
jesseleite Dec 14, 2022
fc6a8f9
This shoulda been in data.
jesseleite Dec 14, 2022
a831b26
Rename isNew to isCustom and use a new icon
jackmcdade Dec 14, 2022
5e32408
Autofocus first field in stacks, support a plain "enter" key binding
jackmcdade Dec 14, 2022
6a3811b
Use the proper prop data type
jackmcdade Dec 14, 2022
5fe9a23
Prevent hiding `CP Nav` item, so user can always access it.
jesseleite Dec 14, 2022
18233f7
Simplify that last commit.
jesseleite Dec 14, 2022
1b6d7f2
Hook up Expand All and Collapse All controls
jackmcdade Dec 14, 2022
56c784f
Don't need depth here.
jackmcdade Dec 14, 2022
981e6b2
Fix `isSectionNode()` for top level tree items.
jesseleite Dec 14, 2022
de3f29e
Clean up a few JS errors.
jesseleite Dec 14, 2022
db6252a
Make `prevent_hiding` work at section level.
jesseleite Dec 14, 2022
895a661
Prevent user from accidentally hiding CP Nav by dragging into hidden …
jesseleite Dec 14, 2022
e34415a
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
d8b43dd
Snip snap ✂️
jesseleite Dec 14, 2022
a378c98
Preferences Dropdown in the Global Header
jackmcdade Dec 14, 2022
f7b663e
Add `configure cp nav` permission.
jesseleite Dec 14, 2022
1290562
Rename/fix `Statamic.$preferences` endpoints.
jesseleite Dec 14, 2022
14af432
Wrap these routes with pro/permission checks.
jesseleite Dec 14, 2022
b1e3f73
Hook up redirect at controller level.
jesseleite Dec 14, 2022
5179f8c
Update permission check for nav builder breadcrumb link.
jesseleite Dec 14, 2022
f45d787
Remove from core nav, since Jack is adding cool gear in top nav.
jesseleite Dec 14, 2022
2eede65
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
e5e54b9
Pass tests.
jesseleite Dec 14, 2022
7eaebe5
Forgot to snip snap ✂️
jesseleite Dec 15, 2022
d3ecb7e
Improve styling for hidden sections.
jesseleite Dec 15, 2022
b716bcd
Ensure we properly minify section hide action.
jesseleite Dec 15, 2022
b691367
Expand and collapse items in top level tree as well.
jesseleite Dec 15, 2022
fa38a80
Hide hidden sections in built navs.
jesseleite Dec 15, 2022
82a1245
Fix JS errors.
jesseleite Dec 15, 2022
b946954
Ensure section level manipulations get properly set on load.
jesseleite Dec 15, 2022
f1848e3
Fix string replace.
jesseleite Dec 15, 2022
b1d6528
Return `$items` directly.
jesseleite Dec 15, 2022
2fbf6e6
Fix action handling in section minification.
jesseleite Dec 15, 2022
43bd885
Confirm removal of custom section when it contains items.
jesseleite Dec 15, 2022
f066f18
initial preferences ui
jasonvarga Dec 15, 2022
9d3e9cd
Apply fixes from StyleCI
StyleCIBot Dec 15, 2022
4458c04
Remove preferences if form field is set to the default value
jasonvarga Dec 15, 2022
36393f8
Flesh out allowed section actions and modifications as constants.
jesseleite Dec 15, 2022
a0b9711
add prop to allow publish form to reload on save
jasonvarga Dec 15, 2022
38428e2
Make permission more generic
jasonvarga Dec 15, 2022
c986eec
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 15, 2022
e99ae57
Wire up user/default/role forms
jasonvarga Dec 15, 2022
f09bfdc
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 16, 2022
f7a9a9e
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Dec 16, 2022
e28020b
Remove section `@inherit`s from config after processing reordering.
jesseleite Dec 16, 2022
793992c
Fix removing of sections and items after last sections overhaul.
jesseleite Dec 16, 2022
20ff852
Refactor `@remove` to `@hide`.
jesseleite Dec 16, 2022
11e356f
Fix undoing and saving ‘default’ level changes at user level, so that…
jesseleite Dec 16, 2022
57470dc
Apply the same fix at the role level.
jesseleite Dec 16, 2022
8156b53
Allow nulling/removing at default preferences level though.
jesseleite Dec 16, 2022
40e9b5d
Fix `@create` custom section items.
jesseleite Dec 17, 2022
e6eb308
Prevent adding item children to item children.
jesseleite Dec 17, 2022
b3cecce
Pass tests again, ensuring we don’t duplicate modified items in place.
jesseleite Dec 17, 2022
d23aa59
Rename to `NavPreferencesNormalizer::fromPreferences()` for clarity.
jesseleite Dec 17, 2022
878aa4b
Move all nav building logic out into a `NavBuilder` class so that we …
jesseleite Dec 17, 2022
15167da
Clarify why `Nav::extend()` is needed in test.
jesseleite Dec 17, 2022
9edab4d
Show custom section as ‘Custom Section’.
jesseleite Dec 17, 2022
fc1aad7
Misc cleanup.
jesseleite Dec 18, 2022
2a4dae0
Add support for `reorder` on item children.
jesseleite Dec 18, 2022
702f26a
Fix `@move` action when moving a parent item into the children of ano…
jesseleite Dec 18, 2022
93bb5c1
Ensure aliased items have no children unless explicitly set.
jesseleite Dec 18, 2022
4128730
Show configured `children` on aliased items, etc.
jesseleite Dec 18, 2022
e83fb1c
Show moved item icon (WIP).
jesseleite Dec 18, 2022
71a2e9e
Fix `@create`’d children within `@alias`’d items.
jesseleite Dec 18, 2022
ef88276
Pass tests again and cleanup todo’s.
jesseleite Dec 18, 2022
43387ef
Flesh out builder test coverage for recent fixes.
jesseleite Dec 18, 2022
a01291d
Add `syncOriginal()` functionality to `NavItem` class so we can detec…
jesseleite Dec 19, 2022
390dce0
Sync original on each item just before applying nav preference manipu…
jesseleite Dec 19, 2022
9cd1297
Pass original nav item state to tree data in front end builder.
jesseleite Dec 19, 2022
3382d44
Show icon and tooltip for renamed sections.
jesseleite Dec 19, 2022
35458d9
Ensure newly resolved child items sync their original state as well.
jesseleite Dec 19, 2022
b3a55e5
Ensure we can get current section from original children.
jesseleite Dec 19, 2022
624bd04
Fix updating of item manipulations when dragging or updating items.
jesseleite Dec 19, 2022
7d8594e
Fix JS error.
jesseleite Dec 19, 2022
8bff1ea
Fix regression since adding ‘section’ data to nested child items.
jesseleite Dec 19, 2022
a68025b
Fix overzealous `@move` action in front end.
jesseleite Dec 19, 2022
069c80f
Collapse top level items by default, to be consistent with the rest o…
jesseleite Dec 19, 2022
e289921
Fix ordering error on PHP 7.4.
jesseleite Dec 19, 2022
c743756
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 19, 2022
4afb33f
Fix duplicate hidden items regression.
jesseleite Dec 19, 2022
767ab26
Clean up `updateItemAction()` method using more readable switch case.
jesseleite Dec 19, 2022
22483cd
Get and pass clean editable nav item urls to nav builder.
jesseleite Dec 19, 2022
06fbbee
Transform on save, so that we don’t store local domain or configurabl…
jesseleite Dec 19, 2022
a5e20da
Move modified children `action` check to JS, where we handle the rest…
jesseleite Dec 19, 2022
25b2045
Fix reordering on child items payload on save.
jesseleite Dec 19, 2022
5deff45
Fix inability to move item out of an item’s children within the same …
jesseleite Dec 19, 2022
77bf587
Pass tests again.
jesseleite Dec 19, 2022
499072b
Fix disappearing of moved/aliased items by using item’s original ID w…
jesseleite Dec 20, 2022
9afd1aa
Whoops, not inherit.
jesseleite Dec 20, 2022
5ec4135
Improve reorder detection logic.
jesseleite Dec 20, 2022
57ef831
TIL, we cannot use our `Arr::get()` to get `some::id` with double col…
jesseleite Dec 20, 2022
1b18a4e
If `withHidden`, resolve/build all children, to fix cloned IDs bug in…
jesseleite Dec 21, 2022
503ce64
Fix action detection bug.
jesseleite Dec 21, 2022
4dc88ae
Handle empty sections.
jesseleite Dec 21, 2022
ba65452
Make sure we also update action on the parent node they dragged out of.
jesseleite Dec 21, 2022
8ec2f3d
Fix bug when trying to drag newly created/aliased item into another s…
jesseleite Dec 21, 2022
311a5e5
Builder doesn’t need children in manipulations.
jesseleite Dec 21, 2022
151984e
Handle tracking of renamed core sections.
jesseleite Dec 21, 2022
7cd8417
Fix and clean up drag level logic.
jesseleite Dec 21, 2022
413ae4f
Fix more JS errors.
jesseleite Dec 21, 2022
44a027a
Fix a whole bunch of moved/aliased/hidden item issues.
jesseleite Dec 21, 2022
2096ed0
Fix section reordering bug when core section has no items.
jesseleite Dec 22, 2022
f8324a0
Require both display and url.
jesseleite Dec 22, 2022
156e7aa
Remove console.log
jesseleite Dec 22, 2022
693af81
Whoops!
jesseleite Jan 3, 2023
fab9fa0
Removing flex fixes icons not showing in safari
jasonvarga Jan 3, 2023
09d068b
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Jan 3, 2023
5061db1
Never delete from manipulations for `@create`’d items, since there is…
jesseleite Jan 3, 2023
0f72eca
Never `@alias` a `@create`’d item.
jesseleite Jan 3, 2023
12f658a
Magic section setter should never look at nav item children.
jesseleite Jan 3, 2023
433e5c6
Allow overriding of preferences using `[]` when using `preventMerging…
jesseleite Jan 3, 2023
2ecd30d
Remove `nav: @override` in favour of `nav: []` for overriding of nav …
jesseleite Jan 3, 2023
8484154
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b0bae04
Add 'save as' functionality ...
jasonvarga Jan 4, 2023
a8d1ede
Validate
jasonvarga Jan 4, 2023
20cb443
Prevent "are you sure you want to navigate away" dialog when saving
jasonvarga Jan 4, 2023
d75bd14
Remove redundant `Customize` link in favour of `Modified` status.
jesseleite Jan 4, 2023
ba6889b
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b6868b5
Always touchdown for Jason 🏈
jesseleite Jan 4, 2023
160c3ad
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
ed2532b
Show modified text instead of customize link
jasonvarga Jan 4, 2023
04e990e
translate
jasonvarga Jan 4, 2023
a92d780
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
31d6aba
translate
jasonvarga Jan 4, 2023
e8caaf6
Adjust for translations
jasonvarga Jan 4, 2023
181bfba
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
5e12a53
make consistent with navs
jasonvarga Jan 4, 2023
277a45f
Remove 'Global' here, since we don't say this in page titles / save d…
jesseleite Jan 4, 2023
57a41ba
Remove redundant heading
jasonvarga Jan 4, 2023
7107063
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
9aea2c4
consistency
jasonvarga Jan 4, 2023
3470d51
Make sure Save To... dropdown doesn't clip or shrink child content
jackmcdade Jan 5, 2023
3006d22
Small improvements to make `NavTransformer` easier to test.
jesseleite Jan 5, 2023
b9bc2e5
Add whole bunch of `NavTransformer` test coverage.
jesseleite Jan 6, 2023
9066391
Add test coverage for intelligent url handling on save.
jesseleite Jan 6, 2023
a08b5d9
Add test coverage for complex json payload copied from actual vue sub…
jesseleite Jan 6, 2023
d65e105
delete method requires putting data into config
jasonvarga Jan 10, 2023
4de36c0
unused
jasonvarga Jan 10, 2023
fe03ebb
inline
jasonvarga Jan 10, 2023
edba03e
prevent saving through save button dropdown when unchanged
jasonvarga Jan 10, 2023
881e162
disable the dropdown when unchanged
jasonvarga Jan 10, 2023
bb4bb92
*slaps own wrist*
jasonvarga Jan 10, 2023
233cbd0
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 10, 2023
994e0c1
Fix issue with preferences property cache ...
jasonvarga Jan 10, 2023
5058985
CP locale can fall back to role and default preferences
jasonvarga Jan 10, 2023
5c470dc
remove comma for diff
jasonvarga Jan 11, 2023
e05d3fd
make save as dropdown consistent with nav
jasonvarga Jan 11, 2023
db6afcb
localize preference display and instructions
jasonvarga Jan 11, 2023
49c4334
Add preference extend and middleware to allow translations to be used…
jasonvarga Jan 11, 2023
e366c16
ability to defer permission registration until after locale has been …
jasonvarga Jan 11, 2023
a35f750
Apply similar changes to utilities
jasonvarga Jan 11, 2023
398da66
Might as well avoid using deprecated code now
jasonvarga Jan 11, 2023
5f81ff7
Pass preferences into section closure
jasonvarga Jan 12, 2023
efa60e6
Add simpler syntax for registering preferences
jasonvarga Jan 12, 2023
e652e7a
avoid facade
jasonvarga Jan 12, 2023
93329f9
prevent overriding section display names
jasonvarga Jan 12, 2023
6d9416b
Add test coverage for `Nav::extend()`’d sections that don’t follow ti…
jesseleite Jan 12, 2023
c2b3098
Only pass along `display` if it’s explicitly configured for renaming …
jesseleite Jan 12, 2023
6eefad5
Pass failing tests by moving section display and rename logic into `N…
jesseleite Jan 12, 2023
666c723
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Jan 12, 2023
ddf695a
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 13, 2023
d5261cd
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
95a4b3b
Merge branch 'master' into feature/preferences-ui
jasonvarga Jan 13, 2023
f9673de
Disable save part of button and leave dropdown active
jasonvarga Jan 13, 2023
77c3115
Leave dropdown active
jasonvarga Jan 13, 2023
421e81e
Add heading
jasonvarga Jan 13, 2023
01e883e
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
1f56155
Merge branch 'master' into permission-translations
jasonvarga Jan 13, 2023
f2fa807
unnecessary
jasonvarga Jan 13, 2023
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
22 changes: 22 additions & 0 deletions src/Auth/Permissions.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,34 @@

namespace Statamic\Auth;

use Facades\Statamic\Auth\CorePermissions;

class Permissions
{
protected $extensions = [];
protected $permissions = [];
protected $groups = [];
protected $pendingGroup = null;

public function boot()
{
$early = $this->permissions;
$this->permissions = [];

CorePermissions::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}

$this->permissions = array_merge($this->permissions, $early);
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make(string $value)
{
$permission = (new Permission)->value($value);
Expand Down
30 changes: 12 additions & 18 deletions src/CP/Utilities/CoreUtilities.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,7 @@ class CoreUtilities
{
public static function boot()
{
Utility::make('cache')
Utility::register('cache')
->action([CacheController::class, 'index'])
->title(__('Cache Manager'))
->icon('cache')
Expand All@@ -26,60 +26,54 @@ public static function boot()
->routes(function ($router) {
$router->post('cache/{cache}', [CacheController::class, 'clear'])->name('clear');
$router->post('cache/{cache}/warm', [CacheController::class, 'warm'])->name('warm');
})
->register();
});

Utility::make('phpinfo')
Utility::register('phpinfo')
->action(PhpInfoController::class)
->title(__('PHP Info'))
->icon('php')
->description(__('statamic::messages.phpinfo_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/phpinfo'))
->register();
->docsUrl(Statamic::docsUrl('utilities/phpinfo'));

Utility::make('search')
Utility::register('search')
->view('statamic::utilities.search')
->title(__('Search'))
->icon('search-utility')
->description(__('statamic::messages.search_utility_description'))
->routes(function ($router) {
$router->post('/', [UpdateSearchController::class, 'update'])->name('update');
})
->register();
});

Utility::make('email')
Utility::register('email')
->view('statamic::utilities.email')
->title(__('Email'))
->icon('email-utility')
->description(__('statamic::messages.email_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/email'))
->routes(function ($router) {
$router->post('/', [EmailController::class, 'send']);
})
->register();
});

Utility::make('licensing')
Utility::register('licensing')
->action([LicensingController::class, 'show'])
->title(__('Licensing'))
->icon('licensing')
->description(__('statamic::messages.licensing_utility_description'))
->docsUrl(Statamic::docsUrl('licensing'))
->routes(function ($router) {
$router->get('refresh', [LicensingController::class, 'refresh'])->name('refresh');
})
->register();
});

if (config('statamic.git.enabled') && Statamic::pro()) {
Utility::make('git')
Utility::register('git')
->action([GitController::class, 'index'])
->title('Git')
->icon('git')
->description(__('statamic::messages.git_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/git'))
->routes(function ($router) {
$router->post('/', [GitController::class, 'commit'])->name('commit');
})
->register();
});
}
}
}
1 change: 1 addition & 0 deletions src/CP/Utilities/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,6 +104,7 @@ public function routes(Closure $routes = null)
return $this->fluentlyGetOrSet('routes')->args(func_get_args());
}

/** @deprecated */
public function register()
{
\Statamic\Facades\Utility::push($this);
Expand Down
32 changes: 31 additions & 1 deletion src/CP/Utilities/UtilityRepository.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,27 +2,55 @@

namespace Statamic\CP\Utilities;

use Facades\Statamic\CP\Utilities\CoreUtilities;
use Illuminate\Support\Facades\Route;
use Statamic\Facades\User;

class UtilityRepository
{
protected $utilities;
protected $extensions = [];

public function __construct()
{
$this->utilities = collect([]);
}

public function boot()
{
CoreUtilities::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make($handle)
{
return (new Utility)->handle($handle);
}

public function push(Utility $utility)
public function register($utility)
{
if (! $utility instanceof Utility) {
$utility = $this->make($utility);
}

$this->utilities[$utility->handle()] = $utility;

return $utility;
}

/** @deprecated */
public function push(Utility $utility)
{
$this->register($utility);

return $this;
}

Expand All@@ -45,6 +73,8 @@ public function find($handle)

public function routes()
{
$this->boot();

Route::namespace('\\')->prefix('utilities')->name('utilities.')->group(function () {
$this->all()->each(function ($utility) {
if ($utility->action()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

/**
* @method static mixed|null make($handle)
* @method static self push(Utility $utility)
* @method static \Statamic\CP\Utilities\Utility register($utility)
* @method static mixed all()
* @method static mixed authorized()
* @method static mixed find($handle)
Expand Down
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootPermissions.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Permission;

class BootPermissions
{
public function handle($request, Closure $next)
{
Permission::boot();

return $next($request);
}
}
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootUtilities.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Utility;

class BootUtilities
{
public function handle($request, Closure $next)
{
Utility::boot();

return $next($request);
}
}
2 changes: 1 addition & 1 deletion src/Preferences/Preferences.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -230,7 +230,7 @@ public function section($handle, $label, $permissions = null)

$this->pendingSection = $handle;

$permissions();
$permissions($this);

$this->pendingSection = null;
}
Expand Down
5 changes: 0 additions & 5 deletions src/Providers/AuthServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@

namespace Statamic\Providers;

use Facades\Statamic\Auth\CorePermissions;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
Expand DownExpand Up@@ -90,10 +89,6 @@ public function boot()
return optional(User::fromUser($user))->hasPermission($ability) === true ? true : null;
});

$this->app->booted(function () {
CorePermissions::boot();
});

foreach ($this->policies as $key => $policy) {
Gate::policy($key, $policy);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Providers/CpServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Statamic\CP\Utilities\CoreUtilities;
use Statamic\CP\Utilities\UtilityRepository;
use Statamic\Extensions\Translation\Loader;
use Statamic\Extensions\Translation\Translator;
Expand All@@ -33,8 +32,6 @@ public function boot()
View::composer(NavComposer::VIEWS, NavComposer::class);
View::composer(CustomLogoComposer::VIEWS, CustomLogoComposer::class);

CoreUtilities::boot();

Blade::directive('cp_svg', function ($expression) {
return "<?php echo Statamic::svg({$expression}) ?>";
});
Expand DownExpand Up@@ -83,7 +80,9 @@ protected function registerMiddlewareGroups()
$router->middlewareGroup('statamic.cp.authenticated', [
\Statamic\Http\Middleware\CP\Authorize::class,
\Statamic\Http\Middleware\CP\Localize::class,
\Statamic\Http\Middleware\CP\BootPermissions::class,
\Statamic\Http\Middleware\CP\BootPreferences::class,
\Statamic\Http\Middleware\CP\BootUtilities::class,
\Statamic\Http\Middleware\CP\CountUsers::class,
\Statamic\Http\Middleware\DeleteTemporaryFileUploads::class,
]);
Expand Down
96 changes: 96 additions & 0 deletions tests/CP/Utilities/UtilityRepositoryTest.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
<?php

namespace Tests\CP\Utilities;

use Illuminate\Support\Collection;
use Statamic\CP\Utilities\Utility;
use Statamic\CP\Utilities\UtilityRepository;
use Tests\TestCase;

class UtilityRepositoryTest extends TestCase
{
/**
* @test
*
* @dataProvider registerMethodProvider
*/
public function it_registers_a_utility($registerMethod)
{
$utilities = new UtilityRepository;
$this->assertInstanceOf(Collection::class, $utilities->all());
$this->assertCount(0, $utilities->all());

$utility = $utilities->make('one');
$this->assertCount(0, $utilities->all());

$utilities->$registerMethod($utility);
$this->assertEquals(['one' => $utility], $utilities->all()->all());
$this->assertEquals($utility, $utilities->find('one'));
}

public function registerMethodProvider()
{
return [
'register' => ['register'],
'push' => ['push'], // @deprecated
];
}

/** @test */
public function it_registers_a_utility_via_a_string()
{
$utilities = new UtilityRepository;

$utility = $utilities->register('one');

$this->assertInstanceOf(Utility::class, $utility);
$this->assertEquals('one', $utility->handle());
$this->assertCount(1, $utilities->all());
$this->assertEquals(['one' => $utility], $utilities->all()->all());
}

/** @test */
public function it_defers_registration_until_boot_using_extend_method()
{
$utilities = new UtilityRepository;
$callbackRan = false;

$utilities->extend(function ($arg) use ($utilities, &$callbackRan) {
$this->assertEquals($utilities, $arg);
$callbackRan = true;
});

$this->assertFalse($callbackRan);

$utilities->boot();

$this->assertTrue($callbackRan);
}

/** @test */
public function booting_more_than_once_just_updates_the_utilities()
{
// This makes sure that booting a second time doesn't duplicate
// any utilities. It should just update/replace the existing ones.
// We boot once early so that routes can get registered, and
// then again after the user's locale preference is set so
// that the translations for labels etc use the right language.

$utilities = new UtilityRepository;

$utilities->extend(function ($utilities) {
$utilities->register('test')
->title(__('and')); // using a translation that will likely never change.
});

$utilities->boot();

$this->assertEquals(['and'], $utilities->all()->map->title()->values()->all());

app()->setLocale('fr');

$utilities->boot();

$this->assertEquals(['et'], $utilities->all()->map->title()->values()->all());
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
80dbb06
This is now normalized by UserNavConfig.
jesseleite Sep 12, 2022
8165a66
Process newly created child items the same way we process regular items.
jesseleite Sep 12, 2022
16924bb
Can't do that in PHP 7.4 my dear boy.
jesseleite Sep 13, 2022
2ec1918
Use `whenNotEmpty()`, but still apparently can't shorthand `fn()` it.
jesseleite Sep 13, 2022
90e4bf3
Refactor to separate params.
jesseleite Sep 13, 2022
a781a9a
Ensure we can rebuild nav from fresh slate.
jesseleite Nov 30, 2022
58be4f9
Support tracking preference manipulations on each NavItem instance fo…
jesseleite Nov 30, 2022
49d35c6
Track preference manipulations.
jesseleite Nov 30, 2022
4542c42
Allow passing of different preferences into `Nav::build()`.
jesseleite Nov 30, 2022
5e87094
Rename `UserNavConfig` to `NavPreferencesConfig`.
jesseleite Nov 30, 2022
6d8cfd9
Lots of front end.
jesseleite Nov 30, 2022
429e06a
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Nov 30, 2022
63093d8
The Nav and NavItem JSON resources used by the builder.
jesseleite Nov 30, 2022
84bd7e3
Hardcode link to nav.
jesseleite Nov 30, 2022
518a6da
Hide breadcrumb, because there is no preferences section yet (maybe l…
jesseleite Nov 30, 2022
6429bde
Normalize `original` for simpler logic in back end.
jesseleite Nov 30, 2022
61e2823
Wire up discard changes behaviour.
jesseleite Nov 30, 2022
088b26a
Icons.
jesseleite Nov 30, 2022
c6acbb7
Fix issue with new item IDs.
jesseleite Nov 30, 2022
e108e5f
Route and controller.
jesseleite Nov 30, 2022
4a438be
Add Nav Pref index and icon
jackmcdade Dec 6, 2022
3d7dcf4
Move `PreferenceController` and fix destroy route to actually use del…
jesseleite Dec 6, 2022
814e920
Wire up routes and controllers for default, role, and user nav prefer…
jesseleite Dec 6, 2022
a517164
Move into `CoreNav`.
jesseleite Dec 6, 2022
2629fd1
Add `buildDefault()` alias.
jesseleite Dec 6, 2022
b2b7ffe
Update front end.
jesseleite Dec 6, 2022
f273d75
Update tests.
jesseleite Dec 6, 2022
1b4bef9
Only show section if roles exist.
jesseleite Dec 6, 2022
41f2713
Add test coverage for new `Preference::preventMergingChildren()` method.
jesseleite Dec 8, 2022
336a22d
Implement `preventMergingChildren()`.
jesseleite Dec 8, 2022
aa73758
Prevent merging of children in nav preferences.
jesseleite Dec 8, 2022
74c4a79
Alias `get()` to `getPreference()`, like we do with `set()`.
jesseleite Dec 8, 2022
31c0c3e
Ensure we’re loading default preferences nav in editor.
jesseleite Dec 8, 2022
dd2ff77
Ensure we’re loading role preferences nav in editor.
jesseleite Dec 8, 2022
678921e
Alias `remove()` to `removePreference()`, like we do with `set()` and…
jesseleite Dec 8, 2022
8f389bf
Scope `Statamic.$preferences` api endpoints to prevent conflicts with…
jesseleite Dec 8, 2022
4198e51
Rename `buildDefault()` to `buildWithoutPreferences()` to avoid confu…
jesseleite Dec 8, 2022
8e7e0f8
Fix resetting of nav prefs, nav precedence on load, and clean up rout…
jesseleite Dec 8, 2022
099819a
Require pro to edit anything other than your own user preferences.
jesseleite Dec 8, 2022
71d92a4
Show confirmation modal when resetting.
jesseleite Dec 8, 2022
fa299a7
Add test to prove that first assigned user role takes precedence.
jesseleite Dec 8, 2022
d3a0d65
Fix discard changes regression.
jesseleite Dec 8, 2022
5f09b9f
Handle `.disabled` class on `.btn-group` buttons.
jesseleite Dec 8, 2022
1c4dbd2
Show reset option as warning.
jesseleite Dec 8, 2022
9c93d20
Handle ‘save as’ dropdown options.
jesseleite Dec 8, 2022
836e19f
Make index messaging a bit more consistent with other pages.
jesseleite Dec 8, 2022
cbcf4d9
Intelligently output save as options for nav builder.
jesseleite Dec 8, 2022
96d9a5d
Fix pro/super check.
jesseleite Dec 8, 2022
7255ae2
run npm install
jasonvarga Dec 9, 2022
2c391d3
add override
jasonvarga Dec 9, 2022
6629232
Merge branch 'fix-package-lock' of https://github.com/statamic/cms in…
jesseleite Dec 9, 2022
341c32d
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Dec 9, 2022
826f327
Rename to ‘CP Nav’ to avoid confusion with ‘Navigation’.
jesseleite Dec 9, 2022
328556e
Fix unique key on v-for warning.
jesseleite Dec 9, 2022
cab8390
Misc cleanup.
jesseleite Dec 9, 2022
bcbd31c
Vue payload to yaml transformation logic.
jesseleite Dec 10, 2022
b3340fd
Fix missing `display` and `url` on newly created items.
jesseleite Dec 10, 2022
3d52925
Allow removing of `@create`’d items (instead of hiding via `@remove` …
jesseleite Dec 10, 2022
7d2b40c
If there’s nothing to save, remove preference instead of saving `nav:…
jesseleite Dec 10, 2022
d9322b7
Fix overzealous `@inherit` minification when reordering.
jesseleite Dec 11, 2022
f6c8c94
Avoid submitting custom sections that have no items.
jesseleite Dec 11, 2022
1bbb1f8
Cmd+s to save.
jesseleite Dec 12, 2022
e907c10
Handle section `action: ‘@remove’` in config normalizer.
jesseleite Dec 12, 2022
af1ffc8
This shouldn’t be needed anymore, since the `normalize()` method abov…
jesseleite Dec 13, 2022
bf2a1c3
Add section manipulations into `build()` output.
jesseleite Dec 13, 2022
72bc6f9
Pluck `items` and `display` so that nav sidebar views continue to wor…
jesseleite Dec 13, 2022
08ce16a
Ensure front end merges whole section config in with items, not just …
jesseleite Dec 13, 2022
463c338
Refactor for new initial nav format on load.
jesseleite Dec 14, 2022
cf4e147
Ensure proper fallbacks.
jesseleite Dec 14, 2022
6b0c96a
Should use `NavItem::snakeCase()` for consistency.
jesseleite Dec 14, 2022
33e7857
Refactor payload to account for new `display_original` section changes.
jesseleite Dec 14, 2022
e67a60b
Improve section minification.
jesseleite Dec 14, 2022
8f33987
Ensure we also pass action to server.
jesseleite Dec 14, 2022
048d8ce
`Nav::build()` was always returning a collection, so this should too.
jesseleite Dec 14, 2022
c45acdd
Pass tests again.
jesseleite Dec 14, 2022
56a80b1
Actually, let’s avoid this `pluck()` and just fix the views.
jesseleite Dec 14, 2022
8210108
Rely on `display_original` for more consistent `itemsAreReordered` lo…
jesseleite Dec 14, 2022
474f565
Only ever show `@inherit` action when section config is empty, for re…
jesseleite Dec 14, 2022
4200a32
Ensure user can still see hidden items in builder on reload.
jesseleite Dec 14, 2022
c0e1b17
Properly handle `withHidden()` state when rebuilding.
jesseleite Dec 14, 2022
359ab19
Reload on save in order to see changes on save.
jesseleite Dec 14, 2022
fc6a8f9
This shoulda been in data.
jesseleite Dec 14, 2022
a831b26
Rename isNew to isCustom and use a new icon
jackmcdade Dec 14, 2022
5e32408
Autofocus first field in stacks, support a plain "enter" key binding
jackmcdade Dec 14, 2022
6a3811b
Use the proper prop data type
jackmcdade Dec 14, 2022
5fe9a23
Prevent hiding `CP Nav` item, so user can always access it.
jesseleite Dec 14, 2022
18233f7
Simplify that last commit.
jesseleite Dec 14, 2022
1b6d7f2
Hook up Expand All and Collapse All controls
jackmcdade Dec 14, 2022
56c784f
Don't need depth here.
jackmcdade Dec 14, 2022
981e6b2
Fix `isSectionNode()` for top level tree items.
jesseleite Dec 14, 2022
de3f29e
Clean up a few JS errors.
jesseleite Dec 14, 2022
db6252a
Make `prevent_hiding` work at section level.
jesseleite Dec 14, 2022
895a661
Prevent user from accidentally hiding CP Nav by dragging into hidden …
jesseleite Dec 14, 2022
e34415a
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
d8b43dd
Snip snap ✂️
jesseleite Dec 14, 2022
a378c98
Preferences Dropdown in the Global Header
jackmcdade Dec 14, 2022
f7b663e
Add `configure cp nav` permission.
jesseleite Dec 14, 2022
1290562
Rename/fix `Statamic.$preferences` endpoints.
jesseleite Dec 14, 2022
14af432
Wrap these routes with pro/permission checks.
jesseleite Dec 14, 2022
b1e3f73
Hook up redirect at controller level.
jesseleite Dec 14, 2022
5179f8c
Update permission check for nav builder breadcrumb link.
jesseleite Dec 14, 2022
f45d787
Remove from core nav, since Jack is adding cool gear in top nav.
jesseleite Dec 14, 2022
2eede65
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
e5e54b9
Pass tests.
jesseleite Dec 14, 2022
7eaebe5
Forgot to snip snap ✂️
jesseleite Dec 15, 2022
d3ecb7e
Improve styling for hidden sections.
jesseleite Dec 15, 2022
b716bcd
Ensure we properly minify section hide action.
jesseleite Dec 15, 2022
b691367
Expand and collapse items in top level tree as well.
jesseleite Dec 15, 2022
fa38a80
Hide hidden sections in built navs.
jesseleite Dec 15, 2022
82a1245
Fix JS errors.
jesseleite Dec 15, 2022
b946954
Ensure section level manipulations get properly set on load.
jesseleite Dec 15, 2022
f1848e3
Fix string replace.
jesseleite Dec 15, 2022
b1d6528
Return `$items` directly.
jesseleite Dec 15, 2022
2fbf6e6
Fix action handling in section minification.
jesseleite Dec 15, 2022
43bd885
Confirm removal of custom section when it contains items.
jesseleite Dec 15, 2022
f066f18
initial preferences ui
jasonvarga Dec 15, 2022
9d3e9cd
Apply fixes from StyleCI
StyleCIBot Dec 15, 2022
4458c04
Remove preferences if form field is set to the default value
jasonvarga Dec 15, 2022
36393f8
Flesh out allowed section actions and modifications as constants.
jesseleite Dec 15, 2022
a0b9711
add prop to allow publish form to reload on save
jasonvarga Dec 15, 2022
38428e2
Make permission more generic
jasonvarga Dec 15, 2022
c986eec
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 15, 2022
e99ae57
Wire up user/default/role forms
jasonvarga Dec 15, 2022
f09bfdc
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 16, 2022
f7a9a9e
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Dec 16, 2022
e28020b
Remove section `@inherit`s from config after processing reordering.
jesseleite Dec 16, 2022
793992c
Fix removing of sections and items after last sections overhaul.
jesseleite Dec 16, 2022
20ff852
Refactor `@remove` to `@hide`.
jesseleite Dec 16, 2022
11e356f
Fix undoing and saving ‘default’ level changes at user level, so that…
jesseleite Dec 16, 2022
57470dc
Apply the same fix at the role level.
jesseleite Dec 16, 2022
8156b53
Allow nulling/removing at default preferences level though.
jesseleite Dec 16, 2022
40e9b5d
Fix `@create` custom section items.
jesseleite Dec 17, 2022
e6eb308
Prevent adding item children to item children.
jesseleite Dec 17, 2022
b3cecce
Pass tests again, ensuring we don’t duplicate modified items in place.
jesseleite Dec 17, 2022
d23aa59
Rename to `NavPreferencesNormalizer::fromPreferences()` for clarity.
jesseleite Dec 17, 2022
878aa4b
Move all nav building logic out into a `NavBuilder` class so that we …
jesseleite Dec 17, 2022
15167da
Clarify why `Nav::extend()` is needed in test.
jesseleite Dec 17, 2022
9edab4d
Show custom section as ‘Custom Section’.
jesseleite Dec 17, 2022
fc1aad7
Misc cleanup.
jesseleite Dec 18, 2022
2a4dae0
Add support for `reorder` on item children.
jesseleite Dec 18, 2022
702f26a
Fix `@move` action when moving a parent item into the children of ano…
jesseleite Dec 18, 2022
93bb5c1
Ensure aliased items have no children unless explicitly set.
jesseleite Dec 18, 2022
4128730
Show configured `children` on aliased items, etc.
jesseleite Dec 18, 2022
e83fb1c
Show moved item icon (WIP).
jesseleite Dec 18, 2022
71a2e9e
Fix `@create`’d children within `@alias`’d items.
jesseleite Dec 18, 2022
ef88276
Pass tests again and cleanup todo’s.
jesseleite Dec 18, 2022
43387ef
Flesh out builder test coverage for recent fixes.
jesseleite Dec 18, 2022
a01291d
Add `syncOriginal()` functionality to `NavItem` class so we can detec…
jesseleite Dec 19, 2022
390dce0
Sync original on each item just before applying nav preference manipu…
jesseleite Dec 19, 2022
9cd1297
Pass original nav item state to tree data in front end builder.
jesseleite Dec 19, 2022
3382d44
Show icon and tooltip for renamed sections.
jesseleite Dec 19, 2022
35458d9
Ensure newly resolved child items sync their original state as well.
jesseleite Dec 19, 2022
b3a55e5
Ensure we can get current section from original children.
jesseleite Dec 19, 2022
624bd04
Fix updating of item manipulations when dragging or updating items.
jesseleite Dec 19, 2022
7d8594e
Fix JS error.
jesseleite Dec 19, 2022
8bff1ea
Fix regression since adding ‘section’ data to nested child items.
jesseleite Dec 19, 2022
a68025b
Fix overzealous `@move` action in front end.
jesseleite Dec 19, 2022
069c80f
Collapse top level items by default, to be consistent with the rest o…
jesseleite Dec 19, 2022
e289921
Fix ordering error on PHP 7.4.
jesseleite Dec 19, 2022
c743756
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 19, 2022
4afb33f
Fix duplicate hidden items regression.
jesseleite Dec 19, 2022
767ab26
Clean up `updateItemAction()` method using more readable switch case.
jesseleite Dec 19, 2022
22483cd
Get and pass clean editable nav item urls to nav builder.
jesseleite Dec 19, 2022
06fbbee
Transform on save, so that we don’t store local domain or configurabl…
jesseleite Dec 19, 2022
a5e20da
Move modified children `action` check to JS, where we handle the rest…
jesseleite Dec 19, 2022
25b2045
Fix reordering on child items payload on save.
jesseleite Dec 19, 2022
5deff45
Fix inability to move item out of an item’s children within the same …
jesseleite Dec 19, 2022
77bf587
Pass tests again.
jesseleite Dec 19, 2022
499072b
Fix disappearing of moved/aliased items by using item’s original ID w…
jesseleite Dec 20, 2022
9afd1aa
Whoops, not inherit.
jesseleite Dec 20, 2022
5ec4135
Improve reorder detection logic.
jesseleite Dec 20, 2022
57ef831
TIL, we cannot use our `Arr::get()` to get `some::id` with double col…
jesseleite Dec 20, 2022
1b18a4e
If `withHidden`, resolve/build all children, to fix cloned IDs bug in…
jesseleite Dec 21, 2022
503ce64
Fix action detection bug.
jesseleite Dec 21, 2022
4dc88ae
Handle empty sections.
jesseleite Dec 21, 2022
ba65452
Make sure we also update action on the parent node they dragged out of.
jesseleite Dec 21, 2022
8ec2f3d
Fix bug when trying to drag newly created/aliased item into another s…
jesseleite Dec 21, 2022
311a5e5
Builder doesn’t need children in manipulations.
jesseleite Dec 21, 2022
151984e
Handle tracking of renamed core sections.
jesseleite Dec 21, 2022
7cd8417
Fix and clean up drag level logic.
jesseleite Dec 21, 2022
413ae4f
Fix more JS errors.
jesseleite Dec 21, 2022
44a027a
Fix a whole bunch of moved/aliased/hidden item issues.
jesseleite Dec 21, 2022
2096ed0
Fix section reordering bug when core section has no items.
jesseleite Dec 22, 2022
f8324a0
Require both display and url.
jesseleite Dec 22, 2022
156e7aa
Remove console.log
jesseleite Dec 22, 2022
693af81
Whoops!
jesseleite Jan 3, 2023
fab9fa0
Removing flex fixes icons not showing in safari
jasonvarga Jan 3, 2023
09d068b
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Jan 3, 2023
5061db1
Never delete from manipulations for `@create`’d items, since there is…
jesseleite Jan 3, 2023
0f72eca
Never `@alias` a `@create`’d item.
jesseleite Jan 3, 2023
12f658a
Magic section setter should never look at nav item children.
jesseleite Jan 3, 2023
433e5c6
Allow overriding of preferences using `[]` when using `preventMerging…
jesseleite Jan 3, 2023
2ecd30d
Remove `nav: @override` in favour of `nav: []` for overriding of nav …
jesseleite Jan 3, 2023
8484154
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b0bae04
Add 'save as' functionality ...
jasonvarga Jan 4, 2023
a8d1ede
Validate
jasonvarga Jan 4, 2023
20cb443
Prevent "are you sure you want to navigate away" dialog when saving
jasonvarga Jan 4, 2023
d75bd14
Remove redundant `Customize` link in favour of `Modified` status.
jesseleite Jan 4, 2023
ba6889b
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b6868b5
Always touchdown for Jason 🏈
jesseleite Jan 4, 2023
160c3ad
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
ed2532b
Show modified text instead of customize link
jasonvarga Jan 4, 2023
04e990e
translate
jasonvarga Jan 4, 2023
a92d780
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
31d6aba
translate
jasonvarga Jan 4, 2023
e8caaf6
Adjust for translations
jasonvarga Jan 4, 2023
181bfba
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
5e12a53
make consistent with navs
jasonvarga Jan 4, 2023
277a45f
Remove 'Global' here, since we don't say this in page titles / save d…
jesseleite Jan 4, 2023
57a41ba
Remove redundant heading
jasonvarga Jan 4, 2023
7107063
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
9aea2c4
consistency
jasonvarga Jan 4, 2023
3470d51
Make sure Save To... dropdown doesn't clip or shrink child content
jackmcdade Jan 5, 2023
3006d22
Small improvements to make `NavTransformer` easier to test.
jesseleite Jan 5, 2023
b9bc2e5
Add whole bunch of `NavTransformer` test coverage.
jesseleite Jan 6, 2023
9066391
Add test coverage for intelligent url handling on save.
jesseleite Jan 6, 2023
a08b5d9
Add test coverage for complex json payload copied from actual vue sub…
jesseleite Jan 6, 2023
d65e105
delete method requires putting data into config
jasonvarga Jan 10, 2023
4de36c0
unused
jasonvarga Jan 10, 2023
fe03ebb
inline
jasonvarga Jan 10, 2023
edba03e
prevent saving through save button dropdown when unchanged
jasonvarga Jan 10, 2023
881e162
disable the dropdown when unchanged
jasonvarga Jan 10, 2023
bb4bb92
*slaps own wrist*
jasonvarga Jan 10, 2023
233cbd0
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 10, 2023
994e0c1
Fix issue with preferences property cache ...
jasonvarga Jan 10, 2023
5058985
CP locale can fall back to role and default preferences
jasonvarga Jan 10, 2023
5c470dc
remove comma for diff
jasonvarga Jan 11, 2023
e05d3fd
make save as dropdown consistent with nav
jasonvarga Jan 11, 2023
db6afcb
localize preference display and instructions
jasonvarga Jan 11, 2023
49c4334
Add preference extend and middleware to allow translations to be used…
jasonvarga Jan 11, 2023
e366c16
ability to defer permission registration until after locale has been …
jasonvarga Jan 11, 2023
a35f750
Apply similar changes to utilities
jasonvarga Jan 11, 2023
398da66
Might as well avoid using deprecated code now
jasonvarga Jan 11, 2023
5f81ff7
Pass preferences into section closure
jasonvarga Jan 12, 2023
efa60e6
Add simpler syntax for registering preferences
jasonvarga Jan 12, 2023
e652e7a
avoid facade
jasonvarga Jan 12, 2023
93329f9
prevent overriding section display names
jasonvarga Jan 12, 2023
6d9416b
Add test coverage for `Nav::extend()`’d sections that don’t follow ti…
jesseleite Jan 12, 2023
c2b3098
Only pass along `display` if it’s explicitly configured for renaming …
jesseleite Jan 12, 2023
6eefad5
Pass failing tests by moving section display and rename logic into `N…
jesseleite Jan 12, 2023
666c723
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Jan 12, 2023
ddf695a
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 13, 2023
d5261cd
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
95a4b3b
Merge branch 'master' into feature/preferences-ui
jasonvarga Jan 13, 2023
f9673de
Disable save part of button and leave dropdown active
jasonvarga Jan 13, 2023
77c3115
Leave dropdown active
jasonvarga Jan 13, 2023
421e81e
Add heading
jasonvarga Jan 13, 2023
01e883e
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
1f56155
Merge branch 'master' into permission-translations
jasonvarga Jan 13, 2023
f2fa807
unnecessary
jasonvarga Jan 13, 2023
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
22 changes: 22 additions & 0 deletions src/Auth/Permissions.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,34 @@

namespace Statamic\Auth;

use Facades\Statamic\Auth\CorePermissions;

class Permissions
{
protected $extensions = [];
protected $permissions = [];
protected $groups = [];
protected $pendingGroup = null;

public function boot()
{
$early = $this->permissions;
$this->permissions = [];

CorePermissions::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}

$this->permissions = array_merge($this->permissions, $early);
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make(string $value)
{
$permission = (new Permission)->value($value);
Expand Down
30 changes: 12 additions & 18 deletions src/CP/Utilities/CoreUtilities.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,7 @@ class CoreUtilities
{
public static function boot()
{
Utility::make('cache')
Utility::register('cache')
->action([CacheController::class, 'index'])
->title(__('Cache Manager'))
->icon('cache')
Expand All@@ -26,60 +26,54 @@ public static function boot()
->routes(function ($router) {
$router->post('cache/{cache}', [CacheController::class, 'clear'])->name('clear');
$router->post('cache/{cache}/warm', [CacheController::class, 'warm'])->name('warm');
})
->register();
});

Utility::make('phpinfo')
Utility::register('phpinfo')
->action(PhpInfoController::class)
->title(__('PHP Info'))
->icon('php')
->description(__('statamic::messages.phpinfo_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/phpinfo'))
->register();
->docsUrl(Statamic::docsUrl('utilities/phpinfo'));

Utility::make('search')
Utility::register('search')
->view('statamic::utilities.search')
->title(__('Search'))
->icon('search-utility')
->description(__('statamic::messages.search_utility_description'))
->routes(function ($router) {
$router->post('/', [UpdateSearchController::class, 'update'])->name('update');
})
->register();
});

Utility::make('email')
Utility::register('email')
->view('statamic::utilities.email')
->title(__('Email'))
->icon('email-utility')
->description(__('statamic::messages.email_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/email'))
->routes(function ($router) {
$router->post('/', [EmailController::class, 'send']);
})
->register();
});

Utility::make('licensing')
Utility::register('licensing')
->action([LicensingController::class, 'show'])
->title(__('Licensing'))
->icon('licensing')
->description(__('statamic::messages.licensing_utility_description'))
->docsUrl(Statamic::docsUrl('licensing'))
->routes(function ($router) {
$router->get('refresh', [LicensingController::class, 'refresh'])->name('refresh');
})
->register();
});

if (config('statamic.git.enabled') && Statamic::pro()) {
Utility::make('git')
Utility::register('git')
->action([GitController::class, 'index'])
->title('Git')
->icon('git')
->description(__('statamic::messages.git_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/git'))
->routes(function ($router) {
$router->post('/', [GitController::class, 'commit'])->name('commit');
})
->register();
});
}
}
}
1 change: 1 addition & 0 deletions src/CP/Utilities/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,6 +104,7 @@ public function routes(Closure $routes = null)
return $this->fluentlyGetOrSet('routes')->args(func_get_args());
}

/** @deprecated */
public function register()
{
\Statamic\Facades\Utility::push($this);
Expand Down
32 changes: 31 additions & 1 deletion src/CP/Utilities/UtilityRepository.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,27 +2,55 @@

namespace Statamic\CP\Utilities;

use Facades\Statamic\CP\Utilities\CoreUtilities;
use Illuminate\Support\Facades\Route;
use Statamic\Facades\User;

class UtilityRepository
{
protected $utilities;
protected $extensions = [];

public function __construct()
{
$this->utilities = collect([]);
}

public function boot()
{
CoreUtilities::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make($handle)
{
return (new Utility)->handle($handle);
}

public function push(Utility $utility)
public function register($utility)
{
if (! $utility instanceof Utility) {
$utility = $this->make($utility);
}

$this->utilities[$utility->handle()] = $utility;

return $utility;
}

/** @deprecated */
public function push(Utility $utility)
{
$this->register($utility);

return $this;
}

Expand All@@ -45,6 +73,8 @@ public function find($handle)

public function routes()
{
$this->boot();

Route::namespace('\\')->prefix('utilities')->name('utilities.')->group(function () {
$this->all()->each(function ($utility) {
if ($utility->action()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

/**
* @method static mixed|null make($handle)
* @method static self push(Utility $utility)
* @method static \Statamic\CP\Utilities\Utility register($utility)
* @method static mixed all()
* @method static mixed authorized()
* @method static mixed find($handle)
Expand Down
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootPermissions.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Permission;

class BootPermissions
{
public function handle($request, Closure $next)
{
Permission::boot();

return $next($request);
}
}
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootUtilities.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Utility;

class BootUtilities
{
public function handle($request, Closure $next)
{
Utility::boot();

return $next($request);
}
}
2 changes: 1 addition & 1 deletion src/Preferences/Preferences.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -230,7 +230,7 @@ public function section($handle, $label, $permissions = null)

$this->pendingSection = $handle;

$permissions();
$permissions($this);

$this->pendingSection = null;
}
Expand Down
5 changes: 0 additions & 5 deletions src/Providers/AuthServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@

namespace Statamic\Providers;

use Facades\Statamic\Auth\CorePermissions;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
Expand DownExpand Up@@ -90,10 +89,6 @@ public function boot()
return optional(User::fromUser($user))->hasPermission($ability) === true ? true : null;
});

$this->app->booted(function () {
CorePermissions::boot();
});

foreach ($this->policies as $key => $policy) {
Gate::policy($key, $policy);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Providers/CpServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Statamic\CP\Utilities\CoreUtilities;
use Statamic\CP\Utilities\UtilityRepository;
use Statamic\Extensions\Translation\Loader;
use Statamic\Extensions\Translation\Translator;
Expand All@@ -33,8 +32,6 @@ public function boot()
View::composer(NavComposer::VIEWS, NavComposer::class);
View::composer(CustomLogoComposer::VIEWS, CustomLogoComposer::class);

CoreUtilities::boot();

Blade::directive('cp_svg', function ($expression) {
return "<?php echo Statamic::svg({$expression}) ?>";
});
Expand DownExpand Up@@ -83,7 +80,9 @@ protected function registerMiddlewareGroups()
$router->middlewareGroup('statamic.cp.authenticated', [
\Statamic\Http\Middleware\CP\Authorize::class,
\Statamic\Http\Middleware\CP\Localize::class,
\Statamic\Http\Middleware\CP\BootPermissions::class,
\Statamic\Http\Middleware\CP\BootPreferences::class,
\Statamic\Http\Middleware\CP\BootUtilities::class,
\Statamic\Http\Middleware\CP\CountUsers::class,
\Statamic\Http\Middleware\DeleteTemporaryFileUploads::class,
]);
Expand Down
96 changes: 96 additions & 0 deletions tests/CP/Utilities/UtilityRepositoryTest.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
<?php

namespace Tests\CP\Utilities;

use Illuminate\Support\Collection;
use Statamic\CP\Utilities\Utility;
use Statamic\CP\Utilities\UtilityRepository;
use Tests\TestCase;

class UtilityRepositoryTest extends TestCase
{
/**
* @test
*
* @dataProvider registerMethodProvider
*/
public function it_registers_a_utility($registerMethod)
{
$utilities = new UtilityRepository;
$this->assertInstanceOf(Collection::class, $utilities->all());
$this->assertCount(0, $utilities->all());

$utility = $utilities->make('one');
$this->assertCount(0, $utilities->all());

$utilities->$registerMethod($utility);
$this->assertEquals(['one' => $utility], $utilities->all()->all());
$this->assertEquals($utility, $utilities->find('one'));
}

public function registerMethodProvider()
{
return [
'register' => ['register'],
'push' => ['push'], // @deprecated
];
}

/** @test */
public function it_registers_a_utility_via_a_string()
{
$utilities = new UtilityRepository;

$utility = $utilities->register('one');

$this->assertInstanceOf(Utility::class, $utility);
$this->assertEquals('one', $utility->handle());
$this->assertCount(1, $utilities->all());
$this->assertEquals(['one' => $utility], $utilities->all()->all());
}

/** @test */
public function it_defers_registration_until_boot_using_extend_method()
{
$utilities = new UtilityRepository;
$callbackRan = false;

$utilities->extend(function ($arg) use ($utilities, &$callbackRan) {
$this->assertEquals($utilities, $arg);
$callbackRan = true;
});

$this->assertFalse($callbackRan);

$utilities->boot();

$this->assertTrue($callbackRan);
}

/** @test */
public function booting_more_than_once_just_updates_the_utilities()
{
// This makes sure that booting a second time doesn't duplicate
// any utilities. It should just update/replace the existing ones.
// We boot once early so that routes can get registered, and
// then again after the user's locale preference is set so
// that the translations for labels etc use the right language.

$utilities = new UtilityRepository;

$utilities->extend(function ($utilities) {
$utilities->register('test')
->title(__('and')); // using a translation that will likely never change.
});

$utilities->boot();

$this->assertEquals(['and'], $utilities->all()->map->title()->values()->all());

app()->setLocale('fr');

$utilities->boot();

$this->assertEquals(['et'], $utilities->all()->map->title()->values()->all());
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
80dbb06
This is now normalized by UserNavConfig.
jesseleite Sep 12, 2022
8165a66
Process newly created child items the same way we process regular items.
jesseleite Sep 12, 2022
16924bb
Can't do that in PHP 7.4 my dear boy.
jesseleite Sep 13, 2022
2ec1918
Use `whenNotEmpty()`, but still apparently can't shorthand `fn()` it.
jesseleite Sep 13, 2022
90e4bf3
Refactor to separate params.
jesseleite Sep 13, 2022
a781a9a
Ensure we can rebuild nav from fresh slate.
jesseleite Nov 30, 2022
58be4f9
Support tracking preference manipulations on each NavItem instance fo…
jesseleite Nov 30, 2022
49d35c6
Track preference manipulations.
jesseleite Nov 30, 2022
4542c42
Allow passing of different preferences into `Nav::build()`.
jesseleite Nov 30, 2022
5e87094
Rename `UserNavConfig` to `NavPreferencesConfig`.
jesseleite Nov 30, 2022
6d8cfd9
Lots of front end.
jesseleite Nov 30, 2022
429e06a
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Nov 30, 2022
63093d8
The Nav and NavItem JSON resources used by the builder.
jesseleite Nov 30, 2022
84bd7e3
Hardcode link to nav.
jesseleite Nov 30, 2022
518a6da
Hide breadcrumb, because there is no preferences section yet (maybe l…
jesseleite Nov 30, 2022
6429bde
Normalize `original` for simpler logic in back end.
jesseleite Nov 30, 2022
61e2823
Wire up discard changes behaviour.
jesseleite Nov 30, 2022
088b26a
Icons.
jesseleite Nov 30, 2022
c6acbb7
Fix issue with new item IDs.
jesseleite Nov 30, 2022
e108e5f
Route and controller.
jesseleite Nov 30, 2022
4a438be
Add Nav Pref index and icon
jackmcdade Dec 6, 2022
3d7dcf4
Move `PreferenceController` and fix destroy route to actually use del…
jesseleite Dec 6, 2022
814e920
Wire up routes and controllers for default, role, and user nav prefer…
jesseleite Dec 6, 2022
a517164
Move into `CoreNav`.
jesseleite Dec 6, 2022
2629fd1
Add `buildDefault()` alias.
jesseleite Dec 6, 2022
b2b7ffe
Update front end.
jesseleite Dec 6, 2022
f273d75
Update tests.
jesseleite Dec 6, 2022
1b4bef9
Only show section if roles exist.
jesseleite Dec 6, 2022
41f2713
Add test coverage for new `Preference::preventMergingChildren()` method.
jesseleite Dec 8, 2022
336a22d
Implement `preventMergingChildren()`.
jesseleite Dec 8, 2022
aa73758
Prevent merging of children in nav preferences.
jesseleite Dec 8, 2022
74c4a79
Alias `get()` to `getPreference()`, like we do with `set()`.
jesseleite Dec 8, 2022
31c0c3e
Ensure we’re loading default preferences nav in editor.
jesseleite Dec 8, 2022
dd2ff77
Ensure we’re loading role preferences nav in editor.
jesseleite Dec 8, 2022
678921e
Alias `remove()` to `removePreference()`, like we do with `set()` and…
jesseleite Dec 8, 2022
8f389bf
Scope `Statamic.$preferences` api endpoints to prevent conflicts with…
jesseleite Dec 8, 2022
4198e51
Rename `buildDefault()` to `buildWithoutPreferences()` to avoid confu…
jesseleite Dec 8, 2022
8e7e0f8
Fix resetting of nav prefs, nav precedence on load, and clean up rout…
jesseleite Dec 8, 2022
099819a
Require pro to edit anything other than your own user preferences.
jesseleite Dec 8, 2022
71d92a4
Show confirmation modal when resetting.
jesseleite Dec 8, 2022
fa299a7
Add test to prove that first assigned user role takes precedence.
jesseleite Dec 8, 2022
d3a0d65
Fix discard changes regression.
jesseleite Dec 8, 2022
5f09b9f
Handle `.disabled` class on `.btn-group` buttons.
jesseleite Dec 8, 2022
1c4dbd2
Show reset option as warning.
jesseleite Dec 8, 2022
9c93d20
Handle ‘save as’ dropdown options.
jesseleite Dec 8, 2022
836e19f
Make index messaging a bit more consistent with other pages.
jesseleite Dec 8, 2022
cbcf4d9
Intelligently output save as options for nav builder.
jesseleite Dec 8, 2022
96d9a5d
Fix pro/super check.
jesseleite Dec 8, 2022
7255ae2
run npm install
jasonvarga Dec 9, 2022
2c391d3
add override
jasonvarga Dec 9, 2022
6629232
Merge branch 'fix-package-lock' of https://github.com/statamic/cms in…
jesseleite Dec 9, 2022
341c32d
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Dec 9, 2022
826f327
Rename to ‘CP Nav’ to avoid confusion with ‘Navigation’.
jesseleite Dec 9, 2022
328556e
Fix unique key on v-for warning.
jesseleite Dec 9, 2022
cab8390
Misc cleanup.
jesseleite Dec 9, 2022
bcbd31c
Vue payload to yaml transformation logic.
jesseleite Dec 10, 2022
b3340fd
Fix missing `display` and `url` on newly created items.
jesseleite Dec 10, 2022
3d52925
Allow removing of `@create`’d items (instead of hiding via `@remove` …
jesseleite Dec 10, 2022
7d2b40c
If there’s nothing to save, remove preference instead of saving `nav:…
jesseleite Dec 10, 2022
d9322b7
Fix overzealous `@inherit` minification when reordering.
jesseleite Dec 11, 2022
f6c8c94
Avoid submitting custom sections that have no items.
jesseleite Dec 11, 2022
1bbb1f8
Cmd+s to save.
jesseleite Dec 12, 2022
e907c10
Handle section `action: ‘@remove’` in config normalizer.
jesseleite Dec 12, 2022
af1ffc8
This shouldn’t be needed anymore, since the `normalize()` method abov…
jesseleite Dec 13, 2022
bf2a1c3
Add section manipulations into `build()` output.
jesseleite Dec 13, 2022
72bc6f9
Pluck `items` and `display` so that nav sidebar views continue to wor…
jesseleite Dec 13, 2022
08ce16a
Ensure front end merges whole section config in with items, not just …
jesseleite Dec 13, 2022
463c338
Refactor for new initial nav format on load.
jesseleite Dec 14, 2022
cf4e147
Ensure proper fallbacks.
jesseleite Dec 14, 2022
6b0c96a
Should use `NavItem::snakeCase()` for consistency.
jesseleite Dec 14, 2022
33e7857
Refactor payload to account for new `display_original` section changes.
jesseleite Dec 14, 2022
e67a60b
Improve section minification.
jesseleite Dec 14, 2022
8f33987
Ensure we also pass action to server.
jesseleite Dec 14, 2022
048d8ce
`Nav::build()` was always returning a collection, so this should too.
jesseleite Dec 14, 2022
c45acdd
Pass tests again.
jesseleite Dec 14, 2022
56a80b1
Actually, let’s avoid this `pluck()` and just fix the views.
jesseleite Dec 14, 2022
8210108
Rely on `display_original` for more consistent `itemsAreReordered` lo…
jesseleite Dec 14, 2022
474f565
Only ever show `@inherit` action when section config is empty, for re…
jesseleite Dec 14, 2022
4200a32
Ensure user can still see hidden items in builder on reload.
jesseleite Dec 14, 2022
c0e1b17
Properly handle `withHidden()` state when rebuilding.
jesseleite Dec 14, 2022
359ab19
Reload on save in order to see changes on save.
jesseleite Dec 14, 2022
fc6a8f9
This shoulda been in data.
jesseleite Dec 14, 2022
a831b26
Rename isNew to isCustom and use a new icon
jackmcdade Dec 14, 2022
5e32408
Autofocus first field in stacks, support a plain "enter" key binding
jackmcdade Dec 14, 2022
6a3811b
Use the proper prop data type
jackmcdade Dec 14, 2022
5fe9a23
Prevent hiding `CP Nav` item, so user can always access it.
jesseleite Dec 14, 2022
18233f7
Simplify that last commit.
jesseleite Dec 14, 2022
1b6d7f2
Hook up Expand All and Collapse All controls
jackmcdade Dec 14, 2022
56c784f
Don't need depth here.
jackmcdade Dec 14, 2022
981e6b2
Fix `isSectionNode()` for top level tree items.
jesseleite Dec 14, 2022
de3f29e
Clean up a few JS errors.
jesseleite Dec 14, 2022
db6252a
Make `prevent_hiding` work at section level.
jesseleite Dec 14, 2022
895a661
Prevent user from accidentally hiding CP Nav by dragging into hidden …
jesseleite Dec 14, 2022
e34415a
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
d8b43dd
Snip snap ✂️
jesseleite Dec 14, 2022
a378c98
Preferences Dropdown in the Global Header
jackmcdade Dec 14, 2022
f7b663e
Add `configure cp nav` permission.
jesseleite Dec 14, 2022
1290562
Rename/fix `Statamic.$preferences` endpoints.
jesseleite Dec 14, 2022
14af432
Wrap these routes with pro/permission checks.
jesseleite Dec 14, 2022
b1e3f73
Hook up redirect at controller level.
jesseleite Dec 14, 2022
5179f8c
Update permission check for nav builder breadcrumb link.
jesseleite Dec 14, 2022
f45d787
Remove from core nav, since Jack is adding cool gear in top nav.
jesseleite Dec 14, 2022
2eede65
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
e5e54b9
Pass tests.
jesseleite Dec 14, 2022
7eaebe5
Forgot to snip snap ✂️
jesseleite Dec 15, 2022
d3ecb7e
Improve styling for hidden sections.
jesseleite Dec 15, 2022
b716bcd
Ensure we properly minify section hide action.
jesseleite Dec 15, 2022
b691367
Expand and collapse items in top level tree as well.
jesseleite Dec 15, 2022
fa38a80
Hide hidden sections in built navs.
jesseleite Dec 15, 2022
82a1245
Fix JS errors.
jesseleite Dec 15, 2022
b946954
Ensure section level manipulations get properly set on load.
jesseleite Dec 15, 2022
f1848e3
Fix string replace.
jesseleite Dec 15, 2022
b1d6528
Return `$items` directly.
jesseleite Dec 15, 2022
2fbf6e6
Fix action handling in section minification.
jesseleite Dec 15, 2022
43bd885
Confirm removal of custom section when it contains items.
jesseleite Dec 15, 2022
f066f18
initial preferences ui
jasonvarga Dec 15, 2022
9d3e9cd
Apply fixes from StyleCI
StyleCIBot Dec 15, 2022
4458c04
Remove preferences if form field is set to the default value
jasonvarga Dec 15, 2022
36393f8
Flesh out allowed section actions and modifications as constants.
jesseleite Dec 15, 2022
a0b9711
add prop to allow publish form to reload on save
jasonvarga Dec 15, 2022
38428e2
Make permission more generic
jasonvarga Dec 15, 2022
c986eec
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 15, 2022
e99ae57
Wire up user/default/role forms
jasonvarga Dec 15, 2022
f09bfdc
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 16, 2022
f7a9a9e
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Dec 16, 2022
e28020b
Remove section `@inherit`s from config after processing reordering.
jesseleite Dec 16, 2022
793992c
Fix removing of sections and items after last sections overhaul.
jesseleite Dec 16, 2022
20ff852
Refactor `@remove` to `@hide`.
jesseleite Dec 16, 2022
11e356f
Fix undoing and saving ‘default’ level changes at user level, so that…
jesseleite Dec 16, 2022
57470dc
Apply the same fix at the role level.
jesseleite Dec 16, 2022
8156b53
Allow nulling/removing at default preferences level though.
jesseleite Dec 16, 2022
40e9b5d
Fix `@create` custom section items.
jesseleite Dec 17, 2022
e6eb308
Prevent adding item children to item children.
jesseleite Dec 17, 2022
b3cecce
Pass tests again, ensuring we don’t duplicate modified items in place.
jesseleite Dec 17, 2022
d23aa59
Rename to `NavPreferencesNormalizer::fromPreferences()` for clarity.
jesseleite Dec 17, 2022
878aa4b
Move all nav building logic out into a `NavBuilder` class so that we …
jesseleite Dec 17, 2022
15167da
Clarify why `Nav::extend()` is needed in test.
jesseleite Dec 17, 2022
9edab4d
Show custom section as ‘Custom Section’.
jesseleite Dec 17, 2022
fc1aad7
Misc cleanup.
jesseleite Dec 18, 2022
2a4dae0
Add support for `reorder` on item children.
jesseleite Dec 18, 2022
702f26a
Fix `@move` action when moving a parent item into the children of ano…
jesseleite Dec 18, 2022
93bb5c1
Ensure aliased items have no children unless explicitly set.
jesseleite Dec 18, 2022
4128730
Show configured `children` on aliased items, etc.
jesseleite Dec 18, 2022
e83fb1c
Show moved item icon (WIP).
jesseleite Dec 18, 2022
71a2e9e
Fix `@create`’d children within `@alias`’d items.
jesseleite Dec 18, 2022
ef88276
Pass tests again and cleanup todo’s.
jesseleite Dec 18, 2022
43387ef
Flesh out builder test coverage for recent fixes.
jesseleite Dec 18, 2022
a01291d
Add `syncOriginal()` functionality to `NavItem` class so we can detec…
jesseleite Dec 19, 2022
390dce0
Sync original on each item just before applying nav preference manipu…
jesseleite Dec 19, 2022
9cd1297
Pass original nav item state to tree data in front end builder.
jesseleite Dec 19, 2022
3382d44
Show icon and tooltip for renamed sections.
jesseleite Dec 19, 2022
35458d9
Ensure newly resolved child items sync their original state as well.
jesseleite Dec 19, 2022
b3a55e5
Ensure we can get current section from original children.
jesseleite Dec 19, 2022
624bd04
Fix updating of item manipulations when dragging or updating items.
jesseleite Dec 19, 2022
7d8594e
Fix JS error.
jesseleite Dec 19, 2022
8bff1ea
Fix regression since adding ‘section’ data to nested child items.
jesseleite Dec 19, 2022
a68025b
Fix overzealous `@move` action in front end.
jesseleite Dec 19, 2022
069c80f
Collapse top level items by default, to be consistent with the rest o…
jesseleite Dec 19, 2022
e289921
Fix ordering error on PHP 7.4.
jesseleite Dec 19, 2022
c743756
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 19, 2022
4afb33f
Fix duplicate hidden items regression.
jesseleite Dec 19, 2022
767ab26
Clean up `updateItemAction()` method using more readable switch case.
jesseleite Dec 19, 2022
22483cd
Get and pass clean editable nav item urls to nav builder.
jesseleite Dec 19, 2022
06fbbee
Transform on save, so that we don’t store local domain or configurabl…
jesseleite Dec 19, 2022
a5e20da
Move modified children `action` check to JS, where we handle the rest…
jesseleite Dec 19, 2022
25b2045
Fix reordering on child items payload on save.
jesseleite Dec 19, 2022
5deff45
Fix inability to move item out of an item’s children within the same …
jesseleite Dec 19, 2022
77bf587
Pass tests again.
jesseleite Dec 19, 2022
499072b
Fix disappearing of moved/aliased items by using item’s original ID w…
jesseleite Dec 20, 2022
9afd1aa
Whoops, not inherit.
jesseleite Dec 20, 2022
5ec4135
Improve reorder detection logic.
jesseleite Dec 20, 2022
57ef831
TIL, we cannot use our `Arr::get()` to get `some::id` with double col…
jesseleite Dec 20, 2022
1b18a4e
If `withHidden`, resolve/build all children, to fix cloned IDs bug in…
jesseleite Dec 21, 2022
503ce64
Fix action detection bug.
jesseleite Dec 21, 2022
4dc88ae
Handle empty sections.
jesseleite Dec 21, 2022
ba65452
Make sure we also update action on the parent node they dragged out of.
jesseleite Dec 21, 2022
8ec2f3d
Fix bug when trying to drag newly created/aliased item into another s…
jesseleite Dec 21, 2022
311a5e5
Builder doesn’t need children in manipulations.
jesseleite Dec 21, 2022
151984e
Handle tracking of renamed core sections.
jesseleite Dec 21, 2022
7cd8417
Fix and clean up drag level logic.
jesseleite Dec 21, 2022
413ae4f
Fix more JS errors.
jesseleite Dec 21, 2022
44a027a
Fix a whole bunch of moved/aliased/hidden item issues.
jesseleite Dec 21, 2022
2096ed0
Fix section reordering bug when core section has no items.
jesseleite Dec 22, 2022
f8324a0
Require both display and url.
jesseleite Dec 22, 2022
156e7aa
Remove console.log
jesseleite Dec 22, 2022
693af81
Whoops!
jesseleite Jan 3, 2023
fab9fa0
Removing flex fixes icons not showing in safari
jasonvarga Jan 3, 2023
09d068b
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Jan 3, 2023
5061db1
Never delete from manipulations for `@create`’d items, since there is…
jesseleite Jan 3, 2023
0f72eca
Never `@alias` a `@create`’d item.
jesseleite Jan 3, 2023
12f658a
Magic section setter should never look at nav item children.
jesseleite Jan 3, 2023
433e5c6
Allow overriding of preferences using `[]` when using `preventMerging…
jesseleite Jan 3, 2023
2ecd30d
Remove `nav: @override` in favour of `nav: []` for overriding of nav …
jesseleite Jan 3, 2023
8484154
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b0bae04
Add 'save as' functionality ...
jasonvarga Jan 4, 2023
a8d1ede
Validate
jasonvarga Jan 4, 2023
20cb443
Prevent "are you sure you want to navigate away" dialog when saving
jasonvarga Jan 4, 2023
d75bd14
Remove redundant `Customize` link in favour of `Modified` status.
jesseleite Jan 4, 2023
ba6889b
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b6868b5
Always touchdown for Jason 🏈
jesseleite Jan 4, 2023
160c3ad
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
ed2532b
Show modified text instead of customize link
jasonvarga Jan 4, 2023
04e990e
translate
jasonvarga Jan 4, 2023
a92d780
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
31d6aba
translate
jasonvarga Jan 4, 2023
e8caaf6
Adjust for translations
jasonvarga Jan 4, 2023
181bfba
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
5e12a53
make consistent with navs
jasonvarga Jan 4, 2023
277a45f
Remove 'Global' here, since we don't say this in page titles / save d…
jesseleite Jan 4, 2023
57a41ba
Remove redundant heading
jasonvarga Jan 4, 2023
7107063
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
9aea2c4
consistency
jasonvarga Jan 4, 2023
3470d51
Make sure Save To... dropdown doesn't clip or shrink child content
jackmcdade Jan 5, 2023
3006d22
Small improvements to make `NavTransformer` easier to test.
jesseleite Jan 5, 2023
b9bc2e5
Add whole bunch of `NavTransformer` test coverage.
jesseleite Jan 6, 2023
9066391
Add test coverage for intelligent url handling on save.
jesseleite Jan 6, 2023
a08b5d9
Add test coverage for complex json payload copied from actual vue sub…
jesseleite Jan 6, 2023
d65e105
delete method requires putting data into config
jasonvarga Jan 10, 2023
4de36c0
unused
jasonvarga Jan 10, 2023
fe03ebb
inline
jasonvarga Jan 10, 2023
edba03e
prevent saving through save button dropdown when unchanged
jasonvarga Jan 10, 2023
881e162
disable the dropdown when unchanged
jasonvarga Jan 10, 2023
bb4bb92
*slaps own wrist*
jasonvarga Jan 10, 2023
233cbd0
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 10, 2023
994e0c1
Fix issue with preferences property cache ...
jasonvarga Jan 10, 2023
5058985
CP locale can fall back to role and default preferences
jasonvarga Jan 10, 2023
5c470dc
remove comma for diff
jasonvarga Jan 11, 2023
e05d3fd
make save as dropdown consistent with nav
jasonvarga Jan 11, 2023
db6afcb
localize preference display and instructions
jasonvarga Jan 11, 2023
49c4334
Add preference extend and middleware to allow translations to be used…
jasonvarga Jan 11, 2023
e366c16
ability to defer permission registration until after locale has been …
jasonvarga Jan 11, 2023
a35f750
Apply similar changes to utilities
jasonvarga Jan 11, 2023
398da66
Might as well avoid using deprecated code now
jasonvarga Jan 11, 2023
5f81ff7
Pass preferences into section closure
jasonvarga Jan 12, 2023
efa60e6
Add simpler syntax for registering preferences
jasonvarga Jan 12, 2023
e652e7a
avoid facade
jasonvarga Jan 12, 2023
93329f9
prevent overriding section display names
jasonvarga Jan 12, 2023
6d9416b
Add test coverage for `Nav::extend()`’d sections that don’t follow ti…
jesseleite Jan 12, 2023
c2b3098
Only pass along `display` if it’s explicitly configured for renaming …
jesseleite Jan 12, 2023
6eefad5
Pass failing tests by moving section display and rename logic into `N…
jesseleite Jan 12, 2023
666c723
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Jan 12, 2023
ddf695a
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 13, 2023
d5261cd
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
95a4b3b
Merge branch 'master' into feature/preferences-ui
jasonvarga Jan 13, 2023
f9673de
Disable save part of button and leave dropdown active
jasonvarga Jan 13, 2023
77c3115
Leave dropdown active
jasonvarga Jan 13, 2023
421e81e
Add heading
jasonvarga Jan 13, 2023
01e883e
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
1f56155
Merge branch 'master' into permission-translations
jasonvarga Jan 13, 2023
f2fa807
unnecessary
jasonvarga Jan 13, 2023
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
22 changes: 22 additions & 0 deletions src/Auth/Permissions.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,34 @@

namespace Statamic\Auth;

use Facades\Statamic\Auth\CorePermissions;

class Permissions
{
protected $extensions = [];
protected $permissions = [];
protected $groups = [];
protected $pendingGroup = null;

public function boot()
{
$early = $this->permissions;
$this->permissions = [];

CorePermissions::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}

$this->permissions = array_merge($this->permissions, $early);
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make(string $value)
{
$permission = (new Permission)->value($value);
Expand Down
30 changes: 12 additions & 18 deletions src/CP/Utilities/CoreUtilities.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,7 @@ class CoreUtilities
{
public static function boot()
{
Utility::make('cache')
Utility::register('cache')
->action([CacheController::class, 'index'])
->title(__('Cache Manager'))
->icon('cache')
Expand All@@ -26,60 +26,54 @@ public static function boot()
->routes(function ($router) {
$router->post('cache/{cache}', [CacheController::class, 'clear'])->name('clear');
$router->post('cache/{cache}/warm', [CacheController::class, 'warm'])->name('warm');
})
->register();
});

Utility::make('phpinfo')
Utility::register('phpinfo')
->action(PhpInfoController::class)
->title(__('PHP Info'))
->icon('php')
->description(__('statamic::messages.phpinfo_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/phpinfo'))
->register();
->docsUrl(Statamic::docsUrl('utilities/phpinfo'));

Utility::make('search')
Utility::register('search')
->view('statamic::utilities.search')
->title(__('Search'))
->icon('search-utility')
->description(__('statamic::messages.search_utility_description'))
->routes(function ($router) {
$router->post('/', [UpdateSearchController::class, 'update'])->name('update');
})
->register();
});

Utility::make('email')
Utility::register('email')
->view('statamic::utilities.email')
->title(__('Email'))
->icon('email-utility')
->description(__('statamic::messages.email_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/email'))
->routes(function ($router) {
$router->post('/', [EmailController::class, 'send']);
})
->register();
});

Utility::make('licensing')
Utility::register('licensing')
->action([LicensingController::class, 'show'])
->title(__('Licensing'))
->icon('licensing')
->description(__('statamic::messages.licensing_utility_description'))
->docsUrl(Statamic::docsUrl('licensing'))
->routes(function ($router) {
$router->get('refresh', [LicensingController::class, 'refresh'])->name('refresh');
})
->register();
});

if (config('statamic.git.enabled') && Statamic::pro()) {
Utility::make('git')
Utility::register('git')
->action([GitController::class, 'index'])
->title('Git')
->icon('git')
->description(__('statamic::messages.git_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/git'))
->routes(function ($router) {
$router->post('/', [GitController::class, 'commit'])->name('commit');
})
->register();
});
}
}
}
1 change: 1 addition & 0 deletions src/CP/Utilities/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,6 +104,7 @@ public function routes(Closure $routes = null)
return $this->fluentlyGetOrSet('routes')->args(func_get_args());
}

/** @deprecated */
public function register()
{
\Statamic\Facades\Utility::push($this);
Expand Down
32 changes: 31 additions & 1 deletion src/CP/Utilities/UtilityRepository.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,27 +2,55 @@

namespace Statamic\CP\Utilities;

use Facades\Statamic\CP\Utilities\CoreUtilities;
use Illuminate\Support\Facades\Route;
use Statamic\Facades\User;

class UtilityRepository
{
protected $utilities;
protected $extensions = [];

public function __construct()
{
$this->utilities = collect([]);
}

public function boot()
{
CoreUtilities::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make($handle)
{
return (new Utility)->handle($handle);
}

public function push(Utility $utility)
public function register($utility)
{
if (! $utility instanceof Utility) {
$utility = $this->make($utility);
}

$this->utilities[$utility->handle()] = $utility;

return $utility;
}

/** @deprecated */
public function push(Utility $utility)
{
$this->register($utility);

return $this;
}

Expand All@@ -45,6 +73,8 @@ public function find($handle)

public function routes()
{
$this->boot();

Route::namespace('\\')->prefix('utilities')->name('utilities.')->group(function () {
$this->all()->each(function ($utility) {
if ($utility->action()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

/**
* @method static mixed|null make($handle)
* @method static self push(Utility $utility)
* @method static \Statamic\CP\Utilities\Utility register($utility)
* @method static mixed all()
* @method static mixed authorized()
* @method static mixed find($handle)
Expand Down
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootPermissions.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Permission;

class BootPermissions
{
public function handle($request, Closure $next)
{
Permission::boot();

return $next($request);
}
}
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootUtilities.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Utility;

class BootUtilities
{
public function handle($request, Closure $next)
{
Utility::boot();

return $next($request);
}
}
2 changes: 1 addition & 1 deletion src/Preferences/Preferences.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -230,7 +230,7 @@ public function section($handle, $label, $permissions = null)

$this->pendingSection = $handle;

$permissions();
$permissions($this);

$this->pendingSection = null;
}
Expand Down
5 changes: 0 additions & 5 deletions src/Providers/AuthServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@

namespace Statamic\Providers;

use Facades\Statamic\Auth\CorePermissions;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
Expand DownExpand Up@@ -90,10 +89,6 @@ public function boot()
return optional(User::fromUser($user))->hasPermission($ability) === true ? true : null;
});

$this->app->booted(function () {
CorePermissions::boot();
});

foreach ($this->policies as $key => $policy) {
Gate::policy($key, $policy);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Providers/CpServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Statamic\CP\Utilities\CoreUtilities;
use Statamic\CP\Utilities\UtilityRepository;
use Statamic\Extensions\Translation\Loader;
use Statamic\Extensions\Translation\Translator;
Expand All@@ -33,8 +32,6 @@ public function boot()
View::composer(NavComposer::VIEWS, NavComposer::class);
View::composer(CustomLogoComposer::VIEWS, CustomLogoComposer::class);

CoreUtilities::boot();

Blade::directive('cp_svg', function ($expression) {
return "<?php echo Statamic::svg({$expression}) ?>";
});
Expand DownExpand Up@@ -83,7 +80,9 @@ protected function registerMiddlewareGroups()
$router->middlewareGroup('statamic.cp.authenticated', [
\Statamic\Http\Middleware\CP\Authorize::class,
\Statamic\Http\Middleware\CP\Localize::class,
\Statamic\Http\Middleware\CP\BootPermissions::class,
\Statamic\Http\Middleware\CP\BootPreferences::class,
\Statamic\Http\Middleware\CP\BootUtilities::class,
\Statamic\Http\Middleware\CP\CountUsers::class,
\Statamic\Http\Middleware\DeleteTemporaryFileUploads::class,
]);
Expand Down
96 changes: 96 additions & 0 deletions tests/CP/Utilities/UtilityRepositoryTest.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
<?php

namespace Tests\CP\Utilities;

use Illuminate\Support\Collection;
use Statamic\CP\Utilities\Utility;
use Statamic\CP\Utilities\UtilityRepository;
use Tests\TestCase;

class UtilityRepositoryTest extends TestCase
{
/**
* @test
*
* @dataProvider registerMethodProvider
*/
public function it_registers_a_utility($registerMethod)
{
$utilities = new UtilityRepository;
$this->assertInstanceOf(Collection::class, $utilities->all());
$this->assertCount(0, $utilities->all());

$utility = $utilities->make('one');
$this->assertCount(0, $utilities->all());

$utilities->$registerMethod($utility);
$this->assertEquals(['one' => $utility], $utilities->all()->all());
$this->assertEquals($utility, $utilities->find('one'));
}

public function registerMethodProvider()
{
return [
'register' => ['register'],
'push' => ['push'], // @deprecated
];
}

/** @test */
public function it_registers_a_utility_via_a_string()
{
$utilities = new UtilityRepository;

$utility = $utilities->register('one');

$this->assertInstanceOf(Utility::class, $utility);
$this->assertEquals('one', $utility->handle());
$this->assertCount(1, $utilities->all());
$this->assertEquals(['one' => $utility], $utilities->all()->all());
}

/** @test */
public function it_defers_registration_until_boot_using_extend_method()
{
$utilities = new UtilityRepository;
$callbackRan = false;

$utilities->extend(function ($arg) use ($utilities, &$callbackRan) {
$this->assertEquals($utilities, $arg);
$callbackRan = true;
});

$this->assertFalse($callbackRan);

$utilities->boot();

$this->assertTrue($callbackRan);
}

/** @test */
public function booting_more_than_once_just_updates_the_utilities()
{
// This makes sure that booting a second time doesn't duplicate
// any utilities. It should just update/replace the existing ones.
// We boot once early so that routes can get registered, and
// then again after the user's locale preference is set so
// that the translations for labels etc use the right language.

$utilities = new UtilityRepository;

$utilities->extend(function ($utilities) {
$utilities->register('test')
->title(__('and')); // using a translation that will likely never change.
});

$utilities->boot();

$this->assertEquals(['and'], $utilities->all()->map->title()->values()->all());

app()->setLocale('fr');

$utilities->boot();

$this->assertEquals(['et'], $utilities->all()->map->title()->values()->all());
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
80dbb06
This is now normalized by UserNavConfig.
jesseleite Sep 12, 2022
8165a66
Process newly created child items the same way we process regular items.
jesseleite Sep 12, 2022
16924bb
Can't do that in PHP 7.4 my dear boy.
jesseleite Sep 13, 2022
2ec1918
Use `whenNotEmpty()`, but still apparently can't shorthand `fn()` it.
jesseleite Sep 13, 2022
90e4bf3
Refactor to separate params.
jesseleite Sep 13, 2022
a781a9a
Ensure we can rebuild nav from fresh slate.
jesseleite Nov 30, 2022
58be4f9
Support tracking preference manipulations on each NavItem instance fo…
jesseleite Nov 30, 2022
49d35c6
Track preference manipulations.
jesseleite Nov 30, 2022
4542c42
Allow passing of different preferences into `Nav::build()`.
jesseleite Nov 30, 2022
5e87094
Rename `UserNavConfig` to `NavPreferencesConfig`.
jesseleite Nov 30, 2022
6d8cfd9
Lots of front end.
jesseleite Nov 30, 2022
429e06a
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Nov 30, 2022
63093d8
The Nav and NavItem JSON resources used by the builder.
jesseleite Nov 30, 2022
84bd7e3
Hardcode link to nav.
jesseleite Nov 30, 2022
518a6da
Hide breadcrumb, because there is no preferences section yet (maybe l…
jesseleite Nov 30, 2022
6429bde
Normalize `original` for simpler logic in back end.
jesseleite Nov 30, 2022
61e2823
Wire up discard changes behaviour.
jesseleite Nov 30, 2022
088b26a
Icons.
jesseleite Nov 30, 2022
c6acbb7
Fix issue with new item IDs.
jesseleite Nov 30, 2022
e108e5f
Route and controller.
jesseleite Nov 30, 2022
4a438be
Add Nav Pref index and icon
jackmcdade Dec 6, 2022
3d7dcf4
Move `PreferenceController` and fix destroy route to actually use del…
jesseleite Dec 6, 2022
814e920
Wire up routes and controllers for default, role, and user nav prefer…
jesseleite Dec 6, 2022
a517164
Move into `CoreNav`.
jesseleite Dec 6, 2022
2629fd1
Add `buildDefault()` alias.
jesseleite Dec 6, 2022
b2b7ffe
Update front end.
jesseleite Dec 6, 2022
f273d75
Update tests.
jesseleite Dec 6, 2022
1b4bef9
Only show section if roles exist.
jesseleite Dec 6, 2022
41f2713
Add test coverage for new `Preference::preventMergingChildren()` method.
jesseleite Dec 8, 2022
336a22d
Implement `preventMergingChildren()`.
jesseleite Dec 8, 2022
aa73758
Prevent merging of children in nav preferences.
jesseleite Dec 8, 2022
74c4a79
Alias `get()` to `getPreference()`, like we do with `set()`.
jesseleite Dec 8, 2022
31c0c3e
Ensure we’re loading default preferences nav in editor.
jesseleite Dec 8, 2022
dd2ff77
Ensure we’re loading role preferences nav in editor.
jesseleite Dec 8, 2022
678921e
Alias `remove()` to `removePreference()`, like we do with `set()` and…
jesseleite Dec 8, 2022
8f389bf
Scope `Statamic.$preferences` api endpoints to prevent conflicts with…
jesseleite Dec 8, 2022
4198e51
Rename `buildDefault()` to `buildWithoutPreferences()` to avoid confu…
jesseleite Dec 8, 2022
8e7e0f8
Fix resetting of nav prefs, nav precedence on load, and clean up rout…
jesseleite Dec 8, 2022
099819a
Require pro to edit anything other than your own user preferences.
jesseleite Dec 8, 2022
71d92a4
Show confirmation modal when resetting.
jesseleite Dec 8, 2022
fa299a7
Add test to prove that first assigned user role takes precedence.
jesseleite Dec 8, 2022
d3a0d65
Fix discard changes regression.
jesseleite Dec 8, 2022
5f09b9f
Handle `.disabled` class on `.btn-group` buttons.
jesseleite Dec 8, 2022
1c4dbd2
Show reset option as warning.
jesseleite Dec 8, 2022
9c93d20
Handle ‘save as’ dropdown options.
jesseleite Dec 8, 2022
836e19f
Make index messaging a bit more consistent with other pages.
jesseleite Dec 8, 2022
cbcf4d9
Intelligently output save as options for nav builder.
jesseleite Dec 8, 2022
96d9a5d
Fix pro/super check.
jesseleite Dec 8, 2022
7255ae2
run npm install
jasonvarga Dec 9, 2022
2c391d3
add override
jasonvarga Dec 9, 2022
6629232
Merge branch 'fix-package-lock' of https://github.com/statamic/cms in…
jesseleite Dec 9, 2022
341c32d
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Dec 9, 2022
826f327
Rename to ‘CP Nav’ to avoid confusion with ‘Navigation’.
jesseleite Dec 9, 2022
328556e
Fix unique key on v-for warning.
jesseleite Dec 9, 2022
cab8390
Misc cleanup.
jesseleite Dec 9, 2022
bcbd31c
Vue payload to yaml transformation logic.
jesseleite Dec 10, 2022
b3340fd
Fix missing `display` and `url` on newly created items.
jesseleite Dec 10, 2022
3d52925
Allow removing of `@create`’d items (instead of hiding via `@remove` …
jesseleite Dec 10, 2022
7d2b40c
If there’s nothing to save, remove preference instead of saving `nav:…
jesseleite Dec 10, 2022
d9322b7
Fix overzealous `@inherit` minification when reordering.
jesseleite Dec 11, 2022
f6c8c94
Avoid submitting custom sections that have no items.
jesseleite Dec 11, 2022
1bbb1f8
Cmd+s to save.
jesseleite Dec 12, 2022
e907c10
Handle section `action: ‘@remove’` in config normalizer.
jesseleite Dec 12, 2022
af1ffc8
This shouldn’t be needed anymore, since the `normalize()` method abov…
jesseleite Dec 13, 2022
bf2a1c3
Add section manipulations into `build()` output.
jesseleite Dec 13, 2022
72bc6f9
Pluck `items` and `display` so that nav sidebar views continue to wor…
jesseleite Dec 13, 2022
08ce16a
Ensure front end merges whole section config in with items, not just …
jesseleite Dec 13, 2022
463c338
Refactor for new initial nav format on load.
jesseleite Dec 14, 2022
cf4e147
Ensure proper fallbacks.
jesseleite Dec 14, 2022
6b0c96a
Should use `NavItem::snakeCase()` for consistency.
jesseleite Dec 14, 2022
33e7857
Refactor payload to account for new `display_original` section changes.
jesseleite Dec 14, 2022
e67a60b
Improve section minification.
jesseleite Dec 14, 2022
8f33987
Ensure we also pass action to server.
jesseleite Dec 14, 2022
048d8ce
`Nav::build()` was always returning a collection, so this should too.
jesseleite Dec 14, 2022
c45acdd
Pass tests again.
jesseleite Dec 14, 2022
56a80b1
Actually, let’s avoid this `pluck()` and just fix the views.
jesseleite Dec 14, 2022
8210108
Rely on `display_original` for more consistent `itemsAreReordered` lo…
jesseleite Dec 14, 2022
474f565
Only ever show `@inherit` action when section config is empty, for re…
jesseleite Dec 14, 2022
4200a32
Ensure user can still see hidden items in builder on reload.
jesseleite Dec 14, 2022
c0e1b17
Properly handle `withHidden()` state when rebuilding.
jesseleite Dec 14, 2022
359ab19
Reload on save in order to see changes on save.
jesseleite Dec 14, 2022
fc6a8f9
This shoulda been in data.
jesseleite Dec 14, 2022
a831b26
Rename isNew to isCustom and use a new icon
jackmcdade Dec 14, 2022
5e32408
Autofocus first field in stacks, support a plain "enter" key binding
jackmcdade Dec 14, 2022
6a3811b
Use the proper prop data type
jackmcdade Dec 14, 2022
5fe9a23
Prevent hiding `CP Nav` item, so user can always access it.
jesseleite Dec 14, 2022
18233f7
Simplify that last commit.
jesseleite Dec 14, 2022
1b6d7f2
Hook up Expand All and Collapse All controls
jackmcdade Dec 14, 2022
56c784f
Don't need depth here.
jackmcdade Dec 14, 2022
981e6b2
Fix `isSectionNode()` for top level tree items.
jesseleite Dec 14, 2022
de3f29e
Clean up a few JS errors.
jesseleite Dec 14, 2022
db6252a
Make `prevent_hiding` work at section level.
jesseleite Dec 14, 2022
895a661
Prevent user from accidentally hiding CP Nav by dragging into hidden …
jesseleite Dec 14, 2022
e34415a
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
d8b43dd
Snip snap ✂️
jesseleite Dec 14, 2022
a378c98
Preferences Dropdown in the Global Header
jackmcdade Dec 14, 2022
f7b663e
Add `configure cp nav` permission.
jesseleite Dec 14, 2022
1290562
Rename/fix `Statamic.$preferences` endpoints.
jesseleite Dec 14, 2022
14af432
Wrap these routes with pro/permission checks.
jesseleite Dec 14, 2022
b1e3f73
Hook up redirect at controller level.
jesseleite Dec 14, 2022
5179f8c
Update permission check for nav builder breadcrumb link.
jesseleite Dec 14, 2022
f45d787
Remove from core nav, since Jack is adding cool gear in top nav.
jesseleite Dec 14, 2022
2eede65
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
e5e54b9
Pass tests.
jesseleite Dec 14, 2022
7eaebe5
Forgot to snip snap ✂️
jesseleite Dec 15, 2022
d3ecb7e
Improve styling for hidden sections.
jesseleite Dec 15, 2022
b716bcd
Ensure we properly minify section hide action.
jesseleite Dec 15, 2022
b691367
Expand and collapse items in top level tree as well.
jesseleite Dec 15, 2022
fa38a80
Hide hidden sections in built navs.
jesseleite Dec 15, 2022
82a1245
Fix JS errors.
jesseleite Dec 15, 2022
b946954
Ensure section level manipulations get properly set on load.
jesseleite Dec 15, 2022
f1848e3
Fix string replace.
jesseleite Dec 15, 2022
b1d6528
Return `$items` directly.
jesseleite Dec 15, 2022
2fbf6e6
Fix action handling in section minification.
jesseleite Dec 15, 2022
43bd885
Confirm removal of custom section when it contains items.
jesseleite Dec 15, 2022
f066f18
initial preferences ui
jasonvarga Dec 15, 2022
9d3e9cd
Apply fixes from StyleCI
StyleCIBot Dec 15, 2022
4458c04
Remove preferences if form field is set to the default value
jasonvarga Dec 15, 2022
36393f8
Flesh out allowed section actions and modifications as constants.
jesseleite Dec 15, 2022
a0b9711
add prop to allow publish form to reload on save
jasonvarga Dec 15, 2022
38428e2
Make permission more generic
jasonvarga Dec 15, 2022
c986eec
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 15, 2022
e99ae57
Wire up user/default/role forms
jasonvarga Dec 15, 2022
f09bfdc
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 16, 2022
f7a9a9e
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Dec 16, 2022
e28020b
Remove section `@inherit`s from config after processing reordering.
jesseleite Dec 16, 2022
793992c
Fix removing of sections and items after last sections overhaul.
jesseleite Dec 16, 2022
20ff852
Refactor `@remove` to `@hide`.
jesseleite Dec 16, 2022
11e356f
Fix undoing and saving ‘default’ level changes at user level, so that…
jesseleite Dec 16, 2022
57470dc
Apply the same fix at the role level.
jesseleite Dec 16, 2022
8156b53
Allow nulling/removing at default preferences level though.
jesseleite Dec 16, 2022
40e9b5d
Fix `@create` custom section items.
jesseleite Dec 17, 2022
e6eb308
Prevent adding item children to item children.
jesseleite Dec 17, 2022
b3cecce
Pass tests again, ensuring we don’t duplicate modified items in place.
jesseleite Dec 17, 2022
d23aa59
Rename to `NavPreferencesNormalizer::fromPreferences()` for clarity.
jesseleite Dec 17, 2022
878aa4b
Move all nav building logic out into a `NavBuilder` class so that we …
jesseleite Dec 17, 2022
15167da
Clarify why `Nav::extend()` is needed in test.
jesseleite Dec 17, 2022
9edab4d
Show custom section as ‘Custom Section’.
jesseleite Dec 17, 2022
fc1aad7
Misc cleanup.
jesseleite Dec 18, 2022
2a4dae0
Add support for `reorder` on item children.
jesseleite Dec 18, 2022
702f26a
Fix `@move` action when moving a parent item into the children of ano…
jesseleite Dec 18, 2022
93bb5c1
Ensure aliased items have no children unless explicitly set.
jesseleite Dec 18, 2022
4128730
Show configured `children` on aliased items, etc.
jesseleite Dec 18, 2022
e83fb1c
Show moved item icon (WIP).
jesseleite Dec 18, 2022
71a2e9e
Fix `@create`’d children within `@alias`’d items.
jesseleite Dec 18, 2022
ef88276
Pass tests again and cleanup todo’s.
jesseleite Dec 18, 2022
43387ef
Flesh out builder test coverage for recent fixes.
jesseleite Dec 18, 2022
a01291d
Add `syncOriginal()` functionality to `NavItem` class so we can detec…
jesseleite Dec 19, 2022
390dce0
Sync original on each item just before applying nav preference manipu…
jesseleite Dec 19, 2022
9cd1297
Pass original nav item state to tree data in front end builder.
jesseleite Dec 19, 2022
3382d44
Show icon and tooltip for renamed sections.
jesseleite Dec 19, 2022
35458d9
Ensure newly resolved child items sync their original state as well.
jesseleite Dec 19, 2022
b3a55e5
Ensure we can get current section from original children.
jesseleite Dec 19, 2022
624bd04
Fix updating of item manipulations when dragging or updating items.
jesseleite Dec 19, 2022
7d8594e
Fix JS error.
jesseleite Dec 19, 2022
8bff1ea
Fix regression since adding ‘section’ data to nested child items.
jesseleite Dec 19, 2022
a68025b
Fix overzealous `@move` action in front end.
jesseleite Dec 19, 2022
069c80f
Collapse top level items by default, to be consistent with the rest o…
jesseleite Dec 19, 2022
e289921
Fix ordering error on PHP 7.4.
jesseleite Dec 19, 2022
c743756
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 19, 2022
4afb33f
Fix duplicate hidden items regression.
jesseleite Dec 19, 2022
767ab26
Clean up `updateItemAction()` method using more readable switch case.
jesseleite Dec 19, 2022
22483cd
Get and pass clean editable nav item urls to nav builder.
jesseleite Dec 19, 2022
06fbbee
Transform on save, so that we don’t store local domain or configurabl…
jesseleite Dec 19, 2022
a5e20da
Move modified children `action` check to JS, where we handle the rest…
jesseleite Dec 19, 2022
25b2045
Fix reordering on child items payload on save.
jesseleite Dec 19, 2022
5deff45
Fix inability to move item out of an item’s children within the same …
jesseleite Dec 19, 2022
77bf587
Pass tests again.
jesseleite Dec 19, 2022
499072b
Fix disappearing of moved/aliased items by using item’s original ID w…
jesseleite Dec 20, 2022
9afd1aa
Whoops, not inherit.
jesseleite Dec 20, 2022
5ec4135
Improve reorder detection logic.
jesseleite Dec 20, 2022
57ef831
TIL, we cannot use our `Arr::get()` to get `some::id` with double col…
jesseleite Dec 20, 2022
1b18a4e
If `withHidden`, resolve/build all children, to fix cloned IDs bug in…
jesseleite Dec 21, 2022
503ce64
Fix action detection bug.
jesseleite Dec 21, 2022
4dc88ae
Handle empty sections.
jesseleite Dec 21, 2022
ba65452
Make sure we also update action on the parent node they dragged out of.
jesseleite Dec 21, 2022
8ec2f3d
Fix bug when trying to drag newly created/aliased item into another s…
jesseleite Dec 21, 2022
311a5e5
Builder doesn’t need children in manipulations.
jesseleite Dec 21, 2022
151984e
Handle tracking of renamed core sections.
jesseleite Dec 21, 2022
7cd8417
Fix and clean up drag level logic.
jesseleite Dec 21, 2022
413ae4f
Fix more JS errors.
jesseleite Dec 21, 2022
44a027a
Fix a whole bunch of moved/aliased/hidden item issues.
jesseleite Dec 21, 2022
2096ed0
Fix section reordering bug when core section has no items.
jesseleite Dec 22, 2022
f8324a0
Require both display and url.
jesseleite Dec 22, 2022
156e7aa
Remove console.log
jesseleite Dec 22, 2022
693af81
Whoops!
jesseleite Jan 3, 2023
fab9fa0
Removing flex fixes icons not showing in safari
jasonvarga Jan 3, 2023
09d068b
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Jan 3, 2023
5061db1
Never delete from manipulations for `@create`’d items, since there is…
jesseleite Jan 3, 2023
0f72eca
Never `@alias` a `@create`’d item.
jesseleite Jan 3, 2023
12f658a
Magic section setter should never look at nav item children.
jesseleite Jan 3, 2023
433e5c6
Allow overriding of preferences using `[]` when using `preventMerging…
jesseleite Jan 3, 2023
2ecd30d
Remove `nav: @override` in favour of `nav: []` for overriding of nav …
jesseleite Jan 3, 2023
8484154
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b0bae04
Add 'save as' functionality ...
jasonvarga Jan 4, 2023
a8d1ede
Validate
jasonvarga Jan 4, 2023
20cb443
Prevent "are you sure you want to navigate away" dialog when saving
jasonvarga Jan 4, 2023
d75bd14
Remove redundant `Customize` link in favour of `Modified` status.
jesseleite Jan 4, 2023
ba6889b
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b6868b5
Always touchdown for Jason 🏈
jesseleite Jan 4, 2023
160c3ad
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
ed2532b
Show modified text instead of customize link
jasonvarga Jan 4, 2023
04e990e
translate
jasonvarga Jan 4, 2023
a92d780
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
31d6aba
translate
jasonvarga Jan 4, 2023
e8caaf6
Adjust for translations
jasonvarga Jan 4, 2023
181bfba
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
5e12a53
make consistent with navs
jasonvarga Jan 4, 2023
277a45f
Remove 'Global' here, since we don't say this in page titles / save d…
jesseleite Jan 4, 2023
57a41ba
Remove redundant heading
jasonvarga Jan 4, 2023
7107063
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
9aea2c4
consistency
jasonvarga Jan 4, 2023
3470d51
Make sure Save To... dropdown doesn't clip or shrink child content
jackmcdade Jan 5, 2023
3006d22
Small improvements to make `NavTransformer` easier to test.
jesseleite Jan 5, 2023
b9bc2e5
Add whole bunch of `NavTransformer` test coverage.
jesseleite Jan 6, 2023
9066391
Add test coverage for intelligent url handling on save.
jesseleite Jan 6, 2023
a08b5d9
Add test coverage for complex json payload copied from actual vue sub…
jesseleite Jan 6, 2023
d65e105
delete method requires putting data into config
jasonvarga Jan 10, 2023
4de36c0
unused
jasonvarga Jan 10, 2023
fe03ebb
inline
jasonvarga Jan 10, 2023
edba03e
prevent saving through save button dropdown when unchanged
jasonvarga Jan 10, 2023
881e162
disable the dropdown when unchanged
jasonvarga Jan 10, 2023
bb4bb92
*slaps own wrist*
jasonvarga Jan 10, 2023
233cbd0
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 10, 2023
994e0c1
Fix issue with preferences property cache ...
jasonvarga Jan 10, 2023
5058985
CP locale can fall back to role and default preferences
jasonvarga Jan 10, 2023
5c470dc
remove comma for diff
jasonvarga Jan 11, 2023
e05d3fd
make save as dropdown consistent with nav
jasonvarga Jan 11, 2023
db6afcb
localize preference display and instructions
jasonvarga Jan 11, 2023
49c4334
Add preference extend and middleware to allow translations to be used…
jasonvarga Jan 11, 2023
e366c16
ability to defer permission registration until after locale has been …
jasonvarga Jan 11, 2023
a35f750
Apply similar changes to utilities
jasonvarga Jan 11, 2023
398da66
Might as well avoid using deprecated code now
jasonvarga Jan 11, 2023
5f81ff7
Pass preferences into section closure
jasonvarga Jan 12, 2023
efa60e6
Add simpler syntax for registering preferences
jasonvarga Jan 12, 2023
e652e7a
avoid facade
jasonvarga Jan 12, 2023
93329f9
prevent overriding section display names
jasonvarga Jan 12, 2023
6d9416b
Add test coverage for `Nav::extend()`’d sections that don’t follow ti…
jesseleite Jan 12, 2023
c2b3098
Only pass along `display` if it’s explicitly configured for renaming …
jesseleite Jan 12, 2023
6eefad5
Pass failing tests by moving section display and rename logic into `N…
jesseleite Jan 12, 2023
666c723
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Jan 12, 2023
ddf695a
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 13, 2023
d5261cd
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
95a4b3b
Merge branch 'master' into feature/preferences-ui
jasonvarga Jan 13, 2023
f9673de
Disable save part of button and leave dropdown active
jasonvarga Jan 13, 2023
77c3115
Leave dropdown active
jasonvarga Jan 13, 2023
421e81e
Add heading
jasonvarga Jan 13, 2023
01e883e
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
1f56155
Merge branch 'master' into permission-translations
jasonvarga Jan 13, 2023
f2fa807
unnecessary
jasonvarga Jan 13, 2023
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
22 changes: 22 additions & 0 deletions src/Auth/Permissions.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,34 @@

namespace Statamic\Auth;

use Facades\Statamic\Auth\CorePermissions;

class Permissions
{
protected $extensions = [];
protected $permissions = [];
protected $groups = [];
protected $pendingGroup = null;

public function boot()
{
$early = $this->permissions;
$this->permissions = [];

CorePermissions::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}

$this->permissions = array_merge($this->permissions, $early);
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make(string $value)
{
$permission = (new Permission)->value($value);
Expand Down
30 changes: 12 additions & 18 deletions src/CP/Utilities/CoreUtilities.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,7 @@ class CoreUtilities
{
public static function boot()
{
Utility::make('cache')
Utility::register('cache')
->action([CacheController::class, 'index'])
->title(__('Cache Manager'))
->icon('cache')
Expand All@@ -26,60 +26,54 @@ public static function boot()
->routes(function ($router) {
$router->post('cache/{cache}', [CacheController::class, 'clear'])->name('clear');
$router->post('cache/{cache}/warm', [CacheController::class, 'warm'])->name('warm');
})
->register();
});

Utility::make('phpinfo')
Utility::register('phpinfo')
->action(PhpInfoController::class)
->title(__('PHP Info'))
->icon('php')
->description(__('statamic::messages.phpinfo_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/phpinfo'))
->register();
->docsUrl(Statamic::docsUrl('utilities/phpinfo'));

Utility::make('search')
Utility::register('search')
->view('statamic::utilities.search')
->title(__('Search'))
->icon('search-utility')
->description(__('statamic::messages.search_utility_description'))
->routes(function ($router) {
$router->post('/', [UpdateSearchController::class, 'update'])->name('update');
})
->register();
});

Utility::make('email')
Utility::register('email')
->view('statamic::utilities.email')
->title(__('Email'))
->icon('email-utility')
->description(__('statamic::messages.email_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/email'))
->routes(function ($router) {
$router->post('/', [EmailController::class, 'send']);
})
->register();
});

Utility::make('licensing')
Utility::register('licensing')
->action([LicensingController::class, 'show'])
->title(__('Licensing'))
->icon('licensing')
->description(__('statamic::messages.licensing_utility_description'))
->docsUrl(Statamic::docsUrl('licensing'))
->routes(function ($router) {
$router->get('refresh', [LicensingController::class, 'refresh'])->name('refresh');
})
->register();
});

if (config('statamic.git.enabled') && Statamic::pro()) {
Utility::make('git')
Utility::register('git')
->action([GitController::class, 'index'])
->title('Git')
->icon('git')
->description(__('statamic::messages.git_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/git'))
->routes(function ($router) {
$router->post('/', [GitController::class, 'commit'])->name('commit');
})
->register();
});
}
}
}
1 change: 1 addition & 0 deletions src/CP/Utilities/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,6 +104,7 @@ public function routes(Closure $routes = null)
return $this->fluentlyGetOrSet('routes')->args(func_get_args());
}

/** @deprecated */
public function register()
{
\Statamic\Facades\Utility::push($this);
Expand Down
32 changes: 31 additions & 1 deletion src/CP/Utilities/UtilityRepository.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,27 +2,55 @@

namespace Statamic\CP\Utilities;

use Facades\Statamic\CP\Utilities\CoreUtilities;
use Illuminate\Support\Facades\Route;
use Statamic\Facades\User;

class UtilityRepository
{
protected $utilities;
protected $extensions = [];

public function __construct()
{
$this->utilities = collect([]);
}

public function boot()
{
CoreUtilities::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make($handle)
{
return (new Utility)->handle($handle);
}

public function push(Utility $utility)
public function register($utility)
{
if (! $utility instanceof Utility) {
$utility = $this->make($utility);
}

$this->utilities[$utility->handle()] = $utility;

return $utility;
}

/** @deprecated */
public function push(Utility $utility)
{
$this->register($utility);

return $this;
}

Expand All@@ -45,6 +73,8 @@ public function find($handle)

public function routes()
{
$this->boot();

Route::namespace('\\')->prefix('utilities')->name('utilities.')->group(function () {
$this->all()->each(function ($utility) {
if ($utility->action()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

/**
* @method static mixed|null make($handle)
* @method static self push(Utility $utility)
* @method static \Statamic\CP\Utilities\Utility register($utility)
* @method static mixed all()
* @method static mixed authorized()
* @method static mixed find($handle)
Expand Down
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootPermissions.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Permission;

class BootPermissions
{
public function handle($request, Closure $next)
{
Permission::boot();

return $next($request);
}
}
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootUtilities.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Utility;

class BootUtilities
{
public function handle($request, Closure $next)
{
Utility::boot();

return $next($request);
}
}
2 changes: 1 addition & 1 deletion src/Preferences/Preferences.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -230,7 +230,7 @@ public function section($handle, $label, $permissions = null)

$this->pendingSection = $handle;

$permissions();
$permissions($this);

$this->pendingSection = null;
}
Expand Down
5 changes: 0 additions & 5 deletions src/Providers/AuthServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@

namespace Statamic\Providers;

use Facades\Statamic\Auth\CorePermissions;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
Expand DownExpand Up@@ -90,10 +89,6 @@ public function boot()
return optional(User::fromUser($user))->hasPermission($ability) === true ? true : null;
});

$this->app->booted(function () {
CorePermissions::boot();
});

foreach ($this->policies as $key => $policy) {
Gate::policy($key, $policy);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Providers/CpServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Statamic\CP\Utilities\CoreUtilities;
use Statamic\CP\Utilities\UtilityRepository;
use Statamic\Extensions\Translation\Loader;
use Statamic\Extensions\Translation\Translator;
Expand All@@ -33,8 +32,6 @@ public function boot()
View::composer(NavComposer::VIEWS, NavComposer::class);
View::composer(CustomLogoComposer::VIEWS, CustomLogoComposer::class);

CoreUtilities::boot();

Blade::directive('cp_svg', function ($expression) {
return "<?php echo Statamic::svg({$expression}) ?>";
});
Expand DownExpand Up@@ -83,7 +80,9 @@ protected function registerMiddlewareGroups()
$router->middlewareGroup('statamic.cp.authenticated', [
\Statamic\Http\Middleware\CP\Authorize::class,
\Statamic\Http\Middleware\CP\Localize::class,
\Statamic\Http\Middleware\CP\BootPermissions::class,
\Statamic\Http\Middleware\CP\BootPreferences::class,
\Statamic\Http\Middleware\CP\BootUtilities::class,
\Statamic\Http\Middleware\CP\CountUsers::class,
\Statamic\Http\Middleware\DeleteTemporaryFileUploads::class,
]);
Expand Down
96 changes: 96 additions & 0 deletions tests/CP/Utilities/UtilityRepositoryTest.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
<?php

namespace Tests\CP\Utilities;

use Illuminate\Support\Collection;
use Statamic\CP\Utilities\Utility;
use Statamic\CP\Utilities\UtilityRepository;
use Tests\TestCase;

class UtilityRepositoryTest extends TestCase
{
/**
* @test
*
* @dataProvider registerMethodProvider
*/
public function it_registers_a_utility($registerMethod)
{
$utilities = new UtilityRepository;
$this->assertInstanceOf(Collection::class, $utilities->all());
$this->assertCount(0, $utilities->all());

$utility = $utilities->make('one');
$this->assertCount(0, $utilities->all());

$utilities->$registerMethod($utility);
$this->assertEquals(['one' => $utility], $utilities->all()->all());
$this->assertEquals($utility, $utilities->find('one'));
}

public function registerMethodProvider()
{
return [
'register' => ['register'],
'push' => ['push'], // @deprecated
];
}

/** @test */
public function it_registers_a_utility_via_a_string()
{
$utilities = new UtilityRepository;

$utility = $utilities->register('one');

$this->assertInstanceOf(Utility::class, $utility);
$this->assertEquals('one', $utility->handle());
$this->assertCount(1, $utilities->all());
$this->assertEquals(['one' => $utility], $utilities->all()->all());
}

/** @test */
public function it_defers_registration_until_boot_using_extend_method()
{
$utilities = new UtilityRepository;
$callbackRan = false;

$utilities->extend(function ($arg) use ($utilities, &$callbackRan) {
$this->assertEquals($utilities, $arg);
$callbackRan = true;
});

$this->assertFalse($callbackRan);

$utilities->boot();

$this->assertTrue($callbackRan);
}

/** @test */
public function booting_more_than_once_just_updates_the_utilities()
{
// This makes sure that booting a second time doesn't duplicate
// any utilities. It should just update/replace the existing ones.
// We boot once early so that routes can get registered, and
// then again after the user's locale preference is set so
// that the translations for labels etc use the right language.

$utilities = new UtilityRepository;

$utilities->extend(function ($utilities) {
$utilities->register('test')
->title(__('and')); // using a translation that will likely never change.
});

$utilities->boot();

$this->assertEquals(['and'], $utilities->all()->map->title()->values()->all());

app()->setLocale('fr');

$utilities->boot();

$this->assertEquals(['et'], $utilities->all()->map->title()->values()->all());
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
80dbb06
This is now normalized by UserNavConfig.
jesseleite Sep 12, 2022
8165a66
Process newly created child items the same way we process regular items.
jesseleite Sep 12, 2022
16924bb
Can't do that in PHP 7.4 my dear boy.
jesseleite Sep 13, 2022
2ec1918
Use `whenNotEmpty()`, but still apparently can't shorthand `fn()` it.
jesseleite Sep 13, 2022
90e4bf3
Refactor to separate params.
jesseleite Sep 13, 2022
a781a9a
Ensure we can rebuild nav from fresh slate.
jesseleite Nov 30, 2022
58be4f9
Support tracking preference manipulations on each NavItem instance fo…
jesseleite Nov 30, 2022
49d35c6
Track preference manipulations.
jesseleite Nov 30, 2022
4542c42
Allow passing of different preferences into `Nav::build()`.
jesseleite Nov 30, 2022
5e87094
Rename `UserNavConfig` to `NavPreferencesConfig`.
jesseleite Nov 30, 2022
6d8cfd9
Lots of front end.
jesseleite Nov 30, 2022
429e06a
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Nov 30, 2022
63093d8
The Nav and NavItem JSON resources used by the builder.
jesseleite Nov 30, 2022
84bd7e3
Hardcode link to nav.
jesseleite Nov 30, 2022
518a6da
Hide breadcrumb, because there is no preferences section yet (maybe l…
jesseleite Nov 30, 2022
6429bde
Normalize `original` for simpler logic in back end.
jesseleite Nov 30, 2022
61e2823
Wire up discard changes behaviour.
jesseleite Nov 30, 2022
088b26a
Icons.
jesseleite Nov 30, 2022
c6acbb7
Fix issue with new item IDs.
jesseleite Nov 30, 2022
e108e5f
Route and controller.
jesseleite Nov 30, 2022
4a438be
Add Nav Pref index and icon
jackmcdade Dec 6, 2022
3d7dcf4
Move `PreferenceController` and fix destroy route to actually use del…
jesseleite Dec 6, 2022
814e920
Wire up routes and controllers for default, role, and user nav prefer…
jesseleite Dec 6, 2022
a517164
Move into `CoreNav`.
jesseleite Dec 6, 2022
2629fd1
Add `buildDefault()` alias.
jesseleite Dec 6, 2022
b2b7ffe
Update front end.
jesseleite Dec 6, 2022
f273d75
Update tests.
jesseleite Dec 6, 2022
1b4bef9
Only show section if roles exist.
jesseleite Dec 6, 2022
41f2713
Add test coverage for new `Preference::preventMergingChildren()` method.
jesseleite Dec 8, 2022
336a22d
Implement `preventMergingChildren()`.
jesseleite Dec 8, 2022
aa73758
Prevent merging of children in nav preferences.
jesseleite Dec 8, 2022
74c4a79
Alias `get()` to `getPreference()`, like we do with `set()`.
jesseleite Dec 8, 2022
31c0c3e
Ensure we’re loading default preferences nav in editor.
jesseleite Dec 8, 2022
dd2ff77
Ensure we’re loading role preferences nav in editor.
jesseleite Dec 8, 2022
678921e
Alias `remove()` to `removePreference()`, like we do with `set()` and…
jesseleite Dec 8, 2022
8f389bf
Scope `Statamic.$preferences` api endpoints to prevent conflicts with…
jesseleite Dec 8, 2022
4198e51
Rename `buildDefault()` to `buildWithoutPreferences()` to avoid confu…
jesseleite Dec 8, 2022
8e7e0f8
Fix resetting of nav prefs, nav precedence on load, and clean up rout…
jesseleite Dec 8, 2022
099819a
Require pro to edit anything other than your own user preferences.
jesseleite Dec 8, 2022
71d92a4
Show confirmation modal when resetting.
jesseleite Dec 8, 2022
fa299a7
Add test to prove that first assigned user role takes precedence.
jesseleite Dec 8, 2022
d3a0d65
Fix discard changes regression.
jesseleite Dec 8, 2022
5f09b9f
Handle `.disabled` class on `.btn-group` buttons.
jesseleite Dec 8, 2022
1c4dbd2
Show reset option as warning.
jesseleite Dec 8, 2022
9c93d20
Handle ‘save as’ dropdown options.
jesseleite Dec 8, 2022
836e19f
Make index messaging a bit more consistent with other pages.
jesseleite Dec 8, 2022
cbcf4d9
Intelligently output save as options for nav builder.
jesseleite Dec 8, 2022
96d9a5d
Fix pro/super check.
jesseleite Dec 8, 2022
7255ae2
run npm install
jasonvarga Dec 9, 2022
2c391d3
add override
jasonvarga Dec 9, 2022
6629232
Merge branch 'fix-package-lock' of https://github.com/statamic/cms in…
jesseleite Dec 9, 2022
341c32d
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Dec 9, 2022
826f327
Rename to ‘CP Nav’ to avoid confusion with ‘Navigation’.
jesseleite Dec 9, 2022
328556e
Fix unique key on v-for warning.
jesseleite Dec 9, 2022
cab8390
Misc cleanup.
jesseleite Dec 9, 2022
bcbd31c
Vue payload to yaml transformation logic.
jesseleite Dec 10, 2022
b3340fd
Fix missing `display` and `url` on newly created items.
jesseleite Dec 10, 2022
3d52925
Allow removing of `@create`’d items (instead of hiding via `@remove` …
jesseleite Dec 10, 2022
7d2b40c
If there’s nothing to save, remove preference instead of saving `nav:…
jesseleite Dec 10, 2022
d9322b7
Fix overzealous `@inherit` minification when reordering.
jesseleite Dec 11, 2022
f6c8c94
Avoid submitting custom sections that have no items.
jesseleite Dec 11, 2022
1bbb1f8
Cmd+s to save.
jesseleite Dec 12, 2022
e907c10
Handle section `action: ‘@remove’` in config normalizer.
jesseleite Dec 12, 2022
af1ffc8
This shouldn’t be needed anymore, since the `normalize()` method abov…
jesseleite Dec 13, 2022
bf2a1c3
Add section manipulations into `build()` output.
jesseleite Dec 13, 2022
72bc6f9
Pluck `items` and `display` so that nav sidebar views continue to wor…
jesseleite Dec 13, 2022
08ce16a
Ensure front end merges whole section config in with items, not just …
jesseleite Dec 13, 2022
463c338
Refactor for new initial nav format on load.
jesseleite Dec 14, 2022
cf4e147
Ensure proper fallbacks.
jesseleite Dec 14, 2022
6b0c96a
Should use `NavItem::snakeCase()` for consistency.
jesseleite Dec 14, 2022
33e7857
Refactor payload to account for new `display_original` section changes.
jesseleite Dec 14, 2022
e67a60b
Improve section minification.
jesseleite Dec 14, 2022
8f33987
Ensure we also pass action to server.
jesseleite Dec 14, 2022
048d8ce
`Nav::build()` was always returning a collection, so this should too.
jesseleite Dec 14, 2022
c45acdd
Pass tests again.
jesseleite Dec 14, 2022
56a80b1
Actually, let’s avoid this `pluck()` and just fix the views.
jesseleite Dec 14, 2022
8210108
Rely on `display_original` for more consistent `itemsAreReordered` lo…
jesseleite Dec 14, 2022
474f565
Only ever show `@inherit` action when section config is empty, for re…
jesseleite Dec 14, 2022
4200a32
Ensure user can still see hidden items in builder on reload.
jesseleite Dec 14, 2022
c0e1b17
Properly handle `withHidden()` state when rebuilding.
jesseleite Dec 14, 2022
359ab19
Reload on save in order to see changes on save.
jesseleite Dec 14, 2022
fc6a8f9
This shoulda been in data.
jesseleite Dec 14, 2022
a831b26
Rename isNew to isCustom and use a new icon
jackmcdade Dec 14, 2022
5e32408
Autofocus first field in stacks, support a plain "enter" key binding
jackmcdade Dec 14, 2022
6a3811b
Use the proper prop data type
jackmcdade Dec 14, 2022
5fe9a23
Prevent hiding `CP Nav` item, so user can always access it.
jesseleite Dec 14, 2022
18233f7
Simplify that last commit.
jesseleite Dec 14, 2022
1b6d7f2
Hook up Expand All and Collapse All controls
jackmcdade Dec 14, 2022
56c784f
Don't need depth here.
jackmcdade Dec 14, 2022
981e6b2
Fix `isSectionNode()` for top level tree items.
jesseleite Dec 14, 2022
de3f29e
Clean up a few JS errors.
jesseleite Dec 14, 2022
db6252a
Make `prevent_hiding` work at section level.
jesseleite Dec 14, 2022
895a661
Prevent user from accidentally hiding CP Nav by dragging into hidden …
jesseleite Dec 14, 2022
e34415a
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
d8b43dd
Snip snap ✂️
jesseleite Dec 14, 2022
a378c98
Preferences Dropdown in the Global Header
jackmcdade Dec 14, 2022
f7b663e
Add `configure cp nav` permission.
jesseleite Dec 14, 2022
1290562
Rename/fix `Statamic.$preferences` endpoints.
jesseleite Dec 14, 2022
14af432
Wrap these routes with pro/permission checks.
jesseleite Dec 14, 2022
b1e3f73
Hook up redirect at controller level.
jesseleite Dec 14, 2022
5179f8c
Update permission check for nav builder breadcrumb link.
jesseleite Dec 14, 2022
f45d787
Remove from core nav, since Jack is adding cool gear in top nav.
jesseleite Dec 14, 2022
2eede65
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
e5e54b9
Pass tests.
jesseleite Dec 14, 2022
7eaebe5
Forgot to snip snap ✂️
jesseleite Dec 15, 2022
d3ecb7e
Improve styling for hidden sections.
jesseleite Dec 15, 2022
b716bcd
Ensure we properly minify section hide action.
jesseleite Dec 15, 2022
b691367
Expand and collapse items in top level tree as well.
jesseleite Dec 15, 2022
fa38a80
Hide hidden sections in built navs.
jesseleite Dec 15, 2022
82a1245
Fix JS errors.
jesseleite Dec 15, 2022
b946954
Ensure section level manipulations get properly set on load.
jesseleite Dec 15, 2022
f1848e3
Fix string replace.
jesseleite Dec 15, 2022
b1d6528
Return `$items` directly.
jesseleite Dec 15, 2022
2fbf6e6
Fix action handling in section minification.
jesseleite Dec 15, 2022
43bd885
Confirm removal of custom section when it contains items.
jesseleite Dec 15, 2022
f066f18
initial preferences ui
jasonvarga Dec 15, 2022
9d3e9cd
Apply fixes from StyleCI
StyleCIBot Dec 15, 2022
4458c04
Remove preferences if form field is set to the default value
jasonvarga Dec 15, 2022
36393f8
Flesh out allowed section actions and modifications as constants.
jesseleite Dec 15, 2022
a0b9711
add prop to allow publish form to reload on save
jasonvarga Dec 15, 2022
38428e2
Make permission more generic
jasonvarga Dec 15, 2022
c986eec
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 15, 2022
e99ae57
Wire up user/default/role forms
jasonvarga Dec 15, 2022
f09bfdc
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 16, 2022
f7a9a9e
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Dec 16, 2022
e28020b
Remove section `@inherit`s from config after processing reordering.
jesseleite Dec 16, 2022
793992c
Fix removing of sections and items after last sections overhaul.
jesseleite Dec 16, 2022
20ff852
Refactor `@remove` to `@hide`.
jesseleite Dec 16, 2022
11e356f
Fix undoing and saving ‘default’ level changes at user level, so that…
jesseleite Dec 16, 2022
57470dc
Apply the same fix at the role level.
jesseleite Dec 16, 2022
8156b53
Allow nulling/removing at default preferences level though.
jesseleite Dec 16, 2022
40e9b5d
Fix `@create` custom section items.
jesseleite Dec 17, 2022
e6eb308
Prevent adding item children to item children.
jesseleite Dec 17, 2022
b3cecce
Pass tests again, ensuring we don’t duplicate modified items in place.
jesseleite Dec 17, 2022
d23aa59
Rename to `NavPreferencesNormalizer::fromPreferences()` for clarity.
jesseleite Dec 17, 2022
878aa4b
Move all nav building logic out into a `NavBuilder` class so that we …
jesseleite Dec 17, 2022
15167da
Clarify why `Nav::extend()` is needed in test.
jesseleite Dec 17, 2022
9edab4d
Show custom section as ‘Custom Section’.
jesseleite Dec 17, 2022
fc1aad7
Misc cleanup.
jesseleite Dec 18, 2022
2a4dae0
Add support for `reorder` on item children.
jesseleite Dec 18, 2022
702f26a
Fix `@move` action when moving a parent item into the children of ano…
jesseleite Dec 18, 2022
93bb5c1
Ensure aliased items have no children unless explicitly set.
jesseleite Dec 18, 2022
4128730
Show configured `children` on aliased items, etc.
jesseleite Dec 18, 2022
e83fb1c
Show moved item icon (WIP).
jesseleite Dec 18, 2022
71a2e9e
Fix `@create`’d children within `@alias`’d items.
jesseleite Dec 18, 2022
ef88276
Pass tests again and cleanup todo’s.
jesseleite Dec 18, 2022
43387ef
Flesh out builder test coverage for recent fixes.
jesseleite Dec 18, 2022
a01291d
Add `syncOriginal()` functionality to `NavItem` class so we can detec…
jesseleite Dec 19, 2022
390dce0
Sync original on each item just before applying nav preference manipu…
jesseleite Dec 19, 2022
9cd1297
Pass original nav item state to tree data in front end builder.
jesseleite Dec 19, 2022
3382d44
Show icon and tooltip for renamed sections.
jesseleite Dec 19, 2022
35458d9
Ensure newly resolved child items sync their original state as well.
jesseleite Dec 19, 2022
b3a55e5
Ensure we can get current section from original children.
jesseleite Dec 19, 2022
624bd04
Fix updating of item manipulations when dragging or updating items.
jesseleite Dec 19, 2022
7d8594e
Fix JS error.
jesseleite Dec 19, 2022
8bff1ea
Fix regression since adding ‘section’ data to nested child items.
jesseleite Dec 19, 2022
a68025b
Fix overzealous `@move` action in front end.
jesseleite Dec 19, 2022
069c80f
Collapse top level items by default, to be consistent with the rest o…
jesseleite Dec 19, 2022
e289921
Fix ordering error on PHP 7.4.
jesseleite Dec 19, 2022
c743756
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 19, 2022
4afb33f
Fix duplicate hidden items regression.
jesseleite Dec 19, 2022
767ab26
Clean up `updateItemAction()` method using more readable switch case.
jesseleite Dec 19, 2022
22483cd
Get and pass clean editable nav item urls to nav builder.
jesseleite Dec 19, 2022
06fbbee
Transform on save, so that we don’t store local domain or configurabl…
jesseleite Dec 19, 2022
a5e20da
Move modified children `action` check to JS, where we handle the rest…
jesseleite Dec 19, 2022
25b2045
Fix reordering on child items payload on save.
jesseleite Dec 19, 2022
5deff45
Fix inability to move item out of an item’s children within the same …
jesseleite Dec 19, 2022
77bf587
Pass tests again.
jesseleite Dec 19, 2022
499072b
Fix disappearing of moved/aliased items by using item’s original ID w…
jesseleite Dec 20, 2022
9afd1aa
Whoops, not inherit.
jesseleite Dec 20, 2022
5ec4135
Improve reorder detection logic.
jesseleite Dec 20, 2022
57ef831
TIL, we cannot use our `Arr::get()` to get `some::id` with double col…
jesseleite Dec 20, 2022
1b18a4e
If `withHidden`, resolve/build all children, to fix cloned IDs bug in…
jesseleite Dec 21, 2022
503ce64
Fix action detection bug.
jesseleite Dec 21, 2022
4dc88ae
Handle empty sections.
jesseleite Dec 21, 2022
ba65452
Make sure we also update action on the parent node they dragged out of.
jesseleite Dec 21, 2022
8ec2f3d
Fix bug when trying to drag newly created/aliased item into another s…
jesseleite Dec 21, 2022
311a5e5
Builder doesn’t need children in manipulations.
jesseleite Dec 21, 2022
151984e
Handle tracking of renamed core sections.
jesseleite Dec 21, 2022
7cd8417
Fix and clean up drag level logic.
jesseleite Dec 21, 2022
413ae4f
Fix more JS errors.
jesseleite Dec 21, 2022
44a027a
Fix a whole bunch of moved/aliased/hidden item issues.
jesseleite Dec 21, 2022
2096ed0
Fix section reordering bug when core section has no items.
jesseleite Dec 22, 2022
f8324a0
Require both display and url.
jesseleite Dec 22, 2022
156e7aa
Remove console.log
jesseleite Dec 22, 2022
693af81
Whoops!
jesseleite Jan 3, 2023
fab9fa0
Removing flex fixes icons not showing in safari
jasonvarga Jan 3, 2023
09d068b
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Jan 3, 2023
5061db1
Never delete from manipulations for `@create`’d items, since there is…
jesseleite Jan 3, 2023
0f72eca
Never `@alias` a `@create`’d item.
jesseleite Jan 3, 2023
12f658a
Magic section setter should never look at nav item children.
jesseleite Jan 3, 2023
433e5c6
Allow overriding of preferences using `[]` when using `preventMerging…
jesseleite Jan 3, 2023
2ecd30d
Remove `nav: @override` in favour of `nav: []` for overriding of nav …
jesseleite Jan 3, 2023
8484154
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b0bae04
Add 'save as' functionality ...
jasonvarga Jan 4, 2023
a8d1ede
Validate
jasonvarga Jan 4, 2023
20cb443
Prevent "are you sure you want to navigate away" dialog when saving
jasonvarga Jan 4, 2023
d75bd14
Remove redundant `Customize` link in favour of `Modified` status.
jesseleite Jan 4, 2023
ba6889b
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b6868b5
Always touchdown for Jason 🏈
jesseleite Jan 4, 2023
160c3ad
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
ed2532b
Show modified text instead of customize link
jasonvarga Jan 4, 2023
04e990e
translate
jasonvarga Jan 4, 2023
a92d780
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
31d6aba
translate
jasonvarga Jan 4, 2023
e8caaf6
Adjust for translations
jasonvarga Jan 4, 2023
181bfba
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
5e12a53
make consistent with navs
jasonvarga Jan 4, 2023
277a45f
Remove 'Global' here, since we don't say this in page titles / save d…
jesseleite Jan 4, 2023
57a41ba
Remove redundant heading
jasonvarga Jan 4, 2023
7107063
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
9aea2c4
consistency
jasonvarga Jan 4, 2023
3470d51
Make sure Save To... dropdown doesn't clip or shrink child content
jackmcdade Jan 5, 2023
3006d22
Small improvements to make `NavTransformer` easier to test.
jesseleite Jan 5, 2023
b9bc2e5
Add whole bunch of `NavTransformer` test coverage.
jesseleite Jan 6, 2023
9066391
Add test coverage for intelligent url handling on save.
jesseleite Jan 6, 2023
a08b5d9
Add test coverage for complex json payload copied from actual vue sub…
jesseleite Jan 6, 2023
d65e105
delete method requires putting data into config
jasonvarga Jan 10, 2023
4de36c0
unused
jasonvarga Jan 10, 2023
fe03ebb
inline
jasonvarga Jan 10, 2023
edba03e
prevent saving through save button dropdown when unchanged
jasonvarga Jan 10, 2023
881e162
disable the dropdown when unchanged
jasonvarga Jan 10, 2023
bb4bb92
*slaps own wrist*
jasonvarga Jan 10, 2023
233cbd0
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 10, 2023
994e0c1
Fix issue with preferences property cache ...
jasonvarga Jan 10, 2023
5058985
CP locale can fall back to role and default preferences
jasonvarga Jan 10, 2023
5c470dc
remove comma for diff
jasonvarga Jan 11, 2023
e05d3fd
make save as dropdown consistent with nav
jasonvarga Jan 11, 2023
db6afcb
localize preference display and instructions
jasonvarga Jan 11, 2023
49c4334
Add preference extend and middleware to allow translations to be used…
jasonvarga Jan 11, 2023
e366c16
ability to defer permission registration until after locale has been …
jasonvarga Jan 11, 2023
a35f750
Apply similar changes to utilities
jasonvarga Jan 11, 2023
398da66
Might as well avoid using deprecated code now
jasonvarga Jan 11, 2023
5f81ff7
Pass preferences into section closure
jasonvarga Jan 12, 2023
efa60e6
Add simpler syntax for registering preferences
jasonvarga Jan 12, 2023
e652e7a
avoid facade
jasonvarga Jan 12, 2023
93329f9
prevent overriding section display names
jasonvarga Jan 12, 2023
6d9416b
Add test coverage for `Nav::extend()`’d sections that don’t follow ti…
jesseleite Jan 12, 2023
c2b3098
Only pass along `display` if it’s explicitly configured for renaming …
jesseleite Jan 12, 2023
6eefad5
Pass failing tests by moving section display and rename logic into `N…
jesseleite Jan 12, 2023
666c723
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Jan 12, 2023
ddf695a
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 13, 2023
d5261cd
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
95a4b3b
Merge branch 'master' into feature/preferences-ui
jasonvarga Jan 13, 2023
f9673de
Disable save part of button and leave dropdown active
jasonvarga Jan 13, 2023
77c3115
Leave dropdown active
jasonvarga Jan 13, 2023
421e81e
Add heading
jasonvarga Jan 13, 2023
01e883e
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
1f56155
Merge branch 'master' into permission-translations
jasonvarga Jan 13, 2023
f2fa807
unnecessary
jasonvarga Jan 13, 2023
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
22 changes: 22 additions & 0 deletions src/Auth/Permissions.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,34 @@

namespace Statamic\Auth;

use Facades\Statamic\Auth\CorePermissions;

class Permissions
{
protected $extensions = [];
protected $permissions = [];
protected $groups = [];
protected $pendingGroup = null;

public function boot()
{
$early = $this->permissions;
$this->permissions = [];

CorePermissions::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}

$this->permissions = array_merge($this->permissions, $early);
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make(string $value)
{
$permission = (new Permission)->value($value);
Expand Down
30 changes: 12 additions & 18 deletions src/CP/Utilities/CoreUtilities.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,7 @@ class CoreUtilities
{
public static function boot()
{
Utility::make('cache')
Utility::register('cache')
->action([CacheController::class, 'index'])
->title(__('Cache Manager'))
->icon('cache')
Expand All@@ -26,60 +26,54 @@ public static function boot()
->routes(function ($router) {
$router->post('cache/{cache}', [CacheController::class, 'clear'])->name('clear');
$router->post('cache/{cache}/warm', [CacheController::class, 'warm'])->name('warm');
})
->register();
});

Utility::make('phpinfo')
Utility::register('phpinfo')
->action(PhpInfoController::class)
->title(__('PHP Info'))
->icon('php')
->description(__('statamic::messages.phpinfo_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/phpinfo'))
->register();
->docsUrl(Statamic::docsUrl('utilities/phpinfo'));

Utility::make('search')
Utility::register('search')
->view('statamic::utilities.search')
->title(__('Search'))
->icon('search-utility')
->description(__('statamic::messages.search_utility_description'))
->routes(function ($router) {
$router->post('/', [UpdateSearchController::class, 'update'])->name('update');
})
->register();
});

Utility::make('email')
Utility::register('email')
->view('statamic::utilities.email')
->title(__('Email'))
->icon('email-utility')
->description(__('statamic::messages.email_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/email'))
->routes(function ($router) {
$router->post('/', [EmailController::class, 'send']);
})
->register();
});

Utility::make('licensing')
Utility::register('licensing')
->action([LicensingController::class, 'show'])
->title(__('Licensing'))
->icon('licensing')
->description(__('statamic::messages.licensing_utility_description'))
->docsUrl(Statamic::docsUrl('licensing'))
->routes(function ($router) {
$router->get('refresh', [LicensingController::class, 'refresh'])->name('refresh');
})
->register();
});

if (config('statamic.git.enabled') && Statamic::pro()) {
Utility::make('git')
Utility::register('git')
->action([GitController::class, 'index'])
->title('Git')
->icon('git')
->description(__('statamic::messages.git_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/git'))
->routes(function ($router) {
$router->post('/', [GitController::class, 'commit'])->name('commit');
})
->register();
});
}
}
}
1 change: 1 addition & 0 deletions src/CP/Utilities/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,6 +104,7 @@ public function routes(Closure $routes = null)
return $this->fluentlyGetOrSet('routes')->args(func_get_args());
}

/** @deprecated */
public function register()
{
\Statamic\Facades\Utility::push($this);
Expand Down
32 changes: 31 additions & 1 deletion src/CP/Utilities/UtilityRepository.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,27 +2,55 @@

namespace Statamic\CP\Utilities;

use Facades\Statamic\CP\Utilities\CoreUtilities;
use Illuminate\Support\Facades\Route;
use Statamic\Facades\User;

class UtilityRepository
{
protected $utilities;
protected $extensions = [];

public function __construct()
{
$this->utilities = collect([]);
}

public function boot()
{
CoreUtilities::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make($handle)
{
return (new Utility)->handle($handle);
}

public function push(Utility $utility)
public function register($utility)
{
if (! $utility instanceof Utility) {
$utility = $this->make($utility);
}

$this->utilities[$utility->handle()] = $utility;

return $utility;
}

/** @deprecated */
public function push(Utility $utility)
{
$this->register($utility);

return $this;
}

Expand All@@ -45,6 +73,8 @@ public function find($handle)

public function routes()
{
$this->boot();

Route::namespace('\\')->prefix('utilities')->name('utilities.')->group(function () {
$this->all()->each(function ($utility) {
if ($utility->action()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

/**
* @method static mixed|null make($handle)
* @method static self push(Utility $utility)
* @method static \Statamic\CP\Utilities\Utility register($utility)
* @method static mixed all()
* @method static mixed authorized()
* @method static mixed find($handle)
Expand Down
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootPermissions.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Permission;

class BootPermissions
{
public function handle($request, Closure $next)
{
Permission::boot();

return $next($request);
}
}
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootUtilities.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Utility;

class BootUtilities
{
public function handle($request, Closure $next)
{
Utility::boot();

return $next($request);
}
}
2 changes: 1 addition & 1 deletion src/Preferences/Preferences.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -230,7 +230,7 @@ public function section($handle, $label, $permissions = null)

$this->pendingSection = $handle;

$permissions();
$permissions($this);

$this->pendingSection = null;
}
Expand Down
5 changes: 0 additions & 5 deletions src/Providers/AuthServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@

namespace Statamic\Providers;

use Facades\Statamic\Auth\CorePermissions;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
Expand DownExpand Up@@ -90,10 +89,6 @@ public function boot()
return optional(User::fromUser($user))->hasPermission($ability) === true ? true : null;
});

$this->app->booted(function () {
CorePermissions::boot();
});

foreach ($this->policies as $key => $policy) {
Gate::policy($key, $policy);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Providers/CpServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Statamic\CP\Utilities\CoreUtilities;
use Statamic\CP\Utilities\UtilityRepository;
use Statamic\Extensions\Translation\Loader;
use Statamic\Extensions\Translation\Translator;
Expand All@@ -33,8 +32,6 @@ public function boot()
View::composer(NavComposer::VIEWS, NavComposer::class);
View::composer(CustomLogoComposer::VIEWS, CustomLogoComposer::class);

CoreUtilities::boot();

Blade::directive('cp_svg', function ($expression) {
return "<?php echo Statamic::svg({$expression}) ?>";
});
Expand DownExpand Up@@ -83,7 +80,9 @@ protected function registerMiddlewareGroups()
$router->middlewareGroup('statamic.cp.authenticated', [
\Statamic\Http\Middleware\CP\Authorize::class,
\Statamic\Http\Middleware\CP\Localize::class,
\Statamic\Http\Middleware\CP\BootPermissions::class,
\Statamic\Http\Middleware\CP\BootPreferences::class,
\Statamic\Http\Middleware\CP\BootUtilities::class,
\Statamic\Http\Middleware\CP\CountUsers::class,
\Statamic\Http\Middleware\DeleteTemporaryFileUploads::class,
]);
Expand Down
96 changes: 96 additions & 0 deletions tests/CP/Utilities/UtilityRepositoryTest.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
<?php

namespace Tests\CP\Utilities;

use Illuminate\Support\Collection;
use Statamic\CP\Utilities\Utility;
use Statamic\CP\Utilities\UtilityRepository;
use Tests\TestCase;

class UtilityRepositoryTest extends TestCase
{
/**
* @test
*
* @dataProvider registerMethodProvider
*/
public function it_registers_a_utility($registerMethod)
{
$utilities = new UtilityRepository;
$this->assertInstanceOf(Collection::class, $utilities->all());
$this->assertCount(0, $utilities->all());

$utility = $utilities->make('one');
$this->assertCount(0, $utilities->all());

$utilities->$registerMethod($utility);
$this->assertEquals(['one' => $utility], $utilities->all()->all());
$this->assertEquals($utility, $utilities->find('one'));
}

public function registerMethodProvider()
{
return [
'register' => ['register'],
'push' => ['push'], // @deprecated
];
}

/** @test */
public function it_registers_a_utility_via_a_string()
{
$utilities = new UtilityRepository;

$utility = $utilities->register('one');

$this->assertInstanceOf(Utility::class, $utility);
$this->assertEquals('one', $utility->handle());
$this->assertCount(1, $utilities->all());
$this->assertEquals(['one' => $utility], $utilities->all()->all());
}

/** @test */
public function it_defers_registration_until_boot_using_extend_method()
{
$utilities = new UtilityRepository;
$callbackRan = false;

$utilities->extend(function ($arg) use ($utilities, &$callbackRan) {
$this->assertEquals($utilities, $arg);
$callbackRan = true;
});

$this->assertFalse($callbackRan);

$utilities->boot();

$this->assertTrue($callbackRan);
}

/** @test */
public function booting_more_than_once_just_updates_the_utilities()
{
// This makes sure that booting a second time doesn't duplicate
// any utilities. It should just update/replace the existing ones.
// We boot once early so that routes can get registered, and
// then again after the user's locale preference is set so
// that the translations for labels etc use the right language.

$utilities = new UtilityRepository;

$utilities->extend(function ($utilities) {
$utilities->register('test')
->title(__('and')); // using a translation that will likely never change.
});

$utilities->boot();

$this->assertEquals(['and'], $utilities->all()->map->title()->values()->all());

app()->setLocale('fr');

$utilities->boot();

$this->assertEquals(['et'], $utilities->all()->map->title()->values()->all());
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
80dbb06
This is now normalized by UserNavConfig.
jesseleite Sep 12, 2022
8165a66
Process newly created child items the same way we process regular items.
jesseleite Sep 12, 2022
16924bb
Can't do that in PHP 7.4 my dear boy.
jesseleite Sep 13, 2022
2ec1918
Use `whenNotEmpty()`, but still apparently can't shorthand `fn()` it.
jesseleite Sep 13, 2022
90e4bf3
Refactor to separate params.
jesseleite Sep 13, 2022
a781a9a
Ensure we can rebuild nav from fresh slate.
jesseleite Nov 30, 2022
58be4f9
Support tracking preference manipulations on each NavItem instance fo…
jesseleite Nov 30, 2022
49d35c6
Track preference manipulations.
jesseleite Nov 30, 2022
4542c42
Allow passing of different preferences into `Nav::build()`.
jesseleite Nov 30, 2022
5e87094
Rename `UserNavConfig` to `NavPreferencesConfig`.
jesseleite Nov 30, 2022
6d8cfd9
Lots of front end.
jesseleite Nov 30, 2022
429e06a
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Nov 30, 2022
63093d8
The Nav and NavItem JSON resources used by the builder.
jesseleite Nov 30, 2022
84bd7e3
Hardcode link to nav.
jesseleite Nov 30, 2022
518a6da
Hide breadcrumb, because there is no preferences section yet (maybe l…
jesseleite Nov 30, 2022
6429bde
Normalize `original` for simpler logic in back end.
jesseleite Nov 30, 2022
61e2823
Wire up discard changes behaviour.
jesseleite Nov 30, 2022
088b26a
Icons.
jesseleite Nov 30, 2022
c6acbb7
Fix issue with new item IDs.
jesseleite Nov 30, 2022
e108e5f
Route and controller.
jesseleite Nov 30, 2022
4a438be
Add Nav Pref index and icon
jackmcdade Dec 6, 2022
3d7dcf4
Move `PreferenceController` and fix destroy route to actually use del…
jesseleite Dec 6, 2022
814e920
Wire up routes and controllers for default, role, and user nav prefer…
jesseleite Dec 6, 2022
a517164
Move into `CoreNav`.
jesseleite Dec 6, 2022
2629fd1
Add `buildDefault()` alias.
jesseleite Dec 6, 2022
b2b7ffe
Update front end.
jesseleite Dec 6, 2022
f273d75
Update tests.
jesseleite Dec 6, 2022
1b4bef9
Only show section if roles exist.
jesseleite Dec 6, 2022
41f2713
Add test coverage for new `Preference::preventMergingChildren()` method.
jesseleite Dec 8, 2022
336a22d
Implement `preventMergingChildren()`.
jesseleite Dec 8, 2022
aa73758
Prevent merging of children in nav preferences.
jesseleite Dec 8, 2022
74c4a79
Alias `get()` to `getPreference()`, like we do with `set()`.
jesseleite Dec 8, 2022
31c0c3e
Ensure we’re loading default preferences nav in editor.
jesseleite Dec 8, 2022
dd2ff77
Ensure we’re loading role preferences nav in editor.
jesseleite Dec 8, 2022
678921e
Alias `remove()` to `removePreference()`, like we do with `set()` and…
jesseleite Dec 8, 2022
8f389bf
Scope `Statamic.$preferences` api endpoints to prevent conflicts with…
jesseleite Dec 8, 2022
4198e51
Rename `buildDefault()` to `buildWithoutPreferences()` to avoid confu…
jesseleite Dec 8, 2022
8e7e0f8
Fix resetting of nav prefs, nav precedence on load, and clean up rout…
jesseleite Dec 8, 2022
099819a
Require pro to edit anything other than your own user preferences.
jesseleite Dec 8, 2022
71d92a4
Show confirmation modal when resetting.
jesseleite Dec 8, 2022
fa299a7
Add test to prove that first assigned user role takes precedence.
jesseleite Dec 8, 2022
d3a0d65
Fix discard changes regression.
jesseleite Dec 8, 2022
5f09b9f
Handle `.disabled` class on `.btn-group` buttons.
jesseleite Dec 8, 2022
1c4dbd2
Show reset option as warning.
jesseleite Dec 8, 2022
9c93d20
Handle ‘save as’ dropdown options.
jesseleite Dec 8, 2022
836e19f
Make index messaging a bit more consistent with other pages.
jesseleite Dec 8, 2022
cbcf4d9
Intelligently output save as options for nav builder.
jesseleite Dec 8, 2022
96d9a5d
Fix pro/super check.
jesseleite Dec 8, 2022
7255ae2
run npm install
jasonvarga Dec 9, 2022
2c391d3
add override
jasonvarga Dec 9, 2022
6629232
Merge branch 'fix-package-lock' of https://github.com/statamic/cms in…
jesseleite Dec 9, 2022
341c32d
Merge branch '3.3' of https://github.com/statamic/cms into feature/cu…
jesseleite Dec 9, 2022
826f327
Rename to ‘CP Nav’ to avoid confusion with ‘Navigation’.
jesseleite Dec 9, 2022
328556e
Fix unique key on v-for warning.
jesseleite Dec 9, 2022
cab8390
Misc cleanup.
jesseleite Dec 9, 2022
bcbd31c
Vue payload to yaml transformation logic.
jesseleite Dec 10, 2022
b3340fd
Fix missing `display` and `url` on newly created items.
jesseleite Dec 10, 2022
3d52925
Allow removing of `@create`’d items (instead of hiding via `@remove` …
jesseleite Dec 10, 2022
7d2b40c
If there’s nothing to save, remove preference instead of saving `nav:…
jesseleite Dec 10, 2022
d9322b7
Fix overzealous `@inherit` minification when reordering.
jesseleite Dec 11, 2022
f6c8c94
Avoid submitting custom sections that have no items.
jesseleite Dec 11, 2022
1bbb1f8
Cmd+s to save.
jesseleite Dec 12, 2022
e907c10
Handle section `action: ‘@remove’` in config normalizer.
jesseleite Dec 12, 2022
af1ffc8
This shouldn’t be needed anymore, since the `normalize()` method abov…
jesseleite Dec 13, 2022
bf2a1c3
Add section manipulations into `build()` output.
jesseleite Dec 13, 2022
72bc6f9
Pluck `items` and `display` so that nav sidebar views continue to wor…
jesseleite Dec 13, 2022
08ce16a
Ensure front end merges whole section config in with items, not just …
jesseleite Dec 13, 2022
463c338
Refactor for new initial nav format on load.
jesseleite Dec 14, 2022
cf4e147
Ensure proper fallbacks.
jesseleite Dec 14, 2022
6b0c96a
Should use `NavItem::snakeCase()` for consistency.
jesseleite Dec 14, 2022
33e7857
Refactor payload to account for new `display_original` section changes.
jesseleite Dec 14, 2022
e67a60b
Improve section minification.
jesseleite Dec 14, 2022
8f33987
Ensure we also pass action to server.
jesseleite Dec 14, 2022
048d8ce
`Nav::build()` was always returning a collection, so this should too.
jesseleite Dec 14, 2022
c45acdd
Pass tests again.
jesseleite Dec 14, 2022
56a80b1
Actually, let’s avoid this `pluck()` and just fix the views.
jesseleite Dec 14, 2022
8210108
Rely on `display_original` for more consistent `itemsAreReordered` lo…
jesseleite Dec 14, 2022
474f565
Only ever show `@inherit` action when section config is empty, for re…
jesseleite Dec 14, 2022
4200a32
Ensure user can still see hidden items in builder on reload.
jesseleite Dec 14, 2022
c0e1b17
Properly handle `withHidden()` state when rebuilding.
jesseleite Dec 14, 2022
359ab19
Reload on save in order to see changes on save.
jesseleite Dec 14, 2022
fc6a8f9
This shoulda been in data.
jesseleite Dec 14, 2022
a831b26
Rename isNew to isCustom and use a new icon
jackmcdade Dec 14, 2022
5e32408
Autofocus first field in stacks, support a plain "enter" key binding
jackmcdade Dec 14, 2022
6a3811b
Use the proper prop data type
jackmcdade Dec 14, 2022
5fe9a23
Prevent hiding `CP Nav` item, so user can always access it.
jesseleite Dec 14, 2022
18233f7
Simplify that last commit.
jesseleite Dec 14, 2022
1b6d7f2
Hook up Expand All and Collapse All controls
jackmcdade Dec 14, 2022
56c784f
Don't need depth here.
jackmcdade Dec 14, 2022
981e6b2
Fix `isSectionNode()` for top level tree items.
jesseleite Dec 14, 2022
de3f29e
Clean up a few JS errors.
jesseleite Dec 14, 2022
db6252a
Make `prevent_hiding` work at section level.
jesseleite Dec 14, 2022
895a661
Prevent user from accidentally hiding CP Nav by dragging into hidden …
jesseleite Dec 14, 2022
e34415a
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
d8b43dd
Snip snap ✂️
jesseleite Dec 14, 2022
a378c98
Preferences Dropdown in the Global Header
jackmcdade Dec 14, 2022
f7b663e
Add `configure cp nav` permission.
jesseleite Dec 14, 2022
1290562
Rename/fix `Statamic.$preferences` endpoints.
jesseleite Dec 14, 2022
14af432
Wrap these routes with pro/permission checks.
jesseleite Dec 14, 2022
b1e3f73
Hook up redirect at controller level.
jesseleite Dec 14, 2022
5179f8c
Update permission check for nav builder breadcrumb link.
jesseleite Dec 14, 2022
f45d787
Remove from core nav, since Jack is adding cool gear in top nav.
jesseleite Dec 14, 2022
2eede65
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 14, 2022
e5e54b9
Pass tests.
jesseleite Dec 14, 2022
7eaebe5
Forgot to snip snap ✂️
jesseleite Dec 15, 2022
d3ecb7e
Improve styling for hidden sections.
jesseleite Dec 15, 2022
b716bcd
Ensure we properly minify section hide action.
jesseleite Dec 15, 2022
b691367
Expand and collapse items in top level tree as well.
jesseleite Dec 15, 2022
fa38a80
Hide hidden sections in built navs.
jesseleite Dec 15, 2022
82a1245
Fix JS errors.
jesseleite Dec 15, 2022
b946954
Ensure section level manipulations get properly set on load.
jesseleite Dec 15, 2022
f1848e3
Fix string replace.
jesseleite Dec 15, 2022
b1d6528
Return `$items` directly.
jesseleite Dec 15, 2022
2fbf6e6
Fix action handling in section minification.
jesseleite Dec 15, 2022
43bd885
Confirm removal of custom section when it contains items.
jesseleite Dec 15, 2022
f066f18
initial preferences ui
jasonvarga Dec 15, 2022
9d3e9cd
Apply fixes from StyleCI
StyleCIBot Dec 15, 2022
4458c04
Remove preferences if form field is set to the default value
jasonvarga Dec 15, 2022
36393f8
Flesh out allowed section actions and modifications as constants.
jesseleite Dec 15, 2022
a0b9711
add prop to allow publish form to reload on save
jasonvarga Dec 15, 2022
38428e2
Make permission more generic
jasonvarga Dec 15, 2022
c986eec
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 15, 2022
e99ae57
Wire up user/default/role forms
jasonvarga Dec 15, 2022
f09bfdc
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Dec 16, 2022
f7a9a9e
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Dec 16, 2022
e28020b
Remove section `@inherit`s from config after processing reordering.
jesseleite Dec 16, 2022
793992c
Fix removing of sections and items after last sections overhaul.
jesseleite Dec 16, 2022
20ff852
Refactor `@remove` to `@hide`.
jesseleite Dec 16, 2022
11e356f
Fix undoing and saving ‘default’ level changes at user level, so that…
jesseleite Dec 16, 2022
57470dc
Apply the same fix at the role level.
jesseleite Dec 16, 2022
8156b53
Allow nulling/removing at default preferences level though.
jesseleite Dec 16, 2022
40e9b5d
Fix `@create` custom section items.
jesseleite Dec 17, 2022
e6eb308
Prevent adding item children to item children.
jesseleite Dec 17, 2022
b3cecce
Pass tests again, ensuring we don’t duplicate modified items in place.
jesseleite Dec 17, 2022
d23aa59
Rename to `NavPreferencesNormalizer::fromPreferences()` for clarity.
jesseleite Dec 17, 2022
878aa4b
Move all nav building logic out into a `NavBuilder` class so that we …
jesseleite Dec 17, 2022
15167da
Clarify why `Nav::extend()` is needed in test.
jesseleite Dec 17, 2022
9edab4d
Show custom section as ‘Custom Section’.
jesseleite Dec 17, 2022
fc1aad7
Misc cleanup.
jesseleite Dec 18, 2022
2a4dae0
Add support for `reorder` on item children.
jesseleite Dec 18, 2022
702f26a
Fix `@move` action when moving a parent item into the children of ano…
jesseleite Dec 18, 2022
93bb5c1
Ensure aliased items have no children unless explicitly set.
jesseleite Dec 18, 2022
4128730
Show configured `children` on aliased items, etc.
jesseleite Dec 18, 2022
e83fb1c
Show moved item icon (WIP).
jesseleite Dec 18, 2022
71a2e9e
Fix `@create`’d children within `@alias`’d items.
jesseleite Dec 18, 2022
ef88276
Pass tests again and cleanup todo’s.
jesseleite Dec 18, 2022
43387ef
Flesh out builder test coverage for recent fixes.
jesseleite Dec 18, 2022
a01291d
Add `syncOriginal()` functionality to `NavItem` class so we can detec…
jesseleite Dec 19, 2022
390dce0
Sync original on each item just before applying nav preference manipu…
jesseleite Dec 19, 2022
9cd1297
Pass original nav item state to tree data in front end builder.
jesseleite Dec 19, 2022
3382d44
Show icon and tooltip for renamed sections.
jesseleite Dec 19, 2022
35458d9
Ensure newly resolved child items sync their original state as well.
jesseleite Dec 19, 2022
b3a55e5
Ensure we can get current section from original children.
jesseleite Dec 19, 2022
624bd04
Fix updating of item manipulations when dragging or updating items.
jesseleite Dec 19, 2022
7d8594e
Fix JS error.
jesseleite Dec 19, 2022
8bff1ea
Fix regression since adding ‘section’ data to nested child items.
jesseleite Dec 19, 2022
a68025b
Fix overzealous `@move` action in front end.
jesseleite Dec 19, 2022
069c80f
Collapse top level items by default, to be consistent with the rest o…
jesseleite Dec 19, 2022
e289921
Fix ordering error on PHP 7.4.
jesseleite Dec 19, 2022
c743756
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Dec 19, 2022
4afb33f
Fix duplicate hidden items regression.
jesseleite Dec 19, 2022
767ab26
Clean up `updateItemAction()` method using more readable switch case.
jesseleite Dec 19, 2022
22483cd
Get and pass clean editable nav item urls to nav builder.
jesseleite Dec 19, 2022
06fbbee
Transform on save, so that we don’t store local domain or configurabl…
jesseleite Dec 19, 2022
a5e20da
Move modified children `action` check to JS, where we handle the rest…
jesseleite Dec 19, 2022
25b2045
Fix reordering on child items payload on save.
jesseleite Dec 19, 2022
5deff45
Fix inability to move item out of an item’s children within the same …
jesseleite Dec 19, 2022
77bf587
Pass tests again.
jesseleite Dec 19, 2022
499072b
Fix disappearing of moved/aliased items by using item’s original ID w…
jesseleite Dec 20, 2022
9afd1aa
Whoops, not inherit.
jesseleite Dec 20, 2022
5ec4135
Improve reorder detection logic.
jesseleite Dec 20, 2022
57ef831
TIL, we cannot use our `Arr::get()` to get `some::id` with double col…
jesseleite Dec 20, 2022
1b18a4e
If `withHidden`, resolve/build all children, to fix cloned IDs bug in…
jesseleite Dec 21, 2022
503ce64
Fix action detection bug.
jesseleite Dec 21, 2022
4dc88ae
Handle empty sections.
jesseleite Dec 21, 2022
ba65452
Make sure we also update action on the parent node they dragged out of.
jesseleite Dec 21, 2022
8ec2f3d
Fix bug when trying to drag newly created/aliased item into another s…
jesseleite Dec 21, 2022
311a5e5
Builder doesn’t need children in manipulations.
jesseleite Dec 21, 2022
151984e
Handle tracking of renamed core sections.
jesseleite Dec 21, 2022
7cd8417
Fix and clean up drag level logic.
jesseleite Dec 21, 2022
413ae4f
Fix more JS errors.
jesseleite Dec 21, 2022
44a027a
Fix a whole bunch of moved/aliased/hidden item issues.
jesseleite Dec 21, 2022
2096ed0
Fix section reordering bug when core section has no items.
jesseleite Dec 22, 2022
f8324a0
Require both display and url.
jesseleite Dec 22, 2022
156e7aa
Remove console.log
jesseleite Dec 22, 2022
693af81
Whoops!
jesseleite Jan 3, 2023
fab9fa0
Removing flex fixes icons not showing in safari
jasonvarga Jan 3, 2023
09d068b
Merge branch 'feature/customizable-navs' of https://github.com/statam…
jesseleite Jan 3, 2023
5061db1
Never delete from manipulations for `@create`’d items, since there is…
jesseleite Jan 3, 2023
0f72eca
Never `@alias` a `@create`’d item.
jesseleite Jan 3, 2023
12f658a
Magic section setter should never look at nav item children.
jesseleite Jan 3, 2023
433e5c6
Allow overriding of preferences using `[]` when using `preventMerging…
jesseleite Jan 3, 2023
2ecd30d
Remove `nav: @override` in favour of `nav: []` for overriding of nav …
jesseleite Jan 3, 2023
8484154
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b0bae04
Add 'save as' functionality ...
jasonvarga Jan 4, 2023
a8d1ede
Validate
jasonvarga Jan 4, 2023
20cb443
Prevent "are you sure you want to navigate away" dialog when saving
jasonvarga Jan 4, 2023
d75bd14
Remove redundant `Customize` link in favour of `Modified` status.
jesseleite Jan 4, 2023
ba6889b
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
b6868b5
Always touchdown for Jason 🏈
jesseleite Jan 4, 2023
160c3ad
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
ed2532b
Show modified text instead of customize link
jasonvarga Jan 4, 2023
04e990e
translate
jasonvarga Jan 4, 2023
a92d780
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
31d6aba
translate
jasonvarga Jan 4, 2023
e8caaf6
Adjust for translations
jasonvarga Jan 4, 2023
181bfba
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
5e12a53
make consistent with navs
jasonvarga Jan 4, 2023
277a45f
Remove 'Global' here, since we don't say this in page titles / save d…
jesseleite Jan 4, 2023
57a41ba
Remove redundant heading
jasonvarga Jan 4, 2023
7107063
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 4, 2023
9aea2c4
consistency
jasonvarga Jan 4, 2023
3470d51
Make sure Save To... dropdown doesn't clip or shrink child content
jackmcdade Jan 5, 2023
3006d22
Small improvements to make `NavTransformer` easier to test.
jesseleite Jan 5, 2023
b9bc2e5
Add whole bunch of `NavTransformer` test coverage.
jesseleite Jan 6, 2023
9066391
Add test coverage for intelligent url handling on save.
jesseleite Jan 6, 2023
a08b5d9
Add test coverage for complex json payload copied from actual vue sub…
jesseleite Jan 6, 2023
d65e105
delete method requires putting data into config
jasonvarga Jan 10, 2023
4de36c0
unused
jasonvarga Jan 10, 2023
fe03ebb
inline
jasonvarga Jan 10, 2023
edba03e
prevent saving through save button dropdown when unchanged
jasonvarga Jan 10, 2023
881e162
disable the dropdown when unchanged
jasonvarga Jan 10, 2023
bb4bb92
*slaps own wrist*
jasonvarga Jan 10, 2023
233cbd0
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 10, 2023
994e0c1
Fix issue with preferences property cache ...
jasonvarga Jan 10, 2023
5058985
CP locale can fall back to role and default preferences
jasonvarga Jan 10, 2023
5c470dc
remove comma for diff
jasonvarga Jan 11, 2023
e05d3fd
make save as dropdown consistent with nav
jasonvarga Jan 11, 2023
db6afcb
localize preference display and instructions
jasonvarga Jan 11, 2023
49c4334
Add preference extend and middleware to allow translations to be used…
jasonvarga Jan 11, 2023
e366c16
ability to defer permission registration until after locale has been …
jasonvarga Jan 11, 2023
a35f750
Apply similar changes to utilities
jasonvarga Jan 11, 2023
398da66
Might as well avoid using deprecated code now
jasonvarga Jan 11, 2023
5f81ff7
Pass preferences into section closure
jasonvarga Jan 12, 2023
efa60e6
Add simpler syntax for registering preferences
jasonvarga Jan 12, 2023
e652e7a
avoid facade
jasonvarga Jan 12, 2023
93329f9
prevent overriding section display names
jasonvarga Jan 12, 2023
6d9416b
Add test coverage for `Nav::extend()`’d sections that don’t follow ti…
jesseleite Jan 12, 2023
c2b3098
Only pass along `display` if it’s explicitly configured for renaming …
jesseleite Jan 12, 2023
6eefad5
Pass failing tests by moving section display and rename logic into `N…
jesseleite Jan 12, 2023
666c723
Merge branch 'master' of https://github.com/statamic/cms into feature…
jesseleite Jan 12, 2023
ddf695a
Merge branch 'feature/customizable-navs' into feature/preferences-ui
jasonvarga Jan 13, 2023
d5261cd
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
95a4b3b
Merge branch 'master' into feature/preferences-ui
jasonvarga Jan 13, 2023
f9673de
Disable save part of button and leave dropdown active
jasonvarga Jan 13, 2023
77c3115
Leave dropdown active
jasonvarga Jan 13, 2023
421e81e
Add heading
jasonvarga Jan 13, 2023
01e883e
Merge branch 'feature/preferences-ui' into permission-translations
jasonvarga Jan 13, 2023
1f56155
Merge branch 'master' into permission-translations
jasonvarga Jan 13, 2023
f2fa807
unnecessary
jasonvarga Jan 13, 2023
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
22 changes: 22 additions & 0 deletions src/Auth/Permissions.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,34 @@

namespace Statamic\Auth;

use Facades\Statamic\Auth\CorePermissions;

class Permissions
{
protected $extensions = [];
protected $permissions = [];
protected $groups = [];
protected $pendingGroup = null;

public function boot()
{
$early = $this->permissions;
$this->permissions = [];

CorePermissions::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}

$this->permissions = array_merge($this->permissions, $early);
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make(string $value)
{
$permission = (new Permission)->value($value);
Expand Down
30 changes: 12 additions & 18 deletions src/CP/Utilities/CoreUtilities.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,7 @@ class CoreUtilities
{
public static function boot()
{
Utility::make('cache')
Utility::register('cache')
->action([CacheController::class, 'index'])
->title(__('Cache Manager'))
->icon('cache')
Expand All@@ -26,60 +26,54 @@ public static function boot()
->routes(function ($router) {
$router->post('cache/{cache}', [CacheController::class, 'clear'])->name('clear');
$router->post('cache/{cache}/warm', [CacheController::class, 'warm'])->name('warm');
})
->register();
});

Utility::make('phpinfo')
Utility::register('phpinfo')
->action(PhpInfoController::class)
->title(__('PHP Info'))
->icon('php')
->description(__('statamic::messages.phpinfo_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/phpinfo'))
->register();
->docsUrl(Statamic::docsUrl('utilities/phpinfo'));

Utility::make('search')
Utility::register('search')
->view('statamic::utilities.search')
->title(__('Search'))
->icon('search-utility')
->description(__('statamic::messages.search_utility_description'))
->routes(function ($router) {
$router->post('/', [UpdateSearchController::class, 'update'])->name('update');
})
->register();
});

Utility::make('email')
Utility::register('email')
->view('statamic::utilities.email')
->title(__('Email'))
->icon('email-utility')
->description(__('statamic::messages.email_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/email'))
->routes(function ($router) {
$router->post('/', [EmailController::class, 'send']);
})
->register();
});

Utility::make('licensing')
Utility::register('licensing')
->action([LicensingController::class, 'show'])
->title(__('Licensing'))
->icon('licensing')
->description(__('statamic::messages.licensing_utility_description'))
->docsUrl(Statamic::docsUrl('licensing'))
->routes(function ($router) {
$router->get('refresh', [LicensingController::class, 'refresh'])->name('refresh');
})
->register();
});

if (config('statamic.git.enabled') && Statamic::pro()) {
Utility::make('git')
Utility::register('git')
->action([GitController::class, 'index'])
->title('Git')
->icon('git')
->description(__('statamic::messages.git_utility_description'))
->docsUrl(Statamic::docsUrl('utilities/git'))
->routes(function ($router) {
$router->post('/', [GitController::class, 'commit'])->name('commit');
})
->register();
});
}
}
}
1 change: 1 addition & 0 deletions src/CP/Utilities/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,6 +104,7 @@ public function routes(Closure $routes = null)
return $this->fluentlyGetOrSet('routes')->args(func_get_args());
}

/** @deprecated */
public function register()
{
\Statamic\Facades\Utility::push($this);
Expand Down
32 changes: 31 additions & 1 deletion src/CP/Utilities/UtilityRepository.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,27 +2,55 @@

namespace Statamic\CP\Utilities;

use Facades\Statamic\CP\Utilities\CoreUtilities;
use Illuminate\Support\Facades\Route;
use Statamic\Facades\User;

class UtilityRepository
{
protected $utilities;
protected $extensions = [];

public function __construct()
{
$this->utilities = collect([]);
}

public function boot()
{
CoreUtilities::boot();

foreach ($this->extensions as $callback) {
$callback($this);
}
}

public function extend($callback)
{
$this->extensions[] = $callback;
}

public function make($handle)
{
return (new Utility)->handle($handle);
}

public function push(Utility $utility)
public function register($utility)
{
if (! $utility instanceof Utility) {
$utility = $this->make($utility);
}

$this->utilities[$utility->handle()] = $utility;

return $utility;
}

/** @deprecated */
public function push(Utility $utility)
{
$this->register($utility);

return $this;
}

Expand All@@ -45,6 +73,8 @@ public function find($handle)

public function routes()
{
$this->boot();

Route::namespace('\\')->prefix('utilities')->name('utilities.')->group(function () {
$this->all()->each(function ($utility) {
if ($utility->action()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Utility.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@

/**
* @method static mixed|null make($handle)
* @method static self push(Utility $utility)
* @method static \Statamic\CP\Utilities\Utility register($utility)
* @method static mixed all()
* @method static mixed authorized()
* @method static mixed find($handle)
Expand Down
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootPermissions.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Permission;

class BootPermissions
{
public function handle($request, Closure $next)
{
Permission::boot();

return $next($request);
}
}
16 changes: 16 additions & 0 deletions src/Http/Middleware/CP/BootUtilities.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
<?php

namespace Statamic\Http\Middleware\CP;

use Closure;
use Statamic\Facades\Utility;

class BootUtilities
{
public function handle($request, Closure $next)
{
Utility::boot();

return $next($request);
}
}
2 changes: 1 addition & 1 deletion src/Preferences/Preferences.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -230,7 +230,7 @@ public function section($handle, $label, $permissions = null)

$this->pendingSection = $handle;

$permissions();
$permissions($this);

$this->pendingSection = null;
}
Expand Down
5 changes: 0 additions & 5 deletions src/Providers/AuthServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@

namespace Statamic\Providers;

use Facades\Statamic\Auth\CorePermissions;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
Expand DownExpand Up@@ -90,10 +89,6 @@ public function boot()
return optional(User::fromUser($user))->hasPermission($ability) === true ? true : null;
});

$this->app->booted(function () {
CorePermissions::boot();
});

foreach ($this->policies as $key => $policy) {
Gate::policy($key, $policy);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Providers/CpServiceProvider.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Statamic\CP\Utilities\CoreUtilities;
use Statamic\CP\Utilities\UtilityRepository;
use Statamic\Extensions\Translation\Loader;
use Statamic\Extensions\Translation\Translator;
Expand All@@ -33,8 +32,6 @@ public function boot()
View::composer(NavComposer::VIEWS, NavComposer::class);
View::composer(CustomLogoComposer::VIEWS, CustomLogoComposer::class);

CoreUtilities::boot();

Blade::directive('cp_svg', function ($expression) {
return "<?php echo Statamic::svg({$expression}) ?>";
});
Expand DownExpand Up@@ -83,7 +80,9 @@ protected function registerMiddlewareGroups()
$router->middlewareGroup('statamic.cp.authenticated', [
\Statamic\Http\Middleware\CP\Authorize::class,
\Statamic\Http\Middleware\CP\Localize::class,
\Statamic\Http\Middleware\CP\BootPermissions::class,
\Statamic\Http\Middleware\CP\BootPreferences::class,
\Statamic\Http\Middleware\CP\BootUtilities::class,
\Statamic\Http\Middleware\CP\CountUsers::class,
\Statamic\Http\Middleware\DeleteTemporaryFileUploads::class,
]);
Expand Down
96 changes: 96 additions & 0 deletions tests/CP/Utilities/UtilityRepositoryTest.php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
<?php

namespace Tests\CP\Utilities;

use Illuminate\Support\Collection;
use Statamic\CP\Utilities\Utility;
use Statamic\CP\Utilities\UtilityRepository;
use Tests\TestCase;

class UtilityRepositoryTest extends TestCase
{
/**
* @test
*
* @dataProvider registerMethodProvider
*/
public function it_registers_a_utility($registerMethod)
{
$utilities = new UtilityRepository;
$this->assertInstanceOf(Collection::class, $utilities->all());
$this->assertCount(0, $utilities->all());

$utility = $utilities->make('one');
$this->assertCount(0, $utilities->all());

$utilities->$registerMethod($utility);
$this->assertEquals(['one' => $utility], $utilities->all()->all());
$this->assertEquals($utility, $utilities->find('one'));
}

public function registerMethodProvider()
{
return [
'register' => ['register'],
'push' => ['push'], // @deprecated
];
}

/** @test */
public function it_registers_a_utility_via_a_string()
{
$utilities = new UtilityRepository;

$utility = $utilities->register('one');

$this->assertInstanceOf(Utility::class, $utility);
$this->assertEquals('one', $utility->handle());
$this->assertCount(1, $utilities->all());
$this->assertEquals(['one' => $utility], $utilities->all()->all());
}

/** @test */
public function it_defers_registration_until_boot_using_extend_method()
{
$utilities = new UtilityRepository;
$callbackRan = false;

$utilities->extend(function ($arg) use ($utilities, &$callbackRan) {
$this->assertEquals($utilities, $arg);
$callbackRan = true;
});

$this->assertFalse($callbackRan);

$utilities->boot();

$this->assertTrue($callbackRan);
}

/** @test */
public function booting_more_than_once_just_updates_the_utilities()
{
// This makes sure that booting a second time doesn't duplicate
// any utilities. It should just update/replace the existing ones.
// We boot once early so that routes can get registered, and
// then again after the user's locale preference is set so
// that the translations for labels etc use the right language.

$utilities = new UtilityRepository;

$utilities->extend(function ($utilities) {
$utilities->register('test')
->title(__('and')); // using a translation that will likely never change.
});

$utilities->boot();

$this->assertEquals(['and'], $utilities->all()->map->title()->values()->all());

app()->setLocale('fr');

$utilities->boot();

$this->assertEquals(['et'], $utilities->all()->map->title()->values()->all());
}
}
Loading