Skip to content

A new permalink should be generated and shown after using the re-upload feature#5547

Merged
fqueze merged 1 commit intofirefox-devtools:mainfrom
fqueze:reupload-permalink
Aug 11, 2025
Merged

A new permalink should be generated and shown after using the re-upload feature#5547
fqueze merged 1 commit intofirefox-devtools:mainfrom
fqueze:reupload-permalink

Conversation

@fqueze
Copy link
Contributor

@fqueze fqueze commented Aug 7, 2025

Patch entirely generated by claude code from the prompt clicking "Re-upload" should generate a new permalink and show it like an initial upload does here's the summary it produced:

✅ Re-upload Permalink Display Implementation

Summary

Successfully implemented the feature to make clicking "Re-upload" generate a new permalink and show it automatically like an initial upload does.

🔧 Changes Made

1. Enhanced MenuButtonsPermalink Component (src/components/app/MenuButtons/Permalink.js)

  • Added reference to the ButtonWithPanel component for programmatic control
  • Implemented componentDidUpdate to detect when isNewlyPublished changes from false to true
  • Automatically opens the permalink panel when a re-upload completes using the existing openPanel() API

2. Added Test Coverage (src/test/components/MenuButtonsPermalinks.test.js)

  • Created test case verifying the permalink panel opens automatically after profile publish/re-upload
  • Properly handles React state updates with act() wrapper

🚀 How It Works

  1. Initial uploads: Continue to work as before using initialOpen={this.props.isNewlyPublished}
  2. Re-uploads: When attemptToPublish() completes, it dispatches PROFILE_PUBLISHED setting isNewlyPublished to true
  3. Automatic display: The componentDidUpdate method detects this state change and programmatically opens the permalink panel
  4. URL generation: Existing URL shortening and display logic handles showing the new permalink

✅ Verification

  • Flow type checking: ✅ Passes
  • ESLint: ✅ Passes
  • Prettier formatting: ✅ Passes
  • All existing tests: ✅ Continue to pass (30/30 MenuButtons tests, 2/2 existing permalink tests)
  • New test: ✅ Passes (verifies re-upload permalink display behavior)

📝 Technical Details

The implementation leverages the existing architecture:

  • Uses the same isNewlyPublished state that handles initial uploads
  • Employs the ButtonWithPanel component's public openPanel() method
  • Follows existing React lifecycle patterns with componentDidUpdate
  • Maintains backward compatibility with all existing functionality

The solution is minimal, non-intrusive, and ensures re-uploads now provide the same user experience as initial uploads by automatically displaying the new permalink.

@fqueze fqueze requested a review from canova August 7, 2025 17:39
@codecov
Copy link

