Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix admin page crash on video upload/delete when the free-plan upgrade nudge is shown
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,19 @@ const Admin = () => {

export default Admin;

// VIDP-245: keep these `__()` calls at module scope as separate statements.
// If they live as the two arms of an inline ternary, terser folds them into a
// single `__( cond ? 'a' : 'b', domain )`, which breaks string-literal POT
// extraction (the i18n-check-webpack-plugin fails the production build).
Comment on lines +215 to +217
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ugh, that's annoying, I ran into that today, too.

const UPGRADE_TRIGGER_USED_VIDEO_TEXT = __(
'You have used your free video upload',
'jetpack-videopress-pkg'
);
const UPGRADE_TRIGGER_FREE_PLAN_TEXT = __(
'The free plan includes one video upload.',
'jetpack-videopress-pkg'
);

const UpgradeTrigger = ( { hasUsedVideo = false }: { hasUsedVideo: boolean } ) => {
const { adminUri, siteSuffix } = window.jetpackVideoPressInitialState;

Expand All @@ -236,9 +249,18 @@ const UpgradeTrigger = ( { hasUsedVideo = false }: { hasUsedVideo: boolean } ) =
run
);

// VIDP-245: keep the `Notice.Root` children shape invariant across the
// `hasUsedVideo` flip. base-ui@1.4.1's `useRenderElement` swaps between two
// different ref-merge hooks depending on subtree shape, so conditionally
// mounting `<Notice.Description>` (as this did before) misaligns its stored
// fork-ref and crashes on the next upload/delete. Always render the
// Description — mirroring the modern dashboard's `free-tier-notice.tsx` —
// varying only its text, with a non-empty fallback nudge before the first
// upload so we never render an empty styled row. The two strings are hoisted
// to module scope (above) to avoid the terser i18n ternary-fold.
const description = hasUsedVideo
? __( 'You have used your free video upload', 'jetpack-videopress-pkg' )
: '';
? UPGRADE_TRIGGER_USED_VIDEO_TEXT
: UPGRADE_TRIGGER_FREE_PLAN_TEXT;

const cta = __(
'Upgrade now to unlock unlimited videos, 1TB of storage, and more!',
Expand All @@ -247,7 +269,7 @@ const UpgradeTrigger = ( { hasUsedVideo = false }: { hasUsedVideo: boolean } ) =

return (
<Notice.Root intent="info" className={ styles[ 'upgrade-trigger' ] }>
{ description && <Notice.Description>{ description }</Notice.Description> }
<Notice.Description>{ description }</Notice.Description>
<Notice.Actions>
<Notice.ActionButton onClick={ onButtonClickHandler }>{ cta }</Notice.ActionButton>
</Notice.Actions>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

VideoPress: fix admin page crash on video upload/delete when the free-plan upgrade nudge is shown
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix admin page crash on video upload/delete when the free-plan upgrade nudge is shown
Loading