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

Pulling fix/display-states into develop #649

Merged
merged 24 commits into from
Feb 19, 2024
Merged

Pulling fix/display-states into develop #649

merged 24 commits into from
Feb 19, 2024

Conversation

github-actions[bot]
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented Feb 16, 2024

Important

Auto Review Skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@ktun95 ktun95 force-pushed the fix/display-states branch from fb7df0a to e6aa653 Compare February 16, 2024 06:18
Copy link

codecov bot commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cbcb485) 94.68% compared to head (5f6fd09) 94.69%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #649      +/-   ##
===========================================
+ Coverage    94.68%   94.69%   +0.01%     
===========================================
  Files          186      188       +2     
  Lines        14034    14072      +38     
  Branches       488      491       +3     
===========================================
+ Hits         13288    13326      +38     
  Misses         746      746              
Files Coverage Δ
packages/header/src/functional/Header.tsx 100.00% <100.00%> (ø)
packages/header/src/functional/Logo.tsx 100.00% <100.00%> (ø)
packages/ui-common/src/LoadingDisplay.tsx 100.00% <100.00%> (ø)
packages/ui-common/src/mocks/content.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

…ble and setLoading function call

The loading state variable and setLoading function call were unnecessary as they were not being used. Removing them simplifies the code and improves readability.
… check for authorization

The cases in the conditionalRouting function have been reordered to to prioritize check for authorization. So if the user is already authorized, it will disregard any subsequent loading states.
…prop type to accept number or string

The import statement for the unused `Box` component has been removed to clean up the code. The `height` prop of the `LoadingDisplay` component has been updated to accept either a number or a string, providing more flexibility in specifying the height of each loading skeleton.
…ding indicators

The EditableLoader component is added to display loading indicators in the UI. It uses the LoadingDisplay component to render multiple loading indicators with different configurations. This component will be used to indicate loading states in editable pages.
…of the EditableLoader component

The EditableLoader component now has a TSDoc comment that provides a brief description of its purpose. This improves code documentation and makes it easier for other developers to understand the intended use of the component.
…laying loading state in editable content pages

The EditableContentLoadingDisplay component is added to the ui-common package. This component is intended for use in editable content pages to display a loading state. It consists of multiple instances of the LoadingDisplay component with different configurations to visually represent the loading state of different sections of the page.
The EditableContentLoadingDisplay component was added to the exports in the index.ts file of the ui-common package. This allows other modules to import and use the EditableContentLoadingDisplay component.
…tLoadingDisplay component for consistency and better user experience

The usage of the Loader component has been replaced with the EditableContentLoadingDisplay component to ensure consistency and improve the user experience when loading editable content.
…LoadingDisplay component for consistency and better user experience

The Editable.tsx file has been refactored to import the EditableContentLoadingDisplay component from the "@dictybase/ui-common" library. This component is now used instead of the previously imported Loader component for displaying a loading state. Additionally, some unused imports have been removed to clean up the code. This change improves the consistency and user experience of the Editable feature.
…isplay component from @dictybase/ui-common package

The code has been refactored to remove unused variables and imports, making the code cleaner and more maintainable. The Loader component has been replaced with the EditableContentLoadingDisplay component from the @dictybase/ui-common package, which provides a more consistent and standardized loading display for editable content.
Closes #648
- Import `EditableContentLoadingDisplay` from `@dictybase/ui-common` and remove unused import `Loader`
- Remove unused variables `gqlLoading` and `logToLoading`
- Replace `<Loader />` with `<EditableContentLoadingDisplay />` when `loading` is true
- Simplify pattern matching for `data` object in `useContentBySlugQuery` hook
- Remove unnecessary condition for `hasNotFoundError` check in `when` block

The changes were made to improve code readability and remove unused code. The `EditableContentLoadingDisplay` component is now used instead of the `Loader` component for displaying loading state. The destructuring of hooks and variables has been simplified for better code organization. The condition for `hasNotFoundError` check in the `when` block has been simplified.
Closes #648
…c to ACCESS.private to restrict access to the NotFoundErrorAuth component

The access variable is now set to ACCESS.private instead of ACCESS.public. This change restricts access to the NotFoundErrorAuth component, ensuring that only authenticated users with the "content-admin" role can access it.
…nd match statement

The isLoading variable and the match statement are no longer needed as the useAuthorization hook now directly returns the isAuthorized value. This simplifies the code and improves readability.
…nd match statement

The isLoading variable and the match statement are no longer needed as the useAuthorization hook no longer returns an isLoading property. The code has been simplified to directly use the isAuthorized property to determine whether to display the authorized or unauthorized Navbar component.
…o enable cache-and-network fetching

The fetchPolicy option is added to the useContentBySlugQuery hook with the value "cache-and-network". This allows the query to fetch data from both the cache and the network, improving the user experience by providing the most up-to-date data while still utilizing the cache when available.
…to be rendered before EditableView component for better user experience

The Editable component now renders the EditableContentLoadingDisplay component before the EditableView component. This change improves the user experience by displaying skipping the loading display when the content is already present.
Even if content data is being fetched, if there is already data present, the data will be rendered. This creates a more seamless user experience.
…e rendered before ContentView component for better readability and maintainability

The EditableContentLoadingDisplay component is now rendered before the ContentView component in the match function, improving the readability and maintainability of the code.
The new file EditableView.test.tsx contains unit tests for the EditableView component. The first test checks if the content data is rendered correctly. It uses the createMemoryRouter function from react-router-dom to set up the router and render the component. The test asserts that the content text is present in the rendered output.

The second test checks if an Edit button is rendered and if clicking on it navigates to the ../edit subpath. It uses the userEvent library to simulate a click on the Edit button. The test asserts that the "edit route" text is present in the rendered output after clicking the button.
The new unit test verifies that the EditButton component renders an "Edit" button and that clicking on it navigates to the "/edit" subpath. This test ensures that the EditButton behaves correctly and allows users to navigate to the appropriate route for editing.
…ugData object in mocks

The contentBySlugData object in the mocks now includes the created_at field with a timestamp and the created_by field with user information. This allows for more comprehensive and realistic data in the content mock.
Removed dynamic key generation for Header items to prevent unnecessary rerendering.
Removed dynamic key generation for Logo items to prevent unnecessary rerendering.
…er public routes only

The publicRoutes function was updated to correctly filter routes based on the access level. Now, only routes with ACCESS.public are included in the resulting array, ensuring that only public routes are returned as intended.
@ktun95 ktun95 force-pushed the fix/display-states branch from b87679f to 5f6fd09 Compare February 19, 2024 07:07
@ktun95 ktun95 merged commit 1b8da80 into develop Feb 19, 2024
5 checks passed
@ktun95 ktun95 deleted the fix/display-states branch February 19, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant