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-collection): refetch is owner 16.10 #16432

Merged
merged 6 commits into from
Oct 16, 2024
Merged

Conversation

albinagu
Copy link
Member

@albinagu albinagu commented Oct 16, 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 detailed cancellation messages for endorsement collections, improving user clarity.
    • Introduced a confirmation button label for canceling the last collection.
  • Enhancements

    • Updated the OwnerView component to refresh owner status after cancellation.
    • Improved messaging in the DialogPrompt based on the number of lists.
  • Refactor

    • Simplified rendering logic in the SignedList component by removing the loading skeleton.

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

coderabbitai bot commented Oct 16, 2024

Walkthrough

This pull request introduces new message definitions for cancellation prompts in the messages.ts file, enhancing user interface clarity. Additionally, it modifies the OwnerView component to include a new prop, refetchIsOwner, which is invoked after canceling a collection to refresh the owner status. Changes also affect the SignatureListsParliamentary component by passing the new prop to OwnerView. Lastly, the SignedList component's loading skeleton has been removed, simplifying its rendering logic.

Changes

File Change Summary
libs/service-portal/signature-collection/src/lib/messages.ts Added two new message definitions: cancelCollectionModalMessageLastList and cancelCollectionModalConfirmButtonLastList.
libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx Introduced refetchIsOwner prop to OwnerView component and updated the onCompleted callback to invoke it after canceling a collection. Modified DialogPrompt logic for conditional messaging.
libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx Updated SignatureListsParliamentary to pass refetchIsOwner to OwnerView.
libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx Removed loading skeleton rendering for SignedList, simplifying the component's rendering logic.

Possibly related PRs

Suggested reviewers

  • kksteini
  • juni-haukur

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6888ac5 and a67a259.

📒 Files selected for processing (1)
  • libs/service-portal/signature-collection/src/lib/messages.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/service-portal/signature-collection/src/lib/messages.ts

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.

@albinagu albinagu changed the title Sp fixes 16.10 2 fix(signature-collection): refetch is owner 16.10 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 (4)
libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx (2)

19-19: LGTM! Consider adding a type annotation for improved clarity.

The addition of refetchIsOwner from the useIsOwner hook is a good improvement, allowing for dynamic refreshing of the owner status. This change aligns well with the component's functionality and the overall structure of the file.

For better type safety and code readability, consider adding a type annotation to the destructured object:

const { isOwner, loadingIsOwner, refetchIsOwner }: { isOwner: boolean; loadingIsOwner: boolean; refetchIsOwner: () => void } = useIsOwner()

This change would further adhere to the TypeScript usage guideline for the libs directory.


Line range hint 1-62: Overall, the changes look good and improve the component's functionality.

The modifications to the SignatureListsParliamentary component enhance its ability to refresh the owner status dynamically. The changes are minimal, focused, and adhere to the coding guidelines for the libs directory. They maintain the component's reusability across different NextJS apps and make good use of TypeScript for prop definitions.

Key improvements:

  1. Addition of refetchIsOwner from the useIsOwner hook.
  2. Passing refetchIsOwner to the OwnerView component.

These changes allow for more dynamic interaction with the ownership status, potentially improving the user experience.

Consider documenting the purpose and usage of the refetchIsOwner function in a comment or in the component's documentation to help other developers understand its role in the component's lifecycle and when it should be called.

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

151-157: Improved UX with context-sensitive messaging, but fix indentation

The conditional logic for the description prop enhances the user experience by providing more relevant messaging based on the number of lists. This is a good improvement.

However, the indentation of this block is inconsistent with the surrounding code. Consider adjusting it for better readability:

 description={
-  listsForOwner.length === 1
-    ? formatMessage(
-        m.cancelCollectionModalMessageLastList,
-      )
-    : formatMessage(m.cancelCollectionModalMessage)
+  listsForOwner.length === 1
+    ? formatMessage(m.cancelCollectionModalMessageLastList)
+    : formatMessage(m.cancelCollectionModalMessage)
 }

This change will align the code with the project's formatting standards and improve readability.

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

204-208: Consider adding a space in "of" to "og" in the button text.

The new message cancelCollectionModalConfirmButtonLastList provides a clear confirmation button label. However, there's a small typo in the Icelandic text.

