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(signature-collections): ongoing updates #16409

Merged
merged 7 commits into from
Oct 16, 2024
Merged

Conversation

albinagu
Copy link
Member

@albinagu albinagu commented Oct 15, 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
    • Added support for localization with a new message indicating "no supervisors" in the signature collection feature.
    • Enhanced the OwnerView component to conditionally render elements based on user status as a list holder.
  • Improvements
    • Updated rendering logic to provide clearer feedback when no supervisors are registered and to reflect the state of the list accurately.
    • Streamlined the user experience by removing unused sections related to managers and supervisors from the form structure.
    • Improved link generation in the CopyLink component to dynamically construct URLs based on application data.

@albinagu albinagu requested a review from a team as a code owner October 15, 2024 14:39
Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

Walkthrough

The changes in this pull request involve the addition of a new message for localization and modifications to the OwnerView component within the signature collection feature. A new property, isListHolder, is introduced to conditionally render components based on user delegation information. The SignatureListsParliamentary component is also updated to pass this new prop to OwnerView, enhancing its functionality by incorporating user-specific data. Additionally, the Draft form structure has been updated to remove sections related to managers and supervisors.

Changes

File Path Change Summary
libs/service-portal/signature-collection/src/lib/messages.ts Added new message noSupervisors with id, defaultMessage, and description for localization support.
libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx Updated OwnerView props to include isListHolder, modified rendering logic based on isListHolder and loadingOwnerLists.
libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx Added useUserInfo hook, initialized userInfo, and passed isListHolder prop to OwnerView based on delegationType.
libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts Removed buildTableRepeaterField import and commented out the managers section, disabling related fields and components.
libs/application/templates/signature-collection/parliamentary-list-creation/src/fields/CopyLink/index.tsx Updated CopyLink component to use slug from application data for dynamic link URL construction instead of hardcoded URL.

Possibly related PRs

Suggested reviewers

  • kksteini

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

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 15, 2024

Datadog Report

All test runs b553081 🔗

4 Total Test Services: 0 Failed, 4 Passed
➡️ Test Sessions change in coverage: 12 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 3.18s 1 no change Link
application-system-api 0 0 0 120 2 3m 10.25s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 34.03s 1 no change Link
application-ui-shell 0 0 0 74 0 36.93s 1 no change Link

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.71%. Comparing base (7a37f44) to head (26bd72a).
Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16409      +/-   ##
==========================================
- Coverage   36.73%   36.71%   -0.02%     
==========================================
  Files        6809     6810       +1     
  Lines      141088   141133      +45     
  Branches    40225    40235      +10     
==========================================
- Hits        51826    51819       -7     
- Misses      89262    89314      +52     
Flag Coverage Δ
api 3.37% <ø> (ø)
application-system-api 41.42% <ø> (ø)
application-template-api-modules 27.87% <ø> (-0.02%) ⬇️
application-ui-shell 21.35% <ø> (ø)
contentful-apps 5.44% <ø> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ae3dac...26bd72a. Read the comment docs.

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

🧹 Outside diff range and nitpick comments (3)
libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (2)

36-40: LGTM! Consider using interface for props.

The addition of the isListHolder prop and its TypeScript annotation is good. It enhances the component's reusability across different NextJS apps, as per our guidelines.

Consider defining an interface for the component props to improve code readability and maintainability:

interface OwnerViewProps {
  currentCollection: SignatureCollection;
  isListHolder: boolean;
}

const OwnerView = ({ currentCollection, isListHolder }: OwnerViewProps) => {
  // ...
}

Line range hint 133-180: LGTM! Consider simplifying the conditional logic.

The changes to the ActionCard tag rendering logic are good. They properly utilize the isListHolder prop and provide better user feedback based on the list's state.

To improve readability, consider simplifying the conditional logic:

tag={
  list.active
    ? (isListHolder
      ? {
          label: 'Cancel collection',
          renderTag: () => (
            // ... existing cancel collection dialog ...
          ),
        }
      : undefined)
    : {
        label: formatMessage(m.listSubmitted),
        variant: 'blueberry',
      }
}

This structure more clearly represents the three possible states: active and list holder, active but not list holder, and inactive.

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

364-368: LGTM! Consider adding a description for clarity.

The new noSupervisors message follows the existing structure and naming conventions. It's correctly defined using TypeScript and appears to be reusable across different NextJS apps within the signature collection feature.

