-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set up app for Jetpack's support bot integration #94768
Open
ice9js
wants to merge
19
commits into
trunk
Choose a base branch
from
update/jetpack-odie-integration
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7a4e2fc
Added the skeleton packages for the Odie-based Jetpackcom support UI …
zinigor b2ce2e2
Merge branch 'trunk' into add/odie-bot-jetpackme-support-app
zinigor 5cd9c60
Removed unnecessary overrides from Webpack config.
anomiex b2f80f4
Merge branch 'trunk' into add/odie-bot-jetpackme-support-app
zinigor e6efc44
Moved the index file to the src folder.
zinigor f93a409
Update webpack config and add example page
ice9js 48d3fbf
Update the entry point to be able to correctly render the prompt on t…
ice9js d487a36
Merge remote-tracking branch 'origin/trunk' into update/jetpack-odie-…
ice9js 115b8c0
Update yarn.lock
ice9js 2e5e5ef
Add jetpack.com to supported sites in wpcom-proxy-request
ice9js 2ad11ae
Update DependencyExtractionPlugin configuration in webpack.config.js
ice9js 276c513
Fix package.json slugs
ice9js 484ebde
Wrap the widget in QueryClientProvider
ice9js 7db0bb3
Update README.md
ice9js 5e129b7
Merge remote-tracking branch 'origin/trunk' into update/jetpack-odie-…
ice9js 2ae1e66
Remove examples directory
ice9js 069e66e
Merge remote-tracking branch 'origin/trunk' into update/jetpack-odie-…
ice9js 1accd87
Merge remote-tracking branch 'origin/trunk' into update/jetpack-odie-…
ice9js 66fc61f
Update yarn.lock
ice9js File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,18 @@ | ||
# Odie Support Widget for Jetpack.com | ||
|
||
This is the support chat interface available over at https://jetpack.com/contact-support. | ||
|
||
## Building | ||
|
||
### Production | ||
|
||
```bash | ||
cd apps/jetpackme-support | ||
yarn build | ||
``` | ||
|
||
### Development | ||
|
||
``` | ||
yarn dev | ||
``` |
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,60 @@ | ||
{ | ||
"name": "@automattic/jetpackme-support", | ||
"version": "1.0.0", | ||
"description": "A Jetpack.com Odie bot interface application.", | ||
"homepage": "https://github.com/Automattic/wp-calypso", | ||
"license": "GPL-2.0-or-later", | ||
"author": "Automattic Inc.", | ||
"sideEffects": [ | ||
"*.css", | ||
"*.scss", | ||
"./config.js" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Automattic/wp-calypso.git", | ||
"directory": "apps/jetpackme-support" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"bugs": "https://github.com/Automattic/wp-calypso/issues", | ||
"types": "dist/types", | ||
"scripts": { | ||
"clean": "rm -rf dist", | ||
"teamcity:build-app": "yarn run build", | ||
"build": "NODE_ENV=production yarn dev", | ||
"build:app": "calypso-build", | ||
"dev": "yarn run calypso-apps-builder --localPath dist --remotePath /home/wpcom/public_html/widgets.wp.com/jetpackme-support", | ||
"prepack": "yarn run clean && yarn run build", | ||
"watch": "tsc --build ./tsconfig.json --watch", | ||
"translate": "rm -rf dist/strings && wp-babel-makepot './dist/*.{js,jsx,ts,tsx}' --ignore '**/node_modules/**,**/test/**,**/*.d.ts' --base './dist' --dir './dist/strings' --output './dist/jetpackme-support.pot' && build-app-languages --stringsFilePath='./dist/jetpackme-support.pot' --outputPath='./dist/languages' --outputFormat='JS'" | ||
}, | ||
"dependencies": { | ||
"@automattic/components": "workspace:^", | ||
"@automattic/i18n-utils": "workspace:^", | ||
"@automattic/odie-client": "workspace:^", | ||
"@tanstack/react-query": "^5.15.5", | ||
"@wordpress/components": "^28.7.0", | ||
"@wordpress/element": "^6.7.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@automattic/calypso-apps-builder": "workspace:^", | ||
"@automattic/calypso-build": "workspace:^", | ||
"@automattic/calypso-typescript-config": "workspace:^", | ||
"@automattic/wp-babel-makepot": "workspace:^", | ||
"@wordpress/dependency-extraction-webpack-plugin": "5.9.0", | ||
"@wordpress/readable-js-assets-webpack-plugin": "3.0.0", | ||
"autoprefixer": "^10.4.20", | ||
"copy-webpack-plugin": "^10.2.4", | ||
"typescript": "^5.3.3", | ||
"webpack": "^5.91.0" | ||
}, | ||
"peerDependencies": { | ||
"@wordpress/data": "^10.2.0", | ||
"postcss": "*" | ||
}, | ||
"private": true | ||
} |
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,23 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { render } from '@wordpress/element'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import SupportPrompt from './support-prompt'; | ||
|
||
window.renderSupportPrompt = ( elementId ) => { | ||
const queryClient = new QueryClient(); | ||
|
||
render( | ||
<QueryClientProvider client={ queryClient }> | ||
<SupportPrompt /> | ||
</QueryClientProvider>, | ||
document.getElementById( elementId ) | ||
); | ||
}; |
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,32 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import OdieAssistantProvider, { | ||
OdieAssistant, | ||
EllipsisMenu, | ||
useOdieAssistantContext, | ||
} from '@automattic/odie-client'; | ||
|
||
const SupportPrompt = () => { | ||
const { clearChat } = useOdieAssistantContext(); | ||
return ( | ||
<OdieAssistantProvider botNameSlug="jetpack-support-chat"> | ||
<div className="custom-class"> | ||
<EllipsisMenu popoverClassName="menu-class" position="bottom"> | ||
<span | ||
role="button" | ||
tabIndex={ 0 } | ||
onClick={ () => clearChat() } | ||
onKeyPress={ () => clearChat() } | ||
className="menu-item-class" | ||
> | ||
Start a New Chat | ||
</span> | ||
</EllipsisMenu> | ||
</div> | ||
<OdieAssistant /> | ||
</OdieAssistantProvider> | ||
); | ||
}; | ||
|
||
export default SupportPrompt; |
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,54 @@ | ||
const path = require( 'path' ); | ||
const getBaseWebpackConfig = require( '@automattic/calypso-build/webpack.config.js' ); | ||
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' ); | ||
const ReadableJsAssetsWebpackPlugin = require( '@wordpress/readable-js-assets-webpack-plugin' ); | ||
const webpack = require( 'webpack' ); | ||
const GenerateChunksMapPlugin = require( '../../build-tools/webpack/generate-chunks-map-plugin' ); | ||
|
||
/* Arguments to this function replicate webpack's so this config can be used on the command line, | ||
* with individual options overridden by command line args. | ||
* @see {@link https://webpack.js.org/configuration/configuration-types/#exporting-a-function} | ||
* @see {@link https://webpack.js.org/api/cli/} | ||
* @param {Object} env environment options | ||
* @param {string} env.source plugin slugs, comma separated list | ||
* @param {Object} argv options map | ||
* @param {string} argv.entry entry path | ||
* @returns {Object} webpack config | ||
*/ | ||
function getWebpackConfig( env = { source: '' }, argv = {} ) { | ||
const webpackConfig = getBaseWebpackConfig( { ...env, WP: true }, argv ); | ||
|
||
return { | ||
...webpackConfig, | ||
entry: { | ||
'jetpackme-support': path.join( __dirname, 'src/index.js' ), | ||
}, | ||
output: { | ||
...webpackConfig.output, | ||
filename: '[name].min.js', // dynamic filename | ||
}, | ||
optimization: { | ||
...webpackConfig.optimization, | ||
// disable module concatenation so that instances of `__()` are not renamed | ||
concatenateModules: false, | ||
}, | ||
plugins: [ | ||
...webpackConfig.plugins.filter( | ||
( plugin ) => plugin.constructor.name !== 'DependencyExtractionWebpackPlugin' | ||
), | ||
new webpack.DefinePlugin( { | ||
__i18n_text_domain__: JSON.stringify( 'default' ), | ||
} ), | ||
new DependencyExtractionWebpackPlugin( { | ||
injectPolyfill: true, | ||
outputFormat: 'json', | ||
} ), | ||
new GenerateChunksMapPlugin( { | ||
output: path.resolve( './dist/chunks-map.json' ), | ||
} ), | ||
new ReadableJsAssetsWebpackPlugin(), | ||
], | ||
}; | ||
} | ||
|
||
module.exports = getWebpackConfig; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is still needed after WordPress/gutenberg#65292. Depends on whether
@wordpress/babel-preset-default
is used I think.