Skip to content

docs(samples): unify the widgets sample apps #363

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

Merged
merged 4 commits into from
Jan 29, 2025

Conversation

rarajes2
Copy link
Contributor

@rarajes2 rarajes2 commented Jan 20, 2025

This PR unifies all the widget samples app on one page.

JIRA - SPARK-569245

The following has been done as part of this PR:

  • Created a widgets-samples directory and inside that we have
    • cc directory containing the samples-cc-react-app and samples-cc-wc-app
    • samples-meeting-app app
  • The above sample apps are with mono-repo setup and have their own webpack config and build:src command
  • Added a shell script which copies the samples build into docs directory to be hosted on the github page
  • Updated the samples:build command to create the build and copy the build to docs directory.
  • Removed the side nav bar (Left menu) from meetings samples app
  • Updated the webpack dev server config for samples-cc-wc-app and updated the serve command to utilize the webpack http dev server

Vidcast - https://app.vidcast.io/share/3a91518d-e682-4838-b621-f5c6666c0bc3

Summary by CodeRabbit

  • New Features

    • Added a new meeting sample application with Webex Widgets
    • Enhanced sample applications with updated configurations and serving options
  • Chores

    • Reorganized project workspace structure
    • Updated package names and build scripts
    • Modified CircleCI configuration for build process
  • Documentation

    • Updated copyright year in sample index page
    • Added new HTML and configuration files for sample applications

Copy link

coderabbitai bot commented Jan 20, 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

This pull request introduces significant changes to the project's workspace structure, build scripts, and sample applications. The modifications include renaming sample applications, updating build and serve commands, introducing a new meeting sample app, and reorganizing the directory structure. The changes aim to streamline the development workflow and provide more flexible sample applications for Webex widgets.

Changes

