Skip to content

Commit e6301fa

Browse files
subscriptions management - add unsusbscribe cell (#103374)
1 parent 9ff703b commit e6301fa

File tree

3 files changed

+48
-40
lines changed

3 files changed

+48
-40
lines changed

client/landing/subscriptions/components/site-subscriptions-list/site-subscription-row.tsx

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Gridicon, ExternalLink, TimeSince } from '@automattic/components';
22
import { Reader, SubscriptionManager } from '@automattic/data-stores';
33
import { localizeUrl } from '@automattic/i18n-utils';
4-
import { __experimentalHStack as HStack } from '@wordpress/components';
4+
import { __experimentalHStack as HStack, Button } from '@wordpress/components';
55
import { useTranslate } from 'i18n-calypso';
66
import { useMemo, useRef } from 'react';
77
import { useDispatch } from 'react-redux';
@@ -163,6 +163,39 @@ const SiteSubscriptionRow = ( {
163163
);
164164
};
165165

166+
const onUnsubscribe = () => {
167+
unsubscribeInProgress.current = true;
168+
unsubscribeCallback();
169+
unsubscribe(
170+
{
171+
blog_id,
172+
subscriptionId: Number( subscriptionId ),
173+
url,
174+
doNotInvalidateSiteSubscriptions: true,
175+
},
176+
{
177+
onSuccess: () => {
178+
unsubscribeInProgress.current = false;
179+
180+
if ( resubscribePending.current ) {
181+
resubscribePending.current = false;
182+
resubscribe( {
183+
blog_id,
184+
url,
185+
doNotInvalidateSiteSubscriptions: true,
186+
resubscribed: true,
187+
} );
188+
recordSiteResubscribed( {
189+
blog_id,
190+
url,
191+
source: SOURCE_SUBSCRIPTIONS_UNSUBSCRIBED_NOTICE,
192+
} );
193+
}
194+
},
195+
}
196+
);
197+
};
198+
166199
const { isReaderPortal, isSubscriptionsPortal } = useSubscriptionManagerContext();
167200

168201
const siteTitleUrl = useMemo( () => {
@@ -320,6 +353,11 @@ const SiteSubscriptionRow = ( {
320353
<span className="email-frequency-cell" role="cell">
321354
{ deliveryFrequencyLabel }
322355
</span>
356+
<span className="unsubscribe-action-cell" role="cell">
357+
<Button variant="secondary" onClick={ onUnsubscribe }>
358+
{ translate( 'Unsubscribe' ) }
359+
</Button>
360+
</span>
323361
<span className="actions-cell" role="cell">
324362
<SiteSettingsPopover
325363
// NotifyMeOfNewPosts
@@ -341,38 +379,7 @@ const SiteSubscriptionRow = ( {
341379
emailMeNewComments={ !! delivery_methods.email?.send_comments }
342380
onEmailMeNewCommentsChange={ handleEmailMeNewCommentsChange }
343381
updatingEmailMeNewComments={ updatingEmailMeNewComments }
344-
onUnsubscribe={ () => {
345-
unsubscribeInProgress.current = true;
346-
unsubscribeCallback();
347-
unsubscribe(
348-
{
349-
blog_id,
350-
subscriptionId: Number( subscriptionId ),
351-
url,
352-
doNotInvalidateSiteSubscriptions: true,
353-
},
354-
{
355-
onSuccess: () => {
356-
unsubscribeInProgress.current = false;
357-
358-
if ( resubscribePending.current ) {
359-
resubscribePending.current = false;
360-
resubscribe( {
361-
blog_id,
362-
url,
363-
doNotInvalidateSiteSubscriptions: true,
364-
resubscribed: true,
365-
} );
366-
recordSiteResubscribed( {
367-
blog_id,
368-
url,
369-
source: SOURCE_SUBSCRIPTIONS_UNSUBSCRIBED_NOTICE,
370-
} );
371-
}
372-
},
373-
}
374-
);
375-
} }
382+
onUnsubscribe={ onUnsubscribe }
376383
unsubscribing={ unsubscribing }
377384
blogId={ sanitizedBlogId }
378385
feedId={ Number( feed_id ) }

client/landing/subscriptions/components/site-subscriptions-list/site-subscriptions-list.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ const SiteSubscriptionsList: React.FC< SiteSubscriptionsListProps > = ( {
8585
<span className="email-frequency-cell" role="columnheader">
8686
{ translate( 'Email frequency' ) }
8787
</span>
88+
<span className="unsubscribe-action-cell" role="columnheader">
89+
{ translate( 'Action' ) }
90+
</span>
8891
<span className="actions-cell" role="columnheader" />
8992
</HStack>
9093
{ subscriptions.map( ( siteSubscription ) => (

client/landing/subscriptions/components/site-subscriptions-list/styles/site-subscriptions-list.scss

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@
7979
.email-frequency-cell,
8080
.date-cell,
8181
.new-posts-cell,
82-
.new-comments-cell {
82+
.new-comments-cell,
83+
.unsubscribe-action-cell {
8384
@extend %site-subscriptions-list-default-text;
8485
}
8586

87+
8688
.new-posts-cell,
8789
.new-comments-cell {
8890
.green,
@@ -103,6 +105,7 @@
103105
.actions-cell {
104106
flex-basis: 36px;
105107
flex-grow: initial;
108+
margin: 0 5px;
106109

107110
.gridicon {
108111
fill: $studio-gray-50;
@@ -117,12 +120,7 @@
117120
}
118121

119122
@media (max-width: $break-large) {
120-
.new-posts-cell {
121-
display: none;
122-
}
123-
}
124-
125-
@media (max-width: $break-medium) {
123+
.new-posts-cell,
126124
.email-frequency-cell {
127125
display: none;
128126
}

0 commit comments

Comments
 (0)