Skip to content

fix: read-only banner, avoid rendering it while isLoading#1114

Merged
carlosthe19916 merged 3 commits into
guacsec:mainfrom
carlosthe19916:hotfix/read-only-message
Jun 29, 2026
Merged

fix: read-only banner, avoid rendering it while isLoading#1114
carlosthe19916 merged 3 commits into
guacsec:mainfrom
carlosthe19916:hotfix/read-only-message

Conversation

@carlosthe19916

@carlosthe19916 carlosthe19916 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Make sure the "Read-Only" banner is not rendered while "isLoading" as requested in the JIRA

Improvements:

  • Avoid adding tooltips for "read-only" mode. This makes the code dirty and we have already a big banner that explains that certain operations are disabled.
  • Set defaults on the fetch process of the "info" endpoints. There is no need to customize it.

Related Issues

https://redhat.atlassian.net/browse/TC-4926

Type of Change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation
  • Other (describe below)

Testing

  • All tests pass (npm test)
  • No lint errors (npm run lint)
  • No type errors (TypeScript compiles cleanly)
  • New/changed UI behavior visually verified in browser
  • Mock data updated if API types changed

Screenshots

Summary by Sourcery

Adjust read-only handling to disable mutations while trustify info is loading and prevent the read-only banner from showing during loading.

Enhancements:

  • Introduce an areMutationsDisabled flag in ReadOnlyContext and propagate it across layout, tables, toolbars, and buttons to consistently disable mutating actions.
  • Wrap the default layout in a LoadingWrapper to show global fetch errors and hide the read-only banner until trustify info is loaded.
  • Simplify the trustify info query hook by relying on default query settings and returning data in a generic shape suitable for reuse.

Tests:

  • Update and extend ReadOnlyContext and DefaultLayout tests to cover the new mutation-disabling behavior and read-only banner visibility during loading.

Chores:

  • Remove read-only tooltips and utility helpers now that mutation disabling is handled centrally, reducing UI clutter and context-specific logic.

@sourcery-ai

sourcery-ai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Refactors the read-only handling into an areMutationsDisabled flag, ensures the read-only banner is hidden while trustify info is loading, simplifies the trustify info fetch defaults, and removes tooltip-based read-only UX in favor of disabled actions and buttons, with corresponding test updates.

Sequence diagram for read-only banner and mutation disabling during trustify info load

sequenceDiagram
  actor User
  participant DefaultLayout
  participant ReadOnlyProvider
  participant useFetchTrustifyInfo
  participant LoadingWrapper

  User->>DefaultLayout: render
  DefaultLayout->>ReadOnlyProvider: React.useContext(ReadOnlyContext)
  ReadOnlyProvider->>useFetchTrustifyInfo: useFetchTrustifyInfo()
  useFetchTrustifyInfo-->>ReadOnlyProvider: { data, isLoading, error }
  ReadOnlyProvider-->>DefaultLayout: { isLoading, areMutationsDisabled }

  DefaultLayout->>LoadingWrapper: isFetching = isLoading

  alt [isLoading]
    LoadingWrapper-->>DefaultLayout: isFetchingState (empty)
    DefaultLayout-->>User: page content only (no read-only Banner)
  else [!isLoading]
    opt [error]
      LoadingWrapper-->>User: Banner status=danger with getAxiosErrorMessage(error)
    end
    opt [areMutationsDisabled]
      DefaultLayout-->>User: read-only Banner status=info
    end
  end
Loading

File-Level Changes

Change Details Files
Wrap the layout main content with a loading/error handler and only show the read-only banner when mutations are disabled and trustify info is not loading.
  • Replace use of isReadOnly in layout with isLoading and areMutationsDisabled from ReadOnlyContext.
  • Add LoadingWrapper around the main layout content to manage loading and error states for trustify info.
  • Render the read-only info banner only when areMutationsDisabled is true, inside the LoadingWrapper.
