AuthorMetaControl.js
3 years ago
CommentsControl.js
4 years ago
ContentTypeControl.js
4 years ago
DynamicSourceControl.js
3 years ago
ExcerptControl.js
4 years ago
LinkTypeControl.js
3 years ago
PostDateControl.js
4 years ago
PostMetaControl.js
3 years ago
TermsControl.js
4 years ago
DynamicSourceControl.js
47 lines
| 1 | import { __ } from '@wordpress/i18n'; |
| 2 | import SelectPostType from '../components/SelectPostType'; |
| 3 | import PostTypeRecordsSelect from '../../../components/post-type-records-select'; |
| 4 | import SelectSource from '../components/SelectSource'; |
| 5 | |
| 6 | export default ( { dynamicSource, postType, postId, setAttributes, dynamicContentType } ) => { |
| 7 | return ( |
| 8 | <> |
| 9 | <SelectSource |
| 10 | source={ dynamicSource } |
| 11 | onChange={ ( option ) => { |
| 12 | setAttributes( { |
| 13 | dynamicSource: option.value, |
| 14 | postId: '', |
| 15 | postType: 'post', |
| 16 | } ); |
| 17 | } } |
| 18 | dynamicContentType={ dynamicContentType } |
| 19 | /> |
| 20 | |
| 21 | { dynamicSource === 'post-type' && |
| 22 | <> |
| 23 | <SelectPostType |
| 24 | postType={ postType } |
| 25 | onChange={ ( option ) => { |
| 26 | setAttributes( { postType: option.value, postId: '' } ); |
| 27 | } } |
| 28 | /> |
| 29 | |
| 30 | <PostTypeRecordsSelect |
| 31 | postId={ postId } |
| 32 | postType={ postType } |
| 33 | value={ !! postId ? [ postId ] : [] } |
| 34 | id={ 'gblocks-select-post' } |
| 35 | label={ __( 'Select source post', 'generateblocks' ) } |
| 36 | help={ __( 'Search by name or ID.', 'generateblocks' ) } |
| 37 | onChange={ ( option ) => { |
| 38 | setAttributes( { postId: option.value } ); |
| 39 | } } |
| 40 | isMulti={ false } |
| 41 | /> |
| 42 | </> |
| 43 | } |
| 44 | </> |
| 45 | ); |
| 46 | }; |
| 47 |