? NPM Resource Changed ? ? Pending

User tests: Successful: Unsuccessful:

avatar C-Lodder
C-Lodder
9 May 2020

Pull Request for Issue #28995

Summary of Changes

This PR adds a "Copy" button allowing you to copy the API token to your clipboard.

Evergreen browsers get to use the async Clipboard API, however this will only work over a secure connection (https://), so if you're on a insecure protocol, you will fallback to execCommand(...).

Testing Instructions

NOTE: The button is supposed to appear next to the input, however you'll see it appear below the input. This is due to the way Joomla is styling it's parameters. It's out of scope and I will NOT fix that in this PR, so please do not flag it as an issue.

  1. Run node build.js --compile-js from your terminal
  2. Go to administrator/index.php?option=com_users and click on a user
  3. Navigate to the Joomla API Token tab
  4. Click the Copy button

Expected result

The token will be copied to your clipboard

avatar C-Lodder C-Lodder - open - 9 May 2020
avatar C-Lodder C-Lodder - change - 9 May 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 9 May 2020
Category Administration Language & Strings JavaScript Repository NPM Change Front End Plugins
56c4445 9 May 2020 avatar C-Lodder woof
avatar C-Lodder C-Lodder - change - 9 May 2020
Labels Added: ? NPM Resource Changed ?
avatar C-Lodder C-Lodder - change - 9 May 2020
The description was changed
avatar C-Lodder C-Lodder - edited - 9 May 2020
avatar C-Lodder C-Lodder - change - 9 May 2020
The description was changed
avatar C-Lodder C-Lodder - edited - 9 May 2020
avatar Quy
Quy - comment - 9 May 2020

M in message should be capitalized.

token-copy

avatar C-Lodder
C-Lodder - comment - 10 May 2020

@Quy will cappitalise the m in message once I figure out how to.

Joomla.renderMessages({ error: [Joomla.Text._('JGLOBAL_WARNCOOKIES')] }, undefined, false, 6000);
Joomla.renderMessages({ danger: [Joomla.Text._('JGLOBAL_WARNCOOKIES')] }, undefined, false, 6000);
Joomla.renderMessages({ message: [Joomla.Text._('JGLOBAL_WARNCOOKIES')] }, undefined, false, 6000);
Joomla.renderMessages({ success: [Joomla.Text._('JGLOBAL_WARNCOOKIES')] }, undefined, false, 6000);
Joomla.renderMessages({ warning: [Joomla.Text._('JGLOBAL_WARNCOOKIES')] }, undefined, false, 6000);
Joomla.renderMessages({ notice: [Joomla.Text._('JGLOBAL_WARNCOOKIES')] }, undefined, false, 6000);

From the above, the only one that has a capitalised title is the error, so how sure how this works

avatar C-Lodder
C-Lodder - comment - 10 May 2020

@wilsonge @SharkyKZ perhaps one of you may know more about this.

The only alerts where the title's first letter is capitalised is an error. The language strings are defined here: https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/language/en-GB/joomla.ini#L42-L46

avatar SharkyKZ
SharkyKZ - comment - 10 May 2020

It means the JS string is missing. Add it using Text::script('MESSAGE');.

avatar SharkyKZ
SharkyKZ - comment - 10 May 2020

Please move plugins/user/token/src/Field/layouts/token.php outside of src directory.

avatar dgrammatiko
dgrammatiko - comment - 10 May 2020

@C-Lodder you need to add here

Text::script('ERROR');
Text::script('INFO');
Text::script('NOTICE');
Text::script('MESSAGE');
Text::script('WARNING');
avatar C-Lodder
C-Lodder - comment - 10 May 2020

@SharkyKZ Moved layout outside of src directory

Lang string fixed now, thanks.

avatar HLeithner
HLeithner - comment - 10 May 2020

Do we have other situations where a copy button would be useful for an input field? The base of the question is wouldn't it make more sense to have this as a parameter to our normal input field or use a more generic name instead of "token"?

avatar brianteeman brianteeman - test_item - 23 May 2020 - Tested successfully
avatar brianteeman
brianteeman - comment - 23 May 2020

I have tested this item successfully on e368ef8

Works as described.

If merged then the styling issue will need to be resolved - its a quick fix

As for using this functionality elsewhere - I am not aware of anywhere else that this would currently be useful.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29005.

avatar bonzani bonzani - test_item - 24 May 2020 - Tested successfully
avatar bonzani
bonzani - comment - 24 May 2020

I have tested this item successfully on e368ef8


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29005.

avatar alikon alikon - change - 24 May 2020
Status Pending Ready to Commit
avatar alikon
alikon - comment - 24 May 2020

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29005.

avatar SharkyKZ SharkyKZ - change - 24 May 2020
Status Ready to Commit Pending
avatar SharkyKZ
SharkyKZ - comment - 24 May 2020

Setting back to Pending. @Fedik's comment needs to be addressed.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29005.

avatar C-Lodder
C-Lodder - comment - 24 May 2020

I've added return parent::getInput();

If I use return $this->getRenderer('token')->render($this->getLayoutData()); in the getInput() method, the field doesn't get displayed.

This is done in other plugins too:

https://github.com/joomla/joomla-cms/blob/4.0-dev/plugins/user/terms/src/Field/TermsField.php#L46

https://github.com/joomla/joomla-cms/blob/4.0-dev/plugins/system/privacyconsent/src/Field/PrivacyField.php#L45

avatar Fedik
Fedik - comment - 25 May 2020

If I use return $this->getRenderer('token')->render($this->getLayoutData()); in the getInput() method, the field doesn't get displayed.

I suspect something mixed up with layout name and layout path, the rendered cannot find the layout, and so renders nothing.

This is done in other plugins too

That crazy, there also wrong ?
That need to fix someday by someone ?

All that need for render a custom layout is a property with layout name, no need override getInput().
so just

/**
 * Layout to render the form field
 *
 * @var  string
 */
protected $renderLayout = 'plugins.token.token';

Btw, the layout name for the token field will be plugins.token.token (not token)
and because of this, the method getLayoutPaths in this pull also incorrect, because it search for <base/template>layouts/token.php but should search for <base/template>layouts/plugins/token/token.php

And a default layout file itself need to be under layouts/plugins/token/token.php, not in plugins/user/token/layouts/token.php.

If it work as it is, it is good, but better if we make it correct, because other people will copy this for sure, and then show as "good example" ?

A bit later, I try to look in detail, and try to help.

avatar C-Lodder
C-Lodder - comment - 25 May 2020

Thanks Fedik, I'll look into it again today or tomorrow

avatar SharkyKZ
SharkyKZ - comment - 25 May 2020

Layouts can be in the plugin directory, as long as those paths are included. Either way works.

avatar Fedik
Fedik - comment - 25 May 2020

That is true. However I have seen that other core plugins use root /layouts/plugins/blabla,
I prefer to keep it consistent

avatar joomla-cms-bot joomla-cms-bot - change - 25 May 2020
Category Administration Language & Strings JavaScript Repository NPM Change Front End Plugins Administration Language & Strings JavaScript Repository NPM Change Layout Front End Plugins
avatar C-Lodder
C-Lodder - comment - 25 May 2020

@Fedik Updated the PR. Is that ok now?

avatar SharkyKZ
SharkyKZ - comment - 25 May 2020

Label is missing, layout is still broken and overrides don't work.

avatar Fedik
Fedik - comment - 25 May 2020

Looks good,

Now you can remove methods getInput(), getLayoutPaths(), getRenderer()
They will inherit from parent class, with the same functionality. That should fix override issue found by @SharkyKZ

I try to test this evening or next days

avatar SharkyKZ
SharkyKZ - comment - 25 May 2020

@C-Lodder see C-Lodder#14 for fixing label issues.

avatar Quy Quy - test_item - 26 May 2020 - Tested successfully
avatar Quy
Quy - comment - 26 May 2020

I have tested this item successfully on 38e9e03


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29005.

avatar Fedik Fedik - test_item - 30 May 2020 - Tested successfully
avatar Fedik
Fedik - comment - 30 May 2020

I have tested this item successfully on 38e9e03


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29005.

avatar alikon alikon - change - 30 May 2020
Status Pending Ready to Commit
avatar alikon
alikon - comment - 30 May 2020

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29005.

avatar wilsonge wilsonge - change - 30 May 2020
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-05-30 12:07:57
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 30 May 2020
avatar wilsonge wilsonge - merge - 30 May 2020
avatar wilsonge
wilsonge - comment - 30 May 2020

Thanks!

Add a Comment

Login with GitHub to post a comment