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

fix(service-portal): parliamentary refactor signee view #16030

Merged
merged 4 commits into from
Sep 17, 2024

Conversation

albinagu
Copy link
Member

@albinagu albinagu commented Sep 17, 2024

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Enhanced localization with new Icelandic messages for signature collection.
    • Introduced a title for parliamentary elections in Icelandic.
  • Bug Fixes

    • Removed unused imports and components from the OwnerView, improving maintainability.
  • Refactor

    • Restructured file organization for better modularity and code reuse.
    • Updated SignedList component to accept a currentCollection prop for dynamic rendering based on collection type.
  • Style

    • Adjusted the visual representation of the SkeletonLoader for a more compact layout.

@albinagu albinagu requested a review from a team as a code owner September 17, 2024 10:57
Copy link
Contributor

coderabbitai bot commented Sep 17, 2024

Walkthrough

The pull request introduces several modifications across multiple files within the signature collection module. Key changes include the localization of messages for Icelandic elections, the removal of unused components and hooks in the OwnerView, and adjustments to the SignedList component to enhance its adaptability. Additionally, several components related to user interactions, such as DeletePerson and LookupPerson, have been removed, streamlining the overall functionality. The visual representation of skeleton loaders has also been compacted for a cleaner user interface.

Changes

File Change Summary
libs/service-portal/signature-collection/src/lib/messages.ts Modified pageDescriptionSignee to Icelandic; added collectionTitleParliamentary for parliamentary elections.
libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx Removed unused imports and components (LookupPerson, DeletePerson, useGetListsForUser, useAuth), adjusted table layout.
libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/DeletePerson/index.tsx Removed DeletePerson modal component.
libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/LookupPerson/index.tsx Removed LookupPerson modal component.
libs/service-portal/signature-collection/src/screens/Parliamentary/SignedList/index.tsx Removed SignedList component.
libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx Updated imports and localization usage in SignatureListsParliamentary.
libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/index.tsx Modified import path for SignedList and updated its usage to include currentCollection prop.
libs/service-portal/signature-collection/src/screens/Presidential/SigneeView/index.tsx Removed SigneeView component.
libs/service-portal/signature-collection/src/screens/Presidential/index.tsx Updated import path for SigneeView.
libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx Modified SignedList to accept currentCollection prop for conditional rendering based on collection type.
libs/service-portal/signature-collection/src/screens/shared/SigneeView/index.tsx Updated SignedList usage to include currentCollection prop; removed date formatting logic.
libs/service-portal/signature-collection/src/skeletons.tsx Adjusted SkeletonLoader height, repeat count, and spacing for a more compact layout.

Possibly related PRs

Suggested labels

automerge, high priority


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 generate interesting stats about this repository and render them as a table.
    -- @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 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.
Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI o1 for code reviews: OpenAI's new o1 model is being tested for generating code suggestions in code reviews.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Copy link
Contributor

@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: 4

Outside diff range and nitpick comments (2)
libs/service-portal/signature-collection/src/skeletons.tsx (1)

Line range hint 9-12: Enhance component reusability by accepting props and defining prop types

The SkeletonTable component currently has hardcoded values for SkeletonLoader properties. Consider accepting these values as props to make the component more reusable across different NextJS apps. Additionally, defining prop types using TypeScript would improve type safety and clarity.

Apply this diff to refactor the component:

+type SkeletonTableProps = {
+  height?: number
+}