File/Path Change Summary
.circleci/config.yml Modified build command for @webex/widgets workspace
copy_to_docs.sh New script to automate documentation directory preparation
package.json Updated workspaces and scripts to accommodate new sample apps
packages/@webex/widgets/package.json Added clean and clean:dist scripts, modified build process
widgets-samples/cc/samples-cc-react-app/* Renamed from @webex/react-samples-app, updated configuration paths
widgets-samples/cc/samples-cc-wc-app/* Renamed from @webex/web-component-samples-app, updated serve and configuration paths
widgets-samples/index.html Updated links, added new link for meetings app, updated copyright year
widgets-samples/samples-meeting-app/* New sample application with React components, styles, and Webpack configuration

Sequence Diagram

sequenceDiagram
    participant User
    participant App
    participant WebexMeetingsWidget
    
    User->>App: Enter Access Token
    User->>App: Select Meeting Options
    App->>WebexMeetingsWidget: Configure Widget
    WebexMeetingsWidget-->>App: Widget Initialized
    User->>WebexMeetingsWidget: Interact with Meeting Controls
Loading

Possibly related PRs

Suggested reviewers

  • Shreyas281299

Poem

🐰 Hop, hop, build and deploy,
Widgets dancing with new joy!
Samples shine, configs align,
CodeRabbit's magic design so fine!
Serving meetings with a smile 🚀


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. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@rarajes2
Copy link
Contributor Author

@coderabbitai review

Copy link

coderabbitai bot commented Jan 20, 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: 6

🔭 Outside diff range comments (1)
packages/@webex/widgets/package.json (1)

⚠️ Suspicious React version detected - recommend immediate update

The specified React version (18.3.1) shows concerning signs of being potentially unofficial or compromised:

  • Missing publication date
  • Not listed in any official distribution tags
  • Unusual version number between stable releases

Recommend updating to either:

  • React 18.2.0 (latest stable in 18.x series)
  • React 19.0.0 (current stable release)
🔗 Analysis chain

Line range hint 1-150: Verify React version compatibility.

The specified React version (18.3.1) seems unusual as the latest stable version is 18.2.0.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if React version exists
curl -s https://registry.npmjs.org/react | jq '.versions | has("18.3.1")'

# List latest React versions for reference
curl -s https://registry.npmjs.org/react | jq -r '.["dist-tags"]'

Length of output: 391


Script:

#!/bin/bash
# Get details about React version 18.3.1
curl -s https://registry.npmjs.org/react/18.3.1 | jq '{
  version: .version,
  published: .time,
  description: .description,
  dist: .dist
}'

Length of output: 808

🧹 Nitpick comments (8)
widgets-samples/samples-meeting-app/src/App.jsx (2)

12-14: Consider consolidating token state.

Currently maintaining two separate states (tokenInput and token) for the same data. Consider using a single state with an additional boolean flag for editing mode.

-  const [tokenInput, setTokenInput] = useState('');
-  const [token, setToken] = useState();
+  const [token, setToken] = useState('');
+  const [isEditing, setIsEditing] = useState(true);

66-71: Enhance button accessibility.

The buttons could benefit from additional ARIA attributes and keyboard handling.

   <Button 
     color="blue" 
     type="submit" 
     onClick={handleSaveToken} 
     disabled={!!token} 
-    ariaLabel="Save Token"
+    ariaLabel="Save access token"
+    role="button"
+    onKeyPress={(e) => e.key === 'Enter' && handleSaveToken(e)}
   >
     Save Token
   </Button>
   <Button 
     type="button" 
     onClick={handleClearToken} 
     disabled={!token} 
-    ariaLabel="Clear Token"
+    ariaLabel="Clear access token"
+    role="button"
+    onKeyPress={(e) => e.key === 'Enter' && handleClearToken(e)}
   >
     Clear Token
   </Button>
widgets-samples/samples-meeting-app/webpack.config.js (1)

63-73: Remove commented code.

The commented file-loader configuration should either be implemented or removed to maintain clean code.

-        // {
-        //   test: /\.(woff(2)?|ttf|eot|svg|png|gif)(\?v=\d+\.\d+\.\d+)?$/,
-        //   use: [
-        //     {
-        //       loader: 'file-loader',
-        //       options: {
-        //         outputPath: 'assets/',
-        //       },
-        //     },
-        //   ],
-        // },
widgets-samples/samples-meeting-app/src/WebexMeetingsWidgetDemo.jsx (3)

9-26: Consider extracting iOS detection logic.

The iOS detection logic could be moved to a separate utility function for better maintainability and reusability.

+const isIOS151 = () => {
+  return typeof navigator !== 'undefined' && navigator.userAgent.includes('iPhone OS 15_1');
+};
+
 export default function WebexMeetingsWidgetDemo({token, fedramp}) {
   // ... other state declarations ...
-  const ON_IOS_15_1 = typeof navigator !== 'undefined'
-  && navigator.userAgent.includes('iPhone OS 15_1');
+  const ON_IOS_15_1 = isIOS151();

60-72: Modernize fullscreen handling.

The fullscreen implementation could be simplified and modernized:

 const handleFullscreen = () => {
   const demoWidget = document.querySelector('.webex-meeting-widget-demo');
-
-  if (demoWidget.requestFullscreen) {
-    demoWidget.requestFullscreen();
-  } else if (demoWidget.webkitRequestFullscreen) {
-    /* Safari */
-    demoWidget.current.webkitRequestFullscreen();
-  } else if (demoWidget.msRequestFullscreen) {
-    /* IE11 */
-    demoWidget.msRequestFullscreen();
-  }
+  if (!document.fullscreenElement) {
+    demoWidget.requestFullscreen?.() ||
+    demoWidget.webkitRequestFullscreen?.() ||
+    demoWidget.msRequestFullscreen?.();
+  }
 };

141-151: Enhance error handling in getHydraId.

