-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(plugin-cc): add agent logout #2
Conversation
740a4f0
to
57015ae
Compare
@@ -112,6 +112,7 @@ <h2 class="collapsible"> | |||
<input id="dialNumber" name="dialNumber" placeholder="Dial Number" value="" type="text"> | |||
<button id="loginAgent" disabled class="btn btn-primary my-3" onclick="doAgentLogin()">Login With | |||
Selected Team</button> | |||
<button id="logoutAgent" style="display: none;" class="btn btn-primary my-3 ml-2" onclick="logoutAgent()">Logout Agent</button> |
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.
Prefer using the already present 'hidden' class instead of display: none
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.
Done
this.webRTCCalling.deregisterWebCallingLine(); | ||
} | ||
|
||
return response; |
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.
Add a log for the success case
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.
this.agent.stationLogout
is already adding the success log. Adding here will add it twice.
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.
@rarajes2 , In that case, let's remove the logs from catch
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.
Done
|
||
try { | ||
const response = await this.agentService.stationLogout({ | ||
logoutReason, |
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.
The options param can be passed as is to agentService without the need for destructuring
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.
Done
eventType: 'Logout', | ||
success: ['AgentLogoutSuccess'], | ||
failure: ['AgentLogoutFailed'], |
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.
These strings can be constants
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.
Done
@@ -236,3 +236,16 @@ export type SubscribeResponse = { | |||
}; | |||
message: string | null; | |||
}; | |||
|
|||
export interface LogoutSuccess { | |||
eventType: 'AgentDesktopMessage'; |
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.
Use a constant for this string
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.
Done
subStatus: string; | ||
loggedOutBy?: string; | ||
roles?: string[]; | ||
type: 'AgentLogoutSuccess'; |
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.
Use a constant for this string
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.
Done
d09dc17
to
e8da707
Compare
|
||
return response; | ||
} catch (error) { | ||
return Promise.reject(error); |
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.
Add log for failures
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.
Done
2ece117
to
ac5285e
Compare
export const AgentDesktopMessage = 'AgentDesktopMessage'; | ||
|
||
export const LOGOUT_EVENT = 'Logout'; | ||
export const AgentLogoutSuccessEvent = 'AgentLogoutSuccess'; |
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.
Constant names should be in caps
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.
Done
@@ -56,4 +65,28 @@ export default class AgentService { | |||
return Promise.reject(error); | |||
} | |||
} | |||
|
|||
public async stationLogout(options: {logoutReason: string}): Promise<LogoutSuccess> { |
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.
The return value should be generic right, either the promise resolves or rejects indicating success or failure
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.
Done
|
||
public async stationLogout(options: {logoutReason: string}): Promise<LogoutSuccess> { | ||
try { | ||
const response = await this.agentService.stationLogout(options); |
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.
If 4xx or 5xx failure occurs, don't we need to handle that and reject promise
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.
Updated the code, now all the logic is in the service, this function simply calls it and returns. It's just one liner now
public async stationLogout(options: {logoutReason: string}): Promise<LogoutSuccess> { | ||
try { | ||
const response = await this.agentService.stationLogout(options); | ||
this.webex.logger.log('Logout API SUCCESS'); |
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.
It's better to say Logout Success and Logout Failure. We don't need to add API in the log messages.
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.
Done
@@ -34,4 +34,15 @@ export default class Agent { | |||
return Promise.reject(new Error('Error while performing agent login', error)); | |||
} | |||
} | |||
|
|||
public async stationLogout(options: {logoutReason: string}): Promise<LogoutSuccess> { |
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.
Let's call it data instead of options
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.
Done
|
||
describe('#stationLogout', () => { |
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.
We should have tests added for changes in the cc.ts file as well and the same goes for AgentService.ts. And we should cover the failure response test case also
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.
Added tests for cc
and AgentService
. Removed tests from Agent
as it's one liner now.
Build seems to be failing with below error: Is this being taken care in any of the PRs? Please add manual testing details in the PR description |
e8da707
to
1ec7373
Compare
1ec7373
to
61f790d
Compare
61f790d
to
f951248
Compare
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.
export const AgentDesktopMessage = 'AgentDesktopMessage'; | ||
|
||
export const LOGOUT_EVENT = 'Logout'; | ||
export const AGENT_LOGOUT_SUCCESS_EVENT = 'AgentLogoutSuccess'; |
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.
These could be moved within CC_EVENTS itself but check with Ravi if we would even need CC_EVENTS enum since we are moving the aqm code
|
||
return response; | ||
} catch (error) { | ||
this.webex.logger.error(`Station logout failed: ${error}`); |
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.
Would we need to have a try-catch block here? I believe we can just return response as it is that we get from httpRequest.sendRequestWithEvent()
* @returns Promise<LogoutSuccess> | ||
* @throws Error | ||
*/ | ||
public async stationLogout(data: {logoutReason: string}): Promise<StationLogoutResponse> { |
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.
Let's create a type for {logoutReason: string} as Logout similar and use that eveyrwhere
} | ||
|
||
return response; | ||
} catch (error) { |
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.
Would we need this catch block? I believe return response should suffice
Closing as this PR changes has been taken in Ravi's PR. |
* feat(cc-sdk): ported-code-for-health-check * feat(cc-sdk): fixed-broken-tests * feat(cc-sdk): fixed-blob-issue * feat(cc-sdk): merged-with-ravi-pr * feat(cc-sdk): re-added-cc-code * feat(cc-sdk): added-logger-proxy * feat(cc-sdk): added-config-values * feat(cc-sdk): added-connection-instance * feat(cc-sdk): added-event-listeners-instead-of-signals * feat(cc-sdk): fixed-broken-tests * feat(cc-sdk): fixed-test-coverage
COMPLETES #< SPARK-558556 >
This pull request addresses
Adds the Agent Station Logout feature
by making the following changes
Agent is able to Logout from station.
Change Type
The following scenarios where tested
Tested the station logout on the samples page after logging in with Browser.
I certified that
I have read and followed contributing guidelines
I discussed changes with code owners prior to submitting this pull request
I have not skipped any automated checks
All existing and new tests passed
I have updated the documentation accordingly
Make sure to have followed the contributing guidelines before submitting.