PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 All 257 releases
give / src / Views / Components / ListTable / BulkActions / BulkActionSelect.tsx

BulkActionSelect.tsx in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at src/Views/Components/ListTable/BulkActions/BulkActionSelect.tsx

57 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {__} from '@wordpress/i18n';
2 import CustomFilter from '../CustomFilter';
3 import styles from './BulkActionSelect.module.scss';
4 import pageStyles from '../ListTablePage/ListTablePage.module.scss';
5
6 export const BulkActionSelect = ({bulkActions = null, selectedState, showModal, data, parameters}) => {
7 const [selectedAction, setSelectedAction] = selectedState;
8
9 if (window.GiveDonations && window.GiveDonations.addonsBulkActions) {
10 bulkActions = [...bulkActions, ...window.GiveDonations.addonsBulkActions];
11 }
12
13 if (!bulkActions) {
14 return null;
15 }
16
17 // Format bulkActions for Custom Select
18 const filteredOptions = bulkActions
19 .filter(action => {
20 if (typeof action?.isVisible == 'function' && !action.isVisible(data, parameters)) {
21 return false;
22 }
23 return true;
24 })
25 .map(action => ({
26 value: action.value,
27 text: action.label
28 }));
29
30 const changeSelected = (name, value) => {
31 setSelectedAction(value);
32 };
33
34 return (
35 <div id={styles.bulkActionsForm}>
36 <CustomFilter
37 name="bulkActions"
38 options={filteredOptions}
39 ariaLabel={__('Bulk Actions', 'give')}
40 placeholder={__('Bulk Actions', 'give')}
41 onChange={changeSelected}
42 value={selectedAction}
43 isSearchable={false}
44 isSelectable={true}
45 isClearable={true}
46 />
47 <button
48 onClick={showModal}
49 className={`button button-tertiary ${pageStyles.secondaryActionButton}`}
50 disabled={!selectedAction}
51 >
52 {__('Apply', 'give')}
53 </button>
54 </div>
55 );
56 };
57