-
Notifications
You must be signed in to change notification settings - Fork 61
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(portals-admin): locklist #16279
fix(portals-admin): locklist #16279
Conversation
WalkthroughThis pull request introduces several modifications primarily focused on localization and functionality enhancements in the signature collection module. Key changes include updates to message definitions in the Changes
Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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 (4)
libs/portals/admin/signature-collection/src/screens-parliamentary/List/paperSignees/index.tsx (1)
47-47
: Approve the optimization of theuseCanSignQuery
hook.The addition of the
!name
condition in theskip
property is a good optimization. It ensures that thecanSign
query is only executed when both thenationalIdInput
is valid and thename
is available. This prevents unnecessary API calls and potential errors.For improved clarity and maintainability, consider extracting the skip condition into a separate variable:
const shouldSkipCanSignQuery = !nationalId.isValid(nationalIdInput) || !name; const { data: canSign, loading: loadingCanSign } = useCanSignQuery({ variables: { input: { signeeNationalId: nationalIdInput, listId, }, }, skip: shouldSkipCanSignQuery, });This refactoring would make the code more readable and easier to maintain in the future.
libs/portals/admin/signature-collection/src/lib/messages.ts (2)
426-430
: LGTM: New message for locking collectionThe addition of the
lockList
message is consistent with the existing pattern and introduces a new action for locking a collection. This enhances the functionality of the signature collection feature.Consider adding a brief description to provide context for translators:
lockList: { id: 'admin-portal.signature-collection:lockList', defaultMessage: 'Læsa söfnun', - description: '', + description: 'Button text for locking a signature collection', },
431-435
: LGTM: Success message for locking collectionThe addition of the
lockListSuccess
message is consistent with the existing pattern and provides user feedback for a successful lock action. This improves the user experience of the signature collection feature.Consider adding a brief description to provide context for translators:
lockListSuccess: { id: 'admin-portal.signature-collection:lockListSuccess', defaultMessage: 'Tókst að læsa söfnun', - description: '', + description: 'Success message shown after locking a signature collection', },libs/portals/admin/signature-collection/src/shared-components/completeReview/index.tsx (1)
83-84
: Improve the modal content to provide clearer user confirmationThe text inside the modal currently displays
{formatMessage(m.lockList)}
, which may not provide sufficient context for the user about the action they are confirming. Consider updating the modal content to include a more descriptive message that explains the consequences of locking the list.Suggested change:
-<Text>{formatMessage(m.lockList)}</Text> +<Text>{formatMessage(m.lockListConfirmationMessage)}</Text>Where
m.lockListConfirmationMessage
is a new localized message, such as:lockListConfirmationMessage: 'Are you sure you want to lock this list? This action cannot be undone.',
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (4)
- libs/portals/admin/signature-collection/src/lib/messages.ts (2 hunks)
- libs/portals/admin/signature-collection/src/screens-parliamentary/List/paperSignees/index.tsx (1 hunks)
- libs/portals/admin/signature-collection/src/shared-components/completeReview/index.tsx (3 hunks)
- libs/portals/admin/signature-collection/src/shared-components/completeReview/lockList.graphql (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
libs/portals/admin/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/portals/admin/signature-collection/src/screens-parliamentary/List/paperSignees/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/portals/admin/signature-collection/src/shared-components/completeReview/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/portals/admin/signature-collection/src/shared-components/completeReview/lockList.graphql (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/portals/admin/signature-collection/src/shared-components/completeReview/lockList.graphql (2)
1-6
: LGTM! Well-structured GraphQL mutation.The
SignatureCollectionLockList
mutation is well-defined and follows GraphQL best practices. It's specific to signature collection, which aligns with its location in the project structure and could be reusable across different NextJS apps dealing with signature collections.
1-6
: Verify input type and return fields in the schema.Please ensure that the
SignatureCollectionListIdInput
type and thereasons
andsuccess
fields are properly defined in the GraphQL schema.libs/portals/admin/signature-collection/src/screens-parliamentary/List/paperSignees/index.tsx (1)
Line range hint
1-224
: Overall, the code quality is high and adheres to best practices.The
PaperSignees
component in this file demonstrates good adherence to coding guidelines and best practices:
- Reusability: The component is well-structured and can be easily reused across different NextJS apps.
- TypeScript usage: Props and types are properly defined using TypeScript, enhancing type safety and developer experience.
- Effective bundling: The code structure supports efficient tree-shaking and bundling.
- State management: React hooks are used effectively for managing component state and side effects.
- API integration: GraphQL queries and mutations are implemented cleanly using generated hooks.
- UI components: The component leverages reusable UI components from the
@island.is/island-ui/core
library.- Localization: The component uses localization hooks for internationalization support.
The recent change improves the efficiency of API calls, further enhancing the overall quality of the component.
libs/portals/admin/signature-collection/src/lib/messages.ts (3)
385-387
: LGTM: Improved clarity in message wordingThe change from "Aflæsa úrvinnslu" to "Opna fyrir úrvinnslu" improves the clarity of the action being described. This refinement in wording makes the user interface more intuitive.
441-444
: LGTM: Grammatical improvement in error messageThe change from "Ekki tókst loka úrvinnslu" to "Ekki tókst að loka úrvinnslu" is a grammatical improvement that enhances the readability of the error message. This minor refinement contributes to a more polished user interface.
Line range hint
1-743
: Overall assessment: Improved functionality with minor issuesThe changes to this file enhance the signature collection feature by adding new messages for locking collections and improving existing messages. The additions and modifications maintain consistency with the existing pattern, ensuring reusability and effective tree-shaking.
Key points:
- New messages for locking collections have been added, improving functionality.
- Existing messages have been refined for better clarity and grammar.
- TypeScript usage is consistent throughout the file.
There's one issue that needs to be addressed:
- The
id
for thelockListError
message is incorrect and should be fixed.Consider adding descriptions to the new messages to provide context for translators.
These changes align well with the coding guidelines for files in the
libs/**/*
pattern, maintaining reusability, proper TypeScript usage, and effective tree-shaking practices.
libs/portals/admin/signature-collection/src/shared-components/completeReview/index.tsx
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #16279 +/- ##
=======================================
Coverage 36.92% 36.92%
=======================================
Files 6781 6781
Lines 140030 140030
Branches 39815 39815
=======================================
Hits 51705 51705
Misses 88325 88325
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (5)
libs/portals/admin/signature-collection/src/shared-components/completeReview/lockList/lockList.graphql (1)
3-3
: Consider documenting thereasons
field.The
reasons
field in the mutation response could benefit from some documentation. Consider adding a comment or description in the schema to clarify its purpose and potential values.libs/portals/admin/signature-collection/src/shared-components/completeReview/lockList/index.tsx (2)
1-16
: Remove unused importListStatus
The
ListStatus
import from../../../lib/utils
is not used in this component. To maintain clean and efficient code, it's recommended to remove unused imports.Apply this change:
-import { ListStatus } from '../../../lib/utils'
Also, since
listStatus
prop is of typestring
, consider using a more specific type if possible, such as a union of allowed status values. This would improve type safety and make the component's API more clear.
17-37
: Hooks and state management look good, consider enhancing error handlingThe use of hooks and state initialization is well-implemented. The GraphQL mutation is properly set up with appropriate callbacks.
Consider enhancing the error handling in the
onError
callback. Instead of a generic error message, you could log the error details or display a more specific error message to the user. For example:onError: (error) => { console.error('Failed to lock list:', error); toast.error(formatMessage(m.lockListError, { error: error.message })); },This would provide more context for debugging and potentially more helpful feedback to the user.
libs/portals/admin/signature-collection/src/shared-components/completeReview/index.tsx (1)
27-41
: Consider extracting toggleListReview mutation into a custom hookThe implementation of the
toggleListReview
mutation is well-structured with proper error handling and success callbacks. However, to enhance reusability across different components or NextJS apps, consider encapsulating this mutation logic into a custom hook. This aligns with the project's emphasis on reusable components and hooks.Example:
// useToggleListReview.ts export const useToggleListReview = (listId: string) => { const { formatMessage } = useLocale() const { revalidate } = useRevalidator() return useToggleListReviewMutation({ variables: { input: { listId } }, onCompleted: () => { revalidate() toast.success(formatMessage(m.toggleReviewSuccess)) }, onError: () => { toast.error(formatMessage(m.toggleReviewError)) }, }) } // In the component const [toggleListReview, { loading }] = useToggleListReview(listId)This refactoring would improve the overall structure and reusability of the code.
libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx (1)
44-47
: Approve with suggestion: Consider extracting the nationalId cleaning logicThe change improves input validation by ensuring only numeric characters are used for the
nationalId
. This is a good practice that can prevent potential errors.To enhance code readability and maintainability, consider extracting the
nationalId
cleaning logic and the length check into a separate function. This would make the code more self-documenting and easier to update if requirements change. For example:const cleanAndValidateNationalId = (id: string): string => { const cleaned = id.replace(/[^0-9]/g, ''); return cleaned.length === 10 ? cleaned : ''; }; // Usage in the component: const cleanedNationalId = cleanAndValidateNationalId(searchTerm); const { data, loading } = useSignatureCollectionSignatureLookupQuery({ variables: { input: { collectionId: collection?.id, nationalId: cleanedNationalId, }, }, skip: !cleanedNationalId, });This approach would also make it easier to add more sophisticated validation if needed in the future.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (5)
- libs/portals/admin/signature-collection/src/lib/messages.ts (2 hunks)
- libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx (1 hunks)
- libs/portals/admin/signature-collection/src/shared-components/completeReview/index.tsx (3 hunks)
- libs/portals/admin/signature-collection/src/shared-components/completeReview/lockList/index.tsx (1 hunks)
- libs/portals/admin/signature-collection/src/shared-components/completeReview/lockList/lockList.graphql (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- libs/portals/admin/signature-collection/src/lib/messages.ts
🧰 Additional context used
📓 Path-based instructions (4)
libs/portals/admin/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/portals/admin/signature-collection/src/shared-components/completeReview/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/portals/admin/signature-collection/src/shared-components/completeReview/lockList/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/portals/admin/signature-collection/src/shared-components/completeReview/lockList/lockList.graphql (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/portals/admin/signature-collection/src/shared-components/completeReview/lockList/index.tsx (3)
39-49
: Button implementation looks goodThe Button component is well-implemented with appropriate props for styling and functionality. The use of
formatMessage
for the button text ensures proper localization.
78-78
: Component export looks goodThe default export of the
ActionLockList
component is correct and follows common React practices.
1-78
: Overall assessment: Well-implemented component with room for minor improvementsThe
ActionLockList
component is generally well-implemented and adheres to the coding guidelines for thelibs
directory. It demonstrates good use of TypeScript, React hooks, and follows best practices for reusability.Key strengths:
- Proper use of TypeScript for prop definitions.
- Effective use of React hooks and state management.
- Integration with localization and UI components.
Areas for improvement:
- Remove unused import and consider more specific prop types.
- Enhance error handling in the GraphQL mutation.
- Improve Modal implementation for better accessibility and user experience.
These suggested improvements will further enhance the component's quality, maintainability, and user-friendliness.
libs/portals/admin/signature-collection/src/shared-components/completeReview/index.tsx (3)
20-26
: LGTM: Improved state management and readabilityThe addition of
modalSubmitReviewIsOpen
state andmodalText
variable, along with thelistReviewed
check based onlistStatus
, enhances the component's functionality and readability. The changes maintain proper TypeScript usage for props.
45-53
: LGTM: Improved layout and functionalityThe changes to the component's JSX structure are well-implemented:
- The layout change to
spaceBetween
improves the visual balance.- The addition of the
LockList
component enhances modularity.- The conditional rendering of the Button's icon based on
listReviewed
status improves user experience.These modifications align well with the project's emphasis on reusable components and enhance the overall functionality of the
ActionReviewComplete
component.
74-76
: LGTM: Enhanced Modal functionality and UXThe changes to the Modal component are well-implemented:
- The use of
modalText
for dynamic content improves flexibility.- The Button now correctly uses the
toggleListReview
function.- The conditional rendering of the Button's icon based on
listReviewed
status enhances user experience.These modifications maintain proper localization practices and improve the overall functionality of the Modal.
...ls/admin/signature-collection/src/shared-components/completeReview/lockList/lockList.graphql
Show resolved
Hide resolved
libs/portals/admin/signature-collection/src/shared-components/completeReview/lockList/index.tsx
Show resolved
Hide resolved
libs/portals/admin/signature-collection/src/shared-components/completeReview/index.tsx
Show resolved
Hide resolved
* fix(portals-admin): locklist * tweak * msg id fix * tweak --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
…-pages (#16234) * Service portal removal. Add portals my pages * minor fixes * Fix * path fix * fix(portals-admin): locklist (#16279) * fix(portals-admin): locklist * tweak * msg id fix * tweak --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(service-portal): feature flag resolver for documents (#16285) * fix: def info and alert * feat: add feature flag to resolver * fix: move ff call to seperate function --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(vehicles-bulk-mileage): Fixes after testing review (#16295) * fix: testing fixes v1 * fix: testing comments v2 * fix: better message * fix: function name * fix: duplicate loading --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(tests): New @island/testing/e2e library (#16287) * Add @swc-node/register and @swc/core * Add testing/e2e library * update project.json for testing/e2e * fix import for libTestingE2e --------- Co-authored-by: Kristofer <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(parental-leave): ApplicationRights (#15901) * feat(parental-leave): ApplicationRights Added applicationRights to parental-leave when sending application. Since we are using a new way of calculating periods * Fix days used by period calculation * Tests for new periods * rename function with proper camelCase * Refactor: Made duplicate code into a function * Make ApplicationRights nullable * refactor: function instead of duplicate code * remove console.log * error handling for period data * clientConfig nullable fix * Fixes for calculation of months. And using clamp to get correct value of daysLeft * Multiply amount of months by 30 for period calculation with month durations * Fix old calculation of endDate with months --------- Co-authored-by: hfhelgason <[email protected]> Co-authored-by: veronikasif <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(passport-application): Updated readme (#16296) * updated readme * updated readme * 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(regulations-admin): date format signature, remove self affect, disclaimer text (#16288) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(regulations-admin): No diff no addition in appendix (#16293) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(web): Global alert banner - Handle null case (#16298) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(web): Change custom syslumenn pages config for header (#16299) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(j-s): Digital mailbox API (#16301) * feat(j-s): Block create subpoena on staging and dev * Update subpoena.service.ts * fix(j-s): Fix mailbox API * remove changes not meant for this branch * Update subpoena.service.ts * fix(j-s): reverting changes from other branch * Update subpoena.response.ts * Update subpoena.response.ts * Update subpoena.response.ts * Update subpoena.response.ts --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(signature-collection): Fix list reviewed toggle (#16300) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * chore(scripts): Stricter shell script checking (#16242) * Set style level for shellcheck * Linting & formatting scripts * Remove _podman.sh script * Format all scripts * Add reviewdog/action-shfmt step * Configure shfmt * Merge from main * Linting * Move shfmt to before lint * Remove reviewdog * Allow external sources in shellcheck * Use Reviewdog for shellcheck * Set version for Reviewdog --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * chore(new-primary-school): Update messages namespace (#16302) Co-authored-by: veronikasif <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(driving-license): check if 65+ renewal is possible (#16292) * check if 65 renewal is possible * remove console log * cleanup * coderabbit tweaks * coderabbit changes * quick fix * add type? --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(service-portal): default defender and has chosen fields for subpoena (#16306) * fix: def info and alert * feat: add feature flag to resolver * fix: move ff call to seperate function * feat: add default choices ans has chosen + loading states * fix: use type * fix: undefined type issue * fix: simplify check * Update service setup for my pages infra * chore: charts update dirty files * Remove from infra * undo rename --------- Co-authored-by: albinagu <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Ásdís Erna Guðmundsdóttir <[email protected]> Co-authored-by: Þorkell Máni Þorkelsson <[email protected]> Co-authored-by: Svanhildur Einarsdóttir <[email protected]> Co-authored-by: Kristofer <[email protected]> Co-authored-by: helgifr <[email protected]> Co-authored-by: hfhelgason <[email protected]> Co-authored-by: veronikasif <[email protected]> Co-authored-by: Rafn Árnason <[email protected]> Co-authored-by: andes-it <[email protected]> Co-authored-by: Rúnar Vestmann <[email protected]> Co-authored-by: mannipje <[email protected]> Co-authored-by: unakb <[email protected]> Co-authored-by: juni-haukur <[email protected]> Co-authored-by: birkirkristmunds <[email protected]> Co-authored-by: Kristján Albert <[email protected]>
Checklist:
Summary by CodeRabbit
New Features
LockList
component to enhance list management capabilities.Bug Fixes