The function could provide more detailed feedback about validation failures:

 const getHydraId = (destination) => {
   const { type, id, cluster } = deconstructHydraId(destination);
   const UUID_REG = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;

   if (id && UUID_REG.test(id) && type === "ROOM") {
     return { room: true, destination: id, cluster };
   }

-  return {};
+  return {
+    room: false,
+    error: !id ? 'Invalid ID format' :
+           !UUID_REG.test(id) ? 'Invalid UUID format' :
+           type !== "ROOM" ? 'Invalid room type' : 'Unknown error'
+  };
 };
package.json (1)

10-10: Simplify workspace path pattern.

The pattern widgets-samples/**/** is redundant. A single ** is sufficient for recursive matching.

-    "widgets-samples/**/**"
+    "widgets-samples/**/*"
widgets-samples/samples-meeting-app/package.json (1)

18-52: Consider optimizing devDependencies.

Some devDependencies might be redundant as they're already available in the root package.json:

  • webpack and related packages
  • babel packages
  • style loaders

Consider moving common devDependencies to the root package.json and removing them from individual packages to reduce installation time and ensure version consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61b5ea9 and c7c2faa.

⛔ Files ignored due to path filters (2)
  • widgets-samples/samples-meeting-app/src/webex-logo.png is excluded by !**/*.png
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (18)
  • .circleci/config.yml (1 hunks)
  • copy_to_docs.sh (1 hunks)
  • package.json (2 hunks)
  • packages/@webex/widgets/package.json (1 hunks)
  • widgets-samples/cc/samples-cc-react-app/package.json (1 hunks)
  • widgets-samples/cc/samples-cc-react-app/tsconfig.json (1 hunks)
  • widgets-samples/cc/samples-cc-react-app/webpack.config.js (1 hunks)
  • widgets-samples/cc/samples-cc-wc-app/package.json (2 hunks)
  • widgets-samples/cc/samples-cc-wc-app/tsconfig.json (1 hunks)
  • widgets-samples/cc/samples-cc-wc-app/webpack.config.js (2 hunks)
  • widgets-samples/index.html (2 hunks)
  • widgets-samples/samples-meeting-app/package.json (1 hunks)
  • widgets-samples/samples-meeting-app/src/App.jsx (1 hunks)
  • widgets-samples/samples-meeting-app/src/App.scss (1 hunks)
  • widgets-samples/samples-meeting-app/src/WebexMeetingsWidgetDemo.jsx (1 hunks)
  • widgets-samples/samples-meeting-app/src/WebexMeetingsWidgetDemo.scss (1 hunks)
  • widgets-samples/samples-meeting-app/src/index.html (1 hunks)
  • widgets-samples/samples-meeting-app/webpack.config.js (1 hunks)
✅ Files skipped from review due to trivial changes (6)
  • widgets-samples/cc/samples-cc-react-app/tsconfig.json
  • widgets-samples/samples-meeting-app/src/index.html
  • widgets-samples/cc/samples-cc-react-app/package.json
  • widgets-samples/cc/samples-cc-wc-app/tsconfig.json
  • widgets-samples/samples-meeting-app/src/WebexMeetingsWidgetDemo.scss
  • widgets-samples/samples-meeting-app/src/App.scss
🧰 Additional context used
🪛 Shellcheck (0.10.0)
copy_to_docs.sh

[warning] 14-14: Quote this to prevent word splitting.

(SC2046)

🔇 Additional comments (10)
widgets-samples/cc/samples-cc-wc-app/webpack.config.js (2)

4-4: Verify the base config import path.

The path change suggests directory restructuring. Ensure the new path correctly resolves to the base webpack config.

✅ Verification successful

Base config import path is correct

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the webpack.config.js exists at the new path
test -f webpack.config.js && echo "Base config exists at repository root" || echo "Base config not found"

Length of output: 112


Script:

#!/bin/bash
# Find the location of the webpack config file
fd -p "samples-cc-wc-app/webpack.config.js$"

Length of output: 101


17-20: Review the development server configuration changes.

The changes include:

  1. Serving static files from the root directory instead of public
  2. Disabling auto-browser opening
  3. Using port 4000 (avoiding conflict with React app on 3000)

Verify that static assets are properly organized in the root directory since we're no longer using the public directory.

✅ Verification successful

Static assets are properly organized, configuration changes are valid

The static assets are correctly organized within their respective module directories, with the main application files (index.html, app.js) located in the same directory as the webpack configuration. The development server configuration change to serve from the root directory is appropriate for this setup.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for static assets in the root directory
echo "Static assets in root directory:"
fd -t f -e html -e css -e js -e png -e ico -d 1

Length of output: 142


Script:

#!/bin/bash
# Check for public directory and static assets in project
echo "Checking project structure for static assets:"
fd -t f -e html -e css -e js -e png -e ico

echo -e "\nChecking webpack configuration:"
cat webpack.config.js

Length of output: 7943

widgets-samples/cc/samples-cc-react-app/webpack.config.js (1)

5-5: LGTM! Base config path updated consistently.

The import path change aligns with the directory restructuring seen in the web components app config.

widgets-samples/samples-meeting-app/webpack.config.js (1)

14-18: Uncomment and verify the docs output path.

The commented path for docs output suggests an incomplete implementation. Consider uncommenting and verifying the path if documentation hosting is required.

✅ Verification successful

Keep using the 'dist' directory configuration.

The commented docs path should remain commented out. Documentation building is handled by the root-level workspace build process through samples:build script and copy_to_docs.sh, not by individual sample app webpack configurations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if docs directory exists and is used
test -d docs && echo "Docs directory exists" || echo "Docs directory not found"

Length of output: 73


Script:

#!/bin/bash
# Check for README files and build documentation
echo "=== README files ==="
fd -t f "README.md" --exec head -n 20 {}

echo -e "\n=== Build related files ==="
fd -t f "(webpack|build|deploy)" --exec echo {}

echo -e "\n=== Checking for docs in package.json ==="
fd "package.json" --exec cat {} | jq -r 'select(.scripts != null) | .scripts | to_entries | .[] | select(.key | contains("doc") or contains("build") or contains("deploy")) | "\(.key): \(.value)"'

Length of output: 3656

widgets-samples/samples-meeting-app/src/WebexMeetingsWidgetDemo.jsx (1)

1-8: LGTM! Well-structured imports.

The component uses appropriate dependencies and follows React best practices.

widgets-samples/cc/samples-cc-wc-app/package.json (1)

2-2: LGTM! Package configuration aligns with project structure.

The changes to project name and serve command appropriately reflect the new unified structure using Webpack dev server.

Also applies to: 17-17

package.json (1)

44-47: LGTM! Build and test scripts properly handle new sample apps.

The scripts have been correctly updated to:

  1. Exclude sample apps from main test/build
  2. Include all sample apps in samples:build
  3. Run copy_to_docs.sh after building samples
packages/@webex/widgets/package.json (1)

10-12: LGTM! Clean and build scripts follow best practices.

The new scripts properly handle cleaning before building, which helps prevent stale artifacts.

widgets-samples/samples-meeting-app/package.json (1)

14-15: Verify React version consistency.

The same React version (18.3.1) is specified here. This should be verified and aligned with the core package.

.circleci/config.yml (1)

64-64: LGTM! Build command properly aligned with new script name.

The command has been correctly updated to use build:src instead of build, matching the changes in package.json.

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.

Looks good

@rarajes2 rarajes2 merged commit 20c9197 into webex:ccwidgets Jan 29, 2025
2 checks passed
@sreenara
Copy link
Contributor

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

The release is available on GitHub release

Your semantic-release bot 📦🚀

@sreenara
Copy link
Contributor

sreenara commented Feb 5, 2025

🎉 This PR is included in version 1.28.0-ccconnectors.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants