Pulling feat/egs-morphing-button into develop#1183
Open
github-actions[bot] wants to merge 127 commits into
Open
Pulling feat/egs-morphing-button into develop#1183github-actions[bot] wants to merge 127 commits into
github-actions[bot] wants to merge 127 commits into
Conversation
The change introduces a Roles enum to define user roles and updates the UserWithRoles type to use the Roles enum for the roles property. This provides a more type-safe and maintainable way to manage user roles within the application.
The EditingContent component was created to allow users to edit the description of a gene. The component includes a multiline text field and save/cancel buttons. The component is used in the returnPanelContentById function in panelGenerator.tsx.
The new EditableContent component displays content and an edit button, setting the editing state to true when clicked. This allows users to edit the content.
…it mode The AuthorizedPanelContent component is implemented, which manages the edit mode state and renders either the EditableContent or EditingContent component based on whether the user is currently editing the content. This allows authorized users to edit the content of the panel.
The save and cancel functionalities are implemented. The cancel button now sets the isEditing state to false, and the save button is prepared for future implementation. The buttons are styled with Material UI for better visual appearance. The type of setIsEditing is changed to Dispatch<SetStateAction<boolean>>. A spacing of 1 is added to the Stack component.
…Content The EditingContent component was replaced with the AuthorizedPanelContent component. This change was made to ensure that only authorized users can edit the content.
…ontentWithAuth The AuthorizedPanelContent component was renamed to PanelContentWithAuth to better reflect its purpose and functionality.
…nts layout The layout of the EditableContent and EditingContent components has been improved by changing the main Stack direction to column and wrapping the buttons in a Stack with `flex-end` alignment. The EditingContent component now uses a TextField with a smaller font size and `defaultValue` prop.
The port was changed to align with project requirements and avoid potential conflicts.
…ules The Roles enum is now exported, allowing other modules to use it.
…thorization for panel content The new PanelContentWithAuth component handles authorization logic for displaying panel content based on user roles. It utilizes the useAuthorization hook to determine if a user has the necessary permissions (CONTENT_ADMIN) to view authorized content, and renders either the standard content or the AuthorizedPanelContent component accordingly.
…e confirmation The ConfirmDeleteDialog component was implemented to provide a confirmation dialog before deleting an item, enhancing user experience and preventing accidental deletions. It uses Material UI components for the dialog and includes delete and cancel actions.
The CreateItemDialog component was created, featuring a title, text field, and action buttons for creating and canceling. This dialog provides a basic user interface for creating new items within the genome page.
…nd create functionality The new EditableContentList component allows displaying a list of strings as chips, with the ability to delete existing items and create new ones. It uses dialogs for confirmation before deletion and for creating new items, enhancing the user interface for managing content lists.
Replaced the commaSeparate function with the new EditableContentList component for "Name Description" and "Alternative Gene Names" to allow editing of the content.
The dicty-graphql-schema dependency was upgraded to the latest version v1.35.0 in multiple packages to ensure compatibility and access to the newest features and fixes.
The @dictybase/auth package is removed from the project. This package was responsible for handling authentication-related components and logic. The removal is part of a larger effort to streamline the project's dependencies and potentially integrate authentication functionality directly into the consuming applications or through a different mechanism.
…AllowedRole` The `entries` prop in `useAuthorizationProperties` is now a `Set<Roles>`, and the authorization check uses `hasAllowedRole` for improved role matching. This change enhances the efficiency and clarity of role-based authorization checks.
The hasAllowedRole function checks if a user has at least one of the allowed roles. It uses set intersection to determine if any of the user's roles match the allowed roles. The matchEntries function was removed.
…ss control The new AuthorizationMatch component allows conditional rendering based on user roles, enhancing access control. The component is exported to be used in other modules.
The new ReadonlyContentList component is created to display a list of strings as readonly content. It uses Material UI's Stack and Chip components to render the list as a series of chips within a stack, allowing for flexible wrapping and spacing.
The label "Gene Product" was changed to "Gene Products" to reflect that the field can contain multiple gene products.
The "Name Description" and "Alternative Gene Names" fields now use the `AuthorizationMatch` component to conditionally render either `EditableContentList` or `ReadonlyContentList` based on user roles. Only users with the `CONTENT_ADMIN` role can edit these fields. A new `ReadonlyContentList` component was created to display the content for unauthorized users. The "Gene Product" content ID was pluralized to "Gene Products".
This commit introduces a new component, `GeneralInfoPanelAuthorized`, which is designed to display general information about a gene in an authorized context. It includes editable lists for name descriptions and alternative gene names, and displays other gene information such as dictyBase ID, gene products, and a description. The component utilizes `EditableContentList` and `AuthorizedInfoText` components for enhanced functionality. The original `GeneralInfoPanel` is modified to use `ReadonlyContentList` and to display data as ReactChild.
The panelGenerator.tsx file was removed as it is no longer needed.
…oggle The new AuthorizedInfoText component allows users to view static content and toggle editing mode. It uses EditableContent for display and EditingContent when editing.
The PanelContentWithAuth component is no longer needed. The component was removed to simplify the codebase.
…reateItemDialog The contentList prop has been renamed to infoList for clarity. The label prop is now passed to the CreateItemDialog component, allowing for dynamic labels within the dialog.
The CreateItemDialog component now accepts a label prop, which is used to dynamically set the dialog title and TextField label. This makes the component more reusable for creating different types of items.
…r roles The GeneralInfoPanel component is now conditionally rendered based on user roles. Users with the CONTENT_ADMIN role will see the GeneralInfoPanelAuthorized component, while others will see the regular GeneralInfoPanel. This change allows for role-based access control to specific features within the panel.
The tests were improved by using `getByTestId` to select the delete button, which is more reliable than traversing the DOM. The mock for `handleDelete` was also improved to correctly simulate a promise that resolves after a delay. This ensures that the loading state is properly tested.
The GraphQL document is now correctly spelled as document. The AuthorizationMatch component is now mocked to avoid LogtoProvider requirement. Vite config is updated to inline @logto/react dependency.
The tests for MorphingButton and MorphingCreateButton were updated to align with fp-ts v3. The right import was changed to TEright for TaskEither and Eright for Either. The mockOnAdd function was updated to return a Promise<Either<any, any>> to align with the expected return type of the onAdd function.
The try/catch block now handles errors during database seeding more gracefully by logging a simple "Seeding failed" message. Console table logs were removed from the handlers to reduce console clutter during testing.
This change introduces constants for test values to avoid duplication and improve maintainability across multiple test files.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1183 +/- ##
===========================================
+ Coverage 94.20% 94.23% +0.03%
===========================================
Files 414 430 +16
Lines 21469 22369 +900
Branches 1437 1522 +85
===========================================
+ Hits 20224 21079 +855
- Misses 1245 1290 +45
🚀 New features to boost your workflow:
|
…tion The matchEntries function was replaced with hasAllowedRole to improve code readability and maintainability. The hasAllowedRole function provides a clearer and more explicit way to check if a user has the required roles for accessing certain features.
…ate e2e test URL The serve script no longer specifies a port, allowing Vite to use the default or configured port. The e2e test URL is updated to reflect the standard port 3000.
The GOA ID in the summary page E2E test was outdated and did not match the latest data. Updating the ID ensures that the test accurately reflects the current state of the application and prevents false negatives.
The GOA ID was updated to reflect the most current data, ensuring the end-to-end tests remain accurate and reliable.
The date assertions in the e2e tests for the GOA page have been updated to reflect the correct date, ensuring that the tests pass with the current data.
…ests and features This commit introduces new tests for the MorphingButton and MorphingCreateButton components, covering scenarios such as collapsing on blur with empty input, handling the Escape key press, and displaying error states when the add operation fails. Additionally, the MorphingButtonTextFieldBox component is updated to improve property forwarding. These changes enhance the robustness and user experience of the components.
… calls in tests The `waitFor` calls were removed to simplify and speed up the tests, as the assertions were already being met without them. The timeout in the error state test was increased to ensure the error state is cleared.
…test The timeout for the error state to appear is reduced from 100ms to 50ms to speed up the test. A new test case is added to verify that the error state automatically clears after a timeout of 1500ms.
This commit adds tests to verify the add and delete functionalities of the EditableContentList component. It ensures that the update function is called correctly when adding or deleting items, and that it is not called when adding empty or duplicate values.
The key prop is added to the DeletableChip component to fix a React warning about missing keys when rendering lists of components. This improves performance and prevents potential issues with component re-rendering.
…m AuthorizedEmptyInfoList and EditableContentList components The label prop was removed from the AuthorizedEmptyInfoList and EditableContentList components to reduce redundancy and simplify the component interface. The label is already defined within the component, so passing it as a prop was unnecessary.
The dicty-graphql-schema dependency was updated to the latest version v1.36.0 in multiple packages to ensure compatibility and access to the newest features and fixes.
The shouldForwardProp property was removed from the styled component as it is no longer needed.
The documentation is updated to remind developers to run tests after adding them, ensuring that new tests are validated and that the codebase remains reliable.
…dback The MorphingButton component is enhanced to display error messages using a Snackbar component, providing visual feedback to the user when an error occurs during the update gene general information process. Additionally, the mock handlers are updated to simulate server errors when specific values are present in the input, allowing for testing of the error handling functionality.
Replaced snackbars with a custom SummaryPageErrorAlert component to handle and display errors in a consistent manner across the genome page. This change improves code maintainability and provides a unified error presentation.
This commit introduces error alerts for create and delete operations in the genome page application. It adds a new `SummaryPageErrorAlert` component for displaying error messages and integrates it into `DeletableChip`, `MorphingButton`, and `MorphingCreateButton` components. The alerts are displayed when the corresponding operations fail, providing users with feedback on the failure. Additionally, the alerts can be closed by clicking the close button, improving the user experience.
…dow and focus outline The create button has been visually enhanced with a shadow, a transition on hover, and a focus outline for better user interaction and accessibility.
…foText The component now displays a loading indicator during the save operation and shows an error message if the save operation fails. The input text is trimmed before saving.
…nent The component now checks if the text is empty before attempting to save. This prevents unnecessary API calls and potential errors when the user tries to save an empty description.
…state and error handling The gene description editing component is enhanced by adding a loading state to indicate when the update is in progress. Error handling is implemented to display an error message if the update fails. The save button is disabled when the text is the same as the initial text. The component now trims the input text before saving and allows setting the description to null if the trimmed text is empty.
The tests for disabling the save button in EditingInfoText are improved by checking if the button is disabled when the text has not changed or reverts to its initial value. The test case where the text is empty is removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.