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 / Campaigns / Blocks / CampaignGoal / edit.tsx

edit.tsx in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at src/Campaigns/Blocks/CampaignGoal/edit.tsx

57 lines 2.0 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 {useSelect} from '@wordpress/data';
3 import {InspectorControls, useBlockProps} from '@wordpress/block-editor';
4 import {BlockEditProps} from '@wordpress/blocks';
5 import {ExternalLink, PanelBody, TextControl} from '@wordpress/components';
6 import useCampaign from '../shared/hooks/useCampaign';
7 import CampaignGoalApp from './app/index';
8 import CampaignSelector from '../shared/components/CampaignSelector';
9 import {getGoalDescription} from './utils';
10
11 /**
12 * @since 4.0.0
13 */
14 export default function Edit({attributes, setAttributes}: BlockEditProps<{
15 campaignId: number;
16 goalType: string;
17 }>) {
18 const {campaign, hasResolved} = useCampaign(attributes.campaignId);
19
20 const blockProps = useBlockProps();
21
22 const adminBaseUrl = useSelect(
23 // @ts-ignore
24 (select) => select('core').getSite()?.url + '/wp-admin/edit.php?post_type=give_forms&page=give-campaigns',
25 []
26 );
27
28 if (!hasResolved) {
29 return null;
30 }
31
32 return (
33 <div {...blockProps}>
34 <CampaignSelector
35 campaignId={attributes.campaignId}
36 handleSelect={(campaignId: number) => setAttributes({campaignId})}
37 >
38 <CampaignGoalApp campaign={campaign} />
39 </CampaignSelector>
40
41 {campaign?.id && (
42 <InspectorControls>
43 <PanelBody title={__('Settings', 'give')} initialOpen={true}>
44 <TextControl value={getGoalDescription(campaign.goalType)} onChange={null} disabled={true} />
45 <ExternalLink
46 href={`${adminBaseUrl}&id=${attributes.campaignId}&tab=settings#campaign-goal`}
47 title={__('Edit campaign goal settings', 'give')}
48 >
49 {__('Edit campaign goal settings', 'give')}
50 </ExternalLink>
51 </PanelBody>
52 </InspectorControls>
53 )}
54 </div>
55 );
56 }
57