Back

43.24% Statements 16/37
62.5% Branches 5/8
21.73% Functions 5/23
43.24% Lines 16/37

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248                14x 14x 14x 14x 14x 14x                   127x   8x   1x                             38x 2x                                                 37x 1x                                                                                                                     37x 1x                                                 7x                                                                                                                                                                                          
import { SocialServiceIcon } from '@automattic/jetpack-components';
import { createInterpolateElement } from '@wordpress/element';
import { __, _x } from '@wordpress/i18n';
import { Link } from '@wordpress/ui';
import { ConnectionService } from '../../types';
import { assetUrl } from '../../utils';
import { ServiceUiDetails } from './types';
 
const connectionsFacebook = assetUrl( 'connections-facebook.webp' );
const connectionsInstagramBusiness = assetUrl( 'connections-instagram-business.webp' );
const connectionsLinkedin = assetUrl( 'connections-linkedin.webp' );
const connectionsNextdoor = assetUrl( 'connections-nextdoor.webp' );
const connectionsThreads = assetUrl( 'connections-threads.webp' );
const connectionsTumblr = assetUrl( 'connections-tumblr.webp' );
 
/**
 * Get the UI details for a given service.
 *
 * @param id - The ID of the service.
 *
 * @return The UI details for the service.
 */
export function getServiceUiDetails( id: ConnectionService[ 'id' ] ): ServiceUiDetails {
	switch ( id ) {
		case 'bluesky':
			return {
				needsCustomInputs: true,
				icon: props => <SocialServiceIcon serviceName="bluesky" { ...props } />,
				accountType: _x( 'Profile', 'social account type', 'jetpack-publicize-pkg' ),
				description: __( 'Share with your network.', 'jetpack-publicize-pkg' ),
				examples: [
					() => (
						<>
							{ __(
								'To share to Bluesky please enter your Bluesky handle and app password below, then click connect.',
								'jetpack-publicize-pkg'
							) }
						</>
					),
				],
			};
		case 'facebook':
			return {
				icon: props => <SocialServiceIcon serviceName="facebook" { ...props } />,
				accountType: _x( 'Page', 'social account type', 'jetpack-publicize-pkg' ),
				description: __( 'Share to your pages', 'jetpack-publicize-pkg' ),
				examples: [
					() => (
						<>
							{ createInterpolateElement(
								__(
									'<strong>Connect</strong> to automatically share posts on your Facebook page.',
									'jetpack-publicize-pkg'
								),
								{ strong: <strong></strong> }
							) }
						</>
					),
					() => (
						<img
							src={ connectionsFacebook }
							alt={ __( 'Add Facebook connection', 'jetpack-publicize-pkg' ) }
						/>
					),
				],
			};
 
		case 'instagram-business':
			return {
				icon: props => <SocialServiceIcon serviceName="instagram" { ...props } />,
				shortLabel: __( 'Instagram', 'jetpack-publicize-pkg' ),
				accountType: _x( 'Business', 'social account type', 'jetpack-publicize-pkg' ),
				description: __( 'Share to your Instagram Business account.', 'jetpack-publicize-pkg' ),
				examples: [
					() => (
						<>
							{ __(
								'Drive engagement and save time by automatically sharing images to Instagram when you publish blog posts.',
								'jetpack-publicize-pkg'
							) }
							<div className="instagram-business__requirements">
								<h4>{ __( 'Requirements for connecting Instagram:', 'jetpack-publicize-pkg' ) }</h4>
								<ol>
									<li>
										{ __(
											'You must have an Instagram Business account.',
											'jetpack-publicize-pkg'
										) }
									</li>
									<li>
										{ __(
											'Your Instagram Business account must be linked to a Facebook page.',
											'jetpack-publicize-pkg'
										) }
									</li>
								</ol>
							</div>
							{ createInterpolateElement(
								__(
									"<i>When you click “connect” you'll be asked to <strong>log into Facebook</strong>. If your Instagram Business account isn't listed, ensure it's linked to a Facebook page.</i>",
									'jetpack-publicize-pkg'
								),
								{ strong: <strong></strong>, i: <em></em> }
							) }
							<br />
							<br />
							<Link
								openInNewTab
								className="instagram-business__help-link"
								href="https://jetpack.com/redirect/?source=jetpack-social-instagram-business-help"
							>
								{ __(
									'Learn how to convert & link your Instagram account.',
									'jetpack-publicize-pkg'
								) }
							</Link>
						</>
					),
					() => (
						<img
							src={ connectionsInstagramBusiness }
							alt={ __( 'Add Instagram photo', 'jetpack-publicize-pkg' ) }
						/>
					),
				],
			};
 
		case 'linkedin':
			return {
				icon: props => <SocialServiceIcon serviceName="linkedin" { ...props } />,
				accountType: _x( 'Profile / Company', 'social account type', 'jetpack-publicize-pkg' ),
				description: __( 'Share with your LinkedIn community.', 'jetpack-publicize-pkg' ),
				examples: [
					() => (
						<>
							{ createInterpolateElement(
								__(
									'<strong>Connect</strong> to automatically share posts with your LinkedIn connections.',
									'jetpack-publicize-pkg'
								),
								{ strong: <strong></strong> }
							) }
						</>
					),
					() => (
						<img
							src={ connectionsLinkedin }
							alt={ __( 'Add LinkedIn connection', 'jetpack-publicize-pkg' ) }
						/>
					),
				],
			};
 
		case 'mastodon':
			return {
				needsCustomInputs: true,
				icon: props => <SocialServiceIcon serviceName="mastodon" { ...props } />,
				accountType: _x( 'Profile', 'social account type', 'jetpack-publicize-pkg' ),
				description: __( 'Share with your network.', 'jetpack-publicize-pkg' ),
				examples: [
					() => (
						<>
							{ __(
								'To share to Mastodon please enter your Mastodon username below, then click connect.',
								'jetpack-publicize-pkg'
							) }
						</>
					),
				],
			};
 
		case 'nextdoor':
			return {
				icon: props => <SocialServiceIcon serviceName="nextdoor" { ...props } />,
				accountType: _x( 'Profile', 'social account type', 'jetpack-publicize-pkg' ),
				description: __( 'Share on communities', 'jetpack-publicize-pkg' ),
				examples: [
					() => (
						<>
							{ createInterpolateElement(
								__(
									'<strong>Connect</strong> with friends, neighbors, and local businesses by automatically sharing your posts to Nextdoor.',
									'jetpack-publicize-pkg'
								),
								{ strong: <strong></strong> }
							) }
						</>
					),
					() => (
						<img
							src={ connectionsNextdoor }
							alt={ __( 'Add Instagram photo', 'jetpack-publicize-pkg' ) }
						/>
					),
				],
			};
 
		case 'threads':
			return {
				icon: props => <SocialServiceIcon serviceName="threads" { ...props } />,
				accountType: _x( 'Profile', 'social account type', 'jetpack-publicize-pkg' ),
				description: __( 'Share posts to your Threads feed.', 'jetpack-publicize-pkg' ),
				examples: [
					() => (
						<>
							{ __(
								'Increase your presence in social media by sharing your posts automatically to Threads.',
								'jetpack-publicize-pkg'
							) }
						</>
					),
					() => (
						<img
							src={ connectionsThreads }
							alt={ __( 'Add Threads connection', 'jetpack-publicize-pkg' ) }
						/>
					),
				],
			};
 
		case 'tumblr':
			return {
				icon: props => <SocialServiceIcon serviceName="tumblr-alt" { ...props } />,
				accountType: _x( 'Page', 'social account type', 'jetpack-publicize-pkg' ),
				description: __( 'Share to your Tumblr blog.', 'jetpack-publicize-pkg' ),
				examples: [
					() => (
						<>
							{ createInterpolateElement(
								__(
									'<strong>Connect</strong> to automatically share posts to your Tumblr blog.',
									'jetpack-publicize-pkg'
								),
								{ strong: <strong></strong> }
							) }
						</>
					),
					() => (
						<img
							src={ connectionsTumblr }
							alt={ __( 'Add Tumblr connection', 'jetpack-publicize-pkg' ) }
						/>
					),
				],
			};
	}
}