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

chore(service-portal): No scope notifications #15053

Merged
merged 5 commits into from
Jun 3, 2024

Conversation

thordurhhh
Copy link
Member

@thordurhhh thordurhhh commented Jun 3, 2024

What

Update ui when no scope available for notifications.

Why

Minor adjustments needed in header and dashboard.

Screenshots / Gifs

Screenshot 2024-06-03 at 12 29 58

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

    • Introduced DocumentsEmpty component to display messages and icons based on delegation access.
    • Added styles for lock icon and image elements in the DocumentsEmpty component.
  • Enhancements

    • Updated Header component to conditionally disable the NotificationButton based on user scopes.
    • Modified FullWidthLayout to check for document delegation access using user scopes.
    • Updated NotificationButton to support a disabled state with corresponding styles.
  • Refactor

    • Replaced empty document list rendering in Dashboard with the new DocumentsEmpty component.

@thordurhhh thordurhhh added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Jun 3, 2024
Copy link
Contributor

coderabbitai bot commented Jun 3, 2024

Walkthrough

The updates introduce a new DocumentsEmpty component to the service portal, which displays different messages based on delegation access. Changes span several files, including new styles for components, modifications to the header and layout to incorporate user scope checks, and updates to the notification button to respect delegation permissions.

Changes

File Path Change Summary
.../DocumentsEmpty/DocumentsEmpty.css.ts Added styles for lock and img elements.
.../DocumentsEmpty/DocumentsEmpty.tsx Introduced DocumentsEmpty component with hasDelegationAccess prop and default export.
.../Header/Header.tsx Added scope checks for DocumentsScope and updated NotificationButton to respect delegation access.
.../Layout/FullWidthLayout.tsx Added imports for useAuth and DocumentsScope, and updated logic for hasDocumentsDelegationAccess.
.../Notifications/NotificationButton.tsx Added disabled prop to NotificationButton and updated its usage.
.../Notifications/Notifications.css.ts Introduced noScope style for disabled buttons.
.../screens/Dashboard/Dashboard.tsx Replaced EmptyImageSmall with DocumentsEmpty component for empty document lists.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant ServicePortal
    participant AuthService
    participant DocumentsEmpty

    User->>ServicePortal: Access Dashboard
    ServicePortal->>AuthService: Fetch User Info
    AuthService-->>ServicePortal: Return User Info
    ServicePortal->>DocumentsEmpty: Render DocumentsEmpty with hasDelegationAccess
    DocumentsEmpty-->>User: Display appropriate message and icon
Loading

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 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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.

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 3, 2024

Datadog Report

All test runs 86c48fc 🔗

68 Total Test Services: 0 Failed, 66 Passed
🔻 Test Sessions change in coverage: 4 decreased, 196 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 81 0 41.08s 1 no change Link
air-discount-scheme-web 0 0 0 2 0 10.55s 1 no change Link
api 0 0 0 4 0 4.68s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 34.38s 1 no change Link
api-domains-assets 0 0 0 3 0 22.62s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 21.46s N/A Link
api-domains-communications 0 0 0 5 0 56.8s 1 no change Link
api-domains-criminal-record 0 0 0 5 0 15.22s 1 no change Link
api-domains-driving-license 0 0 0 23 0 57.89s 1 no change Link
api-domains-education 0 0 0 8 0 37.42s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (4)

  • application-templates-parental-leave - jest 33.16% (-0.1%) - Details
  • judicial-system-backend - jest 59.43% (-0.04%) - Details
  • services-university-gateway - jest 44.58% (-0.02%) - Details
  • services-auth-ids-api - jest 49.76% (-0.01%) - Details

Copy link

codecov bot commented Jun 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.13%. Comparing base (a831ebe) to head (470261a).
Report is 1 commits behind head on main.

Current head 470261a differs from pull request most recent head eae01df

Please upload reports for the commit eae01df to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15053      +/-   ##
==========================================
- Coverage   37.13%   37.13%   -0.01%     
==========================================
  Files        6396     6395       -1     
  Lines      130148   130161      +13     
  Branches    37131    37149      +18     
==========================================
+ Hits        48334    48336       +2     
- Misses      81814    81825      +11     
Flag Coverage Δ
api 3.44% <ø> (ø)
application-system-api 41.98% <ø> (ø)
application-template-api-modules 24.27% <ø> (ø)
application-templates-financial-aid 11.90% <ø> (ø)
application-ui-shell 21.73% <ø> (ø)
financial-aid-backend 56.44% <ø> (ø)
financial-aid-shared 17.92% <ø> (ø)
services-auth-personal-representative 48.59% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 6 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 af29933...eae01df. Read the comment docs.