client/src/app/layout/default-layout.tsx
client/src/app/layout/default-layout.test.tsx
Redefine ReadOnlyContext semantics to expose areMutationsDisabled based on trustify info, and adjust provider and tests to match the new contract.
  • Change ReadOnlyContext interface from isReadOnly to areMutationsDisabled plus isLoading, with new default values.
  • Update ReadOnlyProvider to use the generic useFetchTrustifyInfo data shape, compute isReadOnly from trustifyInfo.readOnly, and derive areMutationsDisabled as isLoading
Simplify the Trustify info query hook to rely on react-query defaults and return a generic data shape without custom caching options.
  • Update useFetchTrustifyInfo to return { data, isLoading, error } using the default query options.
  • Remove custom staleTime, gcTime, refetchOnWindowFocus, refetchOnReconnect, and retry options.
  • Rename the returned trustifyInfo field to data for consistency.
client/src/app/queries/trustifyInfo.ts
Replace tooltip-based read-only UX with disabled actions/buttons driven by areMutationsDisabled across SBOM, advisory, importer, and shared button components.
  • Update SbomToolbar to use areMutationsDisabled from ReadOnlyContext, remove READ_ONLY_TOOLTIP usage, and disable the Upload SBOM dropdown item instead of aria-disabling via tooltip.
  • Change ReadOnlyButton to use areMutationsDisabled to set Button.isDisabled directly and remove tooltip wrapping and READ_ONLY_TOOLTIP dependency.
  • Refactor ImporterList row actions to use areMutationsDisabled and isDisabled flags instead of readOnlyActionProps and isAriaDisabled.
  • Update SbomGroupRow actions to disable Edit/Delete based on areMutationsDisabled and existing constraints, replacing readOnlyActionProps usage.
  • Adjust AdvisoryTable and SbomTable action menus to disable mutation actions when areMutationsDisabled rather than using readOnlyActionProps.
client/src/app/pages/sbom-list/sbom-toolbar.tsx
client/src/app/components/ReadOnlyButton.tsx
client/src/app/pages/importer-list/importer-list.tsx
client/src/app/pages/sbom-groups/sbom-groups-table.tsx
client/src/app/pages/advisory-list/advisory-table.tsx
client/src/app/pages/sbom-list/sbom-table.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@carlosthe19916 carlosthe19916 changed the title Hotfix/read only message fix: read-only banner, avoid rendering it while isLoading Jun 29, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.47%. Comparing base (d7740c4) to head (ce678f1).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
client/src/app/components/ReadOnlyButton.tsx 50.00% 1 Missing ⚠️
client/src/app/layout/default-layout.tsx 75.00% 1 Missing ⚠️
...ient/src/app/pages/importer-list/importer-list.tsx 66.66% 1 Missing ⚠️
client/src/app/pages/sbom-list/sbom-toolbar.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1114      +/-   ##
==========================================
+ Coverage   52.38%   52.47%   +0.09%     
==========================================
  Files         271      270       -1     
  Lines        5874     5867       -7     
  Branches     1842     1839       -3     
==========================================
+ Hits         3077     3079       +2     
+ Misses       2484     2478       -6     
+ Partials      313      310       -3     
Flag Coverage Δ
e2e 70.94% <92.85%> (+0.08%) ⬆️
unit 3.00% <33.33%> (+0.12%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@CryptoRodeo CryptoRodeo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@carlosthe19916 carlosthe19916 added this pull request to the merge queue Jun 29, 2026
Merged via the queue into guacsec:main with commit 99bd439 Jun 29, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Trustify Jun 29, 2026
@carlosthe19916 carlosthe19916 added the backport release/0.5.z This PR should be backported to release/0.5.z branch. label Jul 2, 2026
@carlosthe19916

Copy link
Copy Markdown
Collaborator Author

/backport

@trustify-ci-bot

Copy link
Copy Markdown
Contributor

Successfully created backport PR for release/0.5.z:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport release/0.5.z This PR should be backported to release/0.5.z branch.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants