Download wp-calypso/client/post-editor/media-modal/gallery/remove-button.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/post-editor/media-modal/gallery/remove-button.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/post-editor/media-modal/gallery/remove-button.jsx
-
curl -L -o remove-button.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/post-editor/media-modal/gallery/remove-button.jsx
1.41 kB
| import { ScreenReaderText, Gridicon } from '@automattic/components'; | |
| import { localize } from 'i18n-calypso'; | |
| import { reject } from 'lodash'; | |
| import PropTypes from 'prop-types'; | |
| import { PureComponent } from 'react'; | |
| import { connect } from 'react-redux'; | |
| import { selectMediaItems } from 'calypso/state/media/actions'; | |
| import getMediaLibrarySelectedItems from 'calypso/state/selectors/get-media-library-selected-items'; | |
| /* eslint-disable wpcalypso/jsx-classname-namespace */ | |
| class RemoveButton extends PureComponent { | |
| static propTypes = { | |
| siteId: PropTypes.number, | |
| itemId: PropTypes.number, | |
| }; | |
| remove = () => { | |
| const { siteId, itemId, selectedItems } = this.props; | |
| if ( ! siteId || ! itemId ) { | |
| return; | |
| } | |
| const items = reject( selectedItems, ( item ) => item.ID === itemId ); | |
| this.props.selectMediaItems( siteId, items ); | |
| }; | |
| render() { | |
| const { translate } = this.props; | |
| return ( | |
| <button | |
| onClick={ this.remove } | |
| onMouseDown={ ( event ) => event.stopPropagation() } | |
| className="editor-media-modal-gallery__remove" | |
| > | |
| <ScreenReaderText>{ translate( 'Remove' ) }</ScreenReaderText> | |
| <Gridicon icon="cross" /> | |
| </button> | |
| ); | |
| } | |
| } | |
| RemoveButton.displayName = 'RemoveButton'; | |
| export default connect( | |
| ( state, { siteId } ) => ( { | |
| selectedItems: getMediaLibrarySelectedItems( state, siteId ), | |
| } ), | |
| { selectMediaItems } | |
| )( localize( RemoveButton ) ); | |