-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Post List: Add a Copy Link Quick Action (#41305)
* Post List: Add a Copy Link Quick Action * some feedback * use external js file * Update projects/packages/post-list/webpack.config.js Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com> * feedback * fix php tests * fix php tests and update composer.lock files * changelog * fix package.json * add copy link in all statuses except trash * exclude files from published package * fix composer.lock files --------- Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
- Loading branch information
1 parent
86e33fa
commit 60448fb
Showing
15 changed files
with
224 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
# Files not needed to be distributed in the package. | ||
.gitattributes export-ignore | ||
.github/ export-ignore | ||
package.json export-ignore | ||
webpack.config.js export-ignore | ||
phpunit.xml.dist export-ignore | ||
.babelrc export-ignore | ||
.gitattributes export-ignore | ||
.github/ export-ignore | ||
package.json export-ignore | ||
webpack.config.js export-ignore | ||
phpunit.xml.dist export-ignore | ||
.babelrc export-ignore | ||
|
||
# Files to include in the mirror repo | ||
/build/** production-include | ||
/build/** production-include | ||
|
||
# Files to exclude from the mirror repo | ||
/changelog/** production-exclude | ||
.gitignore production-exclude | ||
.phpcs.dir.xml production-exclude | ||
_inc/** production-exclude | ||
/changelog/** production-exclude | ||
.gitignore production-exclude | ||
.phpcs.dir.xml production-exclude | ||
_inc/** production-exclude | ||
/package.json production-exclude | ||
/src/**/*.js production-exclude | ||
/webpack.config.js production-exclude |
4 changes: 4 additions & 0 deletions
4
projects/packages/post-list/changelog/add-copy-post-link-action-in-posts-list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: added | ||
|
||
Post List: Add a Copy Link Quick Action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"private": true, | ||
"description": "Enhance the classic view of the Admin section of your WordPress site", | ||
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/post-list/#readme", | ||
"bugs": { | ||
"url": "https://github.com/Automattic/jetpack/labels/[Package] Post List" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Automattic/jetpack.git", | ||
"directory": "projects/packages/post-list" | ||
}, | ||
"license": "GPL-2.0-or-later", | ||
"author": "Automattic", | ||
"scripts": { | ||
"build": "pnpm run clean && pnpm run build-js", | ||
"build-js": "webpack", | ||
"build-production": "pnpm run clean && pnpm run build-production-js && pnpm run validate", | ||
"build-production-js": "NODE_ENV=production BABEL_ENV=production pnpm run build-js", | ||
"clean": "rm -rf build", | ||
"validate": "pnpm exec validate-es build/" | ||
}, | ||
"dependencies": { | ||
"@wordpress/i18n": "5.16.0" | ||
}, | ||
"devDependencies": { | ||
"@automattic/jetpack-webpack-config": "workspace:*", | ||
"webpack": "5.94.0", | ||
"webpack-cli": "6.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Closure function to copy the link to the clipboard. | ||
* | ||
* @return {Function} The click event handler. | ||
*/ | ||
function copyLinkQuickAction() { | ||
let timoutId; | ||
/** | ||
* Copy the link to the clipboard. | ||
* @param {object} event - The event object. | ||
*/ | ||
function onClick( event ) { | ||
event.preventDefault(); | ||
clearTimeout( timoutId ); | ||
window.navigator.clipboard.writeText( event.target.getAttribute( 'href' ) ).then( () => { | ||
event.target.textContent = __( 'Copied!', 'jetpack-post-list' ); | ||
timoutId = setTimeout( () => { | ||
event.target.textContent = __( 'Copy link', 'jetpack-post-list' ); | ||
}, 2000 ); | ||
} ); | ||
} | ||
return onClick; | ||
} | ||
|
||
document.addEventListener( 'DOMContentLoaded', () => { | ||
document.querySelectorAll( '.jetpack-post-list__copy-link-action' ).forEach( node => { | ||
node.addEventListener( 'click', copyLinkQuickAction() ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const path = require( 'path' ); | ||
const jetpackWebpackConfig = require( '@automattic/jetpack-webpack-config/webpack' ); | ||
|
||
module.exports = [ | ||
{ | ||
entry: { | ||
index: './src/index.js', | ||
}, | ||
mode: jetpackWebpackConfig.mode, | ||
devtool: jetpackWebpackConfig.devtool, | ||
output: { | ||
...jetpackWebpackConfig.output, | ||
path: path.resolve( './build' ), | ||
}, | ||
optimization: { | ||
...jetpackWebpackConfig.optimization, | ||
}, | ||
resolve: { | ||
...jetpackWebpackConfig.resolve, | ||
}, | ||
node: false, | ||
plugins: [ ...jetpackWebpackConfig.StandardPlugins() ], | ||
module: { | ||
strictExportPresence: true, | ||
rules: [ | ||
// Transpile JavaScript | ||
jetpackWebpackConfig.TranspileRule( { | ||
exclude: /node_modules\//, | ||
} ), | ||
], | ||
}, | ||
}, | ||
]; |
4 changes: 4 additions & 0 deletions
4
projects/plugins/jetpack/changelog/add-copy-post-link-action-in-posts-list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: other | ||
|
||
Post List: Add a Copy Link Quick Action |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
projects/plugins/social/changelog/add-copy-post-link-action-in-posts-list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: added | ||
|
||
Post List: Add a Copy Link Quick Action |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
projects/plugins/wpcomsh/changelog/add-copy-post-link-action-in-posts-list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: added | ||
|
||
Post List: Add a Copy Link Quick Action |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.