-export const SkeletonTable = () => {
+export const SkeletonTable = ({ height = 700 }: SkeletonTableProps) => {
  return (
    <Box marginTop={5}>
-     <SkeletonLoader height={700} borderRadius="large" />
+     <SkeletonLoader height={height} borderRadius="large" />
    </Box>
  )
}
libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx (1)

124-146: Improve accessibility of the modal dialog

To enhance accessibility, it's important to ensure that modals are announced properly to assistive technologies.

Consider using the dialog role and adding aria-modal attributes to the Modal component:

<Modal
  id="unSignList"
  isVisible={modalIsOpen}
  toggleClose={false}
  initialVisibility={false}
  onCloseModal={() => setModalIsOpen(false)}
+ aria-modal="true"
+ role="dialog"
>

Additionally, ensure that the modal has a clearly associated label, either through the aria-labelledby attribute or by including a heading within the modal content.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e8480d9 and ddac422.

Files selected for processing (12)
  • libs/service-portal/signature-collection/src/lib/messages.ts (2 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (1 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/DeletePerson/index.tsx (0 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/LookupPerson/index.tsx (0 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/SignedList/index.tsx (0 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx (2 hunks)
  • libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/index.tsx (2 hunks)
  • libs/service-portal/signature-collection/src/screens/Presidential/SigneeView/index.tsx (0 hunks)
  • libs/service-portal/signature-collection/src/screens/Presidential/index.tsx (1 hunks)
  • libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx (4 hunks)
  • libs/service-portal/signature-collection/src/screens/shared/SigneeView/index.tsx (2 hunks)
  • libs/service-portal/signature-collection/src/skeletons.tsx (1 hunks)
Files not reviewed due to no reviewable changes (4)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/DeletePerson/index.tsx
  • libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/LookupPerson/index.tsx
  • libs/service-portal/signature-collection/src/screens/Parliamentary/SignedList/index.tsx
  • libs/service-portal/signature-collection/src/screens/Presidential/SigneeView/index.tsx
Files skipped from review due to trivial changes (1)
  • libs/service-portal/signature-collection/src/screens/Presidential/index.tsx
Additional context used
Path-based instructions (7)
libs/service-portal/signature-collection/src/skeletons.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/service-portal/signature-collection/src/screens/shared/SigneeView/index.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/index.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/service-portal/signature-collection/src/lib/messages.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
Additional comments not posted (11)
libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx (4)

15-15: Initialization of the localization namespace is appropriate

Calling useNamespaces('sp.signatureCollection') correctly sets up the localization context for this component, enhancing the handling of translation strings.


10-10: Confirm the updated import path for SigneeView

The SigneeView component is now imported from '../shared/SigneeView'. Ensure that the component exists at this new location and that all references are updated accordingly.

You can verify the existence of the component at the new path with the following script:

Verification successful

Import path for SigneeView is correct and verified

The SigneeView component exists at libs/service-portal/signature-collection/src/screens/shared/SigneeView/index.tsx, and the import statement import SigneeView from '../shared/SigneeView' in the Parliamentary screen component is correct. This import path is also consistently used in the Presidential screen component.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if 'SigneeView' exists in the shared directory.

# Test: Look for 'SigneeView' files in the shared directory.
fd --type f --name 'SigneeView.*' libs/service-portal/signature-collection/src/shared/

Length of output: 339


Script:

#!/bin/bash
# Description: Check for SigneeView files and references

# Search for SigneeView files in the shared directory
echo "Searching for SigneeView files:"
fd SigneeView libs/service-portal/signature-collection/src/shared

# Search for SigneeView references in the signature-collection directory
echo "Searching for SigneeView references:"
rg "SigneeView" libs/service-portal/signature-collection

Length of output: 1159


25-25: Ensure m.pageTitleParliamentary is defined in messages

The title prop now uses formatMessage(m.pageTitleParliamentary). Please verify that pageTitleParliamentary is defined in your messages file and that it includes the necessary translations.

Use the following script to check for the message definition:

Verification successful

pageTitleParliamentary is correctly defined in messages

The message pageTitleParliamentary is properly defined in the file libs/service-portal/signature-collection/src/lib/messages.ts on line 266. This confirms that the usage of formatMessage(m.pageTitleParliamentary) in the component is correct and should work as intended.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Confirm that 'pageTitleParliamentary' exists in the messages.

# Test: Search for 'pageTitleParliamentary' in message files.
fd --type f --name 'messages.ts' | xargs grep 'pageTitleParliamentary'

Length of output: 319


Script:

#!/bin/bash
# Description: Verify the existence of 'pageTitleParliamentary' in message files

# Search for 'messages.ts' files and look for various forms of 'pageTitleParliamentary'
fd -t f 'messages.ts' | xargs grep -n -E '(m\.)?pageTitleParliamentary(:|\s*=)'

# If the above doesn't find anything, perform a broader search
if [ $? -ne 0 ]; then
  echo "Broader search:"
  fd -t f -e ts -e js | xargs grep -n -E '(m\.)?pageTitleParliamentary'
fi

Length of output: 190


2-2: Verify the usage of useNamespaces for localization

The addition of useNamespaces suggests that this component now relies on a specific localization namespace. Please ensure that the 'sp.signatureCollection' namespace is correctly defined and includes all necessary translation strings.

You can run the following script to confirm the existence of the namespace:

Verification successful

Verified: The 'sp.signatureCollection' namespace is correctly implemented and used

The addition of useNamespaces('sp.signatureCollection') in the file libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx is correct and consistent with the implementation throughout the signature-collection module. The namespace is properly defined in the messages file and used in multiple components within the module. This change ensures that the component has access to the necessary translations for the signature collection feature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the 'sp.signatureCollection' namespace exists in localization files.

# Test: Search for definitions of 'sp.signatureCollection' in all JSON files.
fd --type f --name '*.json' | xargs grep '"sp.signatureCollection"'

Length of output: 320


Script:

#!/bin/bash
# Description: Verify that the 'sp.signatureCollection' namespace exists in localization files.

# Search for 'sp.signatureCollection' in JSON files
echo "Searching for 'sp.signatureCollection' namespace:"
find . -name '*.json' -type f -print0 | xargs -0 grep -H '"sp\.signatureCollection"'

echo -e "\nSearching for 'sp' namespace (potential parent):"
find . -name '*.json' -type f -print0 | xargs -0 grep -H '"sp":'

echo -e "\nListing all JSON files in the repository:"
find . -name '*.json' -type f

Length of output: 135771


Script:

#!/bin/bash
# Search for 'sp.signatureCollection' namespace in TypeScript and JavaScript files
echo "Searching for 'sp.signatureCollection' namespace in TS/JS files:"
find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" \) -print0 | xargs -0 grep -H "sp\.signatureCollection"

echo -e "\nSearching for files that might define or use 'useNamespaces':"
find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" \) -print0 | xargs -0 grep -H "useNamespaces"

echo -e "\nListing files in the signature-collection directory:"
find ./libs/service-portal/signature-collection -type f

Length of output: 53637

libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/index.tsx (2)

20-20: Import statement updated correctly

The SignedList component import has been updated to reflect the new directory structure, which enhances modularity and promotes better code organization.


88-90: Proper use of the SignedList component with currentCollection prop

The SignedList component is correctly utilized with the currentCollection prop, and the conditional rendering based on !user?.profile.actor ensures it displays appropriately for users without an actor profile.

libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx (1)

Line range hint 45-53: Handle cases where multiple signed lists are present

In the mutation variables for unSign, the listId is set only when there is exactly one signed list. If there are multiple signed lists or none, listId becomes undefined, which may cause unintended behavior or errors during the mutation.

Consider enhancing the logic to handle multiple signed lists appropriately. You might prompt the user to select which list they wish to un-sign or provide feedback if un-signing cannot proceed.

Please verify that the backend handles an undefined listId gracefully and that appropriate error messages are displayed to the user.

libs/service-portal/signature-collection/src/lib/messages.ts (2)

19-19: Update to pageDescriptionSignee default message looks good

The new message provides clearer instructions to the user in Icelandic.


32-36: Addition of collectionTitleParliamentary message is appropriate

The new message supports the parliamentary elections feature and follows the existing naming conventions.

libs/service-portal/signature-collection/src/screens/shared/SigneeView/index.tsx (2)

46-46: Passing currentCollection to SignedList component

Passing the currentCollection prop to the SignedList component enhances its contextual awareness and allows it to render information specific to the current signature collection.


63-66: Conditional rendering of text based on collection type

The conditional rendering of the text prop ensures that the correct message is displayed for presidential or parliamentary collections, providing users with contextually appropriate information.

Copy link
Member

@juni-haukur juni-haukur left a comment

Choose a reason for hiding this comment

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

MVP 🚀

@albinagu albinagu added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Sep 17, 2024
@kodiakhq kodiakhq bot merged commit e7fc253 into main Sep 17, 2024
25 checks passed
@kodiakhq kodiakhq bot deleted the sp_parliamentary_refactor branch September 17, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants