Skip to content

Commit

Permalink
[RNMobile] [Embed block] - Unavailable preview fallback bottom sheet …
Browse files Browse the repository at this point in the history
…title update (#34674)

* Added the word embed to the bottom sheet title to make it clearer.

* Added isDefaultEmbedInfo flag required by the EmbedNoPreview component

* isDefaultEmbedInfo determines if generic label should be shown or not

* used constant to store embedInfoByProvider to get rid of duplicate calls
  • Loading branch information
jd-alexander authored Sep 14, 2021
1 parent 4aaf626 commit a9da8a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/block-library/src/embed/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const EmbedEdit = ( props ) => {
title: _x( 'Embed', 'block title' ),
icon: embedContentIcon,
};
const { icon, title } =
getEmbedInfoByProvider( providerNameSlug ) || defaultEmbedInfo;
const embedInfoByProvider = getEmbedInfoByProvider( providerNameSlug );
const { icon, title } = embedInfoByProvider || defaultEmbedInfo;

const { wasBlockJustInserted } = useSelect(
( select ) => ( {
Expand Down Expand Up @@ -256,6 +256,7 @@ const EmbedEdit = ( props ) => {
previewable={ previewable }
type={ type }
url={ url }
isDefaultEmbedInfo={ ! embedInfoByProvider }
/>
</View>
</>
Expand Down
15 changes: 10 additions & 5 deletions packages/block-library/src/embed/embed-no-preview.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const EmbedNoPreview = ( {
isSelected,
onPress,
previewable,
isDefaultEmbedInfo,
} ) => {
const shouldRequestReview = useRef( false );
const [ isSheetVisible, setIsSheetVisible ] = useState( false );
Expand Down Expand Up @@ -172,11 +173,15 @@ const EmbedNoPreview = ( {
/>
</View>
<Text style={ sheetTitleStyle }>
{ sprintf(
// translators: %s: embed block variant's label e.g: "Twitter".
__( '%s block previews are coming soon' ),
label
) }
{ isDefaultEmbedInfo
? __( 'Embed block previews are coming soon' )
: sprintf(
// translators: %s: embed block variant's label e.g: "Twitter".
__(
'%s embed block previews are coming soon'
),
label
) }
</Text>
<Text style={ sheetDescriptionStyle }>
{ comingSoonDescription }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/embed/embed-preview.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const EmbedPreview = ( {
isProviderPreviewable,
type,
url,
isDefaultEmbedInfo,
} ) => {
const [ isCaptionSelected, setIsCaptionSelected ] = useState( false );
const { locale } = useSelect( blockEditorStore ).getSettings();
Expand Down Expand Up @@ -137,6 +138,7 @@ const EmbedPreview = ( {
isSelected={ isSelected }
onPress={ () => setIsCaptionSelected( false ) }
previewable={ previewable }
isDefaultEmbedInfo={ isDefaultEmbedInfo }
/>
) }
<BlockCaption
Expand Down

0 comments on commit a9da8a9

Please sign in to comment.