Skip to content
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

Social: Indicate that a connection is broken in the overview of the service #38053

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Added service status to broken connections for a service
2 changes: 1 addition & 1 deletion projects/js-packages/publicize-components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-publicize-components",
"version": "0.54.6",
"version": "0.54.7-alpha",
"description": "A library of JS components required by the Publicize editor plugin",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/publicize-components/#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SupportedService } from './use-supported-services';

export type ServicesItemDetailsProps = {
service: SupportedService;
serviceConnections?: Array< Connection >;
serviceConnections: Array< Connection >;
};

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Button, useBreakpointMatch } from '@automattic/jetpack-components';
import { Panel, PanelBody } from '@wordpress/components';
import { useReducer } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { __ } from '@wordpress/i18n';
import { Icon, chevronDown, chevronUp } from '@wordpress/icons';
import { ConnectForm } from './connect-form';
import { ServiceItemDetails, ServicesItemDetailsProps } from './service-item-details';
import { ServiceStatus } from './service-status';
import styles from './style.module.scss';

export type ServicesItemProps = ServicesItemDetailsProps;
Expand Down Expand Up @@ -45,17 +46,11 @@ export function ServiceItem( { service, serviceConnections }: ServicesItemProps
{ ! isSmall && ! serviceConnections.length ? (
<span className={ styles.description }>{ service.description }</span>
) : null }
{ serviceConnections?.length > 0 ? (
<span className={ styles[ 'active-connection' ] }>
{ serviceConnections.length > 1
? sprintf(
// translators: %d: Number of connections
__( '%d connections', 'jetpack' ),
serviceConnections.length
)
: __( 'Connected', 'jetpack' ) }
</span>
) : null }
<ServiceStatus
serviceConnections={ serviceConnections }
// If the panel is already open, we don't need the click handler
onClickBroken={ isPanelOpen ? undefined : togglePanel }
/>
</div>
<div className={ styles.actions }>
{ ! isMastodonPanelOpen ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Button } from '@automattic/jetpack-components';
import { __, _x, sprintf } from '@wordpress/i18n';
import { Connection } from '../../social-store/types';
import styles from './style.module.scss';

export type ServiceStatusProps = {
serviceConnections: Array< Connection >;
onClickBroken?: VoidFunction;
};

/**
* Service status component
*
* @param {ServiceStatusProps} props - Component props
*
* @returns {import('react').ReactNode} Service status component
*/
export function ServiceStatus( { serviceConnections, onClickBroken }: ServiceStatusProps ) {
if ( ! serviceConnections.length ) {
return null;
}

if ( serviceConnections.some( ( { status } ) => status === 'broken' ) ) {
return (
<span>
<Button
variant="link"
className={ styles[ 'broken-connection' ] }
onClick={ onClickBroken }
>
{ serviceConnections.length > 1
? __( 'Broken connections', 'jetpack' )
: _x( 'Broken connection', '', 'jetpack' ) }
</Button>
</span>
);
}

return (
<span className={ styles[ 'active-connection' ] }>
{ serviceConnections.length > 1
? sprintf(
// translators: %d: Number of connections
__( '%d connections', 'jetpack' ),
serviceConnections.length
)
: __( 'Connected', 'jetpack' ) }
</span>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@
white-space: nowrap;
}

.broken-connection {
white-space: nowrap;
font-weight: 500;

// Add some specificity to override the default button styles
&:global(.components-button.is-link) {
color: var(--jp-yellow-40);
text-decoration: none;
font-size: inherit;
}
}

.service-connection-list {
border-top: 1px solid var(--jp-gray-5);
padding-top: 1rem;
Expand Down
Loading