Skip to content
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

Added logged email user on the extension #42

Merged
merged 7 commits into from
Jun 12, 2024

Conversation

NicoMorenoSirius
Copy link
Contributor

@NicoMorenoSirius NicoMorenoSirius commented Jun 12, 2024

This should be merged after https://github.com/Mocksi/nest/pull/10/files

image

Summary by CodeRabbit

  • New Features

    • Added an email property to the ContentApp and Popup components, allowing them to receive and utilize email values.
    • Introduced a new constant STORAGE_KEY with the value "mocksi-auth" for consistent key usage across the app.
  • Enhancements

    • Updated the Footer component to dynamically display the email value.

@elg0nz
Copy link
Contributor

elg0nz commented Jun 12, 2024

Copy link

coderabbitai bot commented Jun 12, 2024

Walkthrough

Walkthrough

The recent updates to the mocksi-lite application primarily involve adding an email property to various components and interfaces, allowing the application to handle and display user email addresses. Additionally, a new constant STORAGE_KEY has been introduced to manage storage-related functionalities. These changes enhance the application's ability to manage user-specific data more effectively.

Changes

File Path Change Summary
apps/mocksi-lite/content/ContentApp.tsx Added email property to ContentProps interface and updated ContentApp function signature.
apps/mocksi-lite/content/Popup/Footer.tsx Updated Footer component to accept and display email prop.
apps/mocksi-lite/content/Popup/index.tsx Added email property to PopupProps interface and updated Popup component.
apps/mocksi-lite/content/constants.ts Added new constant STORAGE_KEY and included it in the exports.
apps/mocksi-lite/consts.ts Added new constant STORAGE_KEY for storage management.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ContentApp
    participant Popup
    participant Footer

    User->>ContentApp: Opens ContentApp
    ContentApp->>Popup: Passes email prop
    Popup->>Footer: Passes email prop
    Footer->>Footer: Displays email
Loading

Poem

In the land of Mocksi, where data flows,
The email now shines, as everyone knows.
Constants were added, to keep things in line,
Storage keys set, everything's fine.
With changes so neat, the app grows and shows!


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

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: 2

Outside diff range and nitpick comments (1)
apps/mocksi-lite/content/ContentApp.tsx (1)

Line range hint 33-56: Consider simplifying the conditional rendering logic for better readability and maintainability.

- if (!isDialogOpen) return null;
- if (state === RecordingState.READY || state === RecordingState.CREATE) {
-   return (
-     <Popup
-       state={state}
-       label={recordingLabel(state)}
-       close={() => setIsDialogOpen(false)}
-       setState={onChangeState}
-       email={email}
-     />
-   );
- }
- // other conditions
+ return isDialogOpen ? (
+   <Popup
+     state={state}
+     label={recordingLabel(state)}
+     close={() => setIsDialogOpen(false)}
+     setState={onChangeState}
+     email={email}
+   />
+ ) : null;
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7feaa56 and 3181ce4.

Files selected for processing (5)
  • apps/mocksi-lite/content/ContentApp.tsx (3 hunks)
  • apps/mocksi-lite/content/Popup/Footer.tsx (1 hunks)
  • apps/mocksi-lite/content/Popup/index.tsx (1 hunks)
  • apps/mocksi-lite/content/constants.ts (1 hunks)
  • apps/mocksi-lite/content/content.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • apps/mocksi-lite/content/constants.ts
Additional comments not posted (6)
apps/mocksi-lite/content/Popup/Footer.tsx (2)

3-3: The addition of the email prop to the Footer component aligns well with the PR's objectives.


6-6: Displaying the email in the UI is a good touch for user awareness.

apps/mocksi-lite/content/Popup/index.tsx (2)

15-15: The addition of the email prop to the Popup component and its interface is consistent with the PR's objectives.

Also applies to: 18-18


18-18: Ensure that the email prop is being correctly passed to all child components that require it.

Verification successful

The search results indicate that the email prop is used in several files, including Popup/index.tsx and Popup/Footer.tsx. Specifically, the email prop is passed to the Footer component within the Popup component.

  • apps/mocksi-lite/content/Popup/index.tsx: The email prop is defined in the Popup component.
  • apps/mocksi-lite/content/Popup/Footer.tsx: The email prop is used in the Footer component.

This confirms that the email prop is being correctly passed to the Footer child component within the Popup component.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `email` prop is being correctly passed to all child components in the Popup component.

# Test: Search for the `email` prop usage within child components. Expect: Correct usage of the `email` prop.
rg --type typescript $'email'

