Skip to content

Added loading state to post analytics export#27998

Merged
EvanHahn merged 1 commit into
mainfrom
chris-ny-1296-add-a-loading-state-to-the-export-post-analytics-button-to
May 21, 2026
Merged

Added loading state to post analytics export#27998
EvanHahn merged 1 commit into
mainfrom
chris-ny-1296-add-a-loading-state-to-the-export-post-analytics-button-to

Conversation

@cmraible

@cmraible cmraible commented May 20, 2026

Copy link
Copy Markdown
Collaborator

closes https://linear.app/ghost/issue/NY-1296/add-a-loading-state-to-the-export-post-analytics-button-to-indicate

Summary

  • Added a loading and disabled state to the Post analytics export button while the CSV export is running
  • Guarded against duplicate export clicks during an in-flight request
  • Added acceptance coverage for the loading and disabled button state

Before

Screenshot.2026-05-20.at.13.53.42.mp4

After

Screenshot.2026-05-20.at.13.55.44.mp4

ref NY-1296

The post analytics export can take a while to prepare, so the export action now gives users feedback and prevents duplicate requests while it is running.
@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR adds loading state management to the post analytics export feature in the Admin X Settings panel. A new isExportingPosts React state variable tracks whether an export is in progress. The exportPosts handler now prevents concurrent exports by early-returning if an export is already running, and always clears the flag via a finally block. The "Post analytics" button is updated to disable during export and display a loading indicator tied to this state. A new acceptance test verifies the button becomes disabled with a "Loading..." label while the export request is pending and re-enables after completion.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: adding a loading state to the post analytics export button.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description clearly explains the changes: adding a loading state to the export button, guarding against duplicate clicks, and adding test coverage.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chris-ny-1296-add-a-loading-state-to-the-export-post-analytics-button-to

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.

@cmraible cmraible marked this pull request as ready for review May 20, 2026 18:20
@cmraible cmraible requested a review from EvanHahn May 20, 2026 18:39
const postAnalyticsButton = section.getByTestId('post-analytics-export-button');
await postAnalyticsButton.click();

await expect.poll(() => exportRequestCount).toBe(1);

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.

praise: TIL this exists

@EvanHahn EvanHahn merged commit 263ee04 into main May 21, 2026
39 checks passed
@EvanHahn EvanHahn deleted the chris-ny-1296-add-a-loading-state-to-the-export-post-analytics-button-to branch May 21, 2026 16:14
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