A new permalink should be generated and shown after using the re-upload feature#5547
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
canova
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
7009adf to
2c3ae1b
Compare
| state = { | ||
| fullUrl: '', | ||
| shortUrl: '', | ||
| panelOpen: !!this.props.isNewlyPublished, |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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).
2c3ae1b to
05e209c
Compare
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
Patch entirely generated by claude code from the prompt
clicking "Re-upload" should generate a new permalink and show it like an initial upload doeshere'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
MenuButtonsPermalinkComponent (src/components/app/MenuButtons/Permalink.js)ButtonWithPanelcomponent for programmatic controlcomponentDidUpdateto detect whenisNewlyPublishedchanges from false to trueopenPanel()API2. Added Test Coverage (
src/test/components/MenuButtonsPermalinks.test.js)act()wrapper🚀 How It Works
initialOpen={this.props.isNewlyPublished}attemptToPublish()completes, it dispatchesPROFILE_PUBLISHEDsettingisNewlyPublishedto truecomponentDidUpdatemethod detects this state change and programmatically opens the permalink panel✅ Verification
📝 Technical Details
The implementation leverages the existing architecture:
isNewlyPublishedstate that handles initial uploadsButtonWithPanelcomponent's publicopenPanel()methodcomponentDidUpdateThe solution is minimal, non-intrusive, and ensures re-uploads now provide the same user experience as initial uploads by automatically displaying the new permalink.