@thordurhhh thordurhhh marked this pull request as ready for review June 3, 2024 12:30
@thordurhhh thordurhhh requested a review from a team as a code owner June 3, 2024 12:30
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: 1

Outside diff range and nitpick comments (2)
apps/service-portal/src/components/Notifications/Notifications.css.ts (1)

16-26: Add comments to describe the purpose of the noScope styles.

It would be beneficial to add comments explaining the purpose of the noScope styles, especially since they are related to the disabled state of buttons. This can help maintainers understand the context and usage of these styles quickly.

apps/service-portal/src/components/Notifications/NotificationButton.tsx (1)

Line range hint 19-61: Refactor to improve readability and maintainability.

Consider destructuring props directly in the function parameter to clean up the component's body and improve readability:

- const NotificationButton = ({ setMenuState, showMenu = false, disabled }: Props) => {
+ const NotificationButton: React.FC<Props> = ({ setMenuState, showMenu = false, disabled }) => {

This change makes it clear that NotificationButton is a functional component and improves the clarity of props usage.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 74e9027 and 51506f9.

Files selected for processing (7)
  • apps/service-portal/src/components/DocumentsEmpty/DocumentsEmpty.css.ts (1 hunks)
  • apps/service-portal/src/components/DocumentsEmpty/DocumentsEmpty.tsx (1 hunks)
  • apps/service-portal/src/components/Header/Header.tsx (4 hunks)
  • apps/service-portal/src/components/Layout/FullWidthLayout.tsx (2 hunks)
  • apps/service-portal/src/components/Notifications/NotificationButton.tsx (2 hunks)
  • apps/service-portal/src/components/Notifications/Notifications.css.ts (1 hunks)
  • apps/service-portal/src/screens/Dashboard/Dashboard.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • apps/service-portal/src/components/DocumentsEmpty/DocumentsEmpty.css.ts
Additional context used
Path-based instructions (6)
apps/service-portal/src/components/Notifications/Notifications.css.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/service-portal/src/components/DocumentsEmpty/DocumentsEmpty.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/service-portal/src/components/Notifications/NotificationButton.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/service-portal/src/components/Layout/FullWidthLayout.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/service-portal/src/components/Header/Header.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/service-portal/src/screens/Dashboard/Dashboard.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Biome
apps/service-portal/src/components/Notifications/NotificationButton.tsx

[error] 8-9: All these imports are only used as types.

apps/service-portal/src/components/Layout/FullWidthLayout.tsx

[error] 1-1: Some named imports are only used as types.


[error] 16-17: All these imports are only used as types.

apps/service-portal/src/components/Header/Header.tsx

[error] 50-50: Do not use template literals if interpolation and special-character handling are not needed.


[error] 47-47: This hook does not specify all of its dependencies: featureFlagClient.getValue

apps/service-portal/src/screens/Dashboard/Dashboard.tsx

[error] 70-70: Change to an optional chain.


[error] 83-83: Template literals are preferred over string concatenation.


[error] 1-1: The default import and some named imports are only used as types.


[error] 56-56: This hook does not specify all of its dependencies: IS_COMPANY


[error] 56-56: This hook specifies more dependencies than necessary: location


[error] 75-154: This block statement doesn't serve any purpose and can be safely removed.


[error] 83-83: Avoid using the index of an array as key property in an element.

Additional comments not posted (3)
apps/service-portal/src/components/Layout/FullWidthLayout.tsx (1)

Line range hint 22-67: Verify the new authentication and scope checks.

Ensure that the new authentication logic and scope checks introduced in FullWidthLayout.tsx are consistently implemented across the application. This script searches for usage patterns to verify consistency.

Verification successful

The search results indicate that both useAuth and DocumentsScope are widely used across the codebase. The new authentication and scope checks introduced in FullWidthLayout.tsx appear to be consistent with other parts of the application.

  • useAuth is used in various components and hooks across multiple modules.
  • DocumentsScope is used in several modules, including service-portal, documents, notifications, and user-profile.

Given the extensive usage and consistent pattern, the new authentication and scope checks in FullWidthLayout.tsx seem to be correctly implemented.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the new authentication and scope checks are correctly implemented across the application.

# Test: Search for usage of `useAuth` and `DocumentsScope` to ensure they are correctly implemented.
rg --type typescript $'useAuth'
rg --type typescript $'DocumentsScope'

Length of output: 138



Script:

#!/bin/bash
# Description: Verify that the new authentication and scope checks are correctly implemented across the application.

# Test: Search for usage of `useAuth` and `DocumentsScope` to ensure they are correctly implemented.
rg 'useAuth' --glob '*.ts' --glob '*.tsx'
rg 'DocumentsScope' --glob '*.ts' --glob '*.tsx'

Length of output: 22450

apps/service-portal/src/components/Header/Header.tsx (1)

Line range hint 29-134: Check the implementation of feature flags and conditional rendering.

Ensure that the feature flags and conditional rendering logic in Header.tsx are correctly implemented and tested across the application. This script searches for usage patterns to verify consistency.

Verification successful

The search results indicate that the featureFlagClient and enableNotificationFlag are used in multiple places across the codebase, including the Header.tsx file. The implementation of feature flags and conditional rendering logic appears to be consistent with the usage patterns found.

  • featureFlagClient is used to fetch feature flag values asynchronously.
  • enableNotificationFlag is used for conditional rendering based on the feature flag value.

The implementation in Header.tsx aligns with these patterns, ensuring that the feature flag is checked and the UI is conditionally rendered based on its value.

  • apps/service-portal/src/components/Header/Header.tsx:
    • featureFlagClient is used to fetch the feature flag value.
    • enableNotificationFlag is used to conditionally render the NotificationButton.

This confirms that the feature flags and conditional rendering logic are correctly implemented in the Header.tsx file.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the feature flags and conditional rendering logic are correctly implemented and tested.

# Test: Search for usage of `featureFlagClient` and conditional rendering logic to ensure they are correctly implemented.
rg --type typescript $'featureFlagClient'
rg --type typescript $'enableNotificationFlag'

Length of output: 156



Script:

#!/bin/bash
# Description: Verify that the feature flags and conditional rendering logic are correctly implemented and tested.

# Test: Search for usage of `featureFlagClient` and conditional rendering logic to ensure they are correctly implemented.
rg --type ts 'featureFlagClient'
rg --type ts 'enableNotificationFlag'

Length of output: 9411

apps/service-portal/src/screens/Dashboard/Dashboard.tsx (1)

237-237: Ensure correct conditional rendering based on delegation access.

This script checks if the conditional rendering logic based on hasDelegationAccess in Dashboard.tsx is consistently implemented across the application.

Verification successful

The search results indicate that hasDelegationAccess is used in both Dashboard.tsx and DocumentsEmpty.tsx for conditional rendering. Here are the relevant locations:

  • apps/service-portal/src/screens/Dashboard/Dashboard.tsx

    • Line 237: <DocumentsEmpty hasDelegationAccess={!!hasDelegationAccess} />
    • Line 236: const hasDelegationAccess = userInfo?.scopes?.includes(DocumentsScope.main)
    • Line 238: {hasDelegationAccess && (
  • apps/service-portal/src/components/DocumentsEmpty/DocumentsEmpty.tsx

    • Line 1: hasDelegationAccess: boolean
    • Line 2: export const DocumentsEmpty = ({ hasDelegationAccess }: Props) => {
    • Line 3: {hasDelegationAccess
    • Line 4: {hasDelegationAccess ? (
    • Line 5: hasDelegationAccess
    • Line 6: {!hasDelegationAccess && (

The conditional rendering based on hasDelegationAccess appears to be correctly implemented in these files.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the conditional rendering based on delegation access is correctly implemented across the application.

# Test: Search for usage of `hasDelegationAccess` to ensure it is correctly implemented.
rg --type typescript $'hasDelegationAccess'

Length of output: 77



Script:

#!/bin/bash
# Description: Verify that the conditional rendering based on delegation access is correctly implemented across the application.

# Test: Search for usage of `hasDelegationAccess` to ensure it is correctly implemented.
rg --type ts 'hasDelegationAccess'

Length of output: 1043

Copy link
Member

@thorkellmani thorkellmani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty good, but checkout coderabbit suggestion

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 51506f9 and eae01df.

Files selected for processing (1)
  • apps/service-portal/src/components/DocumentsEmpty/DocumentsEmpty.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/service-portal/src/components/DocumentsEmpty/DocumentsEmpty.tsx

@kodiakhq kodiakhq bot merged commit 760c6bb into main Jun 3, 2024
173 checks passed
@kodiakhq kodiakhq bot deleted the service-portal/notifications-no-scope branch June 3, 2024 13:46
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