-
Notifications
You must be signed in to change notification settings - Fork 70
fix(tooling): add type checking in ccwidgets #444
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
Changes from 13 commits
aaadc2c
93b8b19
95c6c9f
22cd406
3a23ad7
ec89fa3
e66a7ce
e60dc5c
bb2940f
f76d557
13b133d
ceb69da
58feae4
139f307
60a8c3b
5d6c359
fb6b254
f15b833
c752335
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| "description": "Webex Contact Center UI Components Library for your custom contact center solutions", | ||
| "version": "1.28.0-ccwidgets.91", | ||
| "main": "dist/index.js", | ||
| "types": "dist/types/index.d.ts", | ||
|
Contributor
Author
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. Added this to point to types, so that when this is consumed it is consumed with proper types |
||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
|
|
@@ -20,7 +21,7 @@ | |
| "build": "yarn run -T tsc", | ||
| "build:src": "yarn run clean:dist && webpack", | ||
| "build:watch": "webpack --watch", | ||
| "test:unit": "jest --coverage", | ||
| "test:unit": "tsc --project tsconfig.test.json && jest --coverage", | ||
|
Contributor
Author
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. While building - build:src uses webpack and webpack confirms that the types are correct |
||
| "test:styles": "eslint" | ||
| }, | ||
| "dependencies": { | ||
|
|
@@ -39,6 +40,7 @@ | |
| "@testing-library/react": "16.0.1", | ||
| "@types/jest": "29.5.14", | ||
| "@types/react-test-renderer": "18", | ||
| "@webex/test-fixtures": "workspace:*", | ||
| "babel-loader": "9.2.1", | ||
| "eslint": "^9.20.1", | ||
| "eslint-config-prettier": "^10.0.1", | ||
|
|
@@ -65,4 +67,4 @@ | |
| "react": ">=18.3.1", | ||
| "react-dom": ">=18.3.1" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,16 +27,3 @@ export const StationLoginLabels = { | |
| export const SignInErrors = { | ||
| ['DUPLICATE_LOCATION']: 'This extension is already in use.', | ||
| }; | ||
|
|
||
| // Utility consts | ||
| const DIALNUMBER: string = 'AGENT_DN'; | ||
| const EXTENSION: string = 'EXTENSION'; | ||
| const DESKTOP: string = 'BROWSER'; | ||
|
|
||
| const LoginOptions: {[key: string]: string} = { | ||
| [DIALNUMBER]: 'Dial Number', | ||
| [EXTENSION]: 'Extension', | ||
| [DESKTOP]: 'Desktop', | ||
| }; | ||
|
|
||
| export {DIALNUMBER, EXTENSION, DESKTOP, LoginOptions}; | ||
|
Comment on lines
-30
to
-42
Contributor
Author
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. Moved to cc-store, this is defined in cc-station-login and being used in cc-components creating a dependency and cc-component is a dependency in cc-station-login for the StationLoginComponenet hence we hade created a circular dependency |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| import React, {useEffect, useState} from 'react'; | ||
| import {StationLoginComponentProps} from './station-login.types'; | ||
| import './station-login.style.scss'; | ||
| import {DESKTOP, LoginOptions, SignInErrors, StationLoginLabels} from './constants'; | ||
| import {SignInErrors, StationLoginLabels} from './constants'; | ||
| import {LoginOptions, DESKTOP} from '@webex/cc-store'; | ||
|
Comment on lines
+4
to
+5
Contributor
Author
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. Moved to cc-store |
||
| import {Button, Icon, Select, Option, Text, Tooltip, Input} from '@momentum-design/components/dist/react'; | ||
| import { | ||
| ccCancelButtonClicked, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import {IContactCenter, StationLoginSuccess, StationLogoutSuccess, Team} from '@webex/plugin-cc'; | ||
| import {ILogger} from '@webex/cc-store'; | ||
| import {StationLoginSuccessResponse, LogoutSuccess} from '@webex/plugin-cc'; | ||
| import {IContactCenter, ILogger} from '@webex/cc-store'; | ||
| import {Team} from '@webex/plugin-cc/dist/types/types'; | ||
| /** | ||
| * Interface representing the properties for the Station Login component. | ||
| */ | ||
|
|
@@ -34,7 +35,7 @@ export interface IStationLoginProps { | |
| /** | ||
| * Response data received on agent login success | ||
| */ | ||
| loginSuccess?: StationLoginSuccess; | ||
| loginSuccess?: StationLoginSuccessResponse; | ||
|
Contributor
Author
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. This is the response of stationLogin method in the SDK |
||
|
|
||
| /** | ||
| * Error received on agent login failure | ||
|
|
@@ -44,7 +45,7 @@ export interface IStationLoginProps { | |
| /** | ||
| * Response data received on agent login success | ||
| */ | ||
| logoutSuccess?: StationLogoutSuccess; | ||
| logoutSuccess?: LogoutSuccess; | ||
|
Contributor
Author
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. This type is response type of stationLogout in the SDK |
||
|
|
||
| /** | ||
| * Flag to indicate if the agent is logged in | ||
|
|
@@ -199,11 +200,6 @@ export interface IStationLoginProps { | |
| * The selected team ID for login | ||
| */ | ||
| selectedTeamId: string; | ||
|
|
||
| /** | ||
| * The selected option for login type (e.g., 'Extension', 'Agent DN', etc.) | ||
| */ | ||
| selectedOption: string; | ||
|
Contributor
Author
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. Not being used |
||
| } | ||
|
|
||
| export interface LoginOptionsState { | ||
|
|
@@ -245,5 +241,4 @@ export type StationLoginComponentProps = Pick< | |
| | 'setDialNumberValue' | ||
| | 'setSelectedTeamId' | ||
| | 'selectedTeamId' | ||
| | 'selectedOption' | ||
| >; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import React, {useMemo} from 'react'; | ||
|
|
||
| import {IUserState, AgentUserState} from './user-state.types'; | ||
| import {AgentUserState, UserStateComponentsProps} from './user-state.types'; | ||
|
Contributor
Author
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. IUserState is the base type with all props (for hooks and presentational), UserStateComponentsPrps is a subset of IUserState |
||
| import {formatTime} from '../../utils'; | ||
|
|
||
| import './user-state.scss'; | ||
|
|
@@ -18,7 +18,7 @@ import { | |
| buildDropdownItems, | ||
| } from './user-state.utils'; | ||
|
|
||
| const UserStateComponent: React.FunctionComponent<IUserState> = (props) => { | ||
| const UserStateComponent: React.FunctionComponent<UserStateComponentsProps> = (props) => { | ||
| const { | ||
| idleCodes, | ||
| setAgentStatus, | ||
|
|
@@ -51,6 +51,7 @@ const UserStateComponent: React.FunctionComponent<IUserState> = (props) => { | |
| > | ||
| {(item) => { | ||
| const isRonaOrEngaged = [AgentUserState.RONA, AgentUserState.Engaged].includes( | ||
| //@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762 | ||
| idleCodes.find((code) => code.id === currentState)?.name || '' | ||
| ); | ||
| const shouldHighlight = currentState === item.id || (isRonaOrEngaged && item.id === previousSelectableState); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import {IdleCode, ICustomState, ILogger} from '@webex/cc-store'; | ||
| import {IdleCode, ICustomState, ILogger, IContactCenter} from '@webex/cc-store'; | ||
|
|
||
| /** | ||
| * Interface representing the state of a user. | ||
|
|
@@ -24,11 +24,6 @@ export interface IUserState { | |
| */ | ||
| isSettingAgentStatus: boolean; | ||
|
|
||
| /** | ||
| * The error message to display | ||
| */ | ||
| errorMessage: string; | ||
|
|
||
| /** | ||
| * The duration of the current user state | ||
| */ | ||
|
|
@@ -55,18 +50,49 @@ export interface IUserState { | |
| currentTheme: string; | ||
|
|
||
| /** | ||
| * Function to handle state change | ||
| * @param state The state to change to | ||
|
Contributor
Author
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. Fix the other borken types in user-state
Contributor
Author
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. Fixed all types in user-state |
||
| * @returns void | ||
| * Logger instance | ||
| */ | ||
| onStateChange: (state: string) => void; | ||
| logger: ILogger; | ||
|
|
||
| /** | ||
| * Logger instance | ||
| * Callback function to be called when the state changes. | ||
| * @param state The new state. | ||
| */ | ||
| logger: ILogger; | ||
| onStateChange?: (arg: IdleCode | ICustomState) => void; | ||
|
|
||
| /** | ||
| * The agent ID. | ||
| */ | ||
| agentId: string; | ||
|
|
||
| /** | ||
| * CC SDK Instance. | ||
| */ | ||
| cc: IContactCenter; | ||
|
|
||
| /** | ||
| * The timestamp of the last state change. | ||
| */ | ||
| lastStateChangeTimestamp?: number; | ||
|
|
||
| /** | ||
| * The timestamp of the last idle code change. | ||
| */ | ||
| lastIdleCodeChangeTimestamp?: number; | ||
|
Contributor
Author
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. These all were missing |
||
| } | ||
|
|
||
| export type UserStateComponentsProps = Pick< | ||
| IUserState, | ||
| | 'idleCodes' | ||
| | 'setAgentStatus' | ||
| | 'isSettingAgentStatus' | ||
| | 'elapsedTime' | ||
| | 'lastIdleStateChangeElapsedTime' | ||
| | 'currentState' | ||
| | 'customState' | ||
| | 'logger' | ||
| >; | ||
|
|
||
| export enum AgentUserState { | ||
| Available = 'Available', | ||
| RONA = 'RONA', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,11 @@ const CallControlCADComponent: React.FC<CallControlComponentProps> = (props) => | |
| const mediaChannel = currentTask.data.interaction.mediaType as MediaChannelType; | ||
| const isSocial = mediaChannel === MediaChannelType.SOCIAL; | ||
| const isTelephony = mediaChannel === MediaChannelType.TELEPHONY; | ||
|
|
||
| //@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762 | ||
| const customerName = currentTask?.data?.interaction?.callAssociatedDetails?.customerName; | ||
|
|
||
| //@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762 | ||
|
Contributor
Author
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. callAssociatedDetails is not present in the type of ITask in the SDK |
||
| const ani = currentTask?.data?.interaction?.callAssociatedDetails?.ani; | ||
|
|
||
| // Create unique IDs for tooltips | ||
|
|
@@ -187,12 +191,24 @@ const CallControlCADComponent: React.FC<CallControlComponentProps> = (props) => | |
| <div className="cad-variables"> | ||
| <Text className="queue" type="body-secondary" tagName={'small'}> | ||
| <strong>{QUEUE}</strong>{' '} | ||
| <span>{currentTask?.data?.interaction?.callAssociatedDetails?.virtualTeamName || NO_TEAM_NAME}</span> | ||
| <span> | ||
| { | ||
| //@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762 | ||
|
|
||
| currentTask?.data?.interaction?.callAssociatedDetails?.virtualTeamName || NO_TEAM_NAME | ||
| } | ||
| </span> | ||
| </Text> | ||
| {renderPhoneNumber()} | ||
| <Text className="rona" type="body-secondary" tagName={'small'}> | ||
| <strong>{RONA}</strong>{' '} | ||
| <span>{currentTask?.data?.interaction?.callAssociatedDetails?.ronaTimeout || NO_RONA}</span> | ||
| <span> | ||
| { | ||
| //@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762 | ||
|
|
||
| currentTask?.data?.interaction?.callAssociatedDetails?.ronaTimeout || NO_RONA | ||
| } | ||
| </span> | ||
| </Text> | ||
| </div> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ const IncomingTaskComponent: React.FunctionComponent<IncomingTaskComponentProps> | |
| return <></>; // hidden component | ||
| } | ||
|
|
||
| //@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762 | ||
|
Contributor
Author
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. callAssociatedDetails is not present in ITask |
||
| const callAssociationDetails = incomingTask?.data?.interaction?.callAssociatedDetails; | ||
| const ani = callAssociationDetails?.ani; | ||
| const customerName = callAssociationDetails?.customerName; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ const TaskListComponent: React.FunctionComponent<TaskListComponentProps> = (prop | |
| return ( | ||
| <ul className="task-list" data-testid="task-list"> | ||
| {Object.values(taskList)?.map((task, index) => { | ||
| //@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762IT | ||
|
Contributor
Author
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. callAssociatedDetails not in ITask |
||
| const callAssociationDetails = task?.data?.interaction?.callAssociatedDetails; | ||
| const ani = callAssociationDetails?.ani; | ||
| const customerName = callAssociationDetails?.customerName; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { | |
| ILogger, | ||
| ITask, | ||
| IContactCenter, | ||
| WrapupCodes, | ||
| IWrapupCode, | ||
| BuddyDetails, | ||
| DestinationType, | ||
| ContactServiceQueue, | ||
|
|
@@ -173,7 +173,7 @@ export interface ControlProps { | |
| * Array of wrap-up codes. | ||
| * TODO: Expose this type from SDK. | ||
| */ | ||
| wrapupCodes: WrapupCodes[]; | ||
| wrapupCodes: IWrapupCode[]; | ||
|
Contributor
Author
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. Incorrect type was assigned |
||
|
|
||
| /** | ||
| * Indicates if wrap-up is required. | ||
|
|
@@ -503,8 +503,6 @@ export interface CallControlConsultComponentsProps { | |
| */ | ||
| export type CallControlMenuType = 'Consult' | 'Transfer'; | ||
|
|
||
| export {DestinationType}; | ||
|
|
||
| export const MEDIA_CHANNEL = { | ||
| EMAIL: 'email', | ||
| CHAT: 'chat', | ||
|
|
||
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.
Not ignoring tsconfig.test.json. Will explain why this has been added in this file.