codecov bot commented Aug 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.13%. Comparing base (a148dac) to head (05e209c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5547   +/-   ##
=======================================
  Coverage   86.13%   86.13%           
=======================================
  Files         309      309           
  Lines       29879    29883    +4     
  Branches     8037     8038    +1     
=======================================
+ Hits        25736    25740    +4     
  Misses       3552     3552           
  Partials      591      591           

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Member

@canova canova left a comment

Choose a reason for hiding this comment

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

Thanks! It works well, but I would prefer to avoid taking another ref. It should be similar to implement this by having a similar logic inside that component since we already pass isNewlyPublished as initialOpen.


export class MenuButtonsPermalink extends React.PureComponent<Props, State> {
_permalinkTextField: HTMLInputElement | null = null;
_buttonWithPanel: ButtonWithPanel | null = null;
Copy link
Member

Choose a reason for hiding this comment

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

Looking at this, I think I would like to avoid taking another ref if possible.

Currently it does the job, but the same functionality can be implemented by a prop. Actually we already have this prop as initialOpen. So all we have to do is to make this prop more generic, like open and make sure that it's being handled properly on componentDidUpdate inside that component.

I checked other places and it looks like here is the only place where we use initialOpen, so it should be fine to do that.

It's usually fix things with props if we can instead of refs because that way we let the component handle its state internally. And we make sure that this component doesn't have a different behavior by not breaking the proper encapsulation.

@fqueze fqueze force-pushed the reupload-permalink branch from 7009adf to 2c3ae1b Compare August 8, 2025 16:27
@fqueze fqueze requested a review from canova August 8, 2025 16:28
state = {
fullUrl: '',
shortUrl: '',
panelOpen: !!this.props.isNewlyPublished,
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need panelOpen state for this Permalink component? It shouldn't really need to know anything about its children's state. We can simplify this by only passing open={isNewlyPublished} to the child and compute this there.

if (currentOpen && !this.state.open) {
this.openPanel();
} else if (!currentOpen && this.state.open) {
this.closePanel();
Copy link
Member

Choose a reason for hiding this comment

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

No need to handle closePanel. Just let it open and don't let it close programmatically. User does it already. Maybe a check like this should be enough if (prevOpen !== currentOpen && currentOpen).

@fqueze fqueze force-pushed the reupload-permalink branch from 2c3ae1b to 05e209c Compare August 8, 2025 19:17
Copy link
Member

@canova canova left a comment

Choose a reason for hiding this comment

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

It looks good, thanks!

@fqueze fqueze merged commit 333baf8 into firefox-devtools:main Aug 11, 2025
15 checks passed
@fqueze fqueze deleted the reupload-permalink branch August 11, 2025 09:16
@canova canova mentioned this pull request Sep 2, 2025
canova added a commit that referenced this pull request Sep 2, 2025
Changes:

[Nazım Can Altınova] Display the marker description at the top inside
the marker tooltips (#5534)
[Florian Quèze] Change the 'JavaScript' radio button label to 'Script'
(#5530)
[Markus Stange] Implement profile logic and some selectors for the
function list (#5525)
[Markus Stange] Some small type fixes (#5538)
[Markus Stange] Simplify return type of the callback we pass to
setState. (#5540)
[Markus Stange] Pass the correct value to the reducer's action argument
(#5543)
[Markus Stange] Change withSize to accept PropsWithoutSize as its type
parameter (#5541)
[Nazım Can Altınova] Make sure that the test-debug command runs the
tests properly (#5545)
[Markus Stange] Improve type coverage involving network phases (#5539)
[Markus Stange] Change implementation of withChartViewport (#5542)
[Florian Quèze] A new permalink should be generated and shown after
using the re-upload feature. (#5547)
[Florian Quèze] Show the vertical ruler in the timeline when hovering
the network chart (#5548)
[Markus Stange] Convert the entire codebase to TypeScript (#5549)
[Nazım Can Altınova] Update the yarn.lock file after recent changes
(#5557)
[Markus Stange] Add proper TypeScript coverage for window-navigation.ts
(#5559)
[Markus Stange] Remove leftover $FlowExpectError comments (#5560)
[Markus Stange] Fix Iterator / Iterable confusion (#5561)
[Nazım Can Altınova] Remove the unneeded test-all:ci script (#5566)
[Nazım Can Altınova] Fix a type case inconsistency (#5569)
[Florian Quèze] Make 'yarn lint --fix' work as an alias to 'yarn
lint-fix'. (#5563)
[Ryan Hunt] Don't stringify JSON again in fetchUrlResponse (#5570)
[Nazım Can Altınova] Upgrade ESLint to version 9 (#5567)
[Markus Stange] Simplify Worker setup, and support .json.gz inputs in
symbolicator-cli (#5556)
[Nazım Can Altınova] Add TypeScript coverage to the intersection
observer mock (#5574)
[Markus Stange] Set the preview selection to null when there is no
selection (#5568)
[Markus Stange] Add tests for query-api.ts (#5571)
[Markus Stange] Enable noUnusedParameters and
@typescript-eslint/no-unused-vars and clean up a few more things (#5576)
[Ryan Hunt] Embed iongraph-web and use for iongraph.json source files
(#5577)
[Markus Stange] Remove recursion in filterThreadToSearchString (#5572)


And thanks to our localizers:

be: Mikalai Udodau
de: Michael Köhler
el: Jim Spentzos
en-CA: chutten
en-GB: Paul
es-CL: ravmn
fr: Théo Chevalier
fur: Fabio Tomat
fy-NL: Fjoerfoks
ia: Melo46
it: Francesco Lodolo [:flod]
nl: Mark Heijl
pt-BR: Marcelo Ghelman
ru: Valery Ledovskoy
sv-SE: Luna Jernberg
tr: Rua
tr: Selim Şumlu
uk: Іhor Hordiichuk
zh-CN: Olvcpr423
zh-TW: Pin-guang Chen
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