-
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): Collection admin touchups #16195
Conversation
WalkthroughThe pull request introduces a series of changes across multiple files within the signature collection module. These modifications primarily focus on updating message definitions in Icelandic, adjusting layouts and properties in various components, and enhancing the logic for rendering status-related information. Additionally, some components have undergone structural changes to improve user interaction, such as the handling of button states and the layout of input fields. Changes
Possibly related PRs
Suggested labels
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: 3
🧹 Outside diff range and nitpick comments (8)
libs/portals/admin/signature-collection/src/screens-parliamentary/DownloadReports/index.tsx (1)
Line range hint
1-60
: Overall component structure and adherence to guidelinesThe
DownloadReports
component adheres well to the coding guidelines for files in thelibs
directory:
- Reusability: The component is designed to be reusable across different NextJS apps, accepting
areas
as a prop.- TypeScript usage: Props are properly typed with
SignatureCollectionArea[]
.- Effective bundling: The component imports specific UI components, which should allow for effective tree-shaking.
Additional observations:
- The component uses React hooks appropriately (
useState
,useLocale
).- It leverages the
@island.is/island-ui/core
library for consistent UI components.- The modal implementation enhances user experience by providing a clear interface for downloading reports.
Suggestion for improvement:
Consider extracting theconsole.log('download')
into a separate function that handles the actual download logic. This would make the component more production-ready and easier to maintain.Consider refactoring the download logic:
const handleDownload = (areaId: string) => { // Implement the actual download logic here console.log(`Downloading report for area: ${areaId}`); }; // Then in the ActionCard cta: onClick: () => handleDownload(area.id),This change would centralize the download logic and make it easier to implement the actual functionality in the future.
libs/portals/admin/signature-collection/src/shared-components/completeReview/index.tsx (1)
53-56
: Approve changes with a minor suggestion for improvementThe changes to the
disabled
property of theButton
component improve the functionality by ensuring the button is only active when the list status is appropriate for review actions. This aligns well with the component's purpose.To enhance code readability, consider extracting the condition into a separate variable:
const isReviewActionDisabled = listStatus !== ListStatus.Reviewed && listStatus !== ListStatus.InReview; // Then use it in the Button component <Button // ...other props disabled={isReviewActionDisabled} // ...rest of the component >This change would make the code more self-documenting and easier to maintain.
libs/portals/admin/signature-collection/src/shared-components/extendDeadline/index.tsx (2)
Line range hint
24-26
: Remove unused propallowedToProcess
The
allowedToProcess
prop is defined in the component's props but is no longer used in the component logic. To improve code clarity and maintainability, consider removing this unused prop.Apply the following change:
const ActionExtendDeadline = ({ listId, endTime, - allowedToProcess, }: { listId: string endTime: string - allowedToProcess?: boolean }) => {
66-73
: Enhance button accessibilityThe button lacks a clear label for screen readers. To improve accessibility, consider adding an
aria-label
to the button.Apply the following change:
<Button icon="calendar" iconType="outline" variant="ghost" onClick={() => setModalChangeDateIsOpen(true)} + aria-label={formatMessage(m.openDateChangeModal)} ></Button>
Also, add a new message to the
m
object in the messages file:openDateChangeModal: { id: 'admin.signature-collection.open-date-change-modal', defaultMessage: 'Open date change modal', description: 'Aria label for the button to open the date change modal', },libs/portals/admin/signature-collection/src/screens-presidential/List/index.tsx (1)
Line range hint
64-80
: Approve ListInfo usage and suggest minor refactorThe usage of the ListInfo component is appropriate and flexible. However, we can improve readability by extracting the message logic into a separate function.
Consider refactoring the ListInfo usage as follows:
+ const getListInfoMessage = (status: string) => { + switch (status) { + case ListStatus.Extendable: + return formatMessage(m.listStatusExtendableAlert); + case ListStatus.InReview: + return formatMessage(m.listStatusInReviewAlert); + case ListStatus.Reviewed: + case ListStatus.Inactive: + return formatMessage(m.listStatusReviewedStatusAlert); + default: + return formatMessage(m.listStatusActiveAlert); + } + }; <ListInfo - message={ - listStatus === ListStatus.Extendable - ? formatMessage(m.listStatusExtendableAlert) - : listStatus === ListStatus.InReview - ? formatMessage(m.listStatusInReviewAlert) - : listStatus === ListStatus.Reviewed - ? formatMessage(m.listStatusReviewedStatusAlert) - : listStatus === ListStatus.Inactive - ? formatMessage(m.listStatusReviewedStatusAlert) - : formatMessage(m.listStatusActiveAlert) - } + message={getListInfoMessage(listStatus)} type={ listStatus === ListStatus.Reviewed ? 'success' : undefined } />This refactoring improves readability and makes the component usage more maintainable.
libs/portals/admin/signature-collection/src/shared-components/createCollection/index.tsx (1)
131-180
: Improved layout structure with grid system.The new grid layout enhances the component's structure and visual appeal. The centered content (10/12 span with 1/12 offset) improves the overall design. The changes adhere to the coding guidelines for reusability and TypeScript usage.
Consider adding responsive behavior to the grid layout for better mobile support. You can use the
hiddenBelow
prop onGridColumn
for smaller screens:- <GridColumn span="10/12" offset="1/12"> + <GridColumn span={['12/12', '12/12', '10/12']} offset={['0', '0', '1/12']} hiddenBelow="sm"> + {/* Existing content */} + </GridColumn> + <GridColumn span="12/12" hiddenAbove="sm"> + {/* Duplicate content for mobile */} + </GridColumn>This change will ensure a full-width layout on mobile devices while maintaining the centered layout on larger screens.
libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx (1)
84-84
: Approved: Layout alignment improvementThe change from
center
toflexEnd
for thealignItems
property improves the vertical alignment of elements within the flex container. This adjustment likely provides a more consistent layout, especially when the CreateCollection component is present.For increased flexibility, consider using a custom property or a theme variable for the alignment. This would allow for easier adjustments across different use cases:
- alignItems="flexEnd" + alignItems={theme.alignments.listHeader || "flexEnd"}This suggestion assumes you're using a theming system. If not, you can create a constant for this purpose:
const LIST_HEADER_ALIGNMENT = 'flexEnd' as const; // Then use it in the component alignItems={LIST_HEADER_ALIGNMENT}This approach enhances maintainability and allows for centralized control over such layout decisions.
libs/portals/admin/signature-collection/src/screens-presidential/AllLists/index.tsx (1)
Line range hint
1-352
: Consider refactoring for improved maintainabilityWhile the current changes look good, I noticed that this component is quite large and handles multiple responsibilities. To improve maintainability and align with best practices, consider the following refactoring suggestions:
Split the component into smaller, more focused components. For example, you could create separate components for the filter section, list display, and pagination.
Extract the filtering and pagination logic into custom hooks. This would improve the separation of concerns and make the logic more reusable.
Consider using a container/presenter pattern to separate the data fetching and state management logic from the presentational aspects of the component.
These changes would align with the SOLID principles, particularly the Single Responsibility Principle, and make the code more modular and easier to test.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (9)
- libs/portals/admin/signature-collection/src/lib/messages.ts (5 hunks)
- libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx (1 hunks)
- libs/portals/admin/signature-collection/src/screens-parliamentary/DownloadReports/index.tsx (1 hunks)
- libs/portals/admin/signature-collection/src/screens-parliamentary/List/index.tsx (2 hunks)
- libs/portals/admin/signature-collection/src/screens-presidential/AllLists/index.tsx (2 hunks)
- libs/portals/admin/signature-collection/src/screens-presidential/List/index.tsx (1 hunks)
- libs/portals/admin/signature-collection/src/shared-components/completeReview/index.tsx (1 hunks)
- libs/portals/admin/signature-collection/src/shared-components/createCollection/index.tsx (2 hunks)
- libs/portals/admin/signature-collection/src/shared-components/extendDeadline/index.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
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/Constituency/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/screens-parliamentary/DownloadReports/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/screens-parliamentary/List/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/screens-presidential/AllLists/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/screens-presidential/List/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/createCollection/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/extendDeadline/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 (19)
libs/portals/admin/signature-collection/src/screens-parliamentary/DownloadReports/index.tsx (2)
37-37
: Improved vertical spacing consistencyThe change from
marginTop
tomarginY
provides consistent vertical spacing above and below the content. This improvement enhances the overall layout and visual balance of the modal.
43-43
: Enhanced heading hierarchy withheadingVariant="h4"
Adding
headingVariant="h4"
to the ActionCard component improves the semantic structure of the content. This change likely ensures that the heading style is consistent with the design system and maintains proper heading hierarchy within the modal.libs/portals/admin/signature-collection/src/shared-components/completeReview/index.tsx (1)
Line range hint
1-93
: Approve overall component structure and adherence to coding guidelinesThe
ActionReviewComplete
component adheres well to the coding guidelines for files in thelibs
directory:
Reusability: The component is structured in a way that allows it to be reused across different NextJS apps. It uses shared UI components and custom hooks, promoting consistency and reusability.
TypeScript usage: The component correctly uses TypeScript for defining props (listId and listStatus) and implicitly exports its type through the default export.
Tree-shaking and bundling: The component's structure, with its clear imports and exports, allows for effective tree-shaking and bundling in the build process.
The component's overall structure is clean and well-organized, making it easy to understand and maintain.
libs/portals/admin/signature-collection/src/screens-parliamentary/List/index.tsx (3)
11-11
: LGTM: Import statements are appropriate and follow best practices.The new imports for
m
,ListStatus
, andListInfo
are correctly added and align with the changes in the component. The imports follow the project's structure and naming conventions, which is good for maintainability and readability.Also applies to: 13-13, 19-19
23-26
: Good use of TypeScript for type definitions.The update to
useLoaderData
to includelistStatus
is well-implemented. The use of TypeScript to define the structure of the returned data enhances type safety and adheres to the coding guidelines. This change improves the component's robustness and maintainability.
Line range hint
1-93
: LGTM: Overall structure and adherence to coding guidelines are excellent.The changes to the
List
component maintain its reusability across different NextJS apps while enhancing its functionality. The use of TypeScript for prop and type definitions is consistent throughout the component, improving type safety and maintainability. The component structure remains clean and easy to understand, with the new additions integrating seamlessly into the existing code.The changes adhere well to the coding guidelines for files in the
libs/**/*
pattern, including effective use of TypeScript and maintaining practices that support efficient tree-shaking and bundling.libs/portals/admin/signature-collection/src/screens-presidential/List/index.tsx (1)
Line range hint
1-115
: Verify tree-shaking and bundling practicesThe code adheres to the coding guidelines for libs by using TypeScript and improving component reusability. However, we should verify tree-shaking and bundling practices across the project.
Let's check for configuration files related to bundling:
#!/bin/bash # Check for configuration files related to bundling and tree-shaking echo "Searching for bundler configuration files:" fd -p "(webpack|rollup|parcel)\.config\.(js|ts)" echo "\nSearching for package.json for build scripts:" fd "package.json" -x grep -H '"build":'libs/portals/admin/signature-collection/src/shared-components/createCollection/index.tsx (3)
9-10
: LGTM: New grid components imported correctly.The addition of
GridRow
andGridColumn
imports from the@island.is/island-ui/core
package is consistent with the existing import style and aligns with the coding guidelines for reusability across NextJS apps.
134-177
: LGTM: Consistent placement of form elements within the new grid structure.The input fields, error message display, and button are logically placed within the
GridColumn
, maintaining the existing functionality while improving the layout. The use of TypeScript for props and event handling is effective and adheres to the coding guidelines.
Line range hint
1-195
: Overall improvement in component structure and layout.The changes in this file successfully introduce a grid-based layout that enhances the visual structure of the
CreateCollection
component. The new layout improves the component's maintainability and adheres to the coding guidelines for reusability and TypeScript usage. The core functionality remains intact, with the changes focused on improving the presentation and structure of the form elements.Key improvements:
- Introduction of a centered grid layout
- Consistent placement of form elements within the new structure
- Maintained TypeScript usage and adherence to coding guidelines
These changes contribute to a more polished and maintainable component without introducing any significant issues or altering the core functionality.
libs/portals/admin/signature-collection/src/screens-presidential/AllLists/index.tsx (2)
33-33
: Improved component reusabilityThe change in the import path for the
ListInfo
component to'../../shared-components/listInfoAlert'
is a positive improvement. This modification enhances the reusability of the component across different parts of the application, aligning with our coding guidelines for component sharing across NextJS apps.
166-166
: Verify the design intention for FilterInput background colorThe change of
backgroundColor
from "white" to "blue" for the FilterInput component has been noted. While this change may improve visibility or align with recent design updates, it would be helpful to understand the rationale behind this modification.Could you please provide more context on this change? Is it part of a broader design update, or does it address any specific usability concerns?
libs/portals/admin/signature-collection/src/lib/messages.ts (7)
130-131
: Improved clarity in instructionsThe updated message provides more detailed and specific instructions for creating a signature collection. This change enhances user guidance and improves the overall user experience.
136-136
: Concise wording for candidate national IDThe message has been shortened while maintaining its essential meaning. This change is consistent with Icelandic language usage and contributes to a more streamlined user interface.
146-146
: Consistent terminology for candidate nameThe message has been updated to use "frambjóðs" instead of "frambjóðanda", maintaining consistency with the change made to the
candidateNationalId
message. This ensures a uniform terminology throughout the interface.
279-280
: Greatly improved instructions for report downloadsThe placeholder text has been replaced with clear, specific instructions in Icelandic for downloading overview reports for each constituency. This change significantly enhances the usefulness of the interface and provides valuable guidance to users.
289-289
: Refined search placeholder textThe search placeholder text has been slightly modified to "Leita eftir nafni eða kennitölu". This change maintains the original meaning while potentially using more natural phrasing in Icelandic.
643-645
: Crucial update to parliamentary signature lists introductionThe Latin placeholder text has been replaced with a clear, informative introduction in Icelandic. The new message effectively explains the overview of the six constituencies and guides users on how to access the endorsement lists for each constituency. This change greatly enhances the usability and clarity of the interface for parliamentary elections.
Line range hint
1-693
: Overall improvement in message clarity and usefulnessThe changes made to this file consistently enhance the clarity, specificity, and usefulness of the messages used in the signature collection module. The updates provide better guidance to users, maintain consistency in terminology, and replace placeholder text with informative content. These improvements will significantly enhance the overall user experience of the admin portal.
libs/portals/admin/signature-collection/src/shared-components/extendDeadline/index.tsx
Show resolved
Hide resolved
libs/portals/admin/signature-collection/src/screens-parliamentary/List/index.tsx
Show resolved
Hide resolved
libs/portals/admin/signature-collection/src/screens-presidential/List/index.tsx
Show resolved
Hide resolved
* fix(portals-admin): touchups * tweak * small * text fix --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Checklist:
Summary by CodeRabbit
New Features
ListInfo
component to display list status messages such as "Active" and "In Review."Improvements
CreateCollection
component to a grid format for better organization.ActionReviewComplete
component.ActionExtendDeadline
component.Styling Changes
Constituency
component.List
component to enhance user experience.DownloadReports
component.