Skip to content

Commit

Permalink
Update module namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tr33m4n committed Mar 11, 2020
1 parent fce56e0 commit b1335f8
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 36 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# magento2-config-hints
# magento2-system-path-hints
A convenient way to view and copy a system configuration path from the admin panel

## Why?
Expand All @@ -7,14 +7,14 @@ or piecing it together through various field values in the DOM. I thought there
setting similar to template hints that when enabled would conveniently show a system path in relation
to a field in the admin panel... Alas (unless I've missed something) this does not appear to be the case.

This module adds a "config hint" beneath all system configuration fields when enabled. Clicking on the hint will copy it to your clipboard! Handy dandy.
This module adds a "system path hint" beneath all system configuration fields when enabled. Clicking on the hint will copy it to your clipboard! Handy dandy.

![image](https://user-images.githubusercontent.com/1771667/76467147-df653f00-63e0-11ea-9144-df728a70cc0b.png)

## Installing
This module is available on https://packagist.org/
```shell script
composer require tr33m4n/magento2-config-hints
composer require tr33m4n/magento2-system-path-hints
```
To enable "config hints" head to "Stores" -> "Configuration" -> "Advanced" -> "Developer" -> "Debug"
and set "Enable Admin Config Hints" to "Yes"
To enable "system path hints" head to "Stores" -> "Configuration" -> "Advanced" -> "Developer" -> "Debug"
and set "Enable System Path Hints" to "Yes"
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tr33m4n/magento2-config-hints",
"name": "tr33m4n/magento2-system-path-hints",
"type": "magento2-module",
"description": "Display the associated path beneath a configuration field in the Magento 2 admin panel",
"description": "A convenient way to view and copy a system configuration path from the admin panel",
"license": "MIT",
"authors": [
{
Expand All @@ -15,7 +15,7 @@
"src/registration.php"
],
"psr-4": {
"tr33m4n\\ConfigHints\\": "src"
"tr33m4n\\SystemPathHints\\": "src"
}
},
"require": {
Expand Down
14 changes: 7 additions & 7 deletions src/Plugin/Model/Config/Structure/Element/FieldPlugin.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?php

namespace tr33m4n\ConfigHints\Plugin\Model\Config\Structure\Element;
namespace tr33m4n\SystemPathHints\Plugin\Model\Config\Structure\Element;

use Magento\Config\Model\Config\Structure\Element\Field;
use Magento\Framework\App\Config\ScopeConfigInterface;

/**
* Class FieldPlugin
*
* @package tr33m4n\ConfigHints\Plugin\Model\Config\Structure\Element
* @package tr33m4n\SystemPathHints\Plugin\Model\Config\Structure\Element
*/
class FieldPlugin
{
/**
* Config hints path
* System path hints path
*/
const XML_ENABLE_CONFIG_HINTS_PATH = 'dev/debug/config_hints';
const XML_ENABLE_PATH_HINTS_PATH = 'dev/debug/system_path_hints';

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
Expand All @@ -34,20 +34,20 @@ public function __construct(
}

/**
* Add config path to the field comment
* Add path to the field comment
*
* @param \Magento\Config\Model\Config\Structure\Element\Field $subject
* @param string $result
* @return string
*/
public function afterGetComment(Field $subject, string $result) : string
{
if (!$this->scopeConfig->isSetFlag(self::XML_ENABLE_CONFIG_HINTS_PATH)) {
if (!$this->scopeConfig->isSetFlag(self::XML_ENABLE_PATH_HINTS_PATH)) {
return $result;
}

return $result .= __(
'%1<strong>Path:</strong> <a href="#" data-tooltip-text="Click to copy" data-config-hint>%2</a>',
'%1<strong>Path:</strong> <a href="#" data-tooltip-text="Click to copy" data-path-hint>%2</a>',
strlen($result) ? '<br>' : '',
$subject->getConfigPath() ?: $subject->getPath()
);
Expand Down
4 changes: 2 additions & 2 deletions src/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Config\Model\Config\Structure\Element\Field">
<plugin name="add_config_path_to_field_comments"
type="tr33m4n\ConfigHints\Plugin\Model\Config\Structure\Element\FieldPlugin"
<plugin name="add_system_path_to_field_comments"
type="tr33m4n\SystemPathHints\Plugin\Model\Config\Structure\Element\FieldPlugin"
sortOrder="1"/>
</type>
</config>
4 changes: 2 additions & 2 deletions src/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<system>
<section id="dev">
<group id="debug">
<field id="config_hints" translate="label,comment" type="select" sortOrder="100" showInDefault="1"
<field id="system_path_hints" translate="label,comment" type="select" sortOrder="100" showInDefault="1"
showInWebsite="0" showInStore="0">
<label>Enable Admin Config Hints</label>
<label>Enable System Path Hints</label>
<comment>Enable to display system configuration path's for each admin field</comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
Expand Down
2 changes: 1 addition & 1 deletion src/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<default>
<dev>
<debug>
<config_hints>0</config_hints>
<system_path_hints>0</system_path_hints>
</debug>
</dev>
</default>
Expand Down
2 changes: 1 addition & 1 deletion src/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="tr33m4n_ConfigHints">
<module name="tr33m4n_SystemPathHints">
<sequence>
<module name="Magento_Config"/>
</sequence>
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en_US.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Enable Admin Config Hints","Enable Admin Config Hints"
"Enable to display admin config path for each admin setting","Enable to display admin config path for each admin setting"
"%1<strong>Path:</strong> <a href=""#"" data-tooltip-text=""Click to copy"" data-config-hint>%2</a>","%1<strong>Path:</strong> <a href=""#"" data-tooltip-text=""Click to copy"" data-config-hint>%2</a>"
"%1<strong>Path:</strong> <a href=""#"" data-tooltip-text=""Click to copy"" data-path-hint>%2</a>","%1<strong>Path:</strong> <a href=""#"" data-tooltip-text=""Click to copy"" data-path-hint>%2</a>"
"Copied!","Copied!"
2 changes: 1 addition & 1 deletion src/registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'tr33m4n_ConfigHints',
'tr33m4n_SystemPathHints',
__DIR__
);
4 changes: 2 additions & 2 deletions src/view/adminhtml/layout/adminhtml_system_config_edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="tr33m4n_ConfigHints::js/copy.js"/>
<css src="tr33m4n_ConfigHints::css/styles.css"/>
<script src="tr33m4n_SystemPathHints::js/copy.js"/>
<css src="tr33m4n_SystemPathHints::css/styles.css"/>
</head>
</page>
18 changes: 9 additions & 9 deletions src/view/adminhtml/web/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*------------------------------------
#magento2-config-hints v1.0.0
#magento2-system-path-hints v1.0.0
------------------------------------*/

a[data-config-hint],
.accordion .config .note a[data-config-hint] {
a[data-path-hint],
.accordion .config .note a[data-path-hint] {
position: relative;
font-family: monospace, monospace;
background-color: #e9e9e9;
Expand All @@ -13,16 +13,16 @@ a[data-config-hint],
border-radius: 1px;
}

a[data-config-hint]::after,
a[data-config-hint]::before {
a[data-path-hint]::after,
a[data-path-hint]::before {
visibility: hidden;
opacity: 0;
-webkit-transition: visibility .2s, opacity .2s;
-o-transition: visibility .2s, opacity .2s;
transition: visibility .2s, opacity .2s;
}

a[data-config-hint]::after {
a[data-path-hint]::after {
content: attr(data-tooltip-text);
background-color: #000000;
color: #ffffff;
Expand All @@ -40,7 +40,7 @@ a[data-config-hint]::after {
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

a[data-config-hint]::before {
a[data-path-hint]::before {
content: '';
position: absolute;
border-style: solid;
Expand All @@ -54,8 +54,8 @@ a[data-config-hint]::before {
transform: translateX(-50%);
}

a[data-config-hint]:hover::after,
a[data-config-hint]:hover::before {
a[data-path-hint]:hover::after,
a[data-path-hint]:hover::before {
visibility: visible;
opacity: 1;
}
4 changes: 2 additions & 2 deletions src/view/adminhtml/web/js/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require([
var timeout = null;

document.addEventListener('click', function (event) {
if (!event.target.matches('[data-config-hint]')) {
if (!event.target.matches('[data-path-hint]')) {
return;
}

Expand All @@ -27,7 +27,7 @@ require([
return;
}

event.target.setAttribute('data-tooltip-text', $t('Copied!'))
event.target.setAttribute('data-tooltip-text', $t('Copied!'));
timeout = setTimeout(function () {
event.target.setAttribute('data-tooltip-text', originalText);

Expand Down

0 comments on commit b1335f8

Please sign in to comment.