Please consider applying this change:

-    defaultMessage: 'Já, hætta við söfnun of eyða framboði',
+    defaultMessage: 'Já, hætta við söfnun og eyða framboði',
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d356a2f and 4d17160.

📒 Files selected for processing (4)
  • libs/service-portal/signature-collection/src/lib/messages.ts (1 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (4 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx (2 hunks)
  • libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx
🧰 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 (6)
libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx (1)

37-37: LGTM! Verify the OwnerView component implementation.

The addition of the refetchIsOwner prop to the OwnerView component is a good improvement, allowing for dynamic refreshing of the owner status from within the child component.

To ensure the OwnerView component is correctly implementing this new prop, please run the following verification script:

This script will help verify that the OwnerView component is correctly defined with the refetchIsOwner prop and that it's being used within the component.

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

36-36: LGTM: New prop enhances component reusability

The addition of the refetchIsOwner prop is a good improvement. It allows the parent component to control when to refresh the owner status, enhancing the reusability of this component across different contexts in the application.

The TypeScript type definition is correct, following best practices for prop typing.

Also applies to: 41-41


59-59: LGTM: Proper usage of new prop ensures state consistency

The refetchIsOwner function is correctly called in the onCompleted callback of the cancelCollection mutation. This ensures that the owner status is refreshed only after a successful cancellation, maintaining consistency between this component and its parent.

This change improves the overall reliability of the application's state management.


174-176: LGTM: Consistent improvement in UX for button text

The conditional logic for the buttonTextConfirm prop is a good addition, providing context-sensitive button text based on the number of lists. This change is consistent with the earlier modification to the description prop, further enhancing the user experience.

The use of formatMessage for internationalization and the correct indentation contribute to maintainable and readable code.

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

193-208: Overall, the new messages enhance the user interface and follow best practices.

The added messages provide clear and detailed information about canceling the last collection and deleting the candidacy. They adhere to the coding guidelines for the libs/**/* pattern, use TypeScript effectively, and support reusability across different NextJS apps. The file structure also supports effective tree-shaking and bundling practices.


193-198: LGTM! Clear and informative message for canceling the last collection.

The new message cancelCollectionModalMessageLastList provides a detailed explanation of the consequences of canceling the last collection. It effectively warns the user about losing collected endorsements and deleting the candidacy.

To ensure consistency across the codebase, let's check if similar warning messages exist for other critical actions:

✅ Verification successful

Verified! The new message cancelCollectionModalMessageLastList is consistent with existing warning messages across the codebase, ensuring uniform user experience.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar warning messages in other files
rg --type typescript "Þú ert að fara að" -g '!**/messages.ts'

Length of output: 98


Script:

#!/bin/bash
# Search for similar warning messages in other TypeScript files
rg "Þú ert að fara að" -g '*.ts' -g '!**/messages.ts'

Length of output: 2660

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 16, 2024

Datadog Report

All test runs d65d54d 🔗

4 Total Test Services: 0 Failed, 4 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 13 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 4.12s 1 no change Link
application-system-api 0 0 0 120 2 3m 13.11s 1 no change Link
application-template-api-modules 0 0 0 123 0 3m 22.03s 1 decreased (-0.01%) Link
application-ui-shell 0 0 0 74 0 45.49s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-template-api-modules - jest 30.09% (-0.01%) - Details

Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.72%. Comparing base (8b46f97) to head (a67a259).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #16432   +/-   ##
=======================================
  Coverage   36.72%   36.72%           
=======================================
  Files        6809     6809           
  Lines      141179   141187    +8     
  Branches    40248    40255    +7     
=======================================
+ Hits        51846    51854    +8     
  Misses      89333    89333           
Flag Coverage Δ
api 3.37% <ø> (ø)
application-system-api 41.40% <ø> (ø)
application-template-api-modules 27.87% <ø> (-0.02%) ⬇️
application-ui-shell 21.35% <ø> (ø)

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 8b46f97...a67a259. Read the comment docs.

albina added 2 commits October 16, 2024 15:40
@albinagu albinagu added the deprecated:automerge (Disabled) 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 (2)
libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (2)

81-87: LGTM: Simplified rendering of SignedList component.

The removal of the loading skeleton for the SignedList component aligns with the AI summary and simplifies the rendering logic. This change can improve performance and readability.

Consider adding a comment explaining why the loading state is no longer needed for the SignedList component, to improve code maintainability:

+// Loading state is handled internally by SignedList component
<SignedList currentCollection={currentCollection} />

154-160: LGTM: Improved context-aware messaging in DialogPrompt.

The conditional rendering for description and buttonTextConfirm properties in the DialogPrompt component enhances the user experience by providing more specific messages based on the number of lists. This aligns with the goal of improving context-aware messaging.

To improve readability, consider extracting the conditional logic into separate variables:

const description = listsForOwner.length === 1
  ? formatMessage(m.cancelCollectionModalMessageLastList)
  : formatMessage(m.cancelCollectionModalMessage);

const buttonTextConfirm = formatMessage(
  listsForOwner.length === 1
    ? m.cancelCollectionModalConfirmButtonLastList
    : m.cancelCollectionModalConfirmButton
);

// Then use these variables in the DialogPrompt component
<DialogPrompt
  // ...other props
  description={description}
  buttonTextConfirm={buttonTextConfirm}
  // ...
/>

This approach separates the logic from the JSX, making it easier to read and maintain.

Also applies to: 177-179

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4d17160 and 6888ac5.

📒 Files selected for processing (2)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (5 hunks)
  • libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx
🧰 Additional context used
📓 Path-based instructions (1)
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."
🔇 Additional comments (2)
libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (2)

59-59: LGTM: Correct usage of refetchIsOwner.

The refetchIsOwner function is correctly called in the onCompleted callback of the cancelCollection mutation. This ensures that the owner status is refreshed after successfully canceling a collection, which aligns with the intended functionality.


36-36: LGTM: New prop refetchIsOwner added correctly.

The addition of the refetchIsOwner prop is well-implemented and typed correctly. It adheres to TypeScript conventions and follows the coding guidelines for reusable components in the libs directory.

Let's verify the usage of this new prop:

Also applies to: 41-41

✅ Verification successful

Verification Successful: No additional usages of refetchIsOwner found.

The new refetchIsOwner prop is not used outside the OwnerView component, ensuring that the changes are correctly localized and pose no issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new `refetchIsOwner` prop in other components.

# Test: Search for components that use OwnerView and pass the refetchIsOwner prop.
rg --type typescript 'OwnerView.*refetchIsOwner'

Length of output: 85


Script:

#!/bin/bash
# Description: Verify the usage of the new `refetchIsOwner` prop in other components.

# Test: Search for `.tsx` files that use OwnerView and pass the refetchIsOwner prop.
rg --type tsx 'OwnerView.*refetchIsOwner'

Length of output: 71


Script:

#!/bin/bash
# Description: Verify the usage of the new `refetchIsOwner` prop in other components.

# Test: Search for `.tsx` files that use OwnerView and pass the refetchIsOwner prop.
rg 'OwnerView.*refetchIsOwner' --glob '*.tsx'

Length of output: 47

@kodiakhq kodiakhq bot merged commit 695edee into main Oct 16, 2024
43 checks passed
@kodiakhq kodiakhq bot deleted the sp_fixes_16.10_2 branch October 16, 2024 16:24
kksteini pushed a commit that referenced this pull request Oct 16, 2024
* fix(signature-collection): refetch is owner after remove last list

* tw

* tweak

* tw

* tw

---------

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(application-plc): Detect user delegation type (#16429)

* wip

* wip

* Small fixes

* Conditioned

* Fixed messages

* Fixed conditionals

* feat(signature-collection): user not found handling (#16431)

* feat(signature=collection): user not found handling

* fix: text update

* chore: nx format:write update dirty files

---------

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

* fix(signature-collection): refetch is owner 16.10 (#16432)

* fix(signature-collection): refetch is owner after remove last list

* tw

* tweak

* tw

* tw

---------

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

---------

Co-authored-by: Alex Diljar Birkisbur Hellsing <42963845+alexdiljar@users.noreply.github.com>
Co-authored-by: andes-it <builders@andes.is>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: albinagu <47886428+albinagu@users.noreply.github.com>
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.

2 participants