Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(cc-widgets): added new incomingtask and task ui based on figma design #402

Merged
merged 10 commits into from
Mar 3, 2025

Conversation

cmullenx
Copy link

@cmullenx cmullenx commented Feb 28, 2025

COMPLETES # https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6035

This pull request addresses

UI for Task and IncomingTask

by making the following changes

  • Adds new Task component to share between IncomingTask and TaskList that matches the styling of the figma (except for the expand and collapse functionality) using MRV2 components

Non WebRTC UI
Screenshot 2025-02-28 at 7 02 08 AM

Screenshot 2025-02-28 at 7 53 04 AM

WebRTC UI
Screenshot 2025-02-28 at 6 59 57 AM
Screenshot 2025-02-28 at 7 52 16 AM

Multi Tabs
Screenshot 2025-03-03 at 9 05 04 AM
Screenshot 2025-03-03 at 9 05 04 AM

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

  • The testing is done with the amplify link
    Manually testing the UI locally

Checklist before merging

  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the testing document
  • I have tested the functionality with amplify link

Make sure to have followed the contributing guidelines before submitting.

Copy link

coderabbitai bot commented Feb 28, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

The pull request introduces several changes across multiple packages. In the root configuration, a new runtime dependency (Luxon) and its TypeScript type definitions have been added to the project. Several package.json files in different packages were updated with only newline additions at the end of the files. Significant refactoring occurred in the task-related components: the IncomingTaskPresentational component was simplified to use a newly created Task component, effectively moving from inline styles to a modular component-based approach. Alongside this, a new Task component was added with defined properties and conditional rendering, and a corresponding SCSS stylesheet was created for its styling. Additional modifications include the introduction of a new TaskTimer component, designed to compute and display time-based values using hooks. The overall changes focus on dependency updates, component modularization, and the extraction of inline styles into external stylesheets.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-402.d1b38q61t1z947.amplifyapp.com

@cmullenx cmullenx changed the title Ccwidgets feat(cc-widgets): added new incomingtask and task ui based on figma d… 9de08b9 …esign Feb 28, 2025
@cmullenx cmullenx changed the title feat(cc-widgets): added new incomingtask and task ui based on figma d… 9de08b9 …esign feat(cc-widgets): added new incomingtask and task ui based on figma design Feb 28, 2025
@rsarika
Copy link
Contributor

rsarika commented Mar 2, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Mar 2, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (6)
packages/contact-center/task/src/Task/styles.scss (1)

16-17: Consider avoiding !important for height override.

While the comment explains why you're using !important, this approach can lead to specificity issues and make styles harder to override when needed. Consider using more specific selectors or restructuring the CSS to avoid this.

- height: 80px !important;
+ height: 80px;

If there's a conflicting style from the Momentum framework, you might want to use a more specific selector to override it instead of using !important.

packages/contact-center/task/src/TaskTimer/index.tsx (1)

30-62: Simplify effect dependencies and optimize timer logic.

Your useEffect has running in the dependency array which could cause unexpected re-renders. Also, the timer cleanup can be simplified.

- useEffect(() => {
-   if (!running) {
-     return;
-   }
-
-   const updateDuration = () => {
+ useEffect(() => {
+   if (!running) {
+     return;
+   }
+   
+   let timeoutId: NodeJS.Timeout;
+   
+   const updateDuration = () => {
      const now = DateTime.utc();
      let diff: Duration;

      if (countdown && ronaTimeout !== undefined) {
        const end = start.plus({seconds: ronaTimeout});
        diff = end.diff(now);

        if (diff.toMillis() <= 0) {
          setDuration('00:00');
          setRunning(false);
          return;
        }
      } else {
        diff = now.diff(start);
      }

      setDuration(formatDuration(diff));

-     const timeoutId = setTimeout(updateDuration, 1000);
-
-     return () => clearTimeout(timeoutId);
+     timeoutId = setTimeout(updateDuration, 1000);
    };

    updateDuration();

-   return () => setRunning(false); // Ensure running state is cleaned up
- }, [countdown, ronaTimeout, startTimeStamp, running]);
+   return () => {
+     clearTimeout(timeoutId);
+     setRunning(false); // Ensure running state is cleaned up
+   };
+ }, [countdown, ronaTimeout, startTimeStamp, running, start]);

Also, note that I've added start to the dependency array since it's used in the effect.

packages/contact-center/task/src/Task/index.tsx (3)

33-35: Move utility function outside component.

The capitalizeFirstWord function is recreated on every render. Consider moving it outside the component to improve performance.

+ const capitalizeFirstWord = (str: string) => {
+   return str.replace(/^\s*(\w)/, (match, firstLetter) => firstLetter.toUpperCase());
+ };
+
 const Task: React.FC<TaskProps> = ({
   title,
   state,
   startTimeStamp,
   ronaTimeout,
   selected = false,
   isIncomingTask = false,
   queue,
   acceptTask,
   declineTask,
   isBrowser,
 }) => {
-  const capitalizeFirstWord = (str: string) => {
-    return str.replace(/^\s*(\w)/, (match, firstLetter) => firstLetter.toUpperCase());
-  };

66-74: Simplify conditional rendering logic.

The current conditional expression is complex and could be simplified for better readability.

- {/* Handle Time should render if it's an incoming call without ronaTimeout OR if it's not an incoming call */}
- {(isIncomingTask && !ronaTimeout) || !isIncomingTask
-   ? startTimeStamp && (
-       <Text tagName="span" type="body-midsize-regular" className="task-text task-text--secondary">
-         Handle Time: {'  '}
-         <TaskTimer startTimeStamp={startTimeStamp} />
-       </Text>
-     )
-   : null}
+ {/* Handle Time should render if it's an incoming call without ronaTimeout OR if it's not an incoming call */}
+ {((!isIncomingTask || !ronaTimeout) && startTimeStamp) && (
+   <Text tagName="span" type="body-midsize-regular" className="task-text task-text--secondary">
+     Handle Time: {'  '}
+     <TaskTimer startTimeStamp={startTimeStamp} />
+   </Text>
+ )}

86-96: Improve button rendering logic.

The conditional logic for displaying buttons could be simplified.

<ListItemBaseSection position="end">
-  {isIncomingTask ? (
-    <ButtonPill onPress={acceptTask} color="join" disabled={!isBrowser}>
-      Ringing
-    </ButtonPill>
-  ) : isBrowser ? (
-    <ButtonPill onPress={declineTask} color="join">
-      End
-    </ButtonPill>
-  ) : null}
+  {isIncomingTask && (
+    <ButtonPill onPress={acceptTask} color="join" disabled={!isBrowser}>
+      Ringing
+    </ButtonPill>
+  )}
+  {!isIncomingTask && isBrowser && (
+    <ButtonPill onPress={declineTask} color="join">
+      End
+    </ButtonPill>
+  )}
</ListItemBaseSection>
packages/contact-center/task/src/TaskList/task-list.presentational.tsx (1)

12-35: Verify presence of callAssociatedDetails and consider using stable keys.

  1. If callAssociatedDetails might be missing, destructuring it will cause a runtime error. Verify it’s always present, or add a fallback:
- const {ani, virtualTeamName, ronaTimeout} = task.data.interaction.callAssociatedDetails;
+ const {ani, virtualTeamName, ronaTimeout} =
+   task.data.interaction.callAssociatedDetails || {};
  1. Using the array index as a React key can lead to issues with item reordering. If interactionId (or another stable ID) is guaranteed unique, consider using it:
- key={index}
+ key={task.data.interactionId}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 58c154f and ecd9a8c.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (13)
  • package.json (2 hunks)
  • packages/contact-center/cc-components/package.json (1 hunks)
  • packages/contact-center/cc-widgets/package.json (1 hunks)
  • packages/contact-center/station-login/package.json (1 hunks)
  • packages/contact-center/store/package.json (1 hunks)
  • packages/contact-center/task/package.json (1 hunks)
  • packages/contact-center/task/src/IncomingTask/incoming-task.presentational.tsx (1 hunks)
  • packages/contact-center/task/src/Task/index.tsx (1 hunks)
  • packages/contact-center/task/src/Task/styles.scss (1 hunks)
  • packages/contact-center/task/src/TaskList/styles.scss (1 hunks)
  • packages/contact-center/task/src/TaskList/task-list.presentational.tsx (1 hunks)
  • packages/contact-center/task/src/TaskTimer/index.tsx (1 hunks)
  • packages/contact-center/user-state/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (7)
  • packages/contact-center/user-state/package.json
  • packages/contact-center/task/package.json
  • packages/contact-center/cc-widgets/package.json
  • packages/contact-center/station-login/package.json
  • packages/contact-center/task/src/TaskList/styles.scss
  • packages/contact-center/cc-components/package.json
  • packages/contact-center/store/package.json
🔇 Additional comments (8)
package.json (2)

20-20: Add Luxon TypeScript Definitions
The addition of @types/luxon in the devDependencies section improves type safety for Luxon usage in TypeScript. Ensure that the version (^3) aligns with the rest of the project's TypeScript definitions.


66-68: Include Luxon Runtime Dependency
The new dependency "luxon": "^3.5.0" in the dependencies section provides robust date and time utilities required by the new feature. Verify that this version is compatible with other packages and meets design expectations.

packages/contact-center/task/src/Task/styles.scss (1)

1-9: LGTM! Great support for light and dark mode.

The CSS custom property implementation with media query for dark mode is a clean approach to handle theme variations.

packages/contact-center/task/src/TaskTimer/index.tsx (1)

4-7: Improve formatDuration to handle edge cases.

The current implementation handles negative values correctly, but it could be more robust with additional checks.

The approach to prevent negative values and format based on the duration length is good practice.

packages/contact-center/task/src/Task/index.tsx (1)

8-19: Consider required props instead of optional.

Most props are marked as optional, but some might be required for proper rendering.

You've made all props optional which could lead to unexpected rendering states. Consider making critical props like title required if they're essential for proper component functionality. It's also helpful to add prop validation for required relationships (e.g., if isIncomingTask is true, then queue should be present).

packages/contact-center/task/src/IncomingTask/incoming-task.presentational.tsx (1)

16-25: LGTM! Great modularization with the new Task component.

The refactoring to use the new Task component simplifies the code and improves maintainability by encapsulating the task display logic.

packages/contact-center/task/src/TaskList/task-list.presentational.tsx (2)

3-4: Imports look clean and organized.
No issues found with adding Task and the external stylesheet.


7-8: Short-circuiting when the task list is empty is appropriate.
Returning an empty fragment avoids unnecessary rendering of markup.

@Shreyas281299 Shreyas281299 changed the title feat(cc-widgets): added new incomingtask and task ui based on figma design fix(cc-widgets): added new incomingtask and task ui based on figma design Mar 3, 2025
@Shreyas281299 Shreyas281299 changed the title fix(cc-widgets): added new incomingtask and task ui based on figma design feat(cc-widgets): added new incomingtask and task ui based on figma design Mar 3, 2025
Copy link

@Shreyas281299 Shreyas281299 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge the latest, that should fix the failing pipeline. Changes look good. LGTM!

@Shreyas281299 Shreyas281299 merged commit e69896a into webex:ccwidgets Mar 3, 2025
3 checks passed
@sreenara
Copy link
Contributor

sreenara commented Mar 3, 2025

🎉 This PR is included in version 1.28.0-ccwidgets.26 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

mkesavan13 pushed a commit to mkesavan13/widgets that referenced this pull request Mar 4, 2025
# [1.28.0-ccwidgets.26](webex/widgets@v1.28.0-ccwidgets.25...v1.28.0-ccwidgets.26) (2025-03-03)

### Features

* **cc-widgets:** added new incomingtask and task ui based on figma design ([webex#402](webex#402)) ([e69896a](webex@e69896a))
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants