2
2
* External dependencies
3
3
*/
4
4
import { sprintf , __ } from '@wordpress/i18n' ;
5
- import { useState } from '@wordpress/element' ;
6
5
import { getSetting } from '@woocommerce/settings' ; // eslint-disable-line import/no-unresolved
7
6
// The above is an unpublished package, delivered with WC, we use Dependency Extraction Webpack Plugin to import it.
8
7
// See https://github.com/woocommerce/woocommerce-admin/issues/7781
@@ -11,94 +10,24 @@ import { getSetting } from '@woocommerce/settings'; // eslint-disable-line impor
11
10
* Internal dependencies
12
11
*/
13
12
import AccountCard , { APPEARANCE } from '~/components/account-card' ;
14
- import AppButton from '~/components/app-button' ;
15
13
import ConnectedIconLabel from '~/components/connected-icon-label' ;
16
- import Section from '~/components/section' ;
17
14
import { GOOGLE_WPCOM_APP_CONNECTED_STATUS } from '~/constants' ;
18
- import { API_NAMESPACE } from '~/data/constants' ;
19
- import useDispatchCoreNotices from '~/hooks/useDispatchCoreNotices' ;
20
- import useApiFetchCallback from '~/hooks/useApiFetchCallback' ;
21
- import { useAppDispatch } from '~/data' ;
22
15
import EnableNewProductSyncButton from '~/components/enable-new-product-sync-button' ;
23
16
import AppNotice from '~/components/app-notice' ;
24
- import DisconnectModal , {
25
- API_DATA_FETCH_FEATURE ,
26
- } from '~/pages/settings/disconnect-modal' ;
27
- import { getSettingsUrl } from '~/utils/urls' ;
28
- import { recordGlaEvent } from '~/utils/tracks' ;
29
17
30
18
/**
31
19
* @typedef {import('~/data/types.js').GoogleMCAccount } GoogleMCAccount
32
20
*/
33
21
34
- /**
35
- * Clicking on the button to disable the new product sync (API Pull).
36
- *
37
- * @event gla_disable_product_sync_click
38
- */
39
-
40
22
/**
41
23
* Renders a Google Merchant Center account card UI with connected account information.
42
24
*
43
25
* @param {Object } props React props.
44
26
* @param {GoogleMCAccount } props.googleMCAccount A data payload object of Google Merchant Center account.
45
- *
46
- * @fires gla_disable_product_sync_click
47
27
*/
48
28
const MerchantCenterAccountInfoCard = ( { googleMCAccount } ) => {
49
- const { createNotice, removeNotice } = useDispatchCoreNotices ( ) ;
50
- const { invalidateResolution } = useAppDispatch ( ) ;
51
-
52
- const [
53
- fetchDisableNotifications ,
54
- { loading : loadingDisableNotifications } ,
55
- ] = useApiFetchCallback ( {
56
- path : `${ API_NAMESPACE } /rest-api/authorize` ,
57
- method : 'DELETE' ,
58
- } ) ;
59
-
60
- /**
61
- * Temporary code for disabling the API PULL Beta Feature from the GMC Card
62
- */
63
- const [ openedModal , setOpenedModal ] = useState ( null ) ;
64
- const dismissModal = ( ) => setOpenedModal ( null ) ;
65
- const openDisableDataFetchModal = ( ) =>
66
- setOpenedModal ( API_DATA_FETCH_FEATURE ) ;
67
-
68
29
const domain = new URL ( getSetting ( 'homeUrl' ) ) . host ;
69
30
70
- const disableNotifications = async ( ) => {
71
- recordGlaEvent ( 'gla_disable_product_sync_click' ) ;
72
-
73
- const { notice } = await createNotice (
74
- 'info' ,
75
- __ (
76
- 'Disabling the new Product Sync feature, please wait…' ,
77
- 'google-listings-and-ads'
78
- )
79
- ) ;
80
-
81
- try {
82
- await fetchDisableNotifications ( ) ;
83
- invalidateResolution ( 'getGoogleMCAccount' , [ ] ) ;
84
- } catch ( error ) {
85
- createNotice (
86
- 'error' ,
87
- __ (
88
- 'Unable to disable new product sync. Please try again later.' ,
89
- 'google-listings-and-ads'
90
- )
91
- ) ;
92
- }
93
-
94
- removeNotice ( notice . id ) ;
95
- } ;
96
-
97
- // Show the button if the status is "approved".
98
- const showDisconnectNotificationsButton =
99
- googleMCAccount . wpcom_rest_api_status ===
100
- GOOGLE_WPCOM_APP_CONNECTED_STATUS . APPROVED ;
101
-
102
31
// Show the error if the status is set but is not "approved".
103
32
const showErrorNotificationsNotice =
104
33
googleMCAccount . wpcom_rest_api_status &&
@@ -126,14 +55,6 @@ const MerchantCenterAccountInfoCard = ( { googleMCAccount } ) => {
126
55
)
127
56
}
128
57
>
129
- { showDisconnectNotificationsButton && (
130
- < AppNotice status = "success" isDismissible = { false } >
131
- { __ (
132
- 'Google has been granted access to fetch your product data.' ,
133
- 'google-listings-and-ads'
134
- ) }
135
- </ AppNotice >
136
- ) }
137
58
138
59
{ showErrorNotificationsNotice && (
139
60
< AppNotice status = "warning" isDismissible = { false } >
@@ -143,32 +64,6 @@ const MerchantCenterAccountInfoCard = ( { googleMCAccount } ) => {
143
64
) }
144
65
</ AppNotice >
145
66
) }
146
-
147
- { openedModal && (
148
- < DisconnectModal
149
- onRequestClose = { dismissModal }
150
- onDisconnected = { ( ) => {
151
- window . location . href = getSettingsUrl ( ) ;
152
- } }
153
- disconnectTarget = { openedModal }
154
- disconnectAction = { disableNotifications }
155
- />
156
- ) }
157
-
158
- { showDisconnectNotificationsButton && (
159
- < Section . Card . Footer >
160
- < AppButton
161
- isDestructive
162
- isLink
163
- disabled = { loadingDisableNotifications }
164
- text = { __ (
165
- 'Disable product data fetch' ,
166
- 'google-listings-and-ads'
167
- ) }
168
- onClick = { openDisableDataFetchModal }
169
- />
170
- </ Section . Card . Footer >
171
- ) }
172
67
</ AccountCard >
173
68
) ;
174
69
} ;
0 commit comments