-
Notifications
You must be signed in to change notification settings - Fork 820
Forms: Add integrations status to block sidebar #43178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d3ec0d4
Add form integration status to sidebar
edanzer d385bf1
changelog
edanzer 97cc8f4
Pass block attributes to integration status hook
edanzer 167299d
Return false for Creative Mail
edanzer 0902c20
Add icons to integrations panel
edanzer 26d8f43
Create separate component file, add status circle
edanzer 9734ea7
Return raw response data from hook
edanzer e53c3bf
Remove unrelated variable name change
edanzer 46c9bb9
Remove duplicate file
edanzer 86f3bd3
Update status method to handle array
edanzer 8c2b26d
Restore crm card to original state
edanzer 8b56581
Keep akismet status property on same line
edanzer 90a51be
Update icon styling
edanzer c3339c9
Move loading check
edanzer 369e858
Update ActiveIntegrations to use reduce
edanzer 8987c94
Update class names
edanzer 0fa95dd
Namespace css classes
edanzer eab0253
Add tooltips to icons
edanzer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/packages/forms/changelog/add-form-block-sidebar-icons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: added | ||
|
||
Forms: Added integration status to block sidebar. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...rc/blocks/contact-form/components/jetpack-integrations-modal/active-integrations/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import colorStudio from '@automattic/color-studio'; | ||
import { JetpackIcon } from '@automattic/jetpack-components'; | ||
import { Spinner, Tooltip } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import AkismetIcon from '../../../../../icons/akismet-icon'; | ||
import './style.scss'; | ||
|
||
const COLOR_JETPACK = colorStudio.colors[ 'Jetpack Green 40' ]; | ||
|
||
export default function ActiveIntegrations( { integrations, attributes, isLoading } ) { | ||
const activeIntegrations = integrations.reduce( ( acc, integration ) => { | ||
switch ( integration.id ) { | ||
case 'akismet': | ||
if ( integration.isConnected ) { | ||
acc.push( { | ||
...integration, | ||
icon: <AkismetIcon width={ 30 } height={ 30 } />, | ||
tooltip: __( 'Akismet is connected for this form', 'jetpack-forms' ), | ||
} ); | ||
} | ||
break; | ||
case 'zero-bs-crm': | ||
if ( integration.isActive && integration.details?.hasExtension && attributes.jetpackCRM ) { | ||
acc.push( { | ||
...integration, | ||
icon: <JetpackIcon size={ 30 } color={ COLOR_JETPACK } />, | ||
tooltip: __( 'Jetpack CRM is connected for this form', 'jetpack-forms' ), | ||
} ); | ||
} | ||
break; | ||
} | ||
return acc; | ||
}, [] ); | ||
|
||
if ( isLoading ) { | ||
return ( | ||
<div className="jetpack-forms-active-integrations"> | ||
<Spinner /> | ||
</div> | ||
); | ||
} | ||
|
||
if ( ! activeIntegrations?.length ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="jetpack-forms-active-integrations"> | ||
{ activeIntegrations.map( integration => ( | ||
<Tooltip key={ integration.id } text={ integration.tooltip }> | ||
<span className="jetpack-forms-active-integrations__item"> | ||
{ integration.icon } | ||
<span className="jetpack-forms-active-integrations__status" /> | ||
</span> | ||
</Tooltip> | ||
) ) } | ||
</div> | ||
); | ||
} |
19 changes: 19 additions & 0 deletions
19
.../blocks/contact-form/components/jetpack-integrations-modal/active-integrations/style.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.jetpack-forms-active-integrations { | ||
margin: 8px 0 10px; | ||
|
||
&__item { | ||
position: relative; | ||
margin-right: 8px; | ||
} | ||
|
||
&__status { | ||
position: absolute; | ||
bottom: 1px; | ||
right: 1px; | ||
width: 9px; | ||
height: 9px; | ||
background-color: #4AB866; | ||
box-shadow: 0 0 0 1px #fff; | ||
border-radius: 50%; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ const AkismetCard = ( { isExpanded, onToggle, data, refreshStatus } ) => { | |
const cardData = { | ||
...data, | ||
showHeaderToggle: true, | ||
headerToggleValue: data?.isConnected, | ||
headerToggleValue: akismetActiveWithKey, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is unrelated. It's just a small improvement I saw that didn't warrant it's own PR. We already define akismetActiveWithKey as data.isConnected further up in the component, and use it elsewhere. For consistency, we should use it here. |
||
isHeaderToggleEnabled: false, | ||
isLoading: ! data || typeof data.isInstalled === 'undefined', | ||
refreshStatus, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reduce method takes in the list of integrations, and returns:
(a) just those that are active/enabled for this form and
(b) includes the icon so it can be output below
(c) the tooltip text for each active integration