Skip to content

Commit

Permalink
Check tag type
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusborne committed Dec 6, 2024
1 parent 1b00f7a commit a264160
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions src/dynamic-tags/components/DynamicTagSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ export function DynamicTagSelect( { onInsert, tagName, selectedText, currentPost
setDynamicSource( 'user' );
setUserSource( id );
} else if ( 'media' === type ) {
setDynamicSource( 'media' );
setMediaSource( id );
} else {
setDynamicSource( 'post' );
Expand Down Expand Up @@ -517,8 +516,6 @@ export function DynamicTagSelect( { onInsert, tagName, selectedText, currentPost
setDynamicSource( 'term' );
} else if ( userSource && 'user' === dynamicTagType && 'user' !== dynamicSource ) {
setDynamicSource( 'user' );
} else if ( mediaSource && 'media' === dynamicTagType && 'media' !== dynamicSource ) {
setDynamicSource( 'media' );
} else if ( ! dynamicSource ) {
setDynamicSource( 'current' );
}
Expand All @@ -533,7 +530,7 @@ export function DynamicTagSelect( { onInsert, tagName, selectedText, currentPost
options.push( `id:${ termSource }` );
} else if ( userSource && 'user' === dynamicSource ) {
options.push( `id:${ userSource }` );
} else if ( mediaSource && 'media' === dynamicSource ) {
} else if ( mediaSource && 'media' === dynamicTagType ) {
options.push( `id:${ mediaSource }` );
}

Expand Down Expand Up @@ -731,25 +728,6 @@ export function DynamicTagSelect( { onInsert, tagName, selectedText, currentPost
</>
) }

{ 'media' === dynamicSource && (
<>
<SelectPost
label={ __( 'Select source media', 'generateblocks' ) }
value={ mediaSource }
onChange={ ( selected ) => setMediaSource( selected?.value ?? '' ) }
onClear={ () => setMediaSource( '' ) }
onAdd={ ( { inputValue } ) => setMediaSource( inputValue ) }
onEnter={ ( inputValue ) => {
setMediaSource( inputValue );
} }
currentPostId={ currentPostId }
includeCurrent={ false }
postStatus={ [ 'inherit' ] }
postType={ [ 'attachment' ] }
/>
</>
) }

{ 'user' === dynamicSource && (
<>
<SelectUser
Expand Down Expand Up @@ -783,6 +761,25 @@ export function DynamicTagSelect( { onInsert, tagName, selectedText, currentPost
/>
) }

{ 'media' === dynamicTagType && (
<>
<SelectPost
label={ __( 'Select source media', 'generateblocks' ) }
value={ mediaSource }
onChange={ ( selected ) => setMediaSource( selected?.value ?? '' ) }
onClear={ () => setMediaSource( '' ) }
onAdd={ ( { inputValue } ) => setMediaSource( inputValue ) }
onEnter={ ( inputValue ) => {
setMediaSource( inputValue );
} }
currentPostId={ currentPostId }
includeCurrent={ false }
postStatus={ [ 'inherit' ] }
postType={ [ 'attachment' ] }
/>
</>
) }

{ tagSupportsMeta && (
<SelectMeta
value={ metaKey }
Expand Down

0 comments on commit a264160

Please sign in to comment.