Skip to content

Commit

Permalink
Merge branch 'develop' into hotfix/multi-form-goal-block-filters-7068
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonTheAdams committed Oct 25, 2023
2 parents 8509651 + cc78ba8 commit 2ace5e5
Show file tree
Hide file tree
Showing 19 changed files with 165 additions and 344 deletions.
14 changes: 11 additions & 3 deletions src/FormBuilder/ViewModels/FormBuilderViewModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ public function isRecurringEnabled(): bool
/**
* @since 3.0.0
*/
public function getGoalTypeOption(string $value, string $label, string $description): array
public function getGoalTypeOption(
string $value,
string $label,
string $description,
bool $isCurrency = false
): array
{
return [
'value' => $value,
'label' => $label,
'description' => $description,
'isCurrency' => $isCurrency,
];
}

Expand All @@ -105,7 +111,8 @@ public function getGoalTypeOptions(): array
$this->getGoalTypeOption(
GoalType::AMOUNT,
__('Amount Raised', 'give'),
__('The total amount raised for the form', 'give')
__('The total amount raised for the form', 'give'),
true
),
$this->getGoalTypeOption(
GoalType::DONATIONS,
Expand All @@ -124,7 +131,8 @@ public function getGoalTypeOptions(): array
$this->getGoalTypeOption(
GoalType::AMOUNT_FROM_SUBSCRIPTIONS,
__('Subscription Amount Raised', 'give'),
__('The total amount raised for the form through subscriptions', 'give')
__('The total amount raised for the form through subscriptions', 'give'),
true
),
$this->getGoalTypeOption(
GoalType::SUBSCRIPTIONS,
Expand Down
2 changes: 0 additions & 2 deletions src/FormBuilder/resources/js/form-builder/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import BlockEditorContainer from './containers/BlockEditorContainer';
import {FormStateProvider} from './stores/form-state';
import {Storage} from './common';
import defaultBlocks from './blocks.json';
import Feedback from '@givewp/form-builder/feedback';
import {BlockInstance} from '@wordpress/blocks';
import './App.scss';
import FormBuilderErrorBoundary from '@givewp/form-builder/errors/FormBuilderErrorBounday';
Expand Down Expand Up @@ -55,7 +54,6 @@ export default function App() {
<FormStateProvider initialState={initialState}>
<ShortcutProvider>
<BlockEditorContainer />
<Feedback />
<Transfer />
</ShortcutProvider>
</FormStateProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {BlockEditProps} from '@wordpress/blocks';
import {RichText, InspectorControls} from '@wordpress/block-editor';
import {RichText} from '@wordpress/block-editor';
import {__} from '@wordpress/i18n';
import {PanelBody, PanelRow, TextareaControl, TextControl} from "@wordpress/components";

export default function Edit({attributes, setAttributes}: BlockEditProps<any>) {
const {content} = attributes;
Expand All @@ -15,17 +14,6 @@ export default function Edit({attributes, setAttributes}: BlockEditProps<any>) {
onChange={(content) => setAttributes({content})}
placeholder={__('Enter some text', 'give')}
/>
<InspectorControls>
<PanelBody title={__('Attributes', 'give')} initialOpen={true}>
<PanelRow>
<TextareaControl
label={__('Content', 'give')}
value={content}
onChange={(content) => setAttributes({content})}
/>
</PanelRow>
</PanelBody>
</InspectorControls>
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type GoalTypeOption = {
value: string;
label: string;
description: string;
isCurrency: boolean;
};

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {useState} from 'react';
import {EditIcon, GiveIcon} from '../components/icons';
import {drawerRight, moreVertical, external} from '@wordpress/icons';
import {drawerRight, external, moreVertical} from '@wordpress/icons';
import {setFormSettings, setTransferState, useFormState, useFormStateDispatch} from '../stores/form-state';
import {Button, Dropdown, MenuGroup, MenuItem, TextControl} from '@wordpress/components';
import {Button, Dropdown, ExternalLink, MenuGroup, MenuItem, TextControl} from '@wordpress/components';
import {__} from '@wordpress/i18n';
import {Header} from '../components';
import {getWindowData, Storage} from '../common';
Expand All @@ -11,9 +11,10 @@ import {setIsDirty} from '@givewp/form-builder/stores/form-state/reducer';
import revertMissingBlocks from '@givewp/form-builder/common/revertMissingBlocks';
import {Markup} from 'interweave';
import {InfoModal, ModalType} from '../components/modal';
import {setEditorMode, useEditorState, useEditorStateDispatch} from "@givewp/form-builder/stores/editor-state";
import EditorMode from "@givewp/form-builder/types/editorMode";
import {useDispatch} from "@wordpress/data";
import {setEditorMode, useEditorState, useEditorStateDispatch} from '@givewp/form-builder/stores/editor-state';
import EditorMode from '@givewp/form-builder/types/editorMode';
import {useDispatch} from '@wordpress/data';
import {cleanForSlug} from '@wordpress/url';

const Logo = () => (
<div
Expand All @@ -37,11 +38,10 @@ const Logo = () => (
</div>
);

const HeaderContainer = ({
SecondarySidebarButtons = null,
showSidebar,
toggleShowSidebar,
}) => {
/**
* @unreleased dispatch page slug from form title on initial publish.
*/
const HeaderContainer = ({SecondarySidebarButtons = null, showSidebar, toggleShowSidebar}) => {
const {blocks, settings: formSettings, isDirty, transfer} = useFormState();

const {formTitle} = formSettings;
Expand All @@ -54,6 +54,7 @@ const HeaderContainer = ({
const isPublished = 'publish' === formSettings.formStatus;
const {isMigratedForm, isTransferredForm} = window.migrationOnboardingData;
const {createSuccessNotice} = useDispatch('core/notices');

const {
formPage: {permalink},
} = getWindowData();
Expand All @@ -72,7 +73,12 @@ const HeaderContainer = ({
setErrorMessage(error.message);
})
.then(({formTitle, pageSlug}: FormSettings) => {
dispatch(setFormSettings({formTitle, pageSlug}));
dispatch(
setFormSettings({
formTitle,
pageSlug,
})
);
dispatch(setIsDirty(false));
setSaving(null);
showOnSaveNotice(formStatus);
Expand All @@ -82,22 +88,25 @@ const HeaderContainer = ({
const showOnSaveNotice = (formStatus: string) => {
if ('draft' === formStatus) {
createSuccessNotice(__('Draft saved.', 'give'), {
type: 'snackbar'
type: 'snackbar',
});
} else {
const notice = 'publish' === formStatus && formSettings.formStatus !== 'draft'
? __('Form updated.', 'give')
: __('Form published.', 'give')
const notice =
'publish' === formStatus && formSettings.formStatus !== 'draft'
? __('Form updated.', 'give')
: __('Form published.', 'give');

createSuccessNotice(notice, {
type: 'snackbar',
actions: [{
label: __('View form', 'give'),
url: permalink
}]
actions: [
{
label: __('View form', 'give'),
url: permalink,
},
],
});
}
}
};

const {mode} = useEditorState();
const dispatchEditorState = useEditorStateDispatch();
Expand All @@ -108,7 +117,7 @@ const HeaderContainer = ({
if (EditorMode.design === mode) {
dispatchEditorState(setEditorMode(EditorMode.schema));
}
}
};

// @ts-ignore
return (
Expand All @@ -126,7 +135,7 @@ const HeaderContainer = ({
borderRadius: '4px',
display: 'flex',
gap: 'var(--givewp-spacing-2)',
padding: 'var(--givewp-spacing-3) var(--givewp-spacing-4)'
padding: 'var(--givewp-spacing-3) var(--givewp-spacing-4)',
}}
onClick={() => toggleEditorMode()}
icon={EditIcon}
Expand All @@ -140,7 +149,10 @@ const HeaderContainer = ({
<TextControl
className={'givewp-form-title'}
value={formTitle}
onChange={(formTitle) => dispatch(setFormSettings({formTitle}))}
onChange={(formTitle) => {
!isPublished && dispatch(setFormSettings({pageSlug: cleanForSlug(formTitle)}));
dispatch(setFormSettings({formTitle}));
}}
/>
}
contentRight={
Expand All @@ -154,16 +166,11 @@ const HeaderContainer = ({
{isSaving && 'draft' === isSaving
? __('Saving...', 'give')
: 'draft' === formSettings.formStatus
? __('Save as Draft', 'give')
: __('Switch to Draft', 'give')}
? __('Save as Draft', 'give')
: __('Switch to Draft', 'give')}
</Button>
{isPublished && (
<Button
label={__('View form', 'give')}
href={permalink}
target="_blank"
icon={external}
/>
<Button label={__('View form', 'give')} href={permalink} target="_blank" icon={external} />
)}
<Button
onClick={() => onSave('publish')}
Expand All @@ -174,8 +181,8 @@ const HeaderContainer = ({
{isSaving && 'publish' === isSaving
? __('Updating...', 'give')
: 'publish' === formSettings.formStatus
? __('Update', 'give')
: __('Publish', 'give')}
? __('Update', 'give')
: __('Publish', 'give')}
</Button>
<Button onClick={toggleShowSidebar} isPressed={showSidebar} icon={drawerRight} />
<Dropdown
Expand All @@ -189,16 +196,16 @@ const HeaderContainer = ({
icon={moreVertical}
onClick={() => {
if (transfer.showTooltip) {
dispatch(setTransferState({showTooltip: false}))
dispatch(setTransferState({showTooltip: false}));
}
onToggle();
}}
/>
)
);
}}
renderContent={({onClose}) => (
<div style={{minWidth: '280px', maxWidth: '400px'}}>
<MenuGroup label={__('Tools', 'give')}>
<MenuGroup label={__('Support', 'give')}>
<MenuItem
onClick={() => {
// @ts-ignore
Expand All @@ -214,7 +221,9 @@ const HeaderContainer = ({
{isMigratedForm && !isTransferredForm && !transfer.showNotice && (
<>
<MenuItem
className={transfer.showTooltip && 'givewp-transfer-selected-menuitem'}
className={
transfer.showTooltip && 'givewp-transfer-selected-menuitem'
}
onClick={() => {
dispatch(setTransferState({showTransferModal: true}));
onClose();
Expand All @@ -225,12 +234,22 @@ const HeaderContainer = ({

{transfer.showTooltip && (
<div className="givewp-transfer-tooltip">
{__('Want to transfer donation data later? Access this option in the three dots menu above at any time.', 'give')}
{__(
'Want to transfer donation data later? Access this option in the three dots menu above at any time.',
'give'
)}
</div>
)}
</>
)}
</MenuGroup>
<ExternalLink
className="givewp-support-link"
href="https://docs.givewp.com/nextgenfeedback"
rel="noopener noreferrer"
>
<MenuItem icon={external}>{__('Submit Feedback', 'give')}</MenuItem>
</ExternalLink>
</div>
)}
/>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 2ace5e5

Please sign in to comment.