From 1f5774a1b8995868983154a44ab4d0f927afd088 Mon Sep 17 00:00:00 2001 From: Brian Canini <canini.16@osu.edu> Date: Tue, 7 Jan 2020 09:46:17 -0500 Subject: [PATCH] updating admin_toolbar - 1.26 -> 2.0 --- composer.json | 2 +- composer.lock | 22 +- vendor/composer/installed.json | 30 +- web/modules/admin_toolbar/CHANGELOG.txt | 384 +--------- web/modules/admin_toolbar/README.txt | 2 + .../admin_toolbar/admin_toolbar.info.yml | 9 +- .../admin_toolbar/admin_toolbar.install | 0 .../admin_toolbar/admin_toolbar.libraries.yml | 11 + .../admin_toolbar/admin_toolbar.module | 45 +- .../README.txt | 0 ...admin_toolbar_links_access_filter.info.yml | 9 +- .../admin_toolbar_links_access_filter.module | 44 +- .../composer.json | 0 .../admin_toolbar_tools/README.txt | 2 + .../admin_toolbar_tools.info.yml | 11 +- .../admin_toolbar_tools.libraries.yml | 0 .../admin_toolbar_tools.links.menu.yml | 4 + .../admin_toolbar_tools.module | 667 +----------------- .../admin_toolbar_tools.routing.yml | 7 + .../admin_toolbar_tools.services.yml | 9 + .../admin_toolbar_tools/composer.json | 4 +- .../admin_toolbar_tools/css/tools.css | 1 + .../misc/icons/ffffff/d8-item.svg | 0 .../src/Controller/ToolbarController.php | 57 +- .../src/Plugin/Derivative/ExtraLinks.php | 641 +++++++++++++++++ .../admin_toolbar_tools/src/SearchLinks.php | 287 ++++++++ .../Functional/AdminToolbarToolsAlterTest.php | 2 +- web/modules/admin_toolbar/composer.json | 0 .../admin_toolbar/css/admin.toolbar.css | 7 + .../css/admin.toolbar_search.css | 33 + web/modules/admin_toolbar/js/admin_toolbar.js | 0 .../admin_toolbar/js/admin_toolbar_search.js | 188 +++++ .../admin_toolbar/js/jquery.hoverIntent.js | 0 .../misc/icons/0074bd/chevron-left.svg | 0 .../misc/icons/0074bd/chevron-right.svg | 0 .../admin_toolbar/misc/icons/bebebe/loupe.svg | 1 + .../misc/icons/ffffff/chevron-right.svg | 0 .../admin_toolbar/misc/icons/ffffff/loupe.svg | 1 + .../src/Functional/AdminToolbarAlterTest.php | 2 +- .../Functional/AdminToolbarToolsSortTest.php | 222 ++++++ .../AdminToolbarSearchTest.php | 339 +++++++++ 41 files changed, 1919 insertions(+), 1124 deletions(-) mode change 100644 => 100755 web/modules/admin_toolbar/CHANGELOG.txt mode change 100644 => 100755 web/modules/admin_toolbar/README.txt mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar.install mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar.libraries.yml mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar.module mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_links_access_filter/README.txt mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_links_access_filter/composer.json mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_tools/README.txt mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.libraries.yml mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.links.menu.yml mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.routing.yml create mode 100644 web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.services.yml mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_tools/composer.json mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_tools/css/tools.css mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_tools/misc/icons/ffffff/d8-item.svg mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_tools/src/Controller/ToolbarController.php create mode 100755 web/modules/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php create mode 100644 web/modules/admin_toolbar/admin_toolbar_tools/src/SearchLinks.php mode change 100644 => 100755 web/modules/admin_toolbar/admin_toolbar_tools/tests/src/Functional/AdminToolbarToolsAlterTest.php mode change 100644 => 100755 web/modules/admin_toolbar/composer.json mode change 100644 => 100755 web/modules/admin_toolbar/css/admin.toolbar.css create mode 100755 web/modules/admin_toolbar/css/admin.toolbar_search.css mode change 100644 => 100755 web/modules/admin_toolbar/js/admin_toolbar.js create mode 100755 web/modules/admin_toolbar/js/admin_toolbar_search.js mode change 100644 => 100755 web/modules/admin_toolbar/js/jquery.hoverIntent.js mode change 100644 => 100755 web/modules/admin_toolbar/misc/icons/0074bd/chevron-left.svg mode change 100644 => 100755 web/modules/admin_toolbar/misc/icons/0074bd/chevron-right.svg create mode 100755 web/modules/admin_toolbar/misc/icons/bebebe/loupe.svg mode change 100644 => 100755 web/modules/admin_toolbar/misc/icons/ffffff/chevron-right.svg create mode 100755 web/modules/admin_toolbar/misc/icons/ffffff/loupe.svg mode change 100644 => 100755 web/modules/admin_toolbar/tests/src/Functional/AdminToolbarAlterTest.php create mode 100644 web/modules/admin_toolbar/tests/src/Functional/AdminToolbarToolsSortTest.php create mode 100755 web/modules/admin_toolbar/tests/src/FunctionalJavascript/AdminToolbarSearchTest.php diff --git a/composer.json b/composer.json index df80da6527..d2d53683c1 100644 --- a/composer.json +++ b/composer.json @@ -90,7 +90,7 @@ "drupal-composer/drupal-scaffold": "^2.0.1", "drupal/address": "1.1", "drupal/addtocalendar": "3.1", - "drupal/admin_toolbar": "1.26", + "drupal/admin_toolbar": "2.0", "drupal/administerusersbyrole": "2.0-alpha6", "drupal/allowed_formats": "1.1", "drupal/anchor_link": "^1.6", diff --git a/composer.lock b/composer.lock index a59f391c9d..6e0c39b63c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f63252d2b5f8bcacdc2152608f35e1e1", + "content-hash": "9a04dacb71a790084b49b56a9b48608e", "packages": [ { "name": "alchemy/zippy", @@ -2147,17 +2147,17 @@ }, { "name": "drupal/admin_toolbar", - "version": "1.26.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/admin_toolbar.git", - "reference": "8.x-1.26" + "reference": "8.x-2.0" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/admin_toolbar-8.x-1.26.zip", - "reference": "8.x-1.26", - "shasum": "7be9f91008bf17cf49b43d1c8e2211e7a8e40ce4" + "url": "https://ftp.drupal.org/files/projects/admin_toolbar-8.x-2.0.zip", + "reference": "8.x-2.0", + "shasum": "568de63dbaa8046a82d327dbd0b892ab79fb87aa" }, "require": { "drupal/core": "*" @@ -2165,11 +2165,11 @@ "type": "drupal-module", "extra": { "branch-alias": { - "dev-1.x": "1.x-dev" + "dev-2.x": "2.x-dev" }, "drupal": { - "version": "8.x-1.26", - "datestamp": "1549218480", + "version": "8.x-2.0", + "datestamp": "1573751237", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -12832,6 +12832,7 @@ "psr", "psr-7" ], + "abandoned": "laminas/laminas-diactoros", "time": "2019-08-06T17:53:53+00:00" }, { @@ -12877,6 +12878,7 @@ "escaper", "zf" ], + "abandoned": "laminas/laminas-escaper", "time": "2019-09-05T20:03:20+00:00" }, { @@ -12940,6 +12942,7 @@ "feed", "zf" ], + "abandoned": "laminas/laminas-feed", "time": "2019-03-05T20:08:49+00:00" }, { @@ -12986,6 +12989,7 @@ "stdlib", "zf" ], + "abandoned": "laminas/laminas-stdlib", "time": "2018-08-28T21:34:05+00:00" } ], diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 546cd86083..d9497cafee 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -2214,18 +2214,18 @@ }, { "name": "drupal/admin_toolbar", - "version": "1.26.0", - "version_normalized": "1.26.0.0", + "version": "2.0.0", + "version_normalized": "2.0.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/admin_toolbar.git", - "reference": "8.x-1.26" + "reference": "8.x-2.0" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/admin_toolbar-8.x-1.26.zip", - "reference": "8.x-1.26", - "shasum": "7be9f91008bf17cf49b43d1c8e2211e7a8e40ce4" + "url": "https://ftp.drupal.org/files/projects/admin_toolbar-8.x-2.0.zip", + "reference": "8.x-2.0", + "shasum": "568de63dbaa8046a82d327dbd0b892ab79fb87aa" }, "require": { "drupal/core": "*" @@ -2233,11 +2233,11 @@ "type": "drupal-module", "extra": { "branch-alias": { - "dev-1.x": "1.x-dev" + "dev-2.x": "2.x-dev" }, "drupal": { - "version": "8.x-1.26", - "datestamp": "1549218480", + "version": "8.x-2.0", + "datestamp": "1573751237", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -13256,7 +13256,8 @@ "http", "psr", "psr-7" - ] + ], + "abandoned": "laminas/laminas-diactoros" }, { "name": "zendframework/zend-escaper", @@ -13303,7 +13304,8 @@ "ZendFramework", "escaper", "zf" - ] + ], + "abandoned": "laminas/laminas-escaper" }, { "name": "zendframework/zend-feed", @@ -13368,7 +13370,8 @@ "ZendFramework", "feed", "zf" - ] + ], + "abandoned": "laminas/laminas-feed" }, { "name": "zendframework/zend-stdlib", @@ -13416,6 +13419,7 @@ "ZendFramework", "stdlib", "zf" - ] + ], + "abandoned": "laminas/laminas-stdlib" } ] diff --git a/web/modules/admin_toolbar/CHANGELOG.txt b/web/modules/admin_toolbar/CHANGELOG.txt old mode 100644 new mode 100755 index 5fea31ee3e..a88f05bc69 --- a/web/modules/admin_toolbar/CHANGELOG.txt +++ b/web/modules/admin_toolbar/CHANGELOG.txt @@ -1,382 +1,2 @@ -Admin Toolbar 8.x-1.25, 2018-11-22 ----------------------------------- -Changes since 8.x-1.24: - -- #3012102 by tikaszvince, Jody Lynn, adriancid, grahl, jigarius: Provider - property missing on link definition. -- #3010451 by epowelljr, adriancid: Improve the admin_toolbar module - description. -- #2958415 by adriancid, romainj, Prashant.c, harshita29: Replace usages of the - deprecated drupal_set_message() function. -- #2996485 by idebr, adriancid: Remove unused function - admin_toolbar_tools_get_links(). -- #2989281 by JKerschner, adriancid: Consistently use $entityTypeManager. -- #2985106 by Eli-T, adriancid, eme: Add ability to hide Drupal.org links - exposed by admin_toolbar_tools from certain users. -- #2938884 by Spurlos, bdanin, romainj, purdy_nc, adriancid: A non-existent - route breaks the site. - -Admin Toolbar 8.x-1.24, 2018-05-28 ----------------------------------- -Changes since 8.x-1.23: - -- #2973131 by adriancid: Don't refer to Drupal in the help page. -- #2975170 by adriancid: Add composer.json file to submodules. -- #2975165 by Gamewalker, adriancid: datetime.time services is not found in - ToolbarController. -- #2971466 by recrit, adriancid, acbramley: Add media links incorrectly set to - "node.add.". -- #2972553 by dww, adriancid: Add static cache to speed up - admin_toolbar_links_access_filter_user_has_admin_role(). -- #2971435 by adriancid: Module help page for Admin Toolbar Extra Tools module - doesn't show the links. -- #2971398 by adriancid: Add the docblock to the ToolbarController constructor. -- #2969686 by adriancid, Vidushi Mehta: Add a menu link to clean the twig cache. -- #2969325 by adriancid: Fix the module version in the CHANGELOG.txt. -- #2961450 by adriancid: Convert the AdminToolbarAlterTest test class to - PHPUnit. -- #2961445 by adriancid: Convert the AdminToolbarToolsAlterTest test class to - PHPUnit. -- #2959684 by adriancid: Remove recommended modules section from README.txt. -- #2959647 by adriancid: Use interfaces instead of classes to inject - dependencies. -- #2952643 by romainj, if-jds, adriancid: Add Item for Files under Content Menu. -- #2944463 by adriancid: Update the composer.json file. - -Admin Toolbar 8.x-1.23, 2018-02-06 ----------------------------------- -Changes since 8.x-1.22: - -- #2924266 by sunlix, romainj, adriancid, samerali: Add a menu link for the - media module. -- #2941184 by daniel.nitsche, adriancid: Remove unwanted comment from - admin.toolbar.css. -- #2912503 by Amsteri, m.abdulqader: Right to left language direction support. -- #2937982 by romainj, adriancid: Auto-generation of menu links conflicts with - other modules. -- #2932873 by vaplas, saravanaprasanth, adriancid: Horizontal mode only works if - the page is loaded in horizontal mode. -- #2935311 by romainj, adriancid: Use the $entityTypeManager variable instead of - the \Drupal::entityTypeManager service. -- #2935449 by adriancid: Add the release information for the 1.22 version in the - CHANGELOG.txt. -- #2932476 by romainj: toolbar.tree library should have a dependency to the - core/drupal library. -- #2931503 by K3vin_nl: Admin toolbar generates invalid class names. - -Admin Toolbar 8.x-1.22, 2018-01-02 ----------------------------------- -Changes since 8.x-1.21: - -- #2929053 by kkuhnen, eme, adriancid: admin_toolbar.js should use Drupal - behaviors. -- #2929061 by romainj, dsnopek, adriancid: admin_toolbar_links_access_filter - doesn't do anything unless admin_toolbar is enabled. -- #2928836 by eme: One extra pixel line under the admin toolbar. -- #2925501 by eme, adriancid, RumyanaRuseva: Menu does not take changes into - account (caching issue). -- #2927914 by adriancid: Parameter comment indentation must be 3 spaces. -- #2927911 by adriancid: Remove unused variables. -- #2927905 by adriancid: All dependencies must be prefixed with the project - name. -- #2925327 by Berdir, adriancid: Better check for is-link-in-admin-menu for - local task links. -- #2922046 by mikejw, adriancid, Berdir, BrianLewisDesign: Notice: Undefined - index: entity.eform_type.collection in - admin_toolbar_tools_menu_links_discovered_alter. -- #2925128 by adriancid: Create the module help page for the Admin Toolbar Links - Access Filter submodule. - -Admin Toolbar 8.x-1.21, 2017-11-20 ----------------------------------- -Changes since 8.x-1.20: - -- #2923580 by sylus, adriancid: Unsupported operand types in - ToolbarHandler::lazyBuilder(). -- #2731369 by stefan.r, DuneBL, Berdir, kbasarab, joachim, adriancid: Local - tasks don't show in the toolbar. -- #2920793 by adriancid: Change the user TAKTAK by matio89 in the CHANGELOG.txt - file. -- #2873228 by smustgrave, adriancid, flocondetoile: Toolbar menu accessible and - navigable with keyboard. -- #2919775 by adriancid: Create the CHANGELOG.txt file. -- #2919772 by adriancid: Use the README.txt template. -- #2919769 by adriancid: Use the README.txt template for the admin_toolbar_tools - submodule. -- #2897309 by finne, adriancid, eme, rgpublic: admin_toolbar_tools module - makes all pages uncacheable. -- #2913299 by esod, Chi, adriancid, hudri, eme: CSS Z-Index of toolbar is - inappropriate. -- #2919390 by adriancid: Create the README.txt file for the admin toolbar links - access filter submodule. -- #2919367 by adriancid: Fix coding standard format. -- #2919346 by adriancid: Don't show menu links that you don't have access - permission for. -- #2917710: Create the .info.yml file for the admin_toolbar_links_access_filter - submodule. -- #2916064 by adriancid, eme, finne: Use in drupal.org links url parameter and - not route_name. -- #2916040 by adriancid, finne, eme: Remove unused route admin_development. -- #2915778 by finne, adriancid: Remove the _csrf_token from routes that don't - need it. -- #2909359 by adriancid, Musa.thomas: Add a menu link to clean the Views cache. -- #2910931 by adriancid: .info.yml files don't have the drupal version. -- #2759135 by Johnny vd Laar, miiimooo, romainj, chegor, adriancid, ckaotik, - bdominguez, SpadXIII, mrtndlmt: Content type, Vocabularies and Menus names are - not translated. -- #2909710 by adriancid, Musa.thomas: Fix coding standard format. -- #2910934 by adriancid, romainj: Error trying to clean the cache. -- #2910892 by adriancid: Delete the LICENSE.txt. -- #2909637 by bapi_22, Musa.thomas, adriancid: Avoid static call inside class - method. -- #2909003 by eme: fix z-index for CKEditor. -- #2504449 by robin.ingelbrecht, rwam, eme: Un-hover delay. - -Admin Toolbar 8.x-1.20, 2017-09-07 ----------------------------------- -Changes since 8.x-1.19: - -- #2887439 by romainj: Fix test. -- #2759135 by Johnny vd Laar, miiimooo, chegor, romainj: Content type, - Vocabularies and Menus names are not translated. -- #2894520 by romainj, bapi_22: Remove deprecated constant REQUEST_TIME from - code base. -- #2883098 by romainj, Alka Kumari: Admin Toolbar Extra Tools module display - theme machine names instead of labels. -- #2504449 by robin.ingelbrecht: Un-hover delay. -- #2838636 by ddrozdik, Fons Vandamme, kerby70, romainj: Issue with z-index of - dropdown in horizontal tray. -- #2838636 by Fons Vandamme, ddrozdik, romainj: Issue with z-index of dropdown - in horizontal tray. -- #2870404 by romainj: Add a link to the Webprofiler settings page. -- #2706643 by esod, romainj, Keenegan, DamienMcKenna: Use short array syntax. - -Admin Toolbar 8.x-1.19, 2017-04-06 ----------------------------------- -Changes since 8.x-1.18: - -- #2706643 by esod, romainj, Keenegan, DamienMcKenna: Use short array syntax. -- #2781745 by minakshiPh, eelkeblok, romainj, akhilavnair_zyxware: Drupal coding - standard issues found in most of the files. -- #2855720 by stefan.r, romainj: No logout link in admin toolbar anymore. -- #2841512 by Chi, romainj: User error: Redirects to external URLs are not - allowed by default. - -Admin Toolbar 8.x-1.18, 2016-12-01 ----------------------------------- -Changes since 8.x-1.17: - -- #2830677 by vaplas, romainj: z-index for sub menu. -- by romainj: Get rid of the Hello popup. -- #2805431 by marcusx: Accidentaly committed alert. -- #2630724 by squarecandy, romainj, reblutus, Hemangi Gokhale, jacoferg, - Balu Ertl, Jeff Burnz, Don Greco: Consider changes to link title parameter to - avoid tooltip visual conflict. -- #2518202 by james.williams, chegor, eme, romainj, DuneBL: Change default link - to taxonomy. - -Admin Toolbar 8.x-1.17, 2016-08-19 ----------------------------------- -Changes since 8.x-1.16: - -- #2779251 by romainj, DuneBL: Wrong integration of field_collection delete - form. -- #2776229 by Chi, romainj, mattlt: Chevron icons missing if Drupal is not in - document root. -- by romainj: CSS coding standard cleaning. -- #2781059 by mstrelan, romainj: Why is CRON in all caps? -- #2778935 by akhilavnair_zyxware, rjarraud: As per Drupal Standards each line - in documentation should not exceeds 80 characters. -- by romainj: Adds ending new line where required. -- #2776229 by Chi, rjarraud: Chevron icons missing if Drupal is not in document - root. -- by eme: Commiting again #2707611. -- #2757687 by neerajsingh: Remove usages of \Drupal::url(). -- #2707747 by Balu Ertl, nevergone, eme, esod: D8 logo not rendered with smooth - antialiasing. - -Admin Toolbar 8.x-1.16, 2016-07-28 ----------------------------------- -Changes since 8.x-1.15: - -- #2723209 by andrewmacpherson, colan, mattshoaf: Enabling admin_toolbar_tools - causes Devel Settings to disappear from the main configuration page. -- #2759335 bycwells, jalpesh: fixes a mistaken link in hook_help(). -- #2664564 by kolier, matio89, romainj and Michèle: auto-detect content entities - with Field UI route. -- #2735257 by colan, romainj, Balu Ertl: respect of coding standards in the - module README.txt file. -- #2735257 by colan, romainj, Balu Ertl: shortens the module README.txt - description text. -- by romainj: Fixes a problem with the link to the Admin menu overview page. -- #2735257 by Balu Ertl, colan, romainj: improves Admin Toolbar Extra Tools - description in the README.txt file. -- #2723381 by joachim, romainj: fieldable content entities are no more - hardcoded. -- #2735257 by Balu Ertl, colan, romainj: added some description details in the - README.txt files. -- by romainj: Menu link definitions updated. -- by romainj: Change routing permissions to follow Drupal default permissions - for administration pages. -- by romainj: Fixes issue #2737027. -- by romainj: fixes issue #2701825. -- by romainj: Adds the menu name for each menu item in - admin_toolbar_tools/admin_toolbar_tools.links.menu.yml file. -- #2735153 by Kionn: InvalidArgumentException: Cannot redirect to an empty URL. - в Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl(). -- by matio89: correction InvalidArgumentException: Cannot redirect to an empty - URL. в Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl(). -- by romainj: Add a new Render Cache shortcut on the admin menu. -- by romainj: Fixes issue #2731663 by canceling the move of the Logout menu - link. - -Admin Toolbar 8.x-1.15, 2016-05-23 ----------------------------------- -Changes since 8.x-1.14: - -- by matio89: add RTL in admin.toolbar.css. -- by romainj: Changes Devel menu item titles. -- by romainj: Fixes issue #2713899. -- by romainj: Minor code/typo cleaning. -- #2707611 by Balu Ertl: Add fine shadow under dropdown menus. -- #2707789 by esod: Fix Automated Tests. -- by romainj: Code cleaning. -- by romainj: Replace the deprecated entityManager() by entityTypeManager() - service. -- by romainj: Emptying menu cache with all link types. -- #2614962 by dbt102, seppelM, neha.gangwar, chegor: Correct text in - info.yml(s). -- by eme: Minor typo changes. -- by eme: Fix dependencies to core modules. -- by eme: Fix issue #2666964. -- by eme: Fix css background color level3. -- by eme: fix issue #2658896 and refactor and fix chevron-right.svg. -- by eme: fix Issue #2493037. - -Admin Toolbar 8.x-1.14, 2016-02-08 ----------------------------------- -Changes since 8.x-1.13: - -- by matio89: Correction differents bugs(problem white page when installing a - new module). -- #2643648 by Lord_of_Codes: Proposed README.txt file for Admin Toolbar. -- by matio89: resolving the dependecies problem(dependencies of others modules). -- by matio89: Correction route of entities. - -Admin Toolbar 8.x-1.13, 2016-02-02 ----------------------------------- -Changes since 8.x-1.12: - -- by matio89: Admin toolbar is compatible with 8.0.2. -- by matio89: Commmit dev version compatible with drupal 8.0.2. -- by matio89: New version of admin toolbar compatible with 8.0.2. - -Admin Toolbar 8.x-1.12, 2016-01-15 ----------------------------------- -Changes since 8.x-1.11: - -- by matio89: Correction AdminToolbaToolsAlterTest. -- #2493037 by mimran: Empty elements in #toolbar-bar. -- #2598136 by mimran, felribeiro: Menu items duplicated. -- #2635154 by Lukas von Blarer: Too general CSS selectors. -- by eme: Fix chevron right in local state. - -Admin Toolbar 8.x-1.11, 2015-12-11 ----------------------------------- -Changes since 8.x-1.10: - -- #2620430 by Vagelis, NarendraR: Typo. -- #2632888 by JamesK: Add dependency on node module. -- by eme: Fix admin toolbar test. -- #2552081 by jonhattan, bruvers: chevron-right.svg not found. -- by Vagelis: Minor typos. -- by eme: Refactor basic tests. -- #2613378 by chegor: Add basic test. -- #2612694 by chegor: Add new view. -- #2627918 by joe_carvajal: Version in info.yml files does Update Manager try to - update. -- by matio89: correction collapsible behaviour in vertical menu layout. -- #2582825 by Ben Coleman: Installing Admin Toolbar Tools loses anonymous user - login link. -- by matio89: Correction the login link on the site when in a logged-out state. - -Admin Toolbar 8.x-1.10, 2015-08-07 ----------------------------------- -Changes since 8.x-1.9: - -- #2546939 by jonhattan: Add dependency on toolbar module. - -Admin Toolbar 8.x-1.9, 2015-07-22 ---------------------------------- -Changes since 8.x-1.8: - -- #2537016 by matio89: Removing dependance for user & system. -- #2533420 by Dave Reid, twistor: Chase HEAD changes in toolbar. -- #2537016 by twistor: Rewrite admin_toolbar_tools.module -- by matio89: Correction all bugs and add new security features. - -Admin Toolbar 8.x-1.8, 2015-06-22 ---------------------------------- -Changes since 8.x-1.7: - -- correction not found route. -- #2493037 by bobrov1989: Empty elements in #toolbar-bar. -- by fethi: icones. - -Admin Toolbar 8.x-1.7, 2015-06-22 ---------------------------------- -Changes since 8.x-1.6: - -- correction not found route. -- #2493037 by bobrov1989: Empty elements in #toolbar-bar. -- by fethi: icones. - -Admin Toolbar 8.x-1.6, 2015-06-03 ---------------------------------- -Changes since 8.x-1.5: - -- by matio89: correction admin_toolbar. - -Admin Toolbar 8.x-1.5, 2015-06-03 ---------------------------------- -Changes since 8.x-1.4: - -- by matio89: test if module update exist or no to display install and update - module. -- by fethi: Change the colors used to match the Seven styleguide. -- by matio89: compatibility with Drupal 8 béta 11. -- by fethi: Change the colors used to match the Seven styleguide. - -Admin Toolbar 8.x-1.4, 2015-05-20 ---------------------------------- -Changes since 8.x-1.3: - -- by matio89: correction add/node. - -Admin Toolbar 8.x-1.3, 2015-05-19 ---------------------------------- -Changes since 8.x-1.2: - -- by matio89: add new functionalities. -- by matio89: add administration devel link. -- by matio89: correction reload page. -- by matio89: correction redirect to the same page. - -Admin Toolbar 8.x-1.2, 2015-05-19 ---------------------------------- -Changes since 8.x-1.1: - -- by matio89: add new functionalities. -- by matio89: add administration devel link. -- by matio89: correction reload page. -- by matio89: correction redirect to the same page. - -Admin Toolbar 8.x-1.1, 2015-05-19 ---------------------------------- -Changes since 8.x-1.0: - -- by matio89: add new functionalities. - -Admin Toolbar 8.x-1.0, 2015-05-07 ---------------------------------- -- Initial release. +* For a full list of fixes in the latest release, visit: + https://www.drupal.org/project/admin_toolbar/releases diff --git a/web/modules/admin_toolbar/README.txt b/web/modules/admin_toolbar/README.txt old mode 100644 new mode 100755 index 459cc2ca92..dfcc03a855 --- a/web/modules/admin_toolbar/README.txt +++ b/web/modules/admin_toolbar/README.txt @@ -67,3 +67,5 @@ This project has been sponsored by: Founded in 2009, emerya is a human-sized company, dedicated to the design and implementation of web interfaces. Visit: http://http://emerya.fr/ for more information. + * trained people + Trained People is a training company focused on Drupal. diff --git a/web/modules/admin_toolbar/admin_toolbar.info.yml b/web/modules/admin_toolbar/admin_toolbar.info.yml index 2e6857e41f..b55a509cff 100644 --- a/web/modules/admin_toolbar/admin_toolbar.info.yml +++ b/web/modules/admin_toolbar/admin_toolbar.info.yml @@ -3,13 +3,12 @@ description: Provides an improved drop-down menu interface to the site Toolbar. package: Administration type: module -# core: 8.x +core: 8.x dependencies: - drupal:toolbar -# Information added by Drupal.org packaging script on 2019-02-03 -version: '8.x-1.26' -core: '8.x' +# Information added by Drupal.org packaging script on 2019-10-29 +version: '8.x-2.0' project: 'admin_toolbar' -datestamp: 1549218484 +datestamp: 1572370993 diff --git a/web/modules/admin_toolbar/admin_toolbar.install b/web/modules/admin_toolbar/admin_toolbar.install old mode 100644 new mode 100755 diff --git a/web/modules/admin_toolbar/admin_toolbar.libraries.yml b/web/modules/admin_toolbar/admin_toolbar.libraries.yml old mode 100644 new mode 100755 index 85b322a4e6..34306becdb --- a/web/modules/admin_toolbar/admin_toolbar.libraries.yml +++ b/web/modules/admin_toolbar/admin_toolbar.libraries.yml @@ -8,3 +8,14 @@ toolbar.tree: dependencies: - core/jquery - core/drupal +search: + css: + theme: + css/admin.toolbar_search.css: {} + js: + js/admin_toolbar_search.js: {} + dependencies: + - core/jquery + - core/drupal + - core/jquery.once + - core/jquery.ui.autocomplete diff --git a/web/modules/admin_toolbar/admin_toolbar.module b/web/modules/admin_toolbar/admin_toolbar.module old mode 100644 new mode 100755 index c8ee104dab..3c5e81bda0 --- a/web/modules/admin_toolbar/admin_toolbar.module +++ b/web/modules/admin_toolbar/admin_toolbar.module @@ -9,6 +9,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; use Drupal\Component\Utility\Html; +use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Implements hook_toolbar_alter(). @@ -16,6 +17,45 @@ function admin_toolbar_toolbar_alter(&$items) { $items['administration']['tray']['toolbar_administration']['#pre_render'] = ['admin_toolbar_prerender_toolbar_administration_tray']; $items['administration']['#attached']['library'][] = 'admin_toolbar/toolbar.tree'; + $admin_toolbar_tools = \Drupal::service('module_handler') + ->moduleExists('admin_toolbar_tools'); + $items['administration_search'] = [ + "#type" => "toolbar_item", + 'tab' => [ + '#type' => 'link', + '#title' => new TranslatableMarkup('Search'), + '#url' => URL::fromRoute('system.admin'), + '#attributes' => [ + 'class' => [ + 'toolbar-icon', + ], + ], + ], + 'tray' => [ + 'search' => [ + '#title' => 'Search', + '#type' => 'textfield', + '#size' => 60, + '#attributes' => [ + 'id' => 'admin-toolbar-search-input', + 'aria-labelledby' => 'toolbar-item-administration-search', + ], + ], + ], + '#attached' => [ + 'library' => [ + 'admin_toolbar/search', + ], + 'drupalSettings' => [ + 'adminToolbarSearch' => [ + 'loadExtraLinks' => $admin_toolbar_tools, + ], + ], + ], + '#wrapper_attributes' => [ + "id" => "admin-toolbar-search-tab", + ], + ]; } /** @@ -28,13 +68,11 @@ function admin_toolbar_help($route_name, RouteMatchInterface $route_match) { ':toolbar' => Url::fromRoute('help.page', ['name' => 'toolbar'])->toString(), ':automated_cron' => (\Drupal::moduleHandler()->moduleExists('automated_cron')) ? Url::fromRoute('help.page', ['name' => 'automated_cron'])->toString() : '#', ]; - $output = ''; $output .= '<h3>' . t('About') . '</h3>'; $output .= '<p>' . t('The Admin Toolbar module enhances the <a href=":toolbar">Toolbar</a> module by providing fast access to all the administrative links at the top of your site. Admin Toolbar remains a very "lightweight" module by closely integrating with all Toolbar functionality. It can be used in conjunction with all the sub modules included on Admin Toolbar, for quick access to system commands such as Flush all caches, <a href=":automated_cron">Run cron</a>, Run Updates, etc.', $variables) . '</p>'; $output .= '<h3>' . t('Uses') . '</h3>'; $output .= '<p>' . t('The Admin Toolbar greatly improves the user experience for those who regularly interact with the site Toolbar by providing fast, full access to all links in the site Toolbar without having to click to get there.') . '</p>'; - return $output; } } @@ -65,7 +103,6 @@ function admin_toolbar_prerender_toolbar_administration_tray(array $element) { ]; $tree = $menu_tree->transform($tree, $manipulators); $element['administration_menu'] = $menu_tree->build($tree); - return $element; } @@ -84,10 +121,8 @@ function toolbar_tools_menu_navigation_links(array $tree) { toolbar_tools_menu_navigation_links($element->subtree); } $link = $element->link; - // Get the non-localized title to make the icon class. $definition = $link->getPluginDefinition(); - $element->options['attributes']['class'][] = 'toolbar-icon'; $string = strtolower(str_replace(['.', ' ', '_'], ['-', '-', '-'], $definition['id'])); $element->options['attributes']['class'][] = Html::cleanCssIdentifier('toolbar-icon-' . $string); diff --git a/web/modules/admin_toolbar/admin_toolbar_links_access_filter/README.txt b/web/modules/admin_toolbar/admin_toolbar_links_access_filter/README.txt old mode 100644 new mode 100755 diff --git a/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.info.yml b/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.info.yml index 7e743e26c4..9ac6cdb5a3 100644 --- a/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.info.yml +++ b/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.info.yml @@ -3,13 +3,12 @@ description: Provides a workaround for the common problem that users with 'Use t package: Administration type: module -# core: 8.x +core: 8.x dependencies: - admin_toolbar:admin_toolbar -# Information added by Drupal.org packaging script on 2019-02-03 -version: '8.x-1.26' -core: '8.x' +# Information added by Drupal.org packaging script on 2019-10-29 +version: '8.x-2.0' project: 'admin_toolbar' -datestamp: 1549218484 +datestamp: 1572370993 diff --git a/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module b/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module old mode 100644 new mode 100755 index d9930e07b8..2aff07f402 --- a/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module +++ b/web/modules/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module @@ -6,7 +6,6 @@ */ use Drupal\Core\Session\AccountInterface; -use Drupal\Core\Url; use Drupal\user\Entity\Role; use Symfony\Component\Routing\Exception\RouteNotFoundException; use Drupal\Core\Routing\RouteMatchInterface; @@ -74,7 +73,8 @@ function admin_toolbar_links_access_filter_filter_non_accessible_links(array &$i } // Check, if user has access rights to the route. - if (!\Drupal::accessManager()->checkNamedRoute($route_name, $route_params)) { + if (!\Drupal::accessManager() + ->checkNamedRoute($route_name, $route_params)) { unset($items[$route]); } else { @@ -82,7 +82,8 @@ function admin_toolbar_links_access_filter_filter_non_accessible_links(array &$i // Recursively call this function for the child items. admin_toolbar_links_access_filter_filter_non_accessible_links($items[$route]['below']); } - if (empty($items[$route]['below']) && \Drupal::moduleHandler()->moduleExists('admin_toolbar')) { + if (empty($items[$route]['below']) && \Drupal::moduleHandler() + ->moduleExists('admin_toolbar')) { // Every child item has been cleared out. // Now check, if the given route represents an overview page only, @@ -102,43 +103,6 @@ function admin_toolbar_links_access_filter_filter_non_accessible_links(array &$i } } -/** - * Implements template_preprocess_admin_block_content(). - */ -function admin_toolbar_links_access_filter_admin_block_content(&$variables) { - if (!admin_toolbar_links_access_filter_user_has_admin_role($variables['user'])) { - foreach ($variables['content'] as $key => &$item) { - if (isset($item['url']) && $item['url'] instanceof Url) { - /* @var \Drupal\Core\Url $url */ - $url = $item['url']; - if ($url->access()) { - continue; - } - unset($variables['content'][$key]); - } - - // The key is structured in the form: "ID title route", - // concatenated with spaces. - $key_parts = explode(' ', $key); - $route = end($key_parts); - - // Special handling for Views pages, as they are not defined - // system routes. - // @TODO check the permission for Views + find a generic way for similar - // cases. Best way would be to get the link entity somehow to properly - // check permissions. - if (strpos($route, 'views_view:') === 0) { - continue; - } - - // Check, if user has access rights to the route. - if (!\Drupal::accessManager()->checkNamedRoute($route)) { - unset($variables['content'][$key]); - } - } - } -} - /** * Checks if the given route name is an overview page. * diff --git a/web/modules/admin_toolbar/admin_toolbar_links_access_filter/composer.json b/web/modules/admin_toolbar/admin_toolbar_links_access_filter/composer.json old mode 100644 new mode 100755 diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/README.txt b/web/modules/admin_toolbar/admin_toolbar_tools/README.txt old mode 100644 new mode 100755 index 263cde93c3..4b73b2006d --- a/web/modules/admin_toolbar/admin_toolbar_tools/README.txt +++ b/web/modules/admin_toolbar/admin_toolbar_tools/README.txt @@ -60,3 +60,5 @@ This project has been sponsored by: Founded in 2009, emerya is a human-sized company, dedicated to the design and implementation of web interfaces. Visit: http://http://emerya.fr/ for more information. + * trained people + Trained People is a training company focused on Drupal. diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.info.yml b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.info.yml index d94726473e..7b7728100e 100644 --- a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.info.yml +++ b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.info.yml @@ -3,14 +3,13 @@ description: Adds menu links to the Admin Toolbar. package: Administration type: module -# core: 8.x +core: 8.x dependencies: - admin_toolbar:admin_toolbar - - drupal:system (>=8.5) + - drupal:system (>=8.6) -# Information added by Drupal.org packaging script on 2019-02-03 -version: '8.x-1.26' -core: '8.x' +# Information added by Drupal.org packaging script on 2019-10-29 +version: '8.x-2.0' project: 'admin_toolbar' -datestamp: 1549218484 +datestamp: 1572370993 diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.libraries.yml b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.libraries.yml old mode 100644 new mode 100755 diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.links.menu.yml b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.links.menu.yml old mode 100644 new mode 100755 index e39dbe9409..567e32d16e --- a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.links.menu.yml +++ b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.links.menu.yml @@ -74,3 +74,7 @@ admin_toolbar_tools.flush_rendercache: route_name: admin_toolbar_tools.flush_rendercache parent: admin_toolbar_tools.flush menu_name: admin + +admin_toolbar_tools.extra_links: + deriver: \Drupal\admin_toolbar_tools\Plugin\Derivative\ExtraLinks + menu_name: admin diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module old mode 100644 new mode 100755 index cd56261ec3..ec4e682fa2 --- a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module +++ b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module @@ -7,6 +7,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; +use Drupal\Core\Entity\EntityInterface; /** * Implements hook_toolbar(). @@ -35,668 +36,40 @@ function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match) case 'help.page.admin_toolbar_tools': $output = ''; $output .= '<p>'; - $output .= t('The Admin Toolbar Extra Tools module comes packaged with the <a href=":admin-toolbar">Admin Toolbar</a> module and adds functionality to it. The additional functionality is accessed thru extra links on the main administration Toolbar. Some links to Admin Toolbar Extra Tools administration pages are located at the bottom of this page.</a>', [':admin-toolbar' => Url::fromRoute('help.page', ['name' => 'admin_toolbar'])->toString()]); + $output .= t('The Admin Toolbar Extra Tools module comes packaged with the <a href=":admin-toolbar">Admin Toolbar</a> module and adds functionality to it. The additional functionality is accessed through extra links on the main administration Toolbar. Some links to Admin Toolbar Extra Tools administration pages are located at the bottom of this page.</a>', [':admin-toolbar' => Url::fromRoute('help.page', ['name' => 'admin_toolbar'])->toString()]); $output .= '</p>'; $output .= '<h3>' . t('Uses') . '</h3>'; $output .= '<p>' . t('To use Admin Toolbar Extra Tools just install it like any other module. There is no other configuration required.') . '</p>'; - return $output; } } /** - * Implements hook_menu_links_discovered_alter(). + * Implements hook_entity_insert(). */ -function admin_toolbar_tools_menu_links_discovered_alter(&$links) { - $languageManager = \Drupal::languageManager(); - $config_override_language = $languageManager->getConfigOverrideLanguage(); - $languageManager->setConfigOverrideLanguage($languageManager->getLanguage('en')); - - $moduleHandler = \Drupal::moduleHandler(); - $entityTypeManager = \Drupal::entityTypeManager(); - $routeProvider = \Drupal::service('router.route_provider'); - - /** - * Determine if a route exists by name. - * - * @param $routeName - * The name of the route to check. - * - * @return bool - * Whether a route with that route name exists. - */ - $routeExists = function ($routeName) use ($routeProvider) { - return (count($routeProvider->getRoutesByNames([$routeName])) === 1); - }; - - $entityTypes = $entityTypeManager->getDefinitions(); - $content_entities = []; - foreach ($entityTypes as $key => $entityType) { - if ($entityType->getBundleEntityType() && ($entityType->get('field_ui_base_route') != '')) { - $content_entities[$key] = [ - 'content_entity' => $key, - 'content_entity_bundle' => $entityType->getBundleEntityType(), - ]; - } - } - - // Adding a menu link to clean the Views cache. - if ($moduleHandler->moduleExists('views')) { - $links['admin_toolbar_tools.flush_views'] = [ - 'title' => t('Flush views cache'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'admin_toolbar_tools.flush_views', - 'menu_name' => 'admin', - 'parent' => 'admin_toolbar_tools.flush', - ]; - // Adding a menu link to Files. - if ($moduleHandler->moduleExists('file') && $routeExists('view.files.page_1')) { - $links['admin_toolbar_tools.view.files'] = [ - 'title' => t('Files'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'view.files.page_1', - 'menu_name' => 'admin', - 'parent' => 'system.admin_content', - ]; - } - } - - // Adds common links to entities. - foreach ($content_entities as $entities) { - $content_entity_bundle = $entities['content_entity_bundle']; - $content_entity = $entities['content_entity']; - foreach ($entityTypeManager->getStorage($content_entity_bundle)->loadMultiple() as $machine_name => $bundle) { - // Normally, the edit form for the bundle would be its root link. - $content_entity_bundle_root = NULL; - if ($routeExists('entity.' . $content_entity_bundle . '.overview_form')) { - // Some bundles have an overview/list form that make a better root link. - $content_entity_bundle_root = 'entity.' . $content_entity_bundle . '.overview_form.' . $machine_name; - $links[$content_entity_bundle_root] = [ - 'title' => t($bundle->label()), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.' . $content_entity_bundle . '.overview_form', - 'menu_name' => 'admin', - 'parent' => 'entity.' . $content_entity_bundle . '.collection', - 'route_parameters' => [$content_entity_bundle => $machine_name], - ]; - } - if ($routeExists('entity.' . $content_entity_bundle . '.edit_form')) { - $key = 'entity.' . $content_entity_bundle . '.edit_form.' . $machine_name; - $links[$key] = [ - 'title' => t($bundle->label()), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.' . $content_entity_bundle . '.edit_form', - 'menu_name' => 'admin', - 'parent' => 'entity.' . $content_entity_bundle . '.collection', - 'route_parameters' => [$content_entity_bundle => $machine_name], - ]; - if (empty($content_entity_bundle_root)) { - $content_entity_bundle_root = $key; - } - else { - $links[$key]['parent'] = $content_entity_bundle_root; - $links[$key]['title'] = t('Edit'); - } - } - if ($moduleHandler->moduleExists('field_ui')) { - if ($routeExists('entity.' . $content_entity . '.field_ui_fields')) { - $links['entity.' . $content_entity . '.field_ui_fields' . $machine_name] = [ - 'title' => t('Manage fields'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.' . $content_entity . '.field_ui_fields', - 'menu_name' => 'admin', - 'parent' => $content_entity_bundle_root, - 'route_parameters' => [$content_entity_bundle => $machine_name], - 'weight' => 1, - ]; - } - if ($routeExists('entity.entity_form_display.' . $content_entity . '.default')) { - $links['entity.entity_form_display.' . $content_entity . '.default' . $machine_name] = [ - 'title' => t('Manage form display'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.entity_form_display.' . $content_entity . '.default', - 'menu_name' => 'admin', - 'parent' => $content_entity_bundle_root, - 'route_parameters' => [$content_entity_bundle => $machine_name], - 'weight' => 2, - ]; - } - if ($routeExists('entity.entity_view_display.' . $content_entity . '.default')) { - $links['entity.entity_view_display.' . $content_entity . '.default.' . $machine_name] = [ - 'title' => t('Manage display'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.entity_view_display.' . $content_entity . '.default', - 'menu_name' => 'admin', - 'parent' => $content_entity_bundle_root, - 'route_parameters' => [$content_entity_bundle => $machine_name], - 'weight' => 3, - ]; - } - } - if ($moduleHandler->moduleExists('devel') && $routeExists('entity.' . $content_entity_bundle . '.devel_load')) { - $links['entity.' . $content_entity_bundle . '.devel_load.' . $machine_name] = [ - 'title' => t('Devel'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.' . $content_entity_bundle . '.devel_load', - 'menu_name' => 'admin', - 'parent' => $content_entity_bundle_root, - 'route_parameters' => [$content_entity_bundle => $machine_name], - 'weight' => 4, - ]; - } - if ($routeExists('entity.' . $content_entity_bundle . '.delete_form')) { - $links['entity.' . $content_entity_bundle . '.delete_form.' . $machine_name] = [ - 'title' => t('Delete'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.' . $content_entity_bundle . '.delete_form', - 'menu_name' => 'admin', - 'parent' => $content_entity_bundle_root, - 'route_parameters' => [$content_entity_bundle => $machine_name], - 'weight' => 5, - ]; - } - } - } - - // Add user links. - $links['user.admin_create'] = [ - 'title' => t('Add a new user'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'user.admin_create', - 'menu_name' => 'admin', - 'parent' => 'entity.user.collection', - ]; - $links['user.admin_permissions'] = [ - 'title' => t('Permissions'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'user.admin_permissions', - 'menu_name' => 'admin', - 'parent' => 'entity.user.collection', - ]; - $links['entity.user_role.collection'] = [ - 'title' => t('Roles'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.user_role.collection', - 'menu_name' => 'admin', - 'parent' => 'entity.user.collection', - ]; - $links['admin_toolbar_tools.user.logout'] = [ - 'title' => t('Logout'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'user.logout', - 'parent' => 'admin_toolbar_tools.help', - 'weight' => 10, - ]; - $links['user.role_add'] = [ - 'title' => t('Add a new role'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'user.role_add', - 'menu_name' => 'admin', - 'parent' => 'entity.user_role.collection', - 'weight' => -5, - ]; - if ($moduleHandler->moduleExists('field_ui')) { - $links['entity.user.field_ui_fields_'] = [ - 'title' => t('Manage fields'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.user.field_ui_fields', - 'menu_name' => 'admin', - 'parent' => 'entity.user.admin_form', - ]; - $links['entity.entity_form_display.user.default_'] = [ - 'title' => t('Manage form display'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.entity_form_display.user.default', - 'menu_name' => 'admin', - 'parent' => 'entity.user.admin_form', - ]; - $links['entity.entity_view_display.user.default_'] = [ - 'title' => t('Manage display'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.entity_view_display.user.default', - 'menu_name' => 'admin', - 'parent' => 'entity.user.admin_form', - ]; - } - foreach (user_roles() as $role) { - $links['entity.user_role.edit_form.' . $role->id()] = [ - 'title' => t($role->label()), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.user_role.edit_form', - 'menu_name' => 'admin', - 'parent' => 'entity.user_role.collection', - 'route_parameters' => ['user_role' => $role->id()], - ]; - $links['entity.user_role.edit_permissions_form.' . $role->id()] = [ - 'title' => t('Edit permissions'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.user_role.edit_permissions_form', - 'menu_name' => 'admin', - 'parent' => 'entity.user_role.edit_form.' . $role->id(), - 'route_parameters' => ['user_role' => $role->id()], - ]; - $links['entity.user_role.delete_form.' . $role->id()] = [ - 'title' => t('Delete'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.user_role.delete_form', - 'menu_name' => 'admin', - 'parent' => 'entity.user_role.edit_form.' . $role->id(), - 'route_parameters' => ['user_role' => $role->id()], - ]; - if ($moduleHandler->moduleExists('devel')) { - $links['entity.user_role.devel_load.' . $role->id()] = [ - 'title' => t('Devel'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.user_role.devel_load', - 'menu_name' => 'admin', - 'parent' => 'entity.user_role.edit_form.' . $role->id(), - 'route_parameters' => ['user_role' => $role->id()], - ]; - } - } - - if ($moduleHandler->moduleExists('node')) { - $links['admin_toolbar_tools.add_content'] = $links['node.add_page']; - $links['admin_toolbar_tools.add_content']['parent'] = 'system.admin_content'; - $links['node.type_add'] = [ - 'title' => t('Add content type'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'node.type_add', - 'menu_name' => 'admin', - 'parent' => 'entity.node_type.collection', - 'weight' => -5, - ]; - // Add node links for each content type. - foreach ($entityTypeManager->getStorage('node_type')->loadMultiple() as $type) { - $links['node.add.' . $type->id()] = [ - 'title' => t($type->label()), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'node.add', - 'parent' => 'admin_toolbar_tools.add_content', - 'route_parameters' => ['node_type' => $type->id()], - ]; - } - } - - if ($moduleHandler->moduleExists('field_ui')) { - $links['field_ui.entity_form_mode_add'] = [ - 'title' => t('Add new form mode'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'field_ui.entity_form_mode_add', - 'menu_name' => 'admin', - 'parent' => 'entity.entity_form_mode.collection', - ]; - $links['field_ui.entity_view_mode_add'] = [ - 'title' => t('Add new view mode'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'field_ui.entity_view_mode_add', - 'menu_name' => 'admin', - 'parent' => 'entity.entity_view_mode.collection', - ]; - } - - if ($moduleHandler->moduleExists('taxonomy')) { - $links['entity.taxonomy_vocabulary.add_form'] = [ - 'title' => t('Add vocabulary'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.taxonomy_vocabulary.add_form', - 'menu_name' => 'admin', - 'parent' => 'entity.taxonomy_vocabulary.collection', - 'weight' => -5, - ]; - } - - if ($moduleHandler->moduleExists('menu_ui')) { - $links['entity.menu.add_form'] = [ - 'title' => t('Add menu'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.menu.add_form', - 'menu_name' => 'admin', - 'parent' => 'entity.menu.collection', - 'weight' => -50, - ]; - // Adds links to /admin/structure/menu. - foreach (menu_ui_get_menus() as $machine_name => $label) { - $links['entity.menu.edit_form.' . $machine_name] = [ - 'title' => t($label), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.menu.edit_form', - 'menu_name' => 'admin', - 'parent' => 'entity.menu.collection', - 'route_parameters' => ['menu' => $machine_name], - ]; - $links['entity.menu.delete_form.' . $machine_name] = [ - 'title' => t('Delete'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.menu.delete_form', - 'menu_name' => 'admin', - 'parent' => 'entity.menu.edit_form.' . $machine_name, - 'route_parameters' => ['menu' => $machine_name], - ]; - if ($moduleHandler->moduleExists('devel') && $routeExists('entity.menu.devel_load')) { - $links['entity.menu.devel_load.' . $machine_name] = [ - 'title' => t('Devel'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.menu.devel_load', - 'menu_name' => 'admin', - 'parent' => 'entity.menu.edit_form.' . $machine_name, - 'route_parameters' => ['menu' => $machine_name], - ]; - } - $links['entity.menu.add_link_form.' . $machine_name] = [ - 'title' => t('Add link'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.menu.add_link_form', - 'menu_name' => 'admin', - 'parent' => 'entity.menu.edit_form.' . $machine_name, - 'route_parameters' => ['menu' => $machine_name], - ]; - } - } - - // If module block_content is enabled. - if ($moduleHandler->moduleExists('block_content')) { - $links['block_content.add_page'] = [ - 'title' => t('Add custom block'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'block_content.add_page', - 'menu_name' => 'admin', - 'parent' => 'block.admin_display', - 'weight' => -100, - ]; - $links['entity.block_content.collection'] = [ - 'title' => t('Custom block library'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.block_content.collection', - 'menu_name' => 'admin', - 'parent' => 'block.admin_display', - ]; - $links['entity.block_content_type.collection'] = [ - 'title' => t('Types'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.block_content_type.collection', - 'menu_name' => 'admin', - 'parent' => 'block.admin_display', - ]; - } - - // If module Contact is enabled. - if ($moduleHandler->moduleExists('contact')) { - $links['contact.form_add'] = [ - 'title' => t('Add contact form'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'contact.form_add', - 'menu_name' => 'admin', - 'parent' => 'entity.contact_form.collection', - 'weight' => -5, - ]; - } - - // If module Update Manager is enabled. - if ($moduleHandler->moduleExists('update')) { - $links['update.module_update'] = [ - 'title' => t('Update'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'update.module_update', - 'menu_name' => 'admin', - 'parent' => 'system.modules_list', - ]; - $links['update.module_install'] = [ - 'title' => t('Install new module'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'update.module_install', - 'menu_name' => 'admin', - 'parent' => 'system.modules_list', - ]; - } - - // If module Devel is enabled. - if ($moduleHandler->moduleExists('devel')) { - $links['admin_development'] = [ - 'title' => t('Development'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'system.admin_config_development', - 'menu_name' => 'admin', - 'parent' => 'admin_toolbar_tools.help', - 'weight' => '-8', - ]; - $links['admin_toolbar_tools.devel.admin_settings'] = [ - 'title' => t('Devel settings'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'devel.admin_settings', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - 'weight' => '-1', - ]; - if ($moduleHandler->moduleExists('webprofiler')) { - $links['admin_toolbar_tools.devel.webprofiler'] = [ - 'title' => t('Web Profiler settings'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'webprofiler.settings', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - ]; - } - $links['admin_toolbar_tools.devel.configs_list'] = [ - 'title' => t('Config editor'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'devel.configs_list', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - ]; - $links['admin_toolbar_tools.devel.reinstall'] = [ - 'title' => t('Reinstall modules'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'devel.reinstall', - 'parent' => 'admin_development', - ]; - $links['admin_toolbar_tools.devel.menu_rebuild'] = [ - 'title' => t('Rebuild menu'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'devel.menu_rebuild', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - ]; - $links['admin_toolbar_tools.devel.state_system_page'] = [ - 'title' => t('State editor'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'devel.state_system_page', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - ]; - $links['admin_toolbar_tools.devel.theme_registry'] = [ - 'title' => t('Theme registry'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'devel.theme_registry', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - ]; - $links['admin_toolbar_tools.devel.entity_info_page'] = [ - 'title' => t('Entity Info'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'devel.entity_info_page', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - ]; - $links['admin_toolbar_tools.devel.session'] = [ - 'title' => t('Session viewer'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'devel.session', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - ]; - $links['admin_toolbar_tools.devel.elements_page'] = [ - 'title' => t('Form API field types'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'devel.elements_page', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - ]; - // Menu link for the Toolbar module. - $links['admin_toolbar_tools.toolbar.settings'] = [ - 'title' => t('Toolbar settings'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'devel.toolbar.settings_form', - 'menu_name' => 'admin', - 'parent' => 'devel.admin_settings', - ]; - } - // If module Devel PHP is enabled. - if ($moduleHandler->moduleExists('devel_php') && $routeExists('devel_php.execute_php')) { - $links['admin_toolbar_tools.devel_php.execute_php'] = [ - 'title' => t('Execute PHP Code'), - 'route_name' => 'devel_php.execute_php', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - ]; - } - elseif ($moduleHandler->moduleExists('devel') && $routeExists('devel.execute_php')) { - $links['admin_toolbar_tools.devel.execute_php'] = [ - 'title' => t('Execute PHP Code'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'devel.execute_php', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - ]; - } - // If module Views Ui enabled. - if ($moduleHandler->moduleExists('views_ui')) { - $links['admin_toolbar_tools.views_ui.add'] = [ - 'title' => t('Add new view'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'views_ui.add', - 'menu_name' => 'admin', - 'parent' => 'entity.view.collection', - 'weight' => -5, - ]; - $links['admin_toolbar_tools.views_ui.field_list'] = [ - 'title' => t('Used in views'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'views_ui.reports_fields', - 'menu_name' => 'admin', - 'parent' => 'entity.field_storage_config.collection', - ]; - } - - $links['admin_toolbar_tools.system.theme_settings'] = [ - 'title' => t('Settings'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'system.theme_settings', - 'menu_name' => 'admin', - 'parent' => 'system.themes_page', - ]; - - if ($moduleHandler->moduleExists('webprofiler')) { - $links['admin_toolbar_tools.devel.webprofiler'] = [ - 'title' => t('Webprofiler settings'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'webprofiler.settings', - 'menu_name' => 'admin', - 'parent' => 'admin_development', - ]; - } - - if ($moduleHandler->moduleExists('update')) { - $links['update.theme_install_'] = [ - 'title' => t('Install new theme'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'update.theme_install', - 'menu_name' => 'admin', - 'parent' => 'system.themes_page', - ]; - $links['update.theme_update_'] = [ - 'title' => t('Update'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'update.theme_update', - 'menu_name' => 'admin', - 'parent' => 'system.themes_page', - ]; - // Lists installed themes. - $installed_themes = admin_toolbar_tools_installed_themes(); - foreach ($installed_themes as $key_theme => $label_theme) { - $links['system.theme_settings_theme.' . $key_theme] = [ - 'title' => t($label_theme), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'system.theme_settings_theme', - 'menu_name' => 'admin', - 'parent' => 'system.theme_settings_', - 'route_parameters' => [ - 'theme' => $key_theme, - ], - ]; - } - } - - // If module Language enabled. - if ($moduleHandler->moduleExists('language')) { - $links['admin_toolbar_tools.language.negotiation'] = [ - 'title' => t('Detection and selection'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'language.negotiation', - 'menu_name' => 'admin', - 'parent' => 'entity.configurable_language.collection', - ]; - } - - // If module Media enabled. - if ($moduleHandler->moduleExists('media')) { - $links['admin_toolbar_tools.add_media'] = [ - 'title' => t('Add media'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.media.add_page', - 'menu_name' => 'admin', - 'parent' => 'system.admin_content', - ]; - // Add node links for each media type. - foreach ($entityTypeManager->getStorage('media_type')->loadMultiple() as $type) { - $links['media.add.' . $type->id()] = [ - 'title' => t($type->label()), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'entity.media.add_form', - 'parent' => 'admin_toolbar_tools.add_media', - 'route_parameters' => ['media_type' => $type->id()], - ]; - } +function admin_toolbar_tools_entity_insert(EntityInterface $entity) { + $entities = \Drupal::service('admin_toolbar_tools.search_links')->getRebuildEntityTypes(); + if (in_array($entity->getEntityTypeId(), $entities)) { + \Drupal::service('plugin.manager.menu.link')->rebuild(); } +} - // If module Config enabled. - if ($moduleHandler->moduleExists('config')) { - $links['admin_toolbar_tools.config.import'] = [ - 'title' => t('Import'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'config.import_full', - 'menu_name' => 'admin', - 'parent' => 'config.sync', - 'weight' => 1, - ]; - $links['admin_toolbar_tools.config.export'] = [ - 'title' => t('Export'), - 'provider' => 'admin_toolbar_tools', - 'route_name' => 'config.export_full', - 'menu_name' => 'admin', - 'parent' => 'config.sync', - 'weight' => 2, - ]; +/** + * Implements hook_entity_update(). + */ +function admin_toolbar_tools_entity_update(EntityInterface $entity) { + $entities = \Drupal::service('admin_toolbar_tools.search_links')->getRebuildEntityTypes(); + if (in_array($entity->getEntityTypeId(), $entities)) { + \Drupal::service('plugin.manager.menu.link')->rebuild(); } - - $languageManager->setConfigOverrideLanguage($config_override_language); } /** - * Return installed themes. - * - * @return array - * An array of friendly theme names, keyed by the machine name. + * Implements hook_entity_delete(). */ -function admin_toolbar_tools_installed_themes() { - $themeHandler = \Drupal::service('theme_handler'); - $all_themes = $themeHandler->listInfo(); - $themes_installed = []; - foreach ($all_themes as $key_theme => $theme) { - if ($themeHandler->hasUi($key_theme)) { - $themes_installed[$key_theme] = $themeHandler->getName($key_theme); - } +function admin_toolbar_tools_entity_delete(EntityInterface $entity) { + $entities = \Drupal::service('admin_toolbar_tools.search_links')->getRebuildEntityTypes(); + if (in_array($entity->getEntityTypeId(), $entities)) { + \Drupal::service('plugin.manager.menu.link')->rebuild(); } - - return $themes_installed; } diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.routing.yml b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.routing.yml old mode 100644 new mode 100755 index dc081c860e..ee4eb23a2c --- a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.routing.yml +++ b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.routing.yml @@ -78,3 +78,10 @@ admin_toolbar.run.cron: requirements: _permission: 'administer site configuration' _csrf_token: 'TRUE' + +admin_toolbar.search: + path: '/admin/admin-toolbar-search' + defaults: + _controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::search' + requirements: + _permission: 'administer site configuration' diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.services.yml b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.services.yml new file mode 100644 index 0000000000..f772cffaae --- /dev/null +++ b/web/modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.services.yml @@ -0,0 +1,9 @@ +services: + admin_toolbar_tools.search_links: + class: Drupal\admin_toolbar_tools\SearchLinks + arguments: + - '@entity_type.manager' + - '@module_handler' + - '@router.route_provider' + - '@cache_contexts_manager' + - '@cache.toolbar' diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/composer.json b/web/modules/admin_toolbar/admin_toolbar_tools/composer.json old mode 100644 new mode 100755 index 41366480f4..bb568793a3 --- a/web/modules/admin_toolbar/admin_toolbar_tools/composer.json +++ b/web/modules/admin_toolbar/admin_toolbar_tools/composer.json @@ -33,7 +33,7 @@ "source": "http://cgit.drupalcode.org/admin_toolbar" }, "require": { - "drupal/admin_toolbar": "^1", - "drupal/core": "~8.5" + "drupal/admin_toolbar": "^2", + "drupal/core": "~8.7" } } diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/css/tools.css b/web/modules/admin_toolbar/admin_toolbar_tools/css/tools.css old mode 100644 new mode 100755 index a40a8a4f31..f3eb07f225 --- a/web/modules/admin_toolbar/admin_toolbar_tools/css/tools.css +++ b/web/modules/admin_toolbar/admin_toolbar_tools/css/tools.css @@ -3,6 +3,7 @@ } .toolbar-icon-admin-toolbar-tools-help:before { + box-sizing: content-box; background-image: url(../misc/icons/ffffff/d8-item.svg); padding-bottom: 0; padding-left: 4px; diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/misc/icons/ffffff/d8-item.svg b/web/modules/admin_toolbar/admin_toolbar_tools/misc/icons/ffffff/d8-item.svg old mode 100644 new mode 100755 diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/src/Controller/ToolbarController.php b/web/modules/admin_toolbar/admin_toolbar_tools/src/Controller/ToolbarController.php old mode 100644 new mode 100755 index a8758628a4..7677f2af67 --- a/web/modules/admin_toolbar/admin_toolbar_tools/src/Controller/ToolbarController.php +++ b/web/modules/admin_toolbar/admin_toolbar_tools/src/Controller/ToolbarController.php @@ -2,6 +2,7 @@ namespace Drupal\admin_toolbar_tools\Controller; +use Drupal\admin_toolbar_tools\SearchLinks; use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Controller\ControllerBase; @@ -12,9 +13,10 @@ use Drupal\Core\Menu\MenuLinkManagerInterface; use Drupal\Core\Plugin\CachedDiscoveryClearerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RequestStack; -use Drupal\Core\PhpStorage\PhpStorageFactory; +use Drupal\Core\Template\TwigEnvironment; /** * Class ToolbarController. @@ -86,6 +88,27 @@ class ToolbarController extends ControllerBase { */ protected $pluginCacheClearer; + /** + * The cache menu instance. + * + * @var \Drupal\Core\Cache\CacheBackendInterface + */ + protected $cacheMenu; + + /** + * A TwigEnvironment instance. + * + * @var \Drupal\Core\Template\TwigEnvironment + */ + protected $twig; + + /** + * The search links service. + * + * @var \Drupal\admin_toolbar_tools\SearchLinks + */ + protected $links; + /** * Constructs a ToolbarController object. * @@ -107,6 +130,12 @@ class ToolbarController extends ControllerBase { * A request stack symfony instance. * @param \Drupal\Core\Plugin\CachedDiscoveryClearerInterface $plugin_cache_clearer * A plugin cache clear instance. + * @param \Drupal\Core\Cache\CacheBackendInterface $cache_menu + * A cache menu instance. + * @param \Drupal\Core\Template\TwigEnvironment $twig + * A TwigEnvironment instance. + * @param \Drupal\admin_toolbar_tools\SearchLinks $links + * The search links service. */ public function __construct(CronInterface $cron, MenuLinkManagerInterface $menuLinkManager, @@ -116,7 +145,10 @@ public function __construct(CronInterface $cron, CacheBackendInterface $cacheRender, TimeInterface $time, RequestStack $request_stack, - CachedDiscoveryClearerInterface $plugin_cache_clearer) { + CachedDiscoveryClearerInterface $plugin_cache_clearer, + CacheBackendInterface $cache_menu, + TwigEnvironment $twig, + SearchLinks $links) { $this->cron = $cron; $this->menuLinkManager = $menuLinkManager; $this->contextualLinkManager = $contextualLinkManager; @@ -126,6 +158,9 @@ public function __construct(CronInterface $cron, $this->time = $time; $this->requestStack = $request_stack; $this->pluginCacheClearer = $plugin_cache_clearer; + $this->cacheMenu = $cache_menu; + $this->twig = $twig; + $this->links = $links; } /** @@ -141,7 +176,10 @@ public static function create(ContainerInterface $container) { $container->get('cache.render'), $container->get('datetime.time'), $container->get('request_stack'), - $container->get('plugin.cache_clearer') + $container->get('plugin.cache_clearer'), + $container->get('cache.menu'), + $container->get('twig'), + $container->get('admin_toolbar_tools.search_links') ); } @@ -199,7 +237,7 @@ public function flushStatic() { * Clears all cached menu data. */ public function flushMenu() { - menu_cache_clear_all(); + $this->cacheMenu->invalidateAll(); $this->menuLinkManager->rebuild(); $this->contextualLinkManager->clearCachedDefinitions(); $this->localTaskLinkManager->clearCachedDefinitions(); @@ -221,9 +259,7 @@ public function flushViews() { * Clears the twig cache. */ public function flushTwig() { - // @todo Update once Drupal 8.6 will be released. - // @see https://www.drupal.org/node/2908461 - PhpStorageFactory::get('twig')->deleteAll(); + $this->twig->invalidate(); $this->messenger()->addMessage($this->t('Twig cache cleared.')); return new RedirectResponse($this->reloadPage()); } @@ -246,4 +282,11 @@ public function cacheRender() { return new RedirectResponse($this->reloadPage()); } + /** + * Return additional search links. + */ + public function search() { + return new JsonResponse($this->links->getLinks()); + } + } diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php b/web/modules/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php new file mode 100755 index 0000000000..c667b6b38b --- /dev/null +++ b/web/modules/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php @@ -0,0 +1,641 @@ +<?php + +namespace Drupal\admin_toolbar_tools\Plugin\Derivative; + +use Drupal\Component\Plugin\Derivative\DeriverBase; +use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Extension\ThemeHandlerInterface; +use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; +use Drupal\Core\Routing\RouteProviderInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\system\Entity\Menu; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Provides a default implementation for menu link plugins. + */ +class ExtraLinks extends DeriverBase implements ContainerDeriverInterface { + + use StringTranslationTrait; + + const MAX_BUNDLE_NUMBER = 10; + + /** + * The entity type manager. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + + /** + * The module handler. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** + * The route provider. + * + * @var \Drupal\Core\Routing\RouteProviderInterface + */ + protected $routeProvider; + + /** + * The theme handler. + * + * @var \Drupal\Core\Extension\ThemeHandlerInterface + */ + protected $themeHandler; + + /** + * {@inheritdoc} + */ + public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, ThemeHandlerInterface $theme_handler) { + $this->entityTypeManager = $entity_type_manager; + $this->moduleHandler = $module_handler; + $this->routeProvider = $route_provider; + $this->themeHandler = $theme_handler; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, $base_plugin_id) { + return new static( + $base_plugin_id, + $container->get('entity_type.manager'), + $container->get('module_handler'), + $container->get('router.route_provider'), + $container->get('theme_handler') + ); + } + + /** + * {@inheritdoc} + */ + public function getDerivativeDefinitions($base_plugin_definition) { + $links = []; + $entity_types = $this->entityTypeManager->getDefinitions(); + $content_entities = []; + foreach ($entity_types as $key => $entity_type) { + if ($entity_type->getBundleEntityType() && ($entity_type->get('field_ui_base_route') != '')) { + $content_entities[$key] = [ + 'content_entity' => $key, + 'content_entity_bundle' => $entity_type->getBundleEntityType(), + ]; + } + } + + // Adds common links to entities. + foreach ($content_entities as $entities) { + $content_entity_bundle = $entities['content_entity_bundle']; + $content_entity = $entities['content_entity']; + // We do not display more than 10 different bundles per entity type. + $content_entity_bundle_storage = $this->entityTypeManager->getStorage($content_entity_bundle); + $bundles_ids = $content_entity_bundle_storage->getQuery()->pager(self::MAX_BUNDLE_NUMBER)->execute(); + $bundles = $this->entityTypeManager->getStorage($content_entity_bundle)->loadMultiple($bundles_ids); + if (count($bundles) == self::MAX_BUNDLE_NUMBER) { + $links[$content_entity_bundle . '.collection'] = [ + 'title' => $this->t('All types'), + 'route_name' => 'entity.' . $content_entity_bundle . '.collection', + 'parent' => 'entity.' . $content_entity_bundle . '.collection', + 'weight' => -1, + ] + $base_plugin_definition; + } + foreach ($bundles as $machine_name => $bundle) { + // Normally, the edit form for the bundle would be its root link. + $content_entity_bundle_root = NULL; + if ($this->routeExists('entity.' . $content_entity_bundle . '.overview_form')) { + // Some bundles have an overview/list form that make a better root + // link. + $content_entity_bundle_root = 'entity.' . $content_entity_bundle . '.overview_form.' . $machine_name; + $links[$content_entity_bundle_root] = [ + 'title' => $this->t($bundle->label()), + 'route_name' => 'entity.' . $content_entity_bundle . '.overview_form', + 'parent' => 'entity.' . $content_entity_bundle . '.collection', + 'route_parameters' => [$content_entity_bundle => $machine_name], + ] + $base_plugin_definition; + } + if ($this->routeExists('entity.' . $content_entity_bundle . '.edit_form')) { + $key = 'entity.' . $content_entity_bundle . '.edit_form.' . $machine_name; + $links[$key] = [ + 'title' => $this->t($bundle->label()), + 'route_name' => 'entity.' . $content_entity_bundle . '.edit_form', + 'parent' => 'entity.' . $content_entity_bundle . '.collection', + 'route_parameters' => [$content_entity_bundle => $machine_name], + ] + $base_plugin_definition; + if (empty($content_entity_bundle_root)) { + $content_entity_bundle_root = $key; + } + else { + $links[$key]['parent'] = $content_entity_bundle_root; + $links[$key]['title'] = t('Edit'); + } + } + if ($this->moduleHandler->moduleExists('field_ui')) { + if ($this->routeExists('entity.' . $content_entity . '.field_ui_fields')) { + $links['entity.' . $content_entity . '.field_ui_fields' . $machine_name] = [ + 'title' => $this->t('Manage fields'), + 'route_name' => 'entity.' . $content_entity . '.field_ui_fields', + 'parent' => $base_plugin_definition['id'] . ':' . $content_entity_bundle_root, + 'route_parameters' => [$content_entity_bundle => $machine_name], + 'weight' => 1, + ] + $base_plugin_definition; + } + if ($this->routeExists('entity.entity_form_display.' . $content_entity . '.default')) { + $links['entity.entity_form_display.' . $content_entity . '.default' . $machine_name] = [ + 'title' => $this->t('Manage form display'), + 'route_name' => 'entity.entity_form_display.' . $content_entity . '.default', + 'parent' => $base_plugin_definition['id'] . ':' . $content_entity_bundle_root, + 'route_parameters' => [$content_entity_bundle => $machine_name], + 'weight' => 2, + ] + $base_plugin_definition; + } + if ($this->routeExists('entity.entity_view_display.' . $content_entity . '.default')) { + $links['entity.entity_view_display.' . $content_entity . '.default.' . $machine_name] = [ + 'title' => $this->t('Manage display'), + 'route_name' => 'entity.entity_view_display.' . $content_entity . '.default', + 'parent' => $base_plugin_definition['id'] . ':' . $content_entity_bundle_root, + 'route_parameters' => [$content_entity_bundle => $machine_name], + 'weight' => 3, + ] + $base_plugin_definition; + } + } + if ($this->moduleHandler->moduleExists('devel') && $this->routeExists('entity.' . $content_entity_bundle . '.devel_load')) { + $links['entity.' . $content_entity_bundle . '.devel_load.' . $machine_name] = [ + 'title' => $this->t('Devel'), + 'route_name' => 'entity.' . $content_entity_bundle . '.devel_load', + 'parent' => $base_plugin_definition['id'] . ':' . $content_entity_bundle_root, + 'route_parameters' => [$content_entity_bundle => $machine_name], + 'weight' => 4, + ] + $base_plugin_definition; + } + if ($this->routeExists('entity.' . $content_entity_bundle . '.delete_form')) { + $links['entity.' . $content_entity_bundle . '.delete_form.' . $machine_name] = [ + 'title' => $this->t('Delete'), + 'route_name' => 'entity.' . $content_entity_bundle . '.delete_form', + 'parent' => $base_plugin_definition['id'] . ':' . $content_entity_bundle_root, + 'route_parameters' => [$content_entity_bundle => $machine_name], + 'weight' => 5, + ] + $base_plugin_definition; + } + } + } + + // Adds user links. + $links['user.admin_create'] = [ + 'title' => $this->t('Add user'), + 'route_name' => 'user.admin_create', + 'parent' => 'entity.user.collection', + ] + $base_plugin_definition; + $links['user.admin_permissions'] = [ + 'title' => t('Permissions'), + 'route_name' => 'user.admin_permissions', + 'parent' => 'entity.user.collection', + ] + $base_plugin_definition; + $links['entity.user_role.collection'] = [ + 'title' => t('Roles'), + 'route_name' => 'entity.user_role.collection', + 'parent' => 'entity.user.collection', + ] + $base_plugin_definition; + $links['user.logout'] = [ + 'title' => t('Logout'), + 'route_name' => 'user.logout', + 'parent' => 'admin_toolbar_tools.help', + 'weight' => 10, + ] + $base_plugin_definition; + $links['user.role_add'] = [ + 'title' => t('Add role'), + 'route_name' => 'user.role_add', + 'parent' => $base_plugin_definition['id'] . ':entity.user_role.collection', + 'weight' => -5, + ] + $base_plugin_definition; + // Adds sub-links to Account settings link. + if ($this->moduleHandler->moduleExists('field_ui')) { + $links['entity.user.field_ui_fields_'] = [ + 'title' => $this->t('Manage fields'), + 'route_name' => 'entity.user.field_ui_fields', + 'parent' => 'entity.user.admin_form', + 'weight' => 1, + ] + $base_plugin_definition; + $links['entity.entity_form_display.user.default_'] = [ + 'title' => $this->t('Manage form display'), + 'route_name' => 'entity.entity_form_display.user.default', + 'parent' => 'entity.user.admin_form', + 'weight' => 2, + ] + $base_plugin_definition; + $links['entity.entity_view_display.user.default_'] = [ + 'title' => $this->t('Manage display'), + 'route_name' => 'entity.entity_view_display.user.default', + 'parent' => 'entity.user.admin_form', + 'weight' => 3, + ] + $base_plugin_definition; + } + + foreach ($this->entityTypeManager->getStorage('user_role')->loadMultiple() as $role) { + $links['entity.user_role.edit_form.' . $role->id()] = [ + 'title' => $this->t('@label', ['@label' => $role->label()]), + 'route_name' => 'entity.user_role.edit_form', + 'parent' => $base_plugin_definition['id'] . ':entity.user_role.collection', + 'route_parameters' => ['user_role' => $role->id()], + ] + $base_plugin_definition; + $links['entity.user_role.edit_permissions_form.' . $role->id()] = [ + 'title' => $this->t('Edit permissions'), + 'route_name' => 'entity.user_role.edit_permissions_form', + 'parent' => $base_plugin_definition['id'] . ':entity.user_role.edit_form.' . $role->id(), + 'route_parameters' => ['user_role' => $role->id()], + ] + $base_plugin_definition; + if ($role->id() != 'anonymous' && $role->id() != 'authenticated') { + $links['entity.user_role.delete_form.' . $role->id()] = [ + 'title' => $this->t('Delete'), + 'route_name' => 'entity.user_role.delete_form', + 'parent' => $base_plugin_definition['id'] . ':entity.user_role.edit_form.' . $role->id(), + 'route_parameters' => ['user_role' => $role->id()], + ] + $base_plugin_definition; + } + if ($this->moduleHandler->moduleExists('devel')) { + $links['entity.user_role.devel_load.' . $role->id()] = [ + 'title' => $this->t('Devel'), + 'route_name' => 'entity.user_role.devel_load', + 'parent' => $base_plugin_definition['id'] . ':entity.user_role.edit_form.' . $role->id(), + 'route_parameters' => ['user_role' => $role->id()], + ] + $base_plugin_definition; + } + } + + if ($this->moduleHandler->moduleExists('node')) { + $links['node.type_add'] = [ + 'title' => $this->t('Add content type'), + 'route_name' => 'node.type_add', + 'parent' => 'entity.node_type.collection', + 'weight' => -2, + ] + $base_plugin_definition; + $links['node.add'] = [ + 'title' => $this->t('Add content'), + 'route_name' => 'node.add_page', + 'parent' => 'system.admin_content', + ] + $base_plugin_definition; + // Adds node links for each content type. + foreach ($this->entityTypeManager->getStorage('node_type')->loadMultiple() as $type) { + $links['node.add.' . $type->id()] = [ + 'title' => $this->t($type->label()), + 'route_name' => 'node.add', + 'parent' => $base_plugin_definition['id'] . ':node.add', + 'route_parameters' => ['node_type' => $type->id()], + ] + $base_plugin_definition; + } + } + + if ($this->moduleHandler->moduleExists('field_ui')) { + $links['field_ui.entity_form_mode_add'] = [ + 'title' => $this->t('Add form mode'), + 'route_name' => 'field_ui.entity_form_mode_add', + 'parent' => 'entity.entity_form_mode.collection', + ] + $base_plugin_definition; + $links['field_ui.entity_view_mode_add'] = [ + 'title' => $this->t('Add view mode'), + 'route_name' => 'field_ui.entity_view_mode_add', + 'parent' => 'entity.entity_view_mode.collection', + ] + $base_plugin_definition; + } + + if ($this->moduleHandler->moduleExists('taxonomy')) { + $links['entity.taxonomy_vocabulary.add_form'] = [ + 'title' => $this->t('Add vocabulary'), + 'route_name' => 'entity.taxonomy_vocabulary.add_form', + 'parent' => 'entity.taxonomy_vocabulary.collection', + 'weight' => -5, + ] + $base_plugin_definition; + } + + if ($this->moduleHandler->moduleExists('menu_ui')) { + $links['entity.menu.add_form'] = [ + 'title' => $this->t('Add menu'), + 'route_name' => 'entity.menu.add_form', + 'parent' => 'entity.menu.collection', + 'weight' => -2, + ] + $base_plugin_definition; + // Adds links to /admin/structure/menu. + // We do not display more than 10 different menus. + $menus = $this->entityTypeManager->getStorage('menu')->loadMultiple(); + uasort($menus, [Menu::class, 'sort']); + $menus = array_slice($menus, 0, self::MAX_BUNDLE_NUMBER); + if (count($menus) == self::MAX_BUNDLE_NUMBER) { + $links['entity.menu.collection'] = [ + 'title' => $this->t('All menus'), + 'route_name' => 'entity.menu.collection', + 'parent' => 'entity.menu.collection', + 'weight' => -1, + ] + $base_plugin_definition; + } + $weight = 0; + foreach ($menus as $menu_id => $menu) { + $links['entity.menu.edit_form.' . $menu_id] = [ + 'title' => $menu->label(), + 'route_name' => 'entity.menu.edit_form', + 'parent' => 'entity.menu.collection', + 'route_parameters' => ['menu' => $menu_id], + 'weight' => $weight, + ] + $base_plugin_definition; + $links['entity.menu.add_link_form.' . $menu_id] = [ + 'title' => $this->t('Add link'), + 'route_name' => 'entity.menu.add_link_form', + 'parent' => $base_plugin_definition['id'] . ':entity.menu.edit_form.' . $menu_id, + 'route_parameters' => ['menu' => $menu_id], + ] + $base_plugin_definition; + // Un-deletable menus. + $menus = ['admin', 'devel', 'footer', 'main', 'tools', 'account']; + if (!in_array($menu_id, $menus)) { + $links['entity.menu.delete_form.' . $menu_id] = [ + 'title' => $this->t('Delete'), + 'route_name' => 'entity.menu.delete_form', + 'parent' => $base_plugin_definition['id'] . ':entity.menu.edit_form.' . $menu_id, + 'route_parameters' => ['menu' => $menu_id], + ] + $base_plugin_definition; + } + if ($this->moduleHandler->moduleExists('devel') && $this->routeExists('entity.menu.devel_load')) { + $links['entity.menu.devel_load.' . $menu_id] = [ + 'title' => $this->t('Devel'), + 'route_name' => 'entity.menu.devel_load', + 'parent' => $base_plugin_definition['id'] . ':entity.menu.edit_form.' . $menu_id, + 'route_parameters' => ['menu' => $menu_id], + ] + $base_plugin_definition; + } + $weight++; + } + } + + // If module block_content is enabled. + if ($this->moduleHandler->moduleExists('block_content')) { + $links['block_content.add_page'] = [ + 'title' => $this->t('Add custom block'), + 'route_name' => 'block_content.add_page', + 'parent' => 'block.admin_display', + ] + $base_plugin_definition; + $links['entity.block_content.collection'] = [ + 'title' => $this->t('Custom block library'), + 'route_name' => 'entity.block_content.collection', + 'parent' => 'block.admin_display', + ] + $base_plugin_definition; + $links['entity.block_content_type.collection'] = [ + 'title' => $this->t('Block types'), + 'route_name' => 'entity.block_content_type.collection', + 'parent' => 'block.admin_display', + ] + $base_plugin_definition; + } + + // If module Contact is enabled. + if ($this->moduleHandler->moduleExists('contact')) { + $links['contact.form_add'] = [ + 'title' => $this->t('Add contact form'), + 'route_name' => 'contact.form_add', + 'parent' => 'entity.contact_form.collection', + 'weight' => -5, + ] + $base_plugin_definition; + } + + // If module Update Manager is enabled. + if ($this->moduleHandler->moduleExists('update')) { + $links['update.module_install'] = [ + 'title' => $this->t('Install new module'), + 'route_name' => 'update.module_install', + 'parent' => 'system.modules_list', + ] + $base_plugin_definition; + $links['update.module_update'] = [ + 'title' => $this->t('Update'), + 'route_name' => 'update.module_update', + 'parent' => 'system.modules_list', + ] + $base_plugin_definition; + $links['update.theme_install'] = [ + 'title' => $this->t('Install new theme'), + 'route_name' => 'update.theme_install', + 'parent' => 'system.themes_page', + ] + $base_plugin_definition; + $links['update.theme_update'] = [ + 'title' => $this->t('Update'), + 'route_name' => 'update.theme_update', + 'parent' => 'system.themes_page', + ] + $base_plugin_definition; + } + + // If module Devel is enabled. + if ($this->moduleHandler->moduleExists('devel')) { + $links['devel'] = [ + 'title' => $this->t('Development'), + 'route_name' => 'system.admin_config_development', + 'parent' => 'admin_toolbar_tools.help', + 'weight' => '-8', + ] + $base_plugin_definition; + $links['devel.admin_settings'] = [ + 'title' => $this->t('Devel settings'), + 'route_name' => 'devel.admin_settings', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + $links['devel.configs_list'] = [ + 'title' => $this->t('Config editor'), + 'route_name' => 'devel.configs_list', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + $links['devel.reinstall'] = [ + 'title' => $this->t('Reinstall modules'), + 'route_name' => 'devel.reinstall', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + $links['devel.menu_rebuild'] = [ + 'title' => $this->t('Rebuild menu'), + 'route_name' => 'devel.menu_rebuild', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + $links['devel.state_system_page'] = [ + 'title' => $this->t('State editor'), + 'route_name' => 'devel.state_system_page', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + $links['devel.theme_registry'] = [ + 'title' => $this->t('Theme registry'), + 'route_name' => 'devel.theme_registry', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + $links['devel.entity_info_page'] = [ + 'title' => $this->t('Entity info'), + 'route_name' => 'devel.entity_info_page', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + $links['devel.session'] = [ + 'title' => $this->t('Session viewer'), + 'route_name' => 'devel.session', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + $links['devel.element_info'] = [ + 'title' => $this->t('Element Info'), + 'route_name' => 'devel.elements_page', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + // Menu link for the Toolbar module. + $links['devel.toolbar.settings'] = [ + 'title' => $this->t('Devel Toolbar Settings'), + 'route_name' => 'devel.toolbar.settings_form', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + if ($this->moduleHandler->moduleExists('webprofiler')) { + $links['devel.webprofiler'] = [ + 'title' => $this->t('Webprofiler settings'), + 'route_name' => 'webprofiler.settings', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + } + // If module Devel PHP is enabled. + if ($this->moduleHandler->moduleExists('devel_php') && $this->routeExists('devel_php.execute_php')) { + $links['devel.devel_php.execute_php'] = [ + 'title' => $this->t('Execute PHP Code'), + 'route_name' => 'devel_php.execute_php', + 'parent' => $base_plugin_definition['id'] . ':devel', + ] + $base_plugin_definition; + } + } + + // If module Views Ui enabled. + if ($this->moduleHandler->moduleExists('views_ui')) { + $links['views_ui.add'] = [ + 'title' => $this->t('Add view'), + 'route_name' => 'views_ui.add', + 'parent' => 'entity.view.collection', + 'weight' => -5, + ] + $base_plugin_definition; + $links['views_ui.field_list'] = [ + 'title' => $this->t('Used in views'), + 'route_name' => 'views_ui.reports_fields', + 'parent' => 'entity.field_storage_config.collection', + ] + $base_plugin_definition; + } + + // Adds theme management links. + $links['system.theme_settings'] = [ + 'title' => $this->t('Settings'), + 'route_name' => 'system.theme_settings', + 'parent' => 'system.themes_page', + ] + $base_plugin_definition; + $installed_themes = $this->installedThemes(); + foreach ($installed_themes as $key_theme => $label_theme) { + $links['system.theme_settings_theme.' . $key_theme] = [ + 'title' => $label_theme, + 'route_name' => 'system.theme_settings_theme', + 'parent' => $base_plugin_definition['id'] . ':system.theme_settings', + 'route_parameters' => ['theme' => $key_theme], + ] + $base_plugin_definition; + } + + // If module Language enabled. + if ($this->moduleHandler->moduleExists('language')) { + $links['language.negotiation'] = [ + 'title' => $this->t('Detection and selection'), + 'route_name' => 'language.negotiation', + 'parent' => 'entity.configurable_language.collection', + ] + $base_plugin_definition; + $links['language.add'] = [ + 'title' => $this->t('Add language'), + 'route_name' => 'language.add', + 'parent' => 'entity.configurable_language.collection', + ] + $base_plugin_definition; + } + + // If module Media enabled. + if ($this->moduleHandler->moduleExists('media')) { + $links['media.type_add'] = [ + 'title' => $this->t('Add media type'), + 'route_name' => 'entity.media_type.add_form', + 'parent' => 'entity.media_type.collection', + 'weight' => -2, + ] + $base_plugin_definition; + // Displays media link in toolbar. + $links['media_page'] = [ + 'title' => $this->t('Media'), + 'route_name' => 'entity.media.collection', + 'parent' => 'system.admin_content', + ] + $base_plugin_definition; + $links['add_media'] = [ + 'title' => $this->t('Add media'), + 'route_name' => 'entity.media.add_page', + 'parent' => $base_plugin_definition['id'] . ':media_page', + ] + $base_plugin_definition; + // Adds links for each media type. + foreach ($this->entityTypeManager->getStorage('media_type')->loadMultiple() as $type) { + $links['media.add.' . $type->id()] = [ + 'title' => $type->label(), + 'route_name' => 'entity.media.add_form', + 'parent' => $base_plugin_definition['id'] . ':add_media', + 'route_parameters' => ['media_type' => $type->id()], + ] + $base_plugin_definition; + } + } + + // If module Config enabled. + if ($this->moduleHandler->moduleExists('config')) { + $links['config.import'] = [ + 'title' => $this->t('Import'), + 'route_name' => 'config.import_full', + 'parent' => 'config.sync', + 'weight' => 1, + ] + $base_plugin_definition; + $links['config.export'] = [ + 'title' => $this->t('Export'), + 'route_name' => 'config.export_full', + 'parent' => 'config.sync', + 'weight' => 2, + ] + $base_plugin_definition; + } + + // Adds a menu link to clear Views cache. + if ($this->moduleHandler->moduleExists('views')) { + $links['flush_views'] = [ + 'title' => $this->t('Flush views cache'), + 'route_name' => 'admin_toolbar_tools.flush_views', + 'parent' => 'admin_toolbar_tools.flush', + ] + $base_plugin_definition; + // Adding a menu link to Files. + if ($this->moduleHandler->moduleExists('file') && $this->routeExists('view.files.page_1')) { + $links['view.files'] = [ + 'title' => $this->t('Files'), + 'route_name' => 'view.files.page_1', + 'parent' => 'system.admin_content', + ] + $base_plugin_definition; + } + } + + return $links; + } + + /** + * Determine if a route exists by name. + * + * @param string $route_name + * The name of the route to check. + * + * @return bool + * Whether a route with that route name exists. + */ + public function routeExists($route_name) { + return (count($this->routeProvider->getRoutesByNames([$route_name])) === 1); + } + + /** + * Lists all installed themes. + * + * @return array + * The list of installed themes. + */ + public function installedThemes() { + $themeHandler = $this->themeHandler; + $all_themes = $themeHandler->listInfo(); + $themes_installed = []; + foreach ($all_themes as $key_theme => $theme) { + if ($themeHandler->hasUi($key_theme)) { + $themes_installed[$key_theme] = $themeHandler->getName($key_theme); + } + } + return $themes_installed; + } + +} diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/src/SearchLinks.php b/web/modules/admin_toolbar/admin_toolbar_tools/src/SearchLinks.php new file mode 100644 index 0000000000..703edbee53 --- /dev/null +++ b/web/modules/admin_toolbar/admin_toolbar_tools/src/SearchLinks.php @@ -0,0 +1,287 @@ +<?php + +namespace Drupal\admin_toolbar_tools; + +use Drupal\admin_toolbar_tools\Plugin\Derivative\ExtraLinks; +use Drupal\Core\Cache\Cache; +use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Cache\Context\CacheContextsManager; +use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Language\LanguageInterface; +use Drupal\Core\Routing\RouteProviderInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Core\Url; +use Drupal\system\Entity\Menu; + +/** + * Extra search links. + */ +class SearchLinks { + + use StringTranslationTrait; + + /** + * The entity type manager. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + + /** + * The module handler. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** + * The route provider. + * + * @var \Drupal\Core\Routing\RouteProviderInterface + */ + protected $routeProvider; + + /** + * The cache context manager service. + * + * @var \Drupal\Core\Cache\Context\CacheContextsManager + */ + protected $cacheContextManager; + + /** + * The toolbar cache bin. + * + * @var \Drupal\Core\Cache\CacheBackendInterface + */ + protected $toolbarCache; + + /** + * {@inheritdoc} + */ + public function __construct(EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, CacheContextsManager $cache_context_manager, CacheBackendInterface $toolbar_cache) { + $this->entityTypeManager = $entity_type_manager; + $this->moduleHandler = $module_handler; + $this->routeProvider = $route_provider; + $this->cacheContextManager = $cache_context_manager; + $this->toolbarCache = $toolbar_cache; + } + + /** + * Get extra links for admin toolbar search feature. + * + * @return array + * An array of link data. + * + * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException + * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException + */ + public function getLinks() { + $additional_keys = $this->cacheContextManager->convertTokensToKeys([ + 'languages:' . LanguageInterface::TYPE_INTERFACE, + 'user.permissions', + ])->getKeys(); + $cid_parts = array_merge(['admin_toolbar_search:links'], $additional_keys); + $cid = implode(':', $cid_parts); + + if ($cache = $this->toolbarCache->get($cid)) { + return $cache->data; + } + + $links = []; + $cache_tags = []; + $content_entities = $this->getBundleableEntitiesList(); + + // Adds common links to entities. + foreach ($content_entities as $entities) { + $content_entity_bundle = $entities['content_entity_bundle']; + $content_entity = $entities['content_entity']; + // Start at offset 10, since the toolbar has already loaded the first 10. + $content_entity_bundle_storage = $this->entityTypeManager->getStorage($content_entity_bundle); + $bundles_ids = $content_entity_bundle_storage->getQuery()->range(ExtraLinks::MAX_BUNDLE_NUMBER)->execute(); + if (!empty($bundles_ids)) { + $bundles = $this->entityTypeManager + ->getStorage($content_entity_bundle) + ->loadMultiple($bundles_ids); + foreach ($bundles as $machine_name => $bundle) { + $cache_tags = Cache::mergeTags($cache_tags, $bundle->getEntityType()->getListCacheTags()); + $tparams = [ + '@entity_type' => $bundle->getEntityType()->getLabel(), + '@bundle' => $bundle->label(), + ]; + $label_base = $this->t('@entity_type > @bundle', $tparams); + $params = [$content_entity_bundle => $machine_name]; + if ($this->routeExists('entity.' . $content_entity_bundle . '.overview_form')) { + // Some bundles have an overview/list form that make a better root + // link. + $url = Url::fromRoute('entity.' . $content_entity_bundle . '.overview_form', $params); + $url_string = $url->toString(); + $links[] = [ + 'labelRaw' => $label_base, + 'value' => $url_string, + ]; + } + if ($this->routeExists('entity.' . $content_entity_bundle . '.edit_form')) { + $url = Url::fromRoute('entity.' . $content_entity_bundle . '.edit_form', $params); + $url_string = $url->toString(); + $links[] = [ + 'labelRaw' => $label_base . ' > ' . $this->t('Edit'), + 'value' => $url_string, + ]; + } + if ($this->moduleHandler->moduleExists('field_ui')) { + if ($this->routeExists('entity.' . $content_entity . '.field_ui_fields')) { + $url = Url::fromRoute('entity.' . $content_entity . '.field_ui_fields', $params); + $url_string = $url->toString(); + $links[] = [ + 'labelRaw' => $label_base . ' > ' . $this->t('Manage fields'), + 'value' => $url_string, + ]; + } + + if ($this->routeExists('entity.entity_form_display.' . $content_entity . '.default')) { + $url = Url::fromRoute('entity.entity_form_display.' . $content_entity . '.default', $params); + $url_string = $url->toString(); + $links[] = [ + 'labelRaw' => $label_base . ' > ' . $this->t('Manage form display'), + 'value' => $url_string, + ]; + + } + if ($this->routeExists('entity.entity_view_display.' . $content_entity . '.default')) { + $url = Url::fromRoute('entity.entity_view_display.' . $content_entity . '.default', $params); + $url_string = $url->toString(); + $links[] = [ + 'labelRaw' => $label_base . ' > ' . $this->t('Manage display'), + 'value' => $url_string, + ]; + } + if ($this->moduleHandler->moduleExists('devel') && $this->routeExists('entity.' . $content_entity_bundle . '.devel_load')) { + $url = Url::fromRoute($route_name = 'entity.' . $content_entity_bundle . '.devel_load', $params); + $url_string = $url->toString(); + $links[] = [ + 'labelRaw' => $label_base . ' > ' . $this->t('Devel'), + 'value' => $url_string, + ]; + } + if ($this->routeExists('entity.' . $content_entity_bundle . '.delete_form')) { + $url = Url::fromRoute('entity.' . $content_entity_bundle . '.delete_form', $params); + $url_string = $url->toString(); + $links[] = [ + 'labelRaw' => $label_base . ' > ' . $this->t('Delete'), + 'value' => $url_string, + ]; + } + } + } + } + } + + // Add menu links. + if ($this->moduleHandler->moduleExists('menu_ui')) { + + $menus = $this->entityTypeManager->getStorage('menu')->loadMultiple(); + uasort($menus, [Menu::class, 'sort']); + $menus = array_slice($menus, ExtraLinks::MAX_BUNDLE_NUMBER); + + $cache_tags = Cache::mergeTags($cache_tags, ['config:menu_list']); + foreach ($menus as $menu_id => $menu) { + $route_name = 'entity.menu.edit_form'; + $params = ['menu' => $menu_id]; + $url = Url::fromRoute($route_name, $params); + $url_string = $url->toString(); + + $links[] = [ + 'labelRaw' => $this->t('Menus') . ' > ' . $menu->label(), + 'value' => $url_string, + ]; + + $route_name = 'entity.menu.add_link_form'; + $params = ['menu' => $menu_id]; + $url = Url::fromRoute($route_name, $params); + $url_string = $url->toString(); + + $links[] = [ + 'labelRaw' => $this->t('Menus') . ' > ' . $menu->label() . ' > ' . $this->t('Add link'), + 'value' => $url_string, + ]; + + $menus = ['admin', 'devel', 'footer', 'main', 'tools', 'account']; + if (!in_array($menu_id, $menus)) { + + $route_name = 'entity.menu.delete_form'; + $params = ['menu' => $menu_id]; + $url = Url::fromRoute($route_name, $params); + $url_string = $url->toString(); + + $links[] = [ + 'labelRaw' => $this->t('Menus') . ' > ' . $menu->label() . ' > ' . $this->t('Delete'), + 'value' => $url_string, + ]; + } + if ($this->moduleHandler->moduleExists('devel') && $this->routeExists('entity.menu.devel_load')) { + $route_name = 'entity.menu.devel_load'; + $params = ['menu' => $menu_id]; + $url = Url::fromRoute($route_name, $params); + $url_string = $url->toString(); + + $links[] = [ + 'labelRaw' => $this->t('Menus') . ' > ' . $menu->label() . ' > ' . $this->t('Devel'), + 'value' => $url_string, + ]; + } + } + } + + $this->toolbarCache->set($cid, $links, Cache::PERMANENT, $cache_tags); + + return $links; + } + + /** + * Get a list of content entities. + * + * @return array + * An array of metadata about content entities. + */ + protected function getBundleableEntitiesList() { + $entity_types = $this->entityTypeManager->getDefinitions(); + $content_entities = []; + foreach ($entity_types as $key => $entity_type) { + if ($entity_type->getBundleEntityType() && ($entity_type->get('field_ui_base_route') != '')) { + $content_entities[$key] = [ + 'content_entity' => $key, + 'content_entity_bundle' => $entity_type->getBundleEntityType(), + ]; + } + } + return $content_entities; + } + + /** + * Get an array of entity types that should trigger a menu rebuild. + * + * @return array + * An array of entity machine names. + */ + public function getRebuildEntityTypes() { + $types = ['menu']; + $content_entities = $this->getBundleableEntitiesList(); + $types = array_merge($types, array_column($content_entities, 'content_entity_bundle')); + return $types; + } + + /** + * Determine if a route exists by name. + * + * @param string $route_name + * The name of the route to check. + * + * @return bool + * Whether a route with that route name exists. + */ + public function routeExists($route_name) { + return (count($this->routeProvider->getRoutesByNames([$route_name])) === 1); + } + +} diff --git a/web/modules/admin_toolbar/admin_toolbar_tools/tests/src/Functional/AdminToolbarToolsAlterTest.php b/web/modules/admin_toolbar/admin_toolbar_tools/tests/src/Functional/AdminToolbarToolsAlterTest.php old mode 100644 new mode 100755 index f61329c637..94c27cd59e --- a/web/modules/admin_toolbar/admin_toolbar_tools/tests/src/Functional/AdminToolbarToolsAlterTest.php +++ b/web/modules/admin_toolbar/admin_toolbar_tools/tests/src/Functional/AdminToolbarToolsAlterTest.php @@ -48,7 +48,7 @@ protected function setUp() { */ public function testAdminToolbarTools() { // Assert that special menu items are present in the HTML. - $this->assertRaw('class="toolbar-icon toolbar-icon-admin-toolbar-tools-flush"'); + $this->assertSession()->responseContains('class="toolbar-icon toolbar-icon-admin-toolbar-tools-flush"'); } } diff --git a/web/modules/admin_toolbar/composer.json b/web/modules/admin_toolbar/composer.json old mode 100644 new mode 100755 diff --git a/web/modules/admin_toolbar/css/admin.toolbar.css b/web/modules/admin_toolbar/css/admin.toolbar.css old mode 100644 new mode 100755 index d848b90ef3..a04575263a --- a/web/modules/admin_toolbar/css/admin.toolbar.css +++ b/web/modules/admin_toolbar/css/admin.toolbar.css @@ -104,6 +104,13 @@ display: block; } +.toolbar-menu .menu-item > span { + padding: 1em 1.3333em; + display: block; + color: #434343; + cursor: pointer; +} + [dir="rtl"] .toolbar-tray-horizontal .menu-item:hover { background: #fff; } diff --git a/web/modules/admin_toolbar/css/admin.toolbar_search.css b/web/modules/admin_toolbar/css/admin.toolbar_search.css new file mode 100755 index 0000000000..bd99553855 --- /dev/null +++ b/web/modules/admin_toolbar/css/admin.toolbar_search.css @@ -0,0 +1,33 @@ +#toolbar-item-administration-search-tray { + padding-left: 1em; +} + +#admin-toolbar-search-tab .toolbar-item:before { + background-image: url('../misc/icons/bebebe/loupe.svg'); +} + +#admin-toolbar-search-tab .toolbar-item:active:before, +#admin-toolbar-search-tab .toolbar-item.is-active:before { + background-image: url('../misc/icons/ffffff/loupe.svg'); +} + +#toolbar-item-administration-search-tray label { + display: inline-block; + color: #000000; + margin-right: .5em; + font-weight: bold; +} + +#toolbar-item-administration-search-tray div.form-item { + margin: 0.75em 0; +} + +#toolbar-item-administration-search-tray input { + display: inline-block; + padding: 0.3em 0.4em 0.3em 0.5em; + font-size: 1em; +} + +.ui-autocomplete .ui-menu-item span.admin-toolbar-search-url { + color: rgba(0, 0, 0, 0.50); +} diff --git a/web/modules/admin_toolbar/js/admin_toolbar.js b/web/modules/admin_toolbar/js/admin_toolbar.js old mode 100644 new mode 100755 diff --git a/web/modules/admin_toolbar/js/admin_toolbar_search.js b/web/modules/admin_toolbar/js/admin_toolbar_search.js new file mode 100755 index 0000000000..701d76fb6c --- /dev/null +++ b/web/modules/admin_toolbar/js/admin_toolbar_search.js @@ -0,0 +1,188 @@ +/** + * @file + * Behaviors for the search widget in the admin toolbar. + */ + +(function ($, Drupal) { + + 'use strict'; + + Drupal.behaviors.adminToolbarSearch = { + + // If extra links have been fetched. + extraFetched: false, + + attach: function (context) { + if (context != document) { + return; + } + + var getUrl = window.location; + var baseUrl = getUrl.protocol + "//" + getUrl.host + "/"; + var $self = this; + this.links = []; + $('.toolbar-tray a[data-drupal-link-system-path]').each(function () { + if (this.href != baseUrl) { + var label = $self.getItemLabel(this); + $self.links.push({ + 'value': $(this).attr('href'), + 'label': label + ' ' + $(this).attr('href'), + 'labelRaw': label + }); + } + }); + + $("#admin-toolbar-search-input").autocomplete({ + minLength: 2, + source: function (request, response) { + var data = $self.handleAutocomplete(request.term); + if (!$self.extraFetched && drupalSettings.adminToolbarSearch.loadExtraLinks) { + $.getJSON( "/admin/admin-toolbar-search", function( data ) { + $(data).each(function() { + var item = this; + item.label = this.labelRaw + ' ' + this.value; + $self.links.push(item); + }); + + $self.extraFetched = true; + + var results = $self.handleAutocomplete(request.term); + response(results); + }); + } + else { + response(data); + } + }, + open: function () { + var zIndex = $('#toolbar-item-administration-search-tray') + .css("z-index") + 1; + $(this).autocomplete('widget').css('z-index', zIndex); + + return false; + }, + select: function (event, ui) { + if (ui.item.value) { + location.href = ui.item.value; + return false; + } + } + }).data("ui-autocomplete")._renderItem = (function (ul, item) { + return $("<li>") + .append('<div>' + item.labelRaw + ' <span class="admin-toolbar-search-url">' + item.value + '</span></div>') + .appendTo(ul); + }); + + // Focus on search field when tab is clicked, or enter is pressed. + $(context).find('#toolbar-item-administration-search') + .once('admin_toolbar_search') + .each(function () { + if (Drupal.behaviors.adminToolbarSearch.isSearchVisible()) { + $('#admin-toolbar-search-input').focus(); + } + $(this).on('click', function () { + $self.focusOnSearchElement(); + }); + }); + + // Initialize hotkey / keyboard shortcut. + this.initHotkey(); + }, + focusOnSearchElement: function () { + var waitforVisible = function () { + if ($('#toolbar-item-administration-search-tray:visible').length) { + $('#admin-toolbar-search-input').focus(); + } + else { + setTimeout(function () { + waitforVisible(); + }, 1); + } + }; + waitforVisible(); + }, + getItemLabel: function (item) { + var breadcrumbs = []; + $(item).parents().each(function () { + if ($(this).hasClass('menu-item')) { + var $link = $(this).find('a:first'); + if ($link.length && !$link.hasClass('admin-toolbar-search-ignore')) { + breadcrumbs.unshift($link.text()); + } + } + }); + return breadcrumbs.join(' > '); + }, + handleAutocomplete: function (term) { + var $self = this; + var keywords = term.split(" "); // Split search terms into list. + + var suggestions = []; + $self.links.forEach(function (element) { + var label = element.label.toLowerCase(); + + // Add exact matches. + if (label.indexOf(term.toLowerCase()) >= 0) { + suggestions.push(element); + } + else { + // Add suggestions where it matches all search terms. + var matchCount = 0; + keywords.forEach(function (keyword) { + if (label.indexOf(keyword.toLowerCase()) >= 0) { + matchCount++; + } + }); + if (matchCount == keywords.length) { + suggestions.push(element); + } + } + }); + return suggestions; + }, + /** + * Whether the search is visible or not. + * + * @returns {boolean} + * True if visible, false otherwise. + */ + isSearchVisible: function () { + return $('#toolbar-item-administration-search-tray').is(':visible'); + }, + /** + * Toggles the toolbar search tray. + */ + toggleSearch: function () { + $('#toolbar-item-administration-search').trigger('click'); + }, + /** + * Binds a keyboard shortcut to toggle the search. + */ + initHotkey: function () { + $(document) + .once('admin_toolbar_search') + .keydown(function (event) { + // Show the form with alt + S. + if (!Drupal.behaviors.adminToolbarSearch.isSearchVisible()) { + // 83 = s. + if (event.altKey === true && event.keyCode === 83) { + Drupal.behaviors.adminToolbarSearch.toggleSearch(); + event.preventDefault(); + } + } + // Hide the search with alt + S or ESC. + else { + // 83 = s. + if ( + (event.altKey === true && event.keyCode === 83) || + event.key === 'Escape' + ) { + Drupal.behaviors.adminToolbarSearch.toggleSearch(); + event.preventDefault(); + } + } + }); + } + }; + +})(jQuery, Drupal); diff --git a/web/modules/admin_toolbar/js/jquery.hoverIntent.js b/web/modules/admin_toolbar/js/jquery.hoverIntent.js old mode 100644 new mode 100755 diff --git a/web/modules/admin_toolbar/misc/icons/0074bd/chevron-left.svg b/web/modules/admin_toolbar/misc/icons/0074bd/chevron-left.svg old mode 100644 new mode 100755 diff --git a/web/modules/admin_toolbar/misc/icons/0074bd/chevron-right.svg b/web/modules/admin_toolbar/misc/icons/0074bd/chevron-right.svg old mode 100644 new mode 100755 diff --git a/web/modules/admin_toolbar/misc/icons/bebebe/loupe.svg b/web/modules/admin_toolbar/misc/icons/bebebe/loupe.svg new file mode 100755 index 0000000000..8fcb3bbdd2 --- /dev/null +++ b/web/modules/admin_toolbar/misc/icons/bebebe/loupe.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#BEBEBE" d="M14.648 12.788l-4.23-4.228c.525-.855.834-1.858.834-2.938 0-3.105-2.52-5.624-5.627-5.624-3.106.002-5.625 2.521-5.625 5.627 0 3.105 2.519 5.625 5.625 5.625 1.076 0 2.08-.309 2.936-.832l4.229 4.229c.194.195.515.195.707 0l1.151-1.146c.194-.2.194-.519 0-.713zm-13.35-7.163c0-2.39 1.938-4.327 4.327-4.327 2.391 0 4.328 1.937 4.328 4.327 0 2.391-1.936 4.327-4.328 4.327-2.39 0-4.327-1.936-4.327-4.327z"/></svg> diff --git a/web/modules/admin_toolbar/misc/icons/ffffff/chevron-right.svg b/web/modules/admin_toolbar/misc/icons/ffffff/chevron-right.svg old mode 100644 new mode 100755 diff --git a/web/modules/admin_toolbar/misc/icons/ffffff/loupe.svg b/web/modules/admin_toolbar/misc/icons/ffffff/loupe.svg new file mode 100755 index 0000000000..ff6f24e98f --- /dev/null +++ b/web/modules/admin_toolbar/misc/icons/ffffff/loupe.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#FFFFFF" d="M14.648 12.788l-4.23-4.228c.525-.855.834-1.858.834-2.938 0-3.105-2.52-5.624-5.627-5.624-3.106.002-5.625 2.521-5.625 5.627 0 3.105 2.519 5.625 5.625 5.625 1.076 0 2.08-.309 2.936-.832l4.229 4.229c.194.195.515.195.707 0l1.151-1.146c.194-.2.194-.519 0-.713zm-13.35-7.163c0-2.39 1.938-4.327 4.327-4.327 2.391 0 4.328 1.937 4.328 4.327 0 2.391-1.936 4.327-4.328 4.327-2.39 0-4.327-1.936-4.327-4.327z"/></svg> diff --git a/web/modules/admin_toolbar/tests/src/Functional/AdminToolbarAlterTest.php b/web/modules/admin_toolbar/tests/src/Functional/AdminToolbarAlterTest.php old mode 100644 new mode 100755 index 1403688d3e..bd57d502b3 --- a/web/modules/admin_toolbar/tests/src/Functional/AdminToolbarAlterTest.php +++ b/web/modules/admin_toolbar/tests/src/Functional/AdminToolbarAlterTest.php @@ -48,7 +48,7 @@ protected function setUp() { */ public function testAdminToolbar() { // Assert that expanded links are present in the HTML. - $this->assertRaw('class="toolbar-icon toolbar-icon-user-admin-index"'); + $this->assertSession()->responseContains('class="toolbar-icon toolbar-icon-user-admin-index"'); } } diff --git a/web/modules/admin_toolbar/tests/src/Functional/AdminToolbarToolsSortTest.php b/web/modules/admin_toolbar/tests/src/Functional/AdminToolbarToolsSortTest.php new file mode 100644 index 0000000000..88a6261b1c --- /dev/null +++ b/web/modules/admin_toolbar/tests/src/Functional/AdminToolbarToolsSortTest.php @@ -0,0 +1,222 @@ +<?php + +namespace Drupal\Tests\admin_toolbar\Functional; + +use Drupal\media\Entity\MediaType; +use Drupal\system\Entity\Menu; +use Drupal\Tests\BrowserTestBase; + +/** + * Tests Admin Toolbar tools functionality. + * + * @group admin_toolbar + */ +class AdminToolbarToolsSortTest extends BrowserTestBase { + + /** + * Modules to enable. + * + * @var array + */ + protected static $modules = [ + 'toolbar', + 'breakpoint', + 'admin_toolbar', + 'admin_toolbar_tools', + 'menu_ui', + 'media', + 'field_ui', + ]; + + /** + * A test user with permission to access the administrative toolbar. + * + * @var \Drupal\user\UserInterface + */ + protected $adminUser; + + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + } + + /** + * Tests that menu updates on entity add/update/delete. + */ + public function testMenuUpdate() { + + // Create and log in an administrative user. + $this->adminUser = $this->drupalCreateUser([ + 'access toolbar', + 'access administration pages', + 'administer site configuration', + 'administer menu', + 'access media overview', + 'administer media', + 'administer media fields', + 'administer media form display', + 'administer media display', + 'administer media types', + ]); + $this->drupalLogin($this->adminUser); + + $menu = Menu::create([ + 'id' => 'armadillo', + 'label' => 'Armadillo', + ]); + $menu->save(); + + $this->container->get('plugin.manager.menu.link')->rebuild(); + $this->drupalGet('/admin'); + + // Assert that special menu items are present in the HTML. + $this->assertSession()->responseContains('class="toolbar-icon toolbar-icon-admin-toolbar-tools-flush"'); + + // Assert that adding a media type adds it to the admin toolbar. + $chinchilla_media_type = MediaType::create([ + 'id' => 'chinchilla', + 'label' => 'Chinchilla', + 'source' => 'image', + ]); + $chinchilla_media_type->save(); + $this->drupalGet('/admin'); + $this->assertMenuHasHref('/admin/structure/media/manage/chinchilla'); + + // Assert that adding a menu adds it to the admin toolbar. + $menu = Menu::create([ + 'id' => 'chupacabra', + 'label' => 'Chupacabra', + ]); + $menu->save(); + $this->drupalGet('/admin'); + $this->assertMenuHasHref('/admin/structure/menu/manage/chupacabra'); + + // Assert that deleting a menu removes it from the admin toolbar. + $this->assertMenuHasHref('/admin/structure/menu/manage/armadillo'); + $menu = Menu::load('armadillo'); + $menu->delete(); + $this->drupalGet('/admin'); + $this->assertMenuDoesNotHaveHref('/admin/structure/menu/manage/armadillo'); + + // Assert that deleting a content entity bundle removes it from admin menu. + $this->assertMenuHasHref('/admin/structure/media/manage/chinchilla'); + $chinchilla_media_type = MediaType::load('chinchilla'); + $chinchilla_media_type->delete(); + $this->drupalGet('/admin'); + $this->assertMenuDoesNotHaveHref('/admin/structure/media/manage/chinchilla'); + } + + /** + * Tests sorting of menus by label rather than machine name. + */ + public function testMenuSorting() { + + // Create and log in an administrative user. + $this->adminUser = $this->drupalCreateUser([ + 'access toolbar', + 'access administration pages', + 'administer site configuration', + 'administer menu', + ]); + + $menus = [ + 'aaa' => 'lll', + 'bbb' => 'kkk', + 'ccc' => 'jjj', + 'ddd' => 'iii', + 'eee' => 'hhh', + 'fff' => 'ggg', + 'ggg' => 'fff', + 'hhh' => 'eee', + 'iii' => 'ddd', + 'jjj' => 'ccc', + 'kkk' => 'bbb', + 'lll' => 'aaa', + ]; + + foreach ($menus as $machine_name => $label) { + $menu = Menu::create([ + 'id' => $machine_name, + 'label' => $label, + ]); + $menu->save(); + } + + $this->drupalLogin($this->adminUser); + + $this->container->get('plugin.manager.menu.link')->rebuild(); + $this->drupalGet('/admin'); + + $results = $this->getSession()->getPage()->findAll('xpath', '//a[contains(@href, "/admin/structure/menu/manage")]'); + + $links = []; + foreach ($results as $result) { + $links[] = $result->getAttribute('href'); + } + + $expected = [ + 0 => '/admin/structure/menu/manage/lll', + 1 => '/admin/structure/menu/manage/lll/add', + 2 => '/admin/structure/menu/manage/lll/delete', + 3 => '/admin/structure/menu/manage/admin', + 4 => '/admin/structure/menu/manage/admin/add', + 5 => '/admin/structure/menu/manage/kkk', + 6 => '/admin/structure/menu/manage/kkk/add', + 7 => '/admin/structure/menu/manage/kkk/delete', + 8 => '/admin/structure/menu/manage/jjj', + 9 => '/admin/structure/menu/manage/jjj/add', + 10 => '/admin/structure/menu/manage/jjj/delete', + 11 => '/admin/structure/menu/manage/iii', + 12 => '/admin/structure/menu/manage/iii/add', + 13 => '/admin/structure/menu/manage/iii/delete', + 14 => '/admin/structure/menu/manage/hhh', + 15 => '/admin/structure/menu/manage/hhh/add', + 16 => '/admin/structure/menu/manage/hhh/delete', + 17 => '/admin/structure/menu/manage/ggg', + 18 => '/admin/structure/menu/manage/ggg/add', + 19 => '/admin/structure/menu/manage/ggg/delete', + 20 => '/admin/structure/menu/manage/footer', + 21 => '/admin/structure/menu/manage/footer/add', + 22 => '/admin/structure/menu/manage/fff', + 23 => '/admin/structure/menu/manage/fff/add', + 24 => '/admin/structure/menu/manage/fff/delete', + 25 => '/admin/structure/menu/manage/eee', + 26 => '/admin/structure/menu/manage/eee/add', + 27 => '/admin/structure/menu/manage/eee/delete', + ]; + + foreach ($links as $key => $link) { + // Using assert contains because prefaces the urls with "/subdirectory". + $this->assertContains($expected[$key], $link); + } + } + + /** + * Checks that there is a link with the specified url in the admin toolbar. + * + * @param string $url + * The url to assert exists in the admin menu. + * + * @throws \Behat\Mink\Exception\ElementNotFoundException + */ + protected function assertMenuHasHref($url) { + $this->assertSession() + ->elementExists('xpath', '//div[@id="toolbar-item-administration-tray"]//a[contains(@href, "' . $url . '")]'); + } + + /** + * Checks that there is no link with the specified url in the admin toolbar. + * + * @param string $url + * The url to assert exists in the admin menu. + * + * @throws \Behat\Mink\Exception\ExpectationException + */ + protected function assertMenuDoesNotHaveHref($url) { + $this->assertSession() + ->elementNotExists('xpath', '//div[@id="toolbar-item-administration-tray"]//a[contains(@href, "' . $url . '")]'); + } + +} diff --git a/web/modules/admin_toolbar/tests/src/FunctionalJavascript/AdminToolbarSearchTest.php b/web/modules/admin_toolbar/tests/src/FunctionalJavascript/AdminToolbarSearchTest.php new file mode 100755 index 0000000000..5bd143f470 --- /dev/null +++ b/web/modules/admin_toolbar/tests/src/FunctionalJavascript/AdminToolbarSearchTest.php @@ -0,0 +1,339 @@ +<?php + +namespace Drupal\Tests\admin_toolbar\FunctionalJavascript; + +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; +use Drupal\media\Entity\MediaType; +use Drupal\system\Entity\Menu; +use Drupal\Tests\media\Traits\MediaTypeCreationTrait; + +/** + * Test the functionality of admin toolbar search. + * + * @group admin_toolbar + */ +class AdminToolbarSearchTest extends WebDriverTestBase { + + use MediaTypeCreationTrait; + + /** + * {@inheritdoc} + */ + public static $modules = [ + 'admin_toolbar', + 'admin_toolbar_tools', + 'node', + 'media', + 'field_ui', + 'menu_ui', + 'block', + ]; + + /** + * The admin user for tests. + * + * @var \Drupal\user\UserInterface + */ + protected $adminUser; + + /** + * {@inheritdoc} + */ + public function setUp() { + parent::setUp(); + + $this->drupalCreateContentType([ + 'type' => 'article', + 'name' => 'Article', + ]); + + $dog_names = [ + 'archie' => 'Archie', + 'bailey' => 'Bailey', + 'bella' => 'Bella', + 'buddy' => 'Buddy', + 'charlie' => 'Charlie', + 'coco' => 'Coco', + 'daisy' => 'Daisy', + 'frankie' => 'Frankie', + 'jack' => 'Jack', + 'lola' => 'Lola', + 'lucy' => 'Lucy', + 'max' => 'Max', + 'milo' => 'Milo', + 'molly' => 'Molly', + 'ollie' => 'Ollie', + 'oscar' => 'Oscar', + 'rosie' => 'Rosie', + 'ruby' => 'Ruby', + 'teddy' => 'Teddy', + 'toby' => 'Toby', + ]; + + foreach ($dog_names as $machine_name => $label) { + $this->createMediaType('image', [ + 'id' => $machine_name, + 'label' => $label, + ]); + } + + $baby_names = [ + 'ada' => 'Ada', + 'amara' => 'Amara', + 'amelia' => 'Amelia', + 'arabella' => 'Arabella', + 'asher' => 'Asher', + 'astrid' => 'Astrid', + 'atticus' => 'Atticus', + 'aurora' => 'Aurora', + 'ava' => 'Ava', + 'cora' => 'Cora', + 'eleanor' => 'Eleanor', + 'eloise' => 'Eloise', + 'felix' => 'Felix', + 'freya' => 'Freya', + 'genevieve' => 'Genevieve', + 'isla' => 'Isla', + 'jasper' => 'Jasper', + 'luna' => 'Luna', + 'maeve' => 'Maeve', + 'milo' => 'Milo', + 'nora' => 'Nora', + 'olivia' => 'Olivia', + 'ophelia' => 'Ophelia', + 'posie' => 'Posie', + 'rose' => 'Rose', + 'silas' => 'Silas', + 'soren' => 'Soren', + ]; + + foreach ($baby_names as $id => $label) { + $menu = Menu::create([ + 'id' => $id, + 'label' => $label, + ]); + $menu->save(); + } + + $this->drupalPlaceBlock('local_tasks_block'); + + $this->adminUser = $this->drupalCreateUser([ + 'access toolbar', + 'administer menu', + 'access administration pages', + 'administer site configuration', + 'administer content types', + 'administer node fields', + 'access media overview', + 'administer media', + 'administer media fields', + 'administer media form display', + 'administer media display', + 'administer media types', + ]); + } + + /** + * Tests search functionality. + */ + public function testSearchFunctionality() { + + $search_tab = '#toolbar-item-administration-search'; + $search_tray = '#toolbar-item-administration-search-tray'; + + $this->drupalLogin($this->adminUser); + $this->assertSession()->responseContains('admin.toolbar_search.css'); + $this->assertSession()->responseContains('admin_toolbar_search.js'); + $this->assertSession()->waitForElementVisible('css', $search_tab)->click(); + $this->assertSession()->waitForElementVisible('css', $search_tray); + + $this->assertSuggestionContains('basic', 'admin/config/system/site-information'); + + // Rebuild menu items. + drupal_flush_all_caches(); + + // Test that the route admin_toolbar.search returns expected json. + $this->drupalGet('/admin/admin-toolbar-search'); + + $search_menus = [ + 'cora', + 'eleanor', + 'eloise', + 'felix', + 'freya', + 'genevieve', + 'isla', + 'jasper', + 'luna', + 'maeve', + 'milo', + 'nora', + 'olivia', + 'ophelia', + 'posie', + 'rose', + 'silas', + 'soren', + ]; + + $toolbar_menus = [ + 'ada', + 'amara', + 'amelia', + 'arabella', + 'asher', + 'astrid', + 'atticus', + 'aurora', + 'ava', + ]; + + foreach ($search_menus as $menu_id) { + $this->assertSession()->responseContains('\/admin\/structure\/menu\/manage\/' . $menu_id); + } + + foreach ($toolbar_menus as $menu_id) { + $this->assertSession()->responseNotContains('\/admin\/structure\/menu\/manage\/' . $menu_id); + } + + $this->drupalGet('/admin'); + + foreach ($search_menus as $menu_id) { + $this->assertMenuDoesNotHaveHref('/admin/structure/menu/manage/' . $menu_id); + } + + foreach ($toolbar_menus as $menu_id) { + $this->assertMenuHasHref('/admin/structure/menu/manage/' . $menu_id); + } + + $this->drupalGet('admin/structure/types/manage/article/fields'); + $this->assertSession()->waitForElementVisible('css', $search_tray); + + $this->assertSuggestionContains('article manage fields', '/admin/structure/types/manage/article/fields'); + + $suggestions = $this->assertSession() + ->waitForElementVisible('css', 'ul.ui-autocomplete'); + + // Assert there is only one suggestion with a link to + // /admin/structure/types/manage/article/fields. + $count = count($suggestions->findAll('xpath', '//span[contains(text(), "/admin/structure/types/manage/article/fields")]')); + $this->assertEquals(1, $count); + + // Test that bundle within admin toolbar appears in search. + $this->assertSuggestionContains('lola', 'admin/structure/media/manage/lola/fields'); + + // Assert that a link after the limit (10) doesn't appear in admin toolbar. + $toby_url = '/admin/structure/media/manage/toby/fields'; + $this->assertSession() + ->elementNotContains('css', '#toolbar-administration', $toby_url); + + // Assert that a link excluded from admin toolbar appears in search. + $this->assertSuggestionContains('toby', $toby_url); + + // Test that adding a new bundle updates the extra links loaded from + // admin_toolbar.search route. + $this->createMediaType('image', [ + 'id' => 'zuzu', + 'label' => 'Zuzu', + ]); + + $this->drupalGet('admin'); + $this->assertSession()->waitForElementVisible('css', $search_tray); + $this->assertSuggestionContains('zuzu', '/admin/structure/media/manage/zuzu/fields'); + + // Test that deleting a bundle updates the extra links loaded from + // admin_toolbar.search route. + $toby = MediaType::load('toby'); + $toby->delete(); + + $this->getSession()->reload(); + $this->assertSession()->waitForElementVisible('css', $search_tray); + $this->assertSuggestionNotContains('toby', $toby_url); + + } + + /** + * Assert that the search suggestions contain a given string with given input. + * + * @param string $search + * The string to search for. + * @param string $contains + * Some HTML that is expected to be within the suggestions element. + */ + protected function assertSuggestionContains($search, $contains) { + $this->resetSearch(); + $page = $this->getSession()->getPage(); + $page->fillField('admin-toolbar-search-input', $search); + $page->waitFor(3, function () use ($page) { + return ($page->find('css', 'ul.ui-autocomplete')->isVisible() === TRUE); + }); + $suggestions_markup = $page->find('css', 'ul.ui-autocomplete')->getHtml(); + $this->assertContains($contains, $suggestions_markup); + } + + /** + * Assert that the search suggestions does not contain a given string. + * + * Assert that the search suggestions does not contain a given string with a + * given input. + * + * @param string $search + * The string to search for. + * @param string $contains + * Some HTML that is not expected to be within the suggestions element. + */ + protected function assertSuggestionNotContains($search, $contains) { + $this->resetSearch(); + $page = $this->getSession()->getPage(); + $page->fillField('admin-toolbar-search-input', $search); + $page->waitFor(3, function () use ($page) { + return ($page->find('css', 'ul.ui-autocomplete')->isVisible() === TRUE); + }); + if ($page->find('css', 'ul.ui-autocomplete')->isVisible() === FALSE) { + return; + } + else { + $suggestions_markup = $page->find('css', 'ul.ui-autocomplete')->getHtml(); + $this->assertNotContains($contains, $suggestions_markup); + } + } + + /** + * Search for an empty string to clear out the autocomplete suggestions. + */ + protected function resetSearch() { + $page = $this->getSession()->getPage(); + // Empty out the suggestions. + $page->fillField('admin-toolbar-search-input', ''); + $page->waitFor(3, function () use ($page) { + return ($page->find('css', 'ul.ui-autocomplete')->isVisible() === FALSE); + }); + } + + /** + * Checks that there is a link with the specified url in the admin toolbar. + * + * @param string $url + * The url to assert exists in the admin menu. + * + * @throws \Behat\Mink\Exception\ElementNotFoundException + */ + protected function assertMenuHasHref($url) { + $this->assertSession() + ->elementExists('xpath', '//div[@id="toolbar-item-administration-tray"]//a[contains(@href, "' . $url . '")]'); + } + + /** + * Checks that there is no link with the specified url in the admin toolbar. + * + * @param string $url + * The url to assert exists in the admin menu. + * + * @throws \Behat\Mink\Exception\ExpectationException + */ + protected function assertMenuDoesNotHaveHref($url) { + $this->assertSession() + ->elementNotExists('xpath', '//div[@id="toolbar-item-administration-tray"]//a[contains(@href, "' . $url . '")]'); + } + +} -- GitLab