Skip to content

NP-50911 Use link instead of button for export#8336

Open
iBuzza wants to merge 6 commits intodevelopfrom
NP-50911-move-export-button-to-link
Open

NP-50911 Use link instead of button for export#8336
iBuzza wants to merge 6 commits intodevelopfrom
NP-50911-move-export-button-to-link

Conversation

@iBuzza
Copy link
Contributor

@iBuzza iBuzza commented Mar 23, 2026

Description

Link to Jira issue: https://sikt.atlassian.net/browse/NP-50911

Move the exporting of excel file from button to link.

How to test

Affected part of the application: http://localhost:3000/tasks/nvi/publication-points

  1. Press the link and check that the file is downloaded

Checklist

Ensure that the changes are aligned with the expectations of PO/designer before marking the PR as ready for review.

Also ensure that the following criterias are met:

  • The changes are working as expected
  • The changes are tested OK for different screen sizes
  • The changes are tested OK for a11y
  • Interactive elements have data-testids
  • I have done a QA of my own changes

Note: some of these criterias may not always be relevant, and can simply be marked as completed.

Summary by CodeRabbit

  • New Features

    • Export dataset functionality now available as an inline link within result status messaging.
  • Refactor

    • Redesigned export interface from standalone button to integrated link component within status text.
  • Documentation

    • Added Norwegian translation for export dataset label ("Eksporter datagrunnlag for NVI-rapport").

@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ace48397-0aac-4e65-a592-25a3ae8686e7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description follows the template structure but is severely incomplete, with critical sections missing or containing only placeholder content. Complete the description by: (1) Explaining what the PR solves—what the problem was before, why the change is necessary, and what it achieves; (2) Providing detailed step-by-step testing instructions with clarity on what to verify; (3) Expanding the checklist explanation with specific details about how each criterion was validated.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: replacing the export button with a link component across the NVI publication points interface.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch NP-50911-move-export-button-to-link

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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: 2

🧹 Nitpick comments (1)
src/pages/messages/components/ExportNviStatusLink.tsx (1)

8-10: Interface name does not match the component name.

The interface is named ExportNviStatusButtonProps but the component is ExportNviStatusLink. Consider renaming for consistency.

Suggested rename
-interface ExportNviStatusButtonProps {
+interface ExportNviStatusLinkProps {
   acronym: string;
 }
-export const ExportNviStatusLink = ({ acronym }: ExportNviStatusButtonProps) => {
+export const ExportNviStatusLink = ({ acronym }: ExportNviStatusLinkProps) => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/messages/components/ExportNviStatusLink.tsx` around lines 8 - 10,
Rename the props interface to match the component name: change
ExportNviStatusButtonProps to ExportNviStatusLinkProps (or alternatively rename
the component to ExportNviStatusButton) and update all references accordingly so
the component ExportNviStatusLink uses the matching interface name; ensure
imports/exports and any type annotations (e.g., function signature or
React.FC<...>) reference the new ExportNviStatusLinkProps identifier.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/NviPublicationPointsTexts.tsx`:
- Line 51: The export link is always rendered because exportAcronym is coerced
to '' and passed into ExportNviStatusLink; update the rendering logic in
NviPublicationPointsTexts (the object that contains link: <ExportNviStatusLink
... />) to check exportAcronym first and either render a placeholder/disabled
component or an alternative text when exportAcronym is undefined, or instead
remove the fallback and let ExportNviStatusLink handle empty/undefined values
(update ExportNviStatusLink to early-return a disabled link or null when acronym
is falsy); reference the exportAcronym variable and the ExportNviStatusLink
component to locate where to implement the conditional rendering or early-return
handling.

In `@src/pages/messages/components/ExportNviStatusLink.tsx`:
- Around line 16-20: The click handler calls
fetchNviApprovalReportQuery.refetch() even when acronym is empty, allowing a
manual API call with invalid params; update the handleClick in
ExportNviStatusLink to validate the acronym (derived from exportAcronym) before
calling fetchNviApprovalReportQuery.refetch() or early-return, and also
conditionally render/disable the link when acronym === '' so users cannot
trigger it; reference the handleClick function,
fetchNviApprovalReportQuery.refetch, exportAcronym prop and
useFetchNviReportExport hook when making the change.

---

Nitpick comments:
In `@src/pages/messages/components/ExportNviStatusLink.tsx`:
- Around line 8-10: Rename the props interface to match the component name:
change ExportNviStatusButtonProps to ExportNviStatusLinkProps (or alternatively
rename the component to ExportNviStatusButton) and update all references
accordingly so the component ExportNviStatusLink uses the matching interface
name; ensure imports/exports and any type annotations (e.g., function signature
or React.FC<...>) reference the new ExportNviStatusLinkProps identifier.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 82961bf0-6819-4a2e-b84d-ed101dc90d23

📥 Commits

Reviewing files that changed from the base of the PR and between 50f9f1d and 33253ce.

📒 Files selected for processing (7)
  • src/components/NviPublicationPointsTexts.tsx
  • src/pages/messages/components/ExportNviStatusButton.tsx
  • src/pages/messages/components/ExportNviStatusLink.tsx
  • src/pages/messages/components/NviPublicationPointsPage.tsx
  • src/pages/messages/components/NviStatusPage.tsx
  • src/pages/messages/components/NviStatusWrapper.tsx
  • src/translations/nbTranslations.json
💤 Files with no reviewable changes (3)
  • src/pages/messages/components/NviStatusPage.tsx
  • src/pages/messages/components/NviStatusWrapper.tsx
  • src/pages/messages/components/ExportNviStatusButton.tsx

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 23, 2026
@iBuzza iBuzza marked this pull request as ready for review March 23, 2026 12:59
Copy link
Contributor

@denektenina denektenina left a comment

Choose a reason for hiding this comment

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

Looks good and integrates well with existing code. Could you answer my questions before I approve? Just want to make sure the choices are made on purpose.

components={{
p: <Typography />,
bold: <Typography component="span" sx={{ fontWeight: 'bold' }} />,
link: exportAcronym ? <ExportNviStatusLink acronym={exportAcronym} /> : <span />,
Copy link
Contributor

Choose a reason for hiding this comment

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

Possible to add a spinner here while loading, because there is no indicator that something happened after clicking the button (and the previous button had a spinner)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added spinner 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this Button supposed to download something else soon? Should it maybe be disabled like in the design instead of deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Restored the button and made it only disabled for publication points

opacity: fetchNviApprovalReportQuery.isFetching ? 0.7 : 1,
cursor: fetchNviApprovalReportQuery.isFetching ? 'default' : 'pointer',
}}>
<FileDownloadOutlinedIcon fontSize="small" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it agreed on that you should use a different icon than in the design?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no icon for xls-file in MUI Icons, and I didn't really find a better option than the one already used. Suggestions are welcome, though

Copy link
Contributor

@denektenina denektenina left a comment

Choose a reason for hiding this comment

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

Er det riktig at nedlastningsknappen skal fjernes fra rapporteringsstatus uten å erstattes av link? Går det an å gjøre så aggregation=all-kallet ikke gjøres før linken er klikket?

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.

2 participants