diff --git a/projects/plugins/jetpack/_inc/client/security/sso.jsx b/projects/plugins/jetpack/_inc/client/security/sso.jsx index bad59eb4413d0..540f262e592bb 100644 --- a/projects/plugins/jetpack/_inc/client/security/sso.jsx +++ b/projects/plugins/jetpack/_inc/client/security/sso.jsx @@ -1,4 +1,6 @@ -import { getRedirectUrl, ToggleControl } from '@automattic/jetpack-components'; +import { getRedirectUrl, ToggleControl, Gridicon } from '@automattic/jetpack-components'; +import { useConnection } from '@automattic/jetpack-connection'; +import { Button } from '@wordpress/components'; import { __, _x } from '@wordpress/i18n'; import ConnectUserBar from 'components/connect-user-bar'; import { FormFieldset } from 'components/forms'; @@ -6,7 +8,80 @@ import { withModuleSettingsFormHelpers } from 'components/module-settings/with-m import { ModuleToggle } from 'components/module-toggle'; import SettingsCard from 'components/settings-card'; import SettingsGroup from 'components/settings-group'; -import React, { Component } from 'react'; +import cookie from 'cookie'; +import { useState, Component } from 'react'; +import ReactDOM from 'react-dom'; + +const SSOSurveyNotice = () => { + const { userConnectionData } = useConnection(); + const userId = userConnectionData?.currentUser?.wpcomUser?.ID; + const href = `https://wordpressdotcom.survey.fm/disable-sso-survey?initiated-from=jetpack&user-id=${ userId }`; + const [ hideNotice, setHideNotice ] = useState( + 'dismissed' === cookie.parse( document.cookie )?.sso_disable + ); + + const setSSOSurveyCookie = ( value, maxAge ) => { + document.cookie = cookie.serialize( 'sso_disable', value, { + path: '/', + maxAge, + } ); + }; + + const onClose = () => { + setSSOSurveyCookie( 'dismissed', 365 * 24 * 60 * 60 ); // 1 year + setHideNotice( true ); + }; + + if ( hideNotice ) { + return null; + } + + return ( +
+ { /* eslint-disable-next-line react/jsx-no-bind */ } + +
+
+
+ { __( 'Hi there!', 'jetpack' ) } +
+
+ { __( + "Spare a moment? We'd love to hear why you want to disable SSO in a quick survey.", + 'jetpack' + ) } +
+
+ + +
+
+ + + ); +}; export const SSO = withModuleSettingsFormHelpers( class extends Component { @@ -26,6 +101,7 @@ export const SSO = withModuleSettingsFormHelpers( 'sso', false ), + showSSODisableModal: false, }; handleTwoStepToggleChange = () => { @@ -54,85 +130,95 @@ export const SSO = withModuleSettingsFormHelpers( const isSSOActive = this.props.getOptionValue( 'sso' ), unavailableInOfflineMode = this.props.isUnavailableInOfflineMode( 'sso' ); return ( - - + -

- { __( - 'Add an extra layer of security to your website by enabling WordPress.com login and secure authentication. If you have multiple sites with this option enabled, you will be able to log in to every one of them with the same credentials.', - 'jetpack' - ) } -

- - - { this.props.getModule( 'sso' ).description } - - - - - + { __( + 'Add an extra layer of security to your website by enabling WordPress.com login and secure authentication. If you have multiple sites with this option enabled, you will be able to log in to every one of them with the same credentials.', 'jetpack' ) } - /> - -
+

+ { + if ( isSSOActive ) { + this.setState( { showSSODisableModal: true } ); + } + this.props.toggleModuleNow( name ); + } } + > + + { this.props.getModule( 'sso' ).description } + + + + + + + - { ! this.props.hasConnectedOwner && ! this.props.isOfflineMode && ( - - ) } -
+ { ! this.props.hasConnectedOwner && ! this.props.isOfflineMode && ( + + ) } + + { this.state.showSSODisableModal && + ReactDOM.createPortal( , document.body ) } + ); } } diff --git a/projects/plugins/jetpack/_inc/client/security/style.scss b/projects/plugins/jetpack/_inc/client/security/style.scss index b5a9a2d93dbcf..f2306fff68914 100644 --- a/projects/plugins/jetpack/_inc/client/security/style.scss +++ b/projects/plugins/jetpack/_inc/client/security/style.scss @@ -101,3 +101,102 @@ white-space: nowrap; } } + + +.modal-survey-notice { + position: fixed; + left: 0; + top: 0; + height: 100%; + width: 100%; + z-index: 1000; + + .modal-survey-notice__backdrop { + background: var(--studio-black); + opacity: 0.2; + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + cursor: default; + } + + + .modal-survey-notice__popup { + position: absolute; + right: 25px; + bottom: 25px; + width: 416px; + max-width: calc(100% - 50px); + z-index: 2; + border-radius: 2px; + box-shadow: 0 3px 1px 0 rgba(0, 0, 0, 0.04), 0 3px 8px 0 rgba(0, 0, 0, 0.12); + overflow: hidden; + + .modal-survey-notice__popup-head { + background: #0675c4; + border-bottom: 1px solid #f6f7f7; + height: 56px; + padding: 0 14px 0 16px; + display: flex; + align-items: center; + justify-content: space-between; + + .modal-survey-notice__popup-head-title { + color: var(--studio-white); + font-size: rem(14px); + font-weight: 500; + line-height: 20px; + letter-spacing: -0.15px; + } + + .modal-survey-notice__popup-head-close svg { + fill: var(--studio-white); + } + } + + .modal-survey-notice__popup-content { + padding: 1rem; + background: var(--studio-white); + + .modal-survey-notice__popup-content-title { + font-size: rem(16px); + font-weight: 500; + line-height: 24px; + letter-spacing: -0.32px; + padding-bottom: 8px; + } + + .modal-survey-notice__popup-content-description { + font-size: rem(14px); + line-height: 20px; + letter-spacing: -0.15px; + padding-bottom: 18px; + } + + .modal-survey-notice__popup-content-buttons { + display: flex; + justify-content: flex-end; + + .modal-survey-notice__popup-content-buttons-ok { + padding: 8px 14px; + background: var(--studio-blue-50); + color: var(--studio-white); + font-size: rem(14px); + line-height: 20px; + letter-spacing: -0.15px; + } + + .modal-survey-notice__popup-content-buttons-cancel { + padding: 8px 14px; + color: var(--studio-blue-50); + text-align: center; + font-size: rem(14px); + line-height: 20px; + letter-spacing: -0.15px; + } + } + } + } +} diff --git a/projects/plugins/jetpack/changelog/add-sso-disable-notice b/projects/plugins/jetpack/changelog/add-sso-disable-notice new file mode 100644 index 0000000000000..ddf8c748b3fba --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-sso-disable-notice @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Add sso survey modal for users that disable the module