Skip to content

feat(readme): add hideIfNotFound config and refactor components#364

Merged
anicke merged 2 commits into
mainfrom
feat/readme-nfs-support
May 7, 2026
Merged

feat(readme): add hideIfNotFound config and refactor components#364
anicke merged 2 commits into
mainfrom
feat/readme-nfs-support

Conversation

@anicke
Copy link
Copy Markdown
Contributor

@anicke anicke commented Apr 29, 2026

Summary

Adds a hideIfNotFound config option to the readme card extension for the new frontend system, and refactors the plugin's internal component structure.

New hideIfNotFound config option

When set to true, the entire README card is hidden when no README.md file is found (404), instead of showing an error message. This is the NFS equivalent of the isReadmeAvailable entity filter available in the old frontend system.

app:
  extensions:
    - entity-card:readme:
        config:
          hideIfNotFound: true

Component refactoring

  • Rename FetchComponentReadmeContent (leftover name from plugin scaffolding template)
  • Extract README fetch logic into a new useReadmeContent hook; ReadmeContent is now a purely presentational component that accepts pre-fetched state as props
  • Lift state to ReadmeCard: owns the single useReadmeContent() call and spreads the result to both ReadmeContent and ReadmeDialog, eliminating a duplicate fetch when the dialog was opened
  • Wrap setFullView in useCallback in useFullViewParam

Tests

  • Simplified ReadmeContent and ReadmeDialog tests — no longer need MSW or context providers since the components are purely presentational

@anicke anicke requested a review from a team as a code owner April 29, 2026 12:00
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 29, 2026

🦋 Changeset detected

Latest commit: 9743cef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@axis-backstage/plugin-readme Minor
app-next Patch
app Patch
backend Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

- Add `hideIfNotFound` boolean config option (default: `false`) to the
  readme card NFS extension via `configSchema` in `makeWithOverrides`
- When `true`, the entire card is hidden when no README.md file is found
  (404), rather than rendering an error message — mirrors the old
  `isReadmeAvailable` filter which is not available in NFS
- Add JSDoc with yaml example to the config option in `alpha.tsx`

- Rename `FetchComponent` to `ReadmeContent` (was a leftover name
  from the plugin scaffolding template)
- Extract README fetch logic into a new `useReadmeContent` hook, making
  `ReadmeContent` a purely presentational component that accepts
  pre-fetched state as props
- Lift state to `ReadmeCard`: it now owns the single `useReadmeContent()`
  call and spreads the result to both `ReadmeContent` and `ReadmeDialog`,
  eliminating the duplicate fetch that previously occurred when the
  dialog was opened
- `ReadmeDialog` now accepts and passes through `ReadmeContentProps`
  instead of performing its own fetch

- Wrap `setFullView` in `useCallback` in `useFullViewParam` to avoid
  unnecessary re-renders
- Update tests for `ReadmeContent` and `ReadmeDialog` to pass props
  directly — no longer need MSW or context providers since the
  components are now purely presentational
- Update README.md with `hideIfNotFound` usage documentation
- Add `hideIfNotFound: false` example to `app-config.yaml`
@anicke anicke force-pushed the feat/readme-nfs-support branch from 63730d2 to 899e720 Compare April 29, 2026 13:11
fridajac
fridajac previously approved these changes Apr 30, 2026
Copy link
Copy Markdown

@MartinWallgren MartinWallgren left a comment

Choose a reason for hiding this comment

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

LGTM

@anicke anicke merged commit b5e5411 into main May 7, 2026
8 checks passed
@anicke anicke deleted the feat/readme-nfs-support branch May 7, 2026 06:58
@halkeye
Copy link
Copy Markdown

halkeye commented May 26, 2026

I just saw this in the docs/readme
If i understand whats going on correctly, it won't be released until #365 is merged right?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants