-
Notifications
You must be signed in to change notification settings - Fork 62
feat(cc-digital-channel): add-new-package #586
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
Open
akulakum
wants to merge
14
commits into
webex:next
Choose a base branch
from
akulakum:CC_DIGITAL_CHANNEL
base: next
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 all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
43946ca
feat(cc-digital-channel): add-new-package
akulakum eb2e774
feat(cc-digital-channel): update-yarn-lock-file
akulakum 1bca291
feat(cc-digital-channel): remove-static-values
akulakum 7a694f1
feat(cc-digital-channel): fix-digital-channel-responsive
akulakum efb887c
Merge branch 'next' into CC_DIGITAL_CHANNEL
akulakum 5ab4742
feat(cc-digital-channel): initalize-digital-app-once
akulakum f8f12a7
feat(cc-digital-channel): change-from-vite-to-weback-config
akulakum f0432e0
feat(cc-digital-channel): update-yarn-yml-file
akulakum 598aa3f
feat(cc-digital-channel): add-presentational-layer
akulakum 6273e60
Merge branch 'next' into CC_DIGITAL_CHANNEL
akulakum d3e037d
feat(cc-digital-channel): fix-style-issue
akulakum cd2bbd7
feat(cc-digital-channel): update-beta-version
akulakum 199a7e0
feat(cc-digital-channel): add-visual-rebrand
akulakum 10fca07
Merge branch 'next' into CC_DIGITAL_CHANNEL
akulakum 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,4 +1,9 @@ | ||
| yarnPath: .yarn/releases/yarn-4.5.1.cjs | ||
| checksumBehavior: update | ||
| nodeLinker: node-modules | ||
| npmRegistryServer: "https://registry.npmjs.org" | ||
|
|
||
| npmScopes: | ||
| webex: | ||
| npmRegistryServer: 'https://engci-maven-master.cisco.com/artifactory/api/npm/webex-release-npm/' | ||
| npmAuthToken: 'ACCESS_TOKEN_PLACEHOLDER' | ||
| npmAlwaysAuth: true |
This file contains hidden or 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
20 changes: 20 additions & 0 deletions
20
packages/contact-center/cc-digital-channels/eslint.config.mjs
This file contains hidden or 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,20 @@ | ||
| import globals from 'globals'; | ||
| import pluginJs from '@eslint/js'; | ||
| import tseslint from 'typescript-eslint'; | ||
| import pluginReact from 'eslint-plugin-react'; | ||
| import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; | ||
| import eslintConfigPrettier from 'eslint-config-prettier'; | ||
|
|
||
| export default [ | ||
| {files: ['**/src/**/*.{js,mjs,cjs,ts,jsx,tsx}']}, | ||
| {ignores: ['.babelrc.js', '*config.{js,ts}', 'dist', 'node_modules', 'coverage']}, | ||
| {languageOptions: {globals: globals.browser}}, | ||
| pluginJs.configs.recommended, | ||
| ...tseslint.configs.recommended, | ||
| { | ||
| ...pluginReact.configs.flat.recommended, | ||
| settings: {react: {version: 'detect'}}, | ||
| }, | ||
| eslintPluginPrettierRecommended, | ||
| eslintConfigPrettier, | ||
| ]; |
This file contains hidden or 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,9 @@ | ||
| const jestConfig = require('../../../jest.config.js'); | ||
|
|
||
| jestConfig.rootDir = '../../../'; | ||
| jestConfig.testMatch = ['**/cc-digital-channels/tests/**/*.ts', '**/cc-digital-channels/tests/**/*.tsx']; | ||
| jestConfig.transformIgnorePatterns = [ | ||
| '/node_modules/(?!(@momentum-design/components|@momentum-ui/web-components|@momentum-ui/react-collaboration|@lit|lit|cheerio|@popperjs|@webex-engage|@interactjs|react-error-boundary))', | ||
| ]; | ||
|
|
||
| module.exports = jestConfig; |
This file contains hidden or 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,72 @@ | ||
| { | ||
| "name": "@webex/cc-digital-channels", | ||
| "description": "Webex Contact Center Widgets: Digital Channels", | ||
| "license": "Cisco's General Terms (https://www.cisco.com/site/us/en/about/legal/contract-experience/index.html)", | ||
| "version": "1.28.0-ccwidgets.126", | ||
| "main": "dist/index.js", | ||
| "types": "dist/types/index.d.ts", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "files": [ | ||
| "dist/", | ||
| "package.json" | ||
| ], | ||
| "scripts": { | ||
| "clean": "rm -rf dist && rm -rf node_modules", | ||
| "clean:dist": "rm -rf dist", | ||
| "build": "yarn run -T tsc", | ||
| "build:src": "yarn run clean:dist && yarn run build && webpack", | ||
| "build:watch": "webpack --watch", | ||
| "test:unit": "jest --coverage", | ||
| "test:styles": "eslint", | ||
| "deploy:npm": "yarn npm publish" | ||
| }, | ||
| "dependencies": { | ||
| "@webex/cc-digital-interactions": "3.0.4-beta.3", | ||
| "@webex/cc-store": "workspace:*", | ||
| "mobx-react-lite": "^4.1.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@babel/core": "7.25.2", | ||
| "@babel/preset-env": "7.25.4", | ||
| "@babel/preset-react": "7.24.7", | ||
| "@babel/preset-typescript": "7.25.9", | ||
| "@eslint/js": "^9.20.0", | ||
| "@testing-library/dom": "10.4.0", | ||
| "@testing-library/jest-dom": "6.6.2", | ||
| "@testing-library/react": "16.0.1", | ||
| "@types/jest": "29.5.14", | ||
| "@webex/test-fixtures": "workspace:*", | ||
| "babel-jest": "29.7.0", | ||
| "babel-loader": "9.2.1", | ||
| "css-loader": "7.1.2", | ||
| "eslint": "^9.20.1", | ||
| "eslint-config-prettier": "^10.0.1", | ||
| "eslint-config-standard": "^17.1.0", | ||
| "eslint-plugin-import": "^2.25.2", | ||
| "eslint-plugin-n": "^15.0.0 || ^16.0.0 ", | ||
| "eslint-plugin-prettier": "^5.2.3", | ||
| "eslint-plugin-promise": "^6.0.0", | ||
| "eslint-plugin-react": "^7.37.4", | ||
| "globals": "^16.0.0", | ||
| "jest": "29.7.0", | ||
| "jest-environment-jsdom": "29.7.0", | ||
| "prettier": "^3.5.1", | ||
| "sass": "1.79.5", | ||
| "sass-loader": "16.0.2", | ||
| "style-loader": "4.0.0", | ||
| "ts-jest": "^29.1.1", | ||
| "ts-loader": "9.5.1", | ||
| "typescript": "5.6.3", | ||
| "typescript-eslint": "^8.24.1", | ||
| "webpack": "5.94.0", | ||
| "webpack-cli": "5.1.4", | ||
| "webpack-merge": "6.0.1" | ||
| }, | ||
| "peerDependencies": { | ||
| "@momentum-ui/web-components": "^2.23.35", | ||
| "react": ">=18.3.1", | ||
| "react-dom": ">=18.3.1" | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
...ages/contact-center/cc-digital-channels/src/digital-channels/DigitalChannelsComponent.tsx
This file contains hidden or 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,44 @@ | ||
| import React, {useMemo} from 'react'; | ||
| import Engage from '@webex/cc-digital-interactions'; | ||
|
|
||
| import '@momentum-ui/web-components'; | ||
| import {DigitalChannelsComponentProps} from './digital-channels.types'; | ||
|
|
||
| /** | ||
| * Presentation component for Digital Channels. | ||
| * Renders the Engage widget with proper theming. | ||
| */ | ||
| const DigitalChannelsComponent: React.FunctionComponent<DigitalChannelsComponentProps> = ({ | ||
| conversationId, | ||
| jwtToken, | ||
| dataCenter, | ||
| currentTheme = 'DARK', | ||
| isVisualRebrand = true, | ||
| }) => { | ||
| // Create a stable key based on critical props to force remount when they change | ||
| // This prevents issues with the Froala editor trying to cleanup/reinitialize improperly | ||
| const componentKey = useMemo(() => { | ||
| return `${conversationId}-${jwtToken.slice(-8)}-${dataCenter}`; | ||
| }, [conversationId, jwtToken, dataCenter]); | ||
|
|
||
| const isDarkTheme = currentTheme === 'DARK'; | ||
|
|
||
| return ( | ||
| <div> | ||
| <md-theme id="app-theme" theme="momentumV2" {...(isDarkTheme ? {darktheme: true} : {lighttheme: true})}> | ||
| <Engage | ||
| key={componentKey} | ||
| conversationId={conversationId} | ||
| jwtToken={jwtToken} | ||
| dataCenter={dataCenter} | ||
| interactionId="" | ||
| readonly={false} | ||
| theme={isDarkTheme ? 'dark' : 'light'} | ||
| isVisualRebrand={isVisualRebrand} | ||
| /> | ||
| </md-theme> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export {DigitalChannelsComponent}; |
41 changes: 41 additions & 0 deletions
41
packages/contact-center/cc-digital-channels/src/digital-channels/digital-channels.types.ts
This file contains hidden or 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,41 @@ | ||
| import {ITask} from '@webex/cc-store'; | ||
|
|
||
| export interface UseDigitalChannelsInitProps { | ||
| currentTask: ITask; | ||
| jwtToken: string; | ||
| dataCenter: string; | ||
| onError?: (error: unknown) => boolean; | ||
| logger: { | ||
| log: (message: string, meta?: Record<string, unknown>) => void; | ||
| error: (message: string, error?: unknown, meta?: Record<string, unknown>) => void; | ||
| }; | ||
| isDigitalChannelsInitialized: boolean; | ||
| setDigitalChannelsInitialized: (value: boolean) => void; | ||
| } | ||
|
|
||
| export interface UseDigitalChannelsProps { | ||
| currentTask: ITask; | ||
| jwtToken: string; | ||
| dataCenter: string; | ||
| onError?: (error: unknown) => boolean; | ||
| logger?: { | ||
| log: (message: string, meta?: Record<string, unknown>) => void; | ||
| error: (message: string, error?: unknown, meta?: Record<string, unknown>) => void; | ||
| }; | ||
| } | ||
|
|
||
| export interface DigitalChannelsProps { | ||
| jwtToken: string; | ||
| dataCenter: string; | ||
| currentTheme?: string; | ||
| isVisualRebrand?: boolean; | ||
| onError?: (error: unknown) => boolean; | ||
| } | ||
|
|
||
| export interface DigitalChannelsComponentProps { | ||
| conversationId: string; | ||
| jwtToken: string; | ||
| dataCenter: string; | ||
| currentTheme?: string; | ||
| isVisualRebrand?: boolean; | ||
| } |
65 changes: 65 additions & 0 deletions
65
packages/contact-center/cc-digital-channels/src/digital-channels/index.tsx
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DigitalChannels dont follow the widget's design.
|
This file contains hidden or 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,65 @@ | ||
| import React from 'react'; | ||
| import {observer} from 'mobx-react-lite'; | ||
| import {ErrorBoundary} from 'react-error-boundary'; | ||
|
|
||
| import store from '@webex/cc-store'; | ||
| import {useDigitalChannels, useDigitalChannelsInit} from '../helper'; | ||
| import {DigitalChannelsComponent} from './DigitalChannelsComponent'; | ||
| import {DigitalChannelsProps} from './digital-channels.types'; | ||
|
|
||
| const DigitalChannelsInternal: React.FunctionComponent<DigitalChannelsProps> = observer( | ||
| ({jwtToken, dataCenter, currentTheme, isVisualRebrand = true, onError}) => { | ||
| const {logger, currentTask, isDigitalChannelsInitialized, setDigitalChannelsInitialized} = store; | ||
|
|
||
| if (!currentTask) { | ||
| return null; | ||
| } | ||
|
|
||
| const {initialized} = useDigitalChannelsInit({ | ||
| currentTask, | ||
| jwtToken, | ||
| dataCenter, | ||
| onError, | ||
| logger, | ||
| isDigitalChannelsInitialized, | ||
| setDigitalChannelsInitialized, | ||
| }); | ||
|
|
||
| const {conversationId} = useDigitalChannels({ | ||
| currentTask, | ||
| jwtToken, | ||
| dataCenter, | ||
| onError, | ||
| logger, | ||
| }); | ||
|
|
||
| if (!initialized || !conversationId) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <DigitalChannelsComponent | ||
| conversationId={conversationId} | ||
| jwtToken={jwtToken} | ||
| dataCenter={dataCenter} | ||
| currentTheme={currentTheme} | ||
| isVisualRebrand={isVisualRebrand} | ||
| /> | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| const DigitalChannels: React.FunctionComponent<DigitalChannelsProps> = (props) => { | ||
| return ( | ||
| <ErrorBoundary | ||
| fallbackRender={() => <></>} | ||
| onError={(error: Error) => { | ||
| if (store.onErrorCallback) store.onErrorCallback('DigitalChannels', error); | ||
| }} | ||
| > | ||
| <DigitalChannelsInternal {...props} /> | ||
| </ErrorBoundary> | ||
| ); | ||
| }; | ||
|
|
||
| export {DigitalChannels}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to wrap this in react-error-boundary |
||
103 changes: 103 additions & 0 deletions
103
packages/contact-center/cc-digital-channels/src/helper.ts
This file contains hidden or 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,103 @@ | ||
| import {useEffect, useState} from 'react'; | ||
| import {initializeApp} from '@webex/cc-digital-interactions'; | ||
|
|
||
| import {UseDigitalChannelsProps, UseDigitalChannelsInitProps} from './digital-channels/digital-channels.types'; | ||
|
|
||
| /** | ||
| * Hook to handle Digital Channels initialization. | ||
| * Ensures initialization happens only once per session using store flag. | ||
| */ | ||
| export const useDigitalChannelsInit = (props: UseDigitalChannelsInitProps) => { | ||
| const { | ||
| currentTask, | ||
| jwtToken, | ||
| dataCenter, | ||
| onError, | ||
| logger, | ||
| isDigitalChannelsInitialized, | ||
| setDigitalChannelsInitialized, | ||
| } = props; | ||
|
|
||
| const [initialized, setInitialized] = useState(isDigitalChannelsInitialized); | ||
|
|
||
| useEffect(() => { | ||
| const initialize = async () => { | ||
| // Initialize the digital channels app only once per session | ||
| if (!isDigitalChannelsInitialized) { | ||
| logger.log( | ||
| `[DIGITAL_CHANNELS_INIT] 🚀 Starting Digital Channels initialization for the FIRST TIME (dataCenter: ${dataCenter})...`, | ||
| { | ||
| module: 'cc-digital-channels', | ||
| method: 'useDigitalChannelsInit', | ||
| } | ||
| ); | ||
|
|
||
| try { | ||
| await initializeApp(dataCenter, jwtToken); | ||
| setDigitalChannelsInitialized(true); | ||
| setInitialized(true); | ||
| logger.log('[DIGITAL_CHANNELS_INIT] ✅ Digital Channels app initialized SUCCESSFULLY', { | ||
| module: 'cc-digital-channels', | ||
| method: 'useDigitalChannelsInit', | ||
| }); | ||
| } catch (error) { | ||
| const errorMessage = error instanceof Error ? error.message : 'Unknown error'; | ||
| logger.error(`[DIGITAL_CHANNELS_INIT] ❌ Failed to initialize Digital Channels app: ${errorMessage}`, { | ||
| module: 'cc-digital-channels', | ||
| method: 'useDigitalChannelsInit', | ||
| error, | ||
| }); | ||
| if (onError) { | ||
| onError(error); | ||
| } | ||
| } | ||
| } else { | ||
| logger.log('[DIGITAL_CHANNELS_INIT] ✅ App already initialized. Skipping re-initialization.', { | ||
| module: 'cc-digital-channels', | ||
| method: 'useDigitalChannelsInit', | ||
| }); | ||
| setInitialized(true); | ||
| } | ||
| }; | ||
|
|
||
| initialize(); | ||
| }, [currentTask]); | ||
|
|
||
| return {initialized}; | ||
| }; | ||
|
|
||
| /** | ||
| * Hook to derive props for Digital Channels component. | ||
| * Extracts conversationId and provides error handling. | ||
| */ | ||
| export const useDigitalChannels = (props: UseDigitalChannelsProps) => { | ||
| const {jwtToken, dataCenter, onError, logger, currentTask} = props; | ||
|
|
||
| const handleError = (error: unknown): boolean => { | ||
| const errorMessage = error instanceof Error ? error.message : 'Unknown error'; | ||
|
|
||
| logger?.error('Digital channels error', errorMessage, { | ||
| module: 'widget-cc-digital-channels#helper.ts', | ||
| method: 'handleError', | ||
| }); | ||
|
|
||
| if (onError) { | ||
| return onError(error); | ||
| } | ||
|
|
||
| // Default error handling | ||
| console.debug('Webex Engage component error:', errorMessage); | ||
| return false; // Prevent default error handling | ||
| }; | ||
|
|
||
| const conversationId = (currentTask.data.interaction as {callAssociatedDetails?: {mediaResourceId?: string}}) | ||
| .callAssociatedDetails?.mediaResourceId; | ||
|
|
||
| return { | ||
| name: 'DigitalChannels', | ||
| handleError, | ||
| conversationId, | ||
| jwtToken, | ||
| dataCenter, | ||
| }; | ||
| }; |
This file contains hidden or 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 @@ | ||
| import {DigitalChannels} from './digital-channels'; | ||
|
|
||
| export {DigitalChannels}; | ||
| export default DigitalChannels; |
Oops, something went wrong.
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 would suggest refering cc-statino-login or user-state's package.json rather than creating a new one.