Consider adding a brief description to the description field to provide context for translators or other developers. For example:

 noSupervisors: {
   id: 'sp.signatureCollection:noSupervisors',
   defaultMessage: 'Enginn umsjónaraðili skráður',
-  description: '',
+  description: 'Message displayed when no supervisors are registered for a signature collection.',
 },
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c21a58f and 1a076f7.

📒 Files selected for processing (3)
  • libs/service-portal/signature-collection/src/lib/messages.ts (1 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (5 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
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."
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/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."
🔇 Additional comments (5)
libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx (2)

12-13: LGTM: New imports enhance functionality and type safety

The added imports for useUserInfo and AuthDelegationType are appropriate for the new functionality. They align with the guidelines for reusability and TypeScript usage.


20-20: LGTM: User info retrieval added

The addition of userInfo using the useUserInfo hook is a good practice for accessing user-specific data. This aligns with React best practices and enhances the component's functionality.

libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (3)

Line range hint 86-92: LGTM! Improved conditional rendering.

The changes to the AddConstituency component's rendering logic are well-implemented. The use of isListHolder and !loadingOwnerLists ensures that the component is only rendered when appropriate, improving the overall user experience.


220-228: LGTM! Improved handling of empty collectors list.

The changes to the collectors rendering logic are well-implemented. The addition of a fallback text for when there are no supervisors improves the user experience and provides clear feedback. The use of formatMessage ensures proper localization, which is excellent.


Line range hint 1-265: Overall, excellent improvements to the OwnerView component.

The changes in this file enhance the functionality and flexibility of the OwnerView component. The addition of the isListHolder prop and the corresponding logic changes improve the component's ability to handle different user roles. The use of TypeScript for prop definitions and the consistent application of localization through formatMessage align well with our coding guidelines.

These changes maintain the component's reusability across different NextJS apps while adding more nuanced behavior based on user roles. The improved conditional rendering and better handling of edge cases (like empty collectors list) contribute to a better user experience.

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

🧹 Outside diff range and nitpick comments (1)
libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts (1)

284-287: LGTM! Consider improving readability.

The use of getValueViaPath for dynamic heading construction is a good improvement. It enhances flexibility and reusability of the component.

Consider using template literals for better readability:

heading: `${getValueViaPath(answers, 'list.name')} - ${c.split('|')[1]}`,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1a076f7 and 407969b.

📒 Files selected for processing (1)
  • libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.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 (2)
libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts (2)

Line range hint 1-338: Overall changes improve form structure and flexibility.

The modifications to this file, including the removal of the managers and supervisors section (as mentioned in the AI summary) and the enhancements to dynamic field construction, align well with the PR objectives. These changes simplify the form structure while improving its flexibility and reusability.

Some key points:

  1. The removal of unused sections reduces complexity.
  2. The use of getValueViaPath for dynamic content generation enhances flexibility.
  3. The overall structure maintaining list information, constituency selection, and overview sections remains intact.

These changes should contribute to a more maintainable and adaptable signature collection process.


16-19: LGTM! Verify usage of new imports.

The removal of buildTableRepeaterField and addition of Application and UserProfile imports align with the changes in the form structure. These changes appear to be correct.

Let's verify the usage of the new imports:

✅ Verification successful

Verification Successful: Imports are Used Correctly.
The Application and UserProfile imports are actively utilized in the codebase as confirmed by the shell script results.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of Application and UserProfile types

# Test: Search for usage of Application and UserProfile types
rg --type typescript 'Application' libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts
rg --type typescript 'UserProfile' libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts

Length of output: 329


Script:

#!/bin/bash
# Description: Verify usage of Application and UserProfile types

# Test: Search for usage of Application and UserProfile types in TypeScript files
rg --type ts 'Application' libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts
rg --type ts 'UserProfile' libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts

Length of output: 881

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

🧹 Outside diff range and nitpick comments (2)
libs/application/templates/signature-collection/parliamentary-list-creation/src/fields/CopyLink/index.tsx (2)

17-17: Approve dynamic URL construction with a minor suggestion.

The dynamic URL construction is a good improvement. However, to ensure proper URL formatting, consider adding a leading slash to the slug if it's not already present.

You could modify the URL construction like this:

`${document.location.origin}/${slug.startsWith('/') ? slug.slice(1) : slug}`

This ensures that there's always exactly one slash between the origin and the slug.


Line range hint 1-24: Enhance TypeScript usage for better type safety and documentation.

While the component adheres to the coding guidelines for libs/**/* files, there's room for improvement in TypeScript usage.

Consider the following enhancements:

  1. Define a more specific type for the application prop instead of using FieldBaseProps. This will provide better type safety and documentation.

  2. Export the component's prop type for reuse in other components.

Example:

import { Application } from '@island.is/application/types'

export interface CopyLinkProps {
  application: Application & {
    externalData: {
      createLists: {
        data: {
          slug: string
        }
      }
    }
  }
}

export const CopyLink: FC<CopyLinkProps> = ({ application }) => {
  // ... component logic
}

This change will improve type safety, make the component's requirements more explicit, and enhance reusability across different NextJS apps.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 407969b and 3b65a21.

📒 Files selected for processing (1)
  • libs/application/templates/signature-collection/parliamentary-list-creation/src/fields/CopyLink/index.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/templates/signature-collection/parliamentary-list-creation/src/fields/CopyLink/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."

@albinagu albinagu added the automerge Merge this PR as soon as all checks pass label Oct 16, 2024
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: 0

🧹 Outside diff range and nitpick comments (1)
libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts (1)

281-284: Improved heading clarity, consider extracting constituency name.

The changes enhance the heading by combining the list name and constituency name, which improves clarity for users. Good use of getValueViaPath for safe property access.

Consider extracting the constituency name for improved readability:

const constituencyName = c.split('|')[1];
heading: `${getValueViaPath(answers, 'list.name')} - ${constituencyName}`,

This minor refactoring would make the code slightly more readable and easier to maintain.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3b65a21 and 72f6949.

📒 Files selected for processing (2)
  • libs/application/templates/signature-collection/parliamentary-list-creation/src/fields/CopyLink/index.tsx (1 hunks)
  • libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/application/templates/signature-collection/parliamentary-list-creation/src/fields/CopyLink/index.tsx
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.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 (1)
libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts (1)

Line range hint 1-324: Verify removal of managers and supervisors sections.

The AI-generated summary mentioned the removal of sections related to managers and supervisors. However, these sections are not visible in the provided code snippet.

To ensure all changes are accounted for, please run the following script:

If the script returns any results, please review those sections to ensure they have been properly removed or updated as intended.

✅ Verification successful

Verify removal of managers and supervisors sections.

The search for "manager" and "supervisor" terms returned no results in Draft.ts, confirming that these sections have been successfully removed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to managers or supervisors in the file

# Test: Search for manager or supervisor related terms
rg --type typescript -i '(manager|supervisor)' libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts

# If no results are found, it confirms the removal of these sections

Length of output: 178


Script:

#!/bin/bash
# Description: Check for any remaining references to managers or supervisors in the file

# Test: Search for manager or supervisor related terms
rg -i '(manager|supervisor)' libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts

# If no results are found, it confirms the removal of these sections

Length of output: 125

@kodiakhq kodiakhq bot merged commit 330e4c1 into main Oct 16, 2024
44 checks passed
@kodiakhq kodiakhq bot deleted the tweaks_15.10_random branch October 16, 2024 09:54
kksteini pushed a commit that referenced this pull request Oct 16, 2024
* tweaks

* tweak - create list

* copylink

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
kodiakhq bot added a commit that referenced this pull request Oct 16, 2024
* fix(service-portal): company route signature collections (#16382)

* draft

* chore: nx format:write update dirty files

* fix: company path

* tweaks

* p

* view list company path

* chore: nx format:write update dirty files

* nav tweak

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: Ásdís Erna Guðmundsdóttir <[email protected]>

* fix(service-portal): sp list submitted (#16383)

* fix(service-portal): sp list submitted

* tweak

* chore: nx format:write update dirty files

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: andes-it <[email protected]>

* fix(portals-admin): adding report date (#16384)

* fix(portals-admin): adding report date

* chore: nx format:write update dirty files

* tweak

* tweak supervisors info

* chore: nx format:write update dirty files

* tweak

* message - company card

* tweak

* t

* t

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(signature-collection): tweaks 15.10 (#16402)

* tweaka

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(signature-collection): Tweaks for parliamentary collection (#16407)

* Tweaks for parliamentary collection

* revertt'

* Update libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* managers should see other managers

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(signature-collection): Fix paper signatures for candidacy (#16411)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(signature-collections): ongoing updates (#16409)

* tweaks

* tweak - create list

* copylink

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

---------

Co-authored-by: albinagu <[email protected]>
Co-authored-by: andes-it <[email protected]>
Co-authored-by: Ásdís Erna Guðmundsdóttir <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: juni-haukur <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants