Skip to content

Commit

Permalink
Merge branch 'epic/campaigns' into feature/campaign-block-GIVE-1388
Browse files Browse the repository at this point in the history
  • Loading branch information
jonwaldstein authored Feb 19, 2025
2 parents 75e24c7 + 73b8661 commit 48f520f
Show file tree
Hide file tree
Showing 56 changed files with 665 additions and 340 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wordpress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
Expand Down
4 changes: 4 additions & 0 deletions assets/src/css/admin/_components.admin-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
.post-type-give_forms,
.give_forms_page_give-subscriptions {

.page-title-action:not(.switch-new-view) {
display: none;
}

.wp-header-end + .notice {
margin-top: 11px;
}
Expand Down
119 changes: 65 additions & 54 deletions assets/src/js/admin/reports/components/no-data-notice/index.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,82 @@
// Dependencies
import { useState, Fragment } from 'react';
import { __ } from '@wordpress/i18n'
import { getWindowData } from '../../utils';
import {Fragment, useState} from 'react';
import {__} from '@wordpress/i18n';
import {getWindowData} from '../../utils';

// Store-related dependencies
import { useStoreValue } from '../../store';
import { disablePeriodSelector } from '../../store/actions';
import {useStoreValue} from '../../store';
import {disablePeriodSelector} from '../../store/actions';

// Styles
import './style.scss';

const NoDataNotice = ( { version } ) => {
const [ {}, dispatch ] = useStoreValue();
const NoDataNotice = ({version}) => {
const [{}, dispatch] = useStoreValue();

const [ showNotice, setShowNotice ] = useState( true );
const [showNotice, setShowNotice] = useState(true);

const loadSampleData = () => {
setShowNotice( false );
dispatch( disablePeriodSelector() );
};
const loadSampleData = () => {
setShowNotice(false);
dispatch(disablePeriodSelector());
};

const goToNewFormUrl = () => {
const url = getWindowData( 'newFormUrl' );
window.location = url;
};
const goToNewFormUrl = () => {
const url = getWindowData('newFormUrl');
window.location = url;
};

return (
<Fragment>
{ showNotice && (
<div className="givewp-not-found-notice">
<div className="givewp-not-found-card">
{ version === 'dashboard' ? (
<Fragment>
<h2>{ __( 'Get a quick view of your', 'give' ) }<br />{ __( 'donation activity', 'give' ) }</h2>
<p>
{ __( 'It looks like there hasn\'t been any donations yet on your website.', 'give' ) } <br />
{ __( 'Set up a donation form to begin collecting donations now.', 'give' ) } <br />
</p>
<button
onClick={ () => goToNewFormUrl() }
className="givewp-not-found-notice-button">
{ __( 'Create a Donation Form', 'give' ) }
</button>
</Fragment>
) : (
<Fragment>
<h2>{ __( 'Get a detailed view of your', 'give' ) }<br />{ __( 'donation activity', 'give' ) }</h2>
<p>
{ __( 'It looks like there hasn\'t been any donations yet on your website. ', 'give' ) } <br />
{ __( 'Set up a donation form to begin collection donations or load some sample data to preview what the reports look like.', 'give' ) } <br />
</p>
<button
onClick={ () => loadSampleData() }
className="givewp-not-found-notice-button">
{ __( 'Explore Sample Reports', 'give' ) }
</button>
</Fragment>
) }
</div>
</div>
) }
</Fragment>
);
return (
<Fragment>
{showNotice && (
<div className="givewp-not-found-notice">
<div className="givewp-not-found-card">
{version === 'dashboard' ? (
<Fragment>
<h2>
{__('Get a quick view of your', 'give')}
<br />
{__('donation activity', 'give')}
</h2>
<p>
{__("It looks like there hasn't been any donations yet on your website.", 'give')}{' '}
<br />
{__('Set up a campaign form to begin collecting donations now.', 'give')}
<br />
</p>
<button onClick={() => goToNewFormUrl()} className="givewp-not-found-notice-button">
{__('Create a Campaign Form', 'give')}
</button>
</Fragment>
) : (
<Fragment>
<h2>
{__('Get a detailed view of your', 'give')}
<br />
{__('donation activity', 'give')}
</h2>
<p>
{__("It looks like there hasn't been any donations yet on your website. ", 'give')}{' '}
<br />
{__(
'Set up a campaign form to begin collection donations or load some sample data to preview what the reports look like.',
'give'
)}{' '}
<br />
</p>
<button onClick={() => loadSampleData()} className="givewp-not-found-notice-button">
{__('Explore Sample Reports', 'give')}
</button>
</Fragment>
)}
</div>
</div>
)}
</Fragment>
);
};

NoDataNotice.defaultProps = {
version: 'app',
version: 'app',
};

export default NoDataNotice;
39 changes: 22 additions & 17 deletions blocks/components/no-form/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n'
import { Button } from '@wordpress/components';
import {__} from '@wordpress/i18n';
import {Button} from '@wordpress/components';

/**
* Internal dependencies
*/
import { getSiteUrl } from '../../utils';
import {getSiteUrl} from '../../utils';
import GiveBlankSlate from '../blank-slate';

/**
* Render No forms Found UI
*/
*
* @unreleased Replace "new form" with "new campaign form" link
*/

const NoForms = () => {
return (
<GiveBlankSlate title={ __( 'No donation forms found.', 'give' ) }
description={ __( 'The first step towards accepting online donations is to create a form.', 'give' ) }
helpLink>
<Button
isPrimary
isLarge
className="give-blank-slate__cta"
href={ `${ getSiteUrl() }/wp-admin/post-new.php?post_type=give_forms` }>
{ __( 'Create Donation Form', 'give' ) }
</Button>
</GiveBlankSlate>
);
return (
<GiveBlankSlate
title={__('No campaign forms found.', 'give')}
description={__('The first step towards accepting online donations is to create a campaign.', 'give')}
helpLink
>
<Button
isPrimary
isLarge
className="give-blank-slate__cta"
href={`${getSiteUrl()}/wp-admin/edit.php?post_type=give_forms&page=give-campaigns&new=campaign`}
>
{__('Create Campaign Form', 'give')}
</Button>
</GiveBlankSlate>
);
};

export default NoForms;
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ private function getAsArray($value) {
/**
* Return formatted notice when shortcode return empty string
*
* @unreleased Replace "new form" with "new campaign form" link
* @since 2.4.0
*
* @return string
Expand All @@ -284,10 +285,11 @@ private function blank_slate() {
$content = array(
'image_url' => GIVE_PLUGIN_URL . 'assets/dist/images/give-icon-full-circle.svg',
'image_alt' => __( 'Give Icon', 'give' ),
'heading' => __( 'No donation forms found.', 'give' ),
'message' => __( 'The first step towards accepting online donations is to create a form.', 'give' ),
'cta_text' => __( 'Create Donation Form', 'give' ),
'cta_link' => admin_url( 'post-new.php?post_type=give_forms' ),
'heading' => __('No campaign forms found.', 'give'),
'message' => __('The first step towards accepting online donations is to create a campaign.',
'give'),
'cta_text' => __('Create Campaign Form', 'give'),
'cta_link' => admin_url('edit.php?post_type=give_forms&page=give-campaigns&new=campaign'),
'help' => sprintf(
/* translators: 1: Opening anchor tag. 2: Closing anchor tag. */
__( 'Need help? Get started with %1$sGive 101%2$s.', 'give' ),
Expand Down
1 change: 1 addition & 0 deletions give.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ final class Give
Give\Settings\ServiceProvider::class,
Give\Campaigns\ServiceProvider::class,
Give\FeatureFlags\OptionBasedFormEditor\ServiceProvider::class,
Give\ThirdPartySupport\ServiceProvider::class,
];

/**
Expand Down
15 changes: 9 additions & 6 deletions includes/admin/class-blank-slate.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,20 +249,23 @@ private function donor_exists() {
/**
* Gets the content of a blank slate message based on provided context.
*
* @since 1.8.13
* @unreleased Replace "new form" with "new campaign form" link
* @since 1.8.13
*
* @param string $context The key used to determine which content is returned.
*
* @return array Blank slate content.
*/
private function get_content( $context ) {
// Define default content.
$defaults = array(
'image_url' => GIVE_PLUGIN_URL . 'assets/dist/images/give-icon-full-circle.svg',
'image_alt' => __( 'GiveWP Icon', 'give' ),
'heading' => __( 'No donation forms found.', 'give' ),
'message' => __( 'The first step towards accepting online donations is to create a form.', 'give' ),
'cta_text' => __( 'Create Donation Form', 'give' ),
'cta_link' => admin_url( 'post-new.php?post_type=give_forms' ),
'image_alt' => __( 'GiveWP Icon', 'give'),
'heading' => __('No campaign forms found.', 'give'),
'message' => __('The first step towards accepting online donations is to create a campaign.',
'give'),
'cta_text' => __('Create Campaign Form', 'give'),
'cta_link' => admin_url('edit.php?post_type=give_forms&page=give-campaigns&new=campaign'),
'help' => sprintf(
/* translators: 1: Opening anchor tag. 2: Closing anchor tag. */
__( 'Need help? Get started with %1$sGive 101%2$s.', 'give' ),
Expand Down
15 changes: 9 additions & 6 deletions includes/admin/shortcodes/shortcode-give-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ public function __construct() {
/**
* Define the shortcode attribute fields
*
* @return array
* @unreleased Replace "new form" with "new campaign form" link
*
* @return array
*/
public function define_fields() {

$create_form_link = sprintf(
/* translators: %s: create new form URL */
__( '<a href="%s">Create</a> a new Donation Form.', 'give' ),
admin_url( 'post-new.php?post_type=give_forms' )
__('<a href="%s">Create</a> a new Campaign Form.', 'give'),
admin_url('edit.php?post_type=give_forms&page=give-campaigns&new=campaign')
);

return array(
Expand All @@ -51,10 +53,11 @@ public function define_fields() {
),
'name' => 'id',
'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ),
'placeholder' => '- ' . esc_attr__( 'Select a Donation Form', 'give' ) . ' -',
'placeholder' => '- ' . esc_attr__('Select a Campaign Form', 'give') . ' -',
'required' => array(
'alert' => esc_html__( 'You must first select a Form!', 'give' ),
'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ),
'alert' => esc_html__('You must first select a Campaign Form!', 'give'),
'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>',
esc_html__('No campaign forms found.', 'give'), $create_form_link),
),
),
array(
Expand Down
15 changes: 9 additions & 6 deletions includes/admin/shortcodes/shortcode-give-goal.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ public function __construct() {

/**
* Define the shortcode attribute fields
*
* @unreleased Replace "new form" with "new campaign form" link
*
* @return array
*/
public function define_fields() {

$create_form_link = sprintf(
/* translators: %s: create new form URL */
__( '<a href="%s">Create</a> a new Donation Form.', 'give' ),
admin_url( 'post-new.php?post_type=give_forms' )
__('<a href="%s">Create</a> a new Campaign Form.', 'give'),
admin_url('edit.php?post_type=give_forms&page=give-campaigns&new=campaign')
);

return [
Expand All @@ -51,11 +53,12 @@ public function define_fields() {
'meta_value' => 'enabled',
],
'name' => 'id',
'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ),
'placeholder' => '- ' . esc_attr__( 'Select a Donation Form', 'give' ) . ' -',
'tooltip' => esc_attr__('Select a Campaign Form', 'give'),
'placeholder' => '- ' . esc_attr__('Select a Campaign Form', 'give') . ' -',
'required' => [
'alert' => esc_html__( 'You must first select a Form!', 'give' ),
'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ),
'alert' => esc_html__('You must first select a Campaign Form!', 'give'),
'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>',
esc_html__('No campaign forms found.', 'give'), $create_form_link),
],
],
[
Expand Down
4 changes: 2 additions & 2 deletions includes/post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function give_setup_post_types() {
'name' => __( 'Donation Forms', 'give' ),
'singular_name' => __( 'Form', 'give' ),
'add_new' => __( 'Add Form', 'give' ),
'add_new_item' => __( 'Add New Campaign Form', 'give' ),
'edit_item' => __( 'Edit Campaign Form', 'give' ),
'add_new_item' => __( 'Add New Donation Form', 'give' ),
'edit_item' => __( 'Edit Donation Form', 'give' ),
'new_item' => __( 'New Form', 'give' ),
'all_items' => __( 'All Forms', 'give' ),
'view_item' => __( 'View Form', 'give' ),
Expand Down
4 changes: 2 additions & 2 deletions src/Campaigns/Actions/ConvertQueryDataToCampaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function __invoke(object $queryObject): Campaign
'secondaryColor' => $queryObject->secondaryColor,
'goal' => (int)$queryObject->goal,
'goalType' => new CampaignGoalType($queryObject->goalType),
'startDate' => Temporal::toDateTime($queryObject->startDate),
'endDate' => Temporal::toDateTime($queryObject->endDate),
'startDate' => $queryObject->startDate ? Temporal::toDateTime($queryObject->startDate) : null,
'endDate' => $queryObject->endDate ? Temporal::toDateTime($queryObject->endDate) : null,
'status' => new CampaignStatus($queryObject->status),
'createdAt' => Temporal::toDateTime($queryObject->createdAt),
]);
Expand Down
Loading

0 comments on commit 48f520f

Please sign in to comment.