Length of output: 63



Script:

#!/bin/bash
# Description: Verify that the `email` prop is being correctly passed to all child components in the Popup component.

# Test: Search for the `email` prop usage within TypeScript and TSX files. Expect: Correct usage of the `email` prop.
rg --type-add 'ts:*.{ts,tsx}' --type ts 'email'

Length of output: 1873

apps/mocksi-lite/content/content.tsx (1)

3-3: The integration of STORAGE_KEY for fetching the email and its usage in rendering the ContentApp component is well-implemented.

Also applies to: 23-32

apps/mocksi-lite/content/ContentApp.tsx (1)

14-14: The addition of the email prop to the ContentApp component and its usage in various conditions is well-implemented.

Also applies to: 33-56

return (
<div className={"h-[36px] flex items-center justify-end pr-3"}>
<div className={"text-[13px] text-[#5E5E5E] mr-2"}>jana@mocoso.com</div>
<div className={"text-[13px] text-[#5E5E5E] mr-2"}>{email}</div>
Copy link

Choose a reason for hiding this comment

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

Consider completing the onKeyUp event handler for accessibility.

- event.key === "Enter" && (() => undefined);
+ if (event.key === "Enter") logout();

Committable suggestion was skipped due to low confidence.

@@ -20,7 +20,16 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
root.unmount();
}
root = ReactDOM.createRoot(extensionRoot);
root.render(<ContentApp isOpen={true} sessionCookie={msg.loginToken} />);
chrome.storage.local.get(STORAGE_KEY).then((value) => {
const { email } = JSON.parse(value[STORAGE_KEY] || {});
Copy link

Choose a reason for hiding this comment

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

Consider adding error handling for JSON parsing to prevent runtime errors.

- const { email } = JSON.parse(value[STORAGE_KEY] || {});
+ let email;
+ try {
+   email = JSON.parse(value[STORAGE_KEY] || {}).email;
+ } catch (e) {
+   console.error('Failed to parse email:', e);
+ }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { email } = JSON.parse(value[STORAGE_KEY] || {});
let email;
try {
email = JSON.parse(value[STORAGE_KEY] || {}).email;
} catch (e) {
console.error('Failed to parse email:', e);
}

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3181ce4 and 1de3229.

Files selected for processing (1)
  • apps/mocksi-lite/content/Popup/index.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/mocksi-lite/content/Popup/index.tsx

@NicoMorenoSirius NicoMorenoSirius marked this pull request as ready for review June 12, 2024 17:35
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1de3229 and b9aac38.

Files selected for processing (5)
  • apps/mocksi-lite/consts.ts (1 hunks)
  • apps/mocksi-lite/content/ContentApp.tsx (3 hunks)
  • apps/mocksi-lite/content/Popup/Footer.tsx (1 hunks)
  • apps/mocksi-lite/content/Popup/index.tsx (2 hunks)
  • apps/mocksi-lite/content/content.tsx (2 hunks)
Files skipped from review due to trivial changes (2)
  • apps/mocksi-lite/consts.ts
  • apps/mocksi-lite/content/content.tsx
Files skipped from review as they are similar to previous changes (3)
  • apps/mocksi-lite/content/ContentApp.tsx
  • apps/mocksi-lite/content/Popup/Footer.tsx
  • apps/mocksi-lite/content/Popup/index.tsx

Copy link
Contributor

@elg0nz elg0nz left a comment

Choose a reason for hiding this comment

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

LGTM

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b9aac38 and f38b956.

Files selected for processing (3)
  • apps/mocksi-lite/consts.ts (1 hunks)
  • apps/mocksi-lite/content/ContentApp.tsx (3 hunks)
  • apps/mocksi-lite/content/content.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • apps/mocksi-lite/content/content.tsx
Files skipped from review as they are similar to previous changes (2)
  • apps/mocksi-lite/consts.ts
  • apps/mocksi-lite/content/ContentApp.tsx

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f38b956 and 7412be0.

Files selected for processing (2)
  • apps/mocksi-lite/content/ContentApp.tsx (3 hunks)
  • apps/mocksi-lite/content/content.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/mocksi-lite/content/ContentApp.tsx
  • apps/mocksi-lite/content/content.tsx

@NicoMorenoSirius NicoMorenoSirius merged commit d4d01af into main Jun 12, 2024
2 checks passed
@NicoMorenoSirius NicoMorenoSirius deleted the CU-86b0v7w21-showing-logged-email branch June 12, 2024 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants