From be7202986d52565aa0317a0bba07210888442fec Mon Sep 17 00:00:00 2001
From: heavyweight
Date: Thu, 14 Mar 2024 14:01:52 +0100
Subject: [PATCH 1/8] SSO: Add sso disable modal
---
.../jetpack/_inc/client/security/sso.jsx | 241 ++++++++++++------
.../jetpack/_inc/client/security/style.scss | 99 +++++++
2 files changed, 264 insertions(+), 76 deletions(-)
diff --git a/projects/plugins/jetpack/_inc/client/security/sso.jsx b/projects/plugins/jetpack/_inc/client/security/sso.jsx
index bad59eb4413d0..791561d84be10 100644
--- a/projects/plugins/jetpack/_inc/client/security/sso.jsx
+++ b/projects/plugins/jetpack/_inc/client/security/sso.jsx
@@ -1,4 +1,5 @@
-import { getRedirectUrl, ToggleControl } from '@automattic/jetpack-components';
+import { getRedirectUrl, ToggleControl, Gridicon } from '@automattic/jetpack-components';
+import { Button } from '@wordpress/components';
import { __, _x } from '@wordpress/i18n';
import ConnectUserBar from 'components/connect-user-bar';
import { FormFieldset } from 'components/forms';
@@ -6,7 +7,84 @@ 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 React, { useState, Component } from 'react';
+import ReactDOM from 'react-dom';
+import { connect } from 'react-redux';
+import { getUserId } from 'state/initial-state';
+
+const SSOSurveyNotice = connect( state => {
+ return {
+ userId: getUserId( state ),
+ };
+} )( ( { userId } ) => {
+ const href = `https://wordpressdotcom.survey.fm/sso-disable-survey?initiated-from=jetpack&user-id=${ userId }`;
+ const [ hideNotice, setHideNotice ] = useState(
+ 'dismissed' === cookie.parse( document.cookie )?.sso_survey
+ );
+
+ const setSSOSurveyCookie = ( value, maxAge ) => {
+ document.cookie = cookie.serialize( 'sso_survey', 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 */ }
+
+
+
+
+ { __( 'SSO Survey', 'jetpack' ) }
+
+ { /* 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'
+ ) }
+
+
+
+ { __( 'Maybe later', 'jetpack' ) }
+
+
+ { __( 'Take survey', 'jetpack' ) }
+
+
+
+
+
+ );
+} );
export const SSO = withModuleSettingsFormHelpers(
class extends Component {
@@ -26,6 +104,7 @@ export const SSO = withModuleSettingsFormHelpers(
'sso',
false
),
+ showSSODisableModal: false,
};
handleTwoStepToggleChange = () => {
@@ -54,85 +133,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..64cee053eed5b 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: 18px 24px 30px;
+ 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;
+ }
+ }
+ }
+ }
+}
From 32b436897609ea37b82abac1a5735b8efb6fe075 Mon Sep 17 00:00:00 2001
From: heavyweight
Date: Thu, 14 Mar 2024 14:02:57 +0100
Subject: [PATCH 2/8] changelog
---
projects/plugins/jetpack/changelog/add-sso-disable-notice | 4 ++++
1 file changed, 4 insertions(+)
create mode 100644 projects/plugins/jetpack/changelog/add-sso-disable-notice
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
From 91d363ba2aafc53955fc4c5d6169780bf6c61316 Mon Sep 17 00:00:00 2001
From: Anthony Grullon
Date: Tue, 19 Mar 2024 10:57:22 -0400
Subject: [PATCH 3/8] Update copies
---
projects/plugins/jetpack/_inc/client/security/sso.jsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/projects/plugins/jetpack/_inc/client/security/sso.jsx b/projects/plugins/jetpack/_inc/client/security/sso.jsx
index 791561d84be10..72bc27ec416d3 100644
--- a/projects/plugins/jetpack/_inc/client/security/sso.jsx
+++ b/projects/plugins/jetpack/_inc/client/security/sso.jsx
@@ -59,7 +59,7 @@ const SSOSurveyNotice = connect( state => {
{ __(
- " Spare a moment? We'd love to hear why you want to disable SSO in a quick survey.",
+ "Spare a moment? We'd love to hear why you want to disable SSO in a quick survey.",
'jetpack'
) }
@@ -68,7 +68,7 @@ const SSOSurveyNotice = connect( state => {
className="dmodal-survey-notice__popup-content-buttons-cancel"
onClick={ onClose } // eslint-disable-line react/jsx-no-bind
>
- { __( 'Maybe later', 'jetpack' ) }
+ { __( 'Remind later', 'jetpack' ) }
Date: Tue, 19 Mar 2024 10:59:14 -0400
Subject: [PATCH 4/8] Update sso disable cookie name
---
projects/plugins/jetpack/_inc/client/security/sso.jsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/projects/plugins/jetpack/_inc/client/security/sso.jsx b/projects/plugins/jetpack/_inc/client/security/sso.jsx
index 72bc27ec416d3..a36843e48bf71 100644
--- a/projects/plugins/jetpack/_inc/client/security/sso.jsx
+++ b/projects/plugins/jetpack/_inc/client/security/sso.jsx
@@ -20,11 +20,11 @@ const SSOSurveyNotice = connect( state => {
} )( ( { userId } ) => {
const href = `https://wordpressdotcom.survey.fm/sso-disable-survey?initiated-from=jetpack&user-id=${ userId }`;
const [ hideNotice, setHideNotice ] = useState(
- 'dismissed' === cookie.parse( document.cookie )?.sso_survey
+ 'dismissed' === cookie.parse( document.cookie )?.sso_disable
);
const setSSOSurveyCookie = ( value, maxAge ) => {
- document.cookie = cookie.serialize( 'sso_survey', value, {
+ document.cookie = cookie.serialize( 'sso_disable', value, {
path: '/',
maxAge,
} );
From 771345a0fbce4f40d7fb13b7c7c966b363bcb173 Mon Sep 17 00:00:00 2001
From: Anthony Grullon
Date: Tue, 19 Mar 2024 10:59:29 -0400
Subject: [PATCH 5/8] update sso disable survey link
---
projects/plugins/jetpack/_inc/client/security/sso.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/projects/plugins/jetpack/_inc/client/security/sso.jsx b/projects/plugins/jetpack/_inc/client/security/sso.jsx
index a36843e48bf71..350ad96178eca 100644
--- a/projects/plugins/jetpack/_inc/client/security/sso.jsx
+++ b/projects/plugins/jetpack/_inc/client/security/sso.jsx
@@ -18,7 +18,7 @@ const SSOSurveyNotice = connect( state => {
userId: getUserId( state ),
};
} )( ( { userId } ) => {
- const href = `https://wordpressdotcom.survey.fm/sso-disable-survey?initiated-from=jetpack&user-id=${ userId }`;
+ 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
);
From 3eecbdfde6055e7bb0aa93371f8dd490f9463d96 Mon Sep 17 00:00:00 2001
From: Anthony Grullon
Date: Tue, 19 Mar 2024 14:09:22 -0400
Subject: [PATCH 6/8] Retrieve correct userId
---
.../plugins/jetpack/_inc/client/security/sso.jsx | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/projects/plugins/jetpack/_inc/client/security/sso.jsx b/projects/plugins/jetpack/_inc/client/security/sso.jsx
index 350ad96178eca..215ed6360682a 100644
--- a/projects/plugins/jetpack/_inc/client/security/sso.jsx
+++ b/projects/plugins/jetpack/_inc/client/security/sso.jsx
@@ -1,4 +1,5 @@
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';
@@ -8,16 +9,12 @@ import { ModuleToggle } from 'components/module-toggle';
import SettingsCard from 'components/settings-card';
import SettingsGroup from 'components/settings-group';
import cookie from 'cookie';
-import React, { useState, Component } from 'react';
+import { useState, Component } from 'react';
import ReactDOM from 'react-dom';
-import { connect } from 'react-redux';
-import { getUserId } from 'state/initial-state';
-const SSOSurveyNotice = connect( state => {
- return {
- userId: getUserId( state ),
- };
-} )( ( { userId } ) => {
+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
@@ -84,7 +81,7 @@ const SSOSurveyNotice = connect( state => {
);
-} );
+};
export const SSO = withModuleSettingsFormHelpers(
class extends Component {
From 279769d85bbf5ff5b313a0888f59c94d0870ccf0 Mon Sep 17 00:00:00 2001
From: Anthony Grullon
Date: Tue, 19 Mar 2024 15:34:13 -0400
Subject: [PATCH 7/8] Fix classname
---
projects/plugins/jetpack/_inc/client/security/sso.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/projects/plugins/jetpack/_inc/client/security/sso.jsx b/projects/plugins/jetpack/_inc/client/security/sso.jsx
index 215ed6360682a..540f262e592bb 100644
--- a/projects/plugins/jetpack/_inc/client/security/sso.jsx
+++ b/projects/plugins/jetpack/_inc/client/security/sso.jsx
@@ -62,7 +62,7 @@ const SSOSurveyNotice = () => {
{ __( 'Remind later', 'jetpack' ) }
From 210bfd42ba674dc4cfc71db86a4c719a214d4163 Mon Sep 17 00:00:00 2001
From: Anthony Grullon
Date: Tue, 19 Mar 2024 15:35:03 -0400
Subject: [PATCH 8/8] Update styling
---
projects/plugins/jetpack/_inc/client/security/style.scss | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/projects/plugins/jetpack/_inc/client/security/style.scss b/projects/plugins/jetpack/_inc/client/security/style.scss
index 64cee053eed5b..f2306fff68914 100644
--- a/projects/plugins/jetpack/_inc/client/security/style.scss
+++ b/projects/plugins/jetpack/_inc/client/security/style.scss
@@ -157,7 +157,7 @@
}
.modal-survey-notice__popup-content {
- padding: 18px 24px 30px;
+ padding: 1rem;
background: var(--studio-white);
.modal-survey-notice__popup-content-title {