Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions MIGRATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
This file documents changes in the data model. Please explain any changes to the
data model as well as any custom migrations.

## WordPress 77
- @aerych 2018-07-27
- `SharingService` added `externalUsersOnly` (bool) property. A new field returned by the API.

## WordPress 76

- @frosty 2018-05-16
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def shared_with_networking_pods
pod 'AFNetworking', '3.2.1'
pod 'Alamofire', '4.7.2'
pod 'wpxmlrpc', '0.8.3'
pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :commit => 'c2ae16bbc3fb759e0684fc9e5642d52390d00285'
pod 'WordPressKit', '1.2.1'
end

def shared_test_pods
Expand Down
15 changes: 5 additions & 10 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ PODS:
- WordPressShared (~> 1.0)
- WordPressUI (~> 1.0)
- wpxmlrpc (~> 0.8)
- WordPressKit (1.1):
- WordPressKit (1.2.1):
- Alamofire (~> 4.7)
- CocoaLumberjack (= 3.4.2)
- NSObject-SafeExpectations (= 0.0.3)
Expand Down Expand Up @@ -167,7 +167,7 @@ DEPENDENCIES:
- WordPress-Aztec-iOS (= 1.0.0-beta.23)
- WordPress-Editor-iOS (= 1.0.0-beta.23)
- WordPressAuthenticator (= 1.0.2)
- WordPressKit (from `https://github.com/wordpress-mobile/WordPressKit-iOS.git`, commit `c2ae16bbc3fb759e0684fc9e5642d52390d00285`)
- WordPressKit (= 1.2.1)
- WordPressShared (= 1.0.8)
- WordPressUI (= 1.0.6)
- WPMediaPicker (= 1.1)
Expand Down Expand Up @@ -204,6 +204,7 @@ SPEC REPOS:
- WordPress-Aztec-iOS
- WordPress-Editor-iOS
- WordPressAuthenticator
- WordPressKit
- WordPressShared
- WordPressUI
- WPMediaPicker
Expand All @@ -214,17 +215,11 @@ EXTERNAL SOURCES:
Automattic-Tracks-iOS:
:git: https://github.com/Automattic/Automattic-Tracks-iOS.git
:tag: 0.2.3
WordPressKit:
:commit: c2ae16bbc3fb759e0684fc9e5642d52390d00285
:git: https://github.com/wordpress-mobile/WordPressKit-iOS.git

CHECKOUT OPTIONS:
Automattic-Tracks-iOS:
:git: https://github.com/Automattic/Automattic-Tracks-iOS.git
:tag: 0.2.3
WordPressKit:
:commit: c2ae16bbc3fb759e0684fc9e5642d52390d00285
:git: https://github.com/wordpress-mobile/WordPressKit-iOS.git

SPEC CHECKSUMS:
1PasswordExtension: 0e95bdea64ec8ff2f4f693be5467a09fac42a83d
Expand Down Expand Up @@ -256,13 +251,13 @@ SPEC CHECKSUMS:
WordPress-Aztec-iOS: f2cc5402915e6f62db9681a0872e308ba8c9850c
WordPress-Editor-iOS: 4f46c2fa98f3017e9e39ad30ba9f03dbd6612ce4
WordPressAuthenticator: 20e8eb9cb61bef82370658037bdf9ca24a54570a
WordPressKit: a24baaa783c3a221f2d9a51c19318cbb27333373
WordPressKit: a4a3849684f631a3abf579f6d3f15a32677cbb30
WordPressShared: 063e1e8b1a7aaf635abf17f091a2d235a068abdc
WordPressUI: af141587ec444f9af753a00605bd0d3f14d8d8a3
WPMediaPicker: 5cc9386a4720f906d8fb79c7c4090d216b9f2348
wpxmlrpc: bfc572f62ce7ee897f6f38b098d2ba08732ecef4
ZendeskSDK: 2cda4db2ba6b10ba89aeb8dddaa94e97c85946a0

PODFILE CHECKSUM: 339d865b12a7ec85801b0246d83b31ae9ccc508c
PODFILE CHECKSUM: abbc2ae8b3f8b87e95076bd44e58b7430c94c2c9

COCOAPODS: 1.5.3
12 changes: 12 additions & 0 deletions WordPress/Classes/Models/PublicizeConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ open class PublicizeConnection: NSManagedObject {
@objc open func isBroken() -> Bool {
return status == "broken"
}

@objc open func mustDisconnect() -> Bool {
return status == "must-disconnect"
}

@objc open func requiresUserAction() -> Bool {
return isBroken() || mustDisconnect()
}

@objc open func mustDisconnectFacebook() -> Bool {
return mustDisconnect() && service == PublicizeService.facebookServiceID
}
}
2 changes: 2 additions & 0 deletions WordPress/Classes/Models/PublicizeService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import CoreData

open class PublicizeService: NSManagedObject {
@objc static let googlePlusServiceID = "google_plus"
@objc static let facebookServiceID = "facebook"

@NSManaged open var connectURL: String
@NSManaged open var detail: String
@NSManaged open var externalUsersOnly: Bool
@NSManaged open var icon: String
@NSManaged open var jetpackSupport: Bool
@NSManaged open var jetpackModuleRequired: String
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Services/SharingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ open class SharingService: LocalCoreDataService {
}
pubService?.connectURL = remoteService.connectURL
pubService?.detail = remoteService.detail
pubService?.externalUsersOnly = remoteService.externalUsersOnly
pubService?.icon = remoteService.icon
pubService?.jetpackModuleRequired = remoteService.jetpackModuleRequired
pubService?.jetpackSupport = remoteService.jetpackSupport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ import WordPressShared
@objc var immutableHandler: ImmuTableViewHandler!
@objc var delegate: SharingAccountSelectionDelegate?

fileprivate lazy var noResultsViewController: NoResultsViewController = {
let controller = NoResultsViewController.controller()
controller.view.frame = view.frame
addChildViewController(controller)
view.addSubview(controller.view)
controller.didMove(toParentViewController: self)
return controller
}()


// MARK: - Lifecycle Methods

Expand Down Expand Up @@ -72,6 +81,25 @@ import WordPressShared
}


fileprivate func showNoResultsViewController() {
let title = NSLocalizedString("No Accounts Found",
comment: "Title of an error message. There were no third-party service accounts found to setup sharing.")
let message = NSLocalizedString("Sorry. The social service did not tell us which account could be used for sharing.",
comment: "An error message shown if a third-party social service does not specify any accounts that an be used with publicize sharing.")
noResultsViewController.configure(title: title, buttonTitle: nil, subtitle: message, image: nil, accessoryView: nil)
}


fileprivate func showFacebookNotice() {
let message = NSLocalizedString("The Facebook connection could not be made because this account does not have access to any pages. Facebook supports sharing connections to Facebook Pages, but not to Facebook Profiles.",
comment: "Error message shown to a user who is trying to share to Facebook but does not have any available Facebook Pages.")

let buttonTitle = NSLocalizedString("Learn more", comment: "A button title.")
noResultsViewController.configure(title: "", buttonTitle: buttonTitle, subtitle: message, image: nil, accessoryView: nil)
noResultsViewController.delegate = self
}


// MARK: - View Model Wrangling


Expand All @@ -84,6 +112,15 @@ import WordPressShared
var connectedAccounts = [KeyringAccount]()
var accounts = keyringAccountsFromKeyringConnections(keyringConnections)

if accounts.count == 0 {
if publicizeService.serviceID == PublicizeService.facebookServiceID {
showFacebookNotice()
} else {
showNoResultsViewController()
}
return ImmuTable(sections: [])
}

// Filter out connected accounts into a different Array
for (idx, acct) in accounts.enumerated() {
if accountIsConnected(acct) {
Expand Down Expand Up @@ -196,7 +233,11 @@ import WordPressShared

for connection in connections {
let acct = KeyringAccount(name: connection.externalDisplay, externalID: nil, externalIDForConnection: connection.externalID, keyringConnection: connection)
accounts.append(acct)

// Do not include the service if it only supports external users.
if !publicizeService.externalUsersOnly {
accounts.append(acct)
}

for externalUser in connection.additionalExternalUsers {
let acct = KeyringAccount(name: externalUser.externalName, externalID: externalUser.externalID, externalIDForConnection: externalUser.externalID, keyringConnection: connection)
Expand Down Expand Up @@ -283,3 +324,13 @@ import WordPressShared
func didDismissSharingAccountViewController(_ controller: SharingAccountViewController)
func sharingAccountViewController(_ controller: SharingAccountViewController, selectedKeyringConnection keyringConnection: KeyringConnection, externalID: String?)
}


extension SharingAccountViewController: NoResultsViewControllerDelegate {
func actionButtonPressed() {
if let url = URL(string: "https://en.support.wordpress.com/publicize/#facebook-pages") {
UIApplication.shared.open(url)
}
dismiss(animated: true, completion: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ - (void)configurePublicizeCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath
PublicizeConnection *connection = [[self connectionsForService] objectAtIndex:indexPath.row];
cell.textLabel.text = connection.externalDisplay;

if ([connection isBroken]) {
if ([connection requiresUserAction]) {
cell.accessoryView = [WPStyleGuide sharingCellWarningAccessoryImageView];
}
}
Expand Down
69 changes: 58 additions & 11 deletions WordPress/Classes/ViewRelated/Blog/SharingDetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,46 @@ - (void)viewDidLoad

#pragma mark - Instance Methods

- (void)openFacebookFAQ
{
NSURL *url = [NSURL URLWithString:@"https://en.blog.wordpress.com/2018/07/23/sharing-options-from-wordpress-com-to-facebook-are-changing/"];
[[UIApplication sharedApplication] openURL:url options:[NSDictionary new] completionHandler:nil];
}

- (NSString *)textForFacebookFooter
{
NSString *title = NSLocalizedString(@"As of August 1, 2018, Facebook no longer allows direct sharing of posts to Facebook Profiles. Connections to Facebook Pages remain unchanged.", @"Message shown to users who have an old publicize connection to a facebook profile.");
return [NSString stringWithFormat:title, self.publicizeConnection.label];
}

- (NSString *)textForBrokenConnectionFooter
{
NSString *title = NSLocalizedString(@"There is an issue connecting to %@. Reconnect to continue publicizing.", @"Informs the user about an issue connecting to the third-party sharing service. The `%@` is a placeholder for the service name.");
return [NSString stringWithFormat:title, self.publicizeConnection.label];
}

- (void)configureReconnectCell: (UITableViewCell *)cell
{
cell.textLabel.text = NSLocalizedString(@"Reconnect", @"Verb. Text label. Tapping attempts to reconnect a third-party sharing service to the user's blog.");
[WPStyleGuide configureTableViewActionCell:cell];
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.textLabel.textColor = [WPStyleGuide jazzyOrange];
}

- (void)configureLearnMoreCell: (UITableViewCell *)cell
{
cell.textLabel.text = NSLocalizedString(@"Learn More", @"Title of a button. Tapping allows the user to learn more about the specific error.");
[WPStyleGuide configureTableViewActionCell:cell];
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.textLabel.textColor = [WPStyleGuide wordPressBlue];
}

- (void)configureDisconnectCell: (UITableViewCell *)cell
{
cell.textLabel.text = NSLocalizedString(@"Disconnect", @"Verb. Text label. Tapping disconnects a third-party sharing service from the user's blog.");
[WPStyleGuide configureTableViewDestructiveActionCell:cell];
}

- (NSManagedObjectContext *)managedObjectContext
{
return self.blog.managedObjectContext;
Expand All @@ -70,7 +110,7 @@ - (NSManagedObjectContext *)managedObjectContext

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
if ([self.publicizeConnection isBroken]) {
if ([self.publicizeConnection requiresUserAction]) {
return 3;
}

Expand All @@ -96,10 +136,17 @@ - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInte
if (section == 0) {
return NSLocalizedString(@"Allow this connection to be used by all admins and users of your site.", @"");
}
if (section == 1 && [self.publicizeConnection isBroken]) {
NSString *title = NSLocalizedString(@"There is an issue connecting to %@. Reconnect to continue publicizing.", @"Informs the user about an issue connecting to the third-party sharing service. The `%@` is a placeholder for the service name.");
return [NSString stringWithFormat:title, self.publicizeConnection.label];

if (section == 1) {
if ([self.publicizeConnection mustDisconnectFacebook]) {
return [self textForFacebookFooter];
}

if ([self.publicizeConnection isBroken]) {
return [self textForBrokenConnectionFooter];
}
}

return nil;
}

Expand All @@ -120,14 +167,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = [self switchTableViewCell];

} else if (indexPath.section == 1 && [self.publicizeConnection isBroken]) {
cell.textLabel.text = NSLocalizedString(@"Reconnect", @"Verb. Text label. Tapping attempts to reconnect a third-party sharing service to the user's blog.");
[WPStyleGuide configureTableViewActionCell:cell];
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.textLabel.textColor = [WPStyleGuide jazzyOrange];
[self configureReconnectCell:cell];

} else if (indexPath.section == 1 && [self.publicizeConnection mustDisconnectFacebook]) {
[self configureLearnMoreCell:cell];

} else {
cell.textLabel.text = NSLocalizedString(@"Disconnect", @"Verb. Text label. Tapping disconnects a third-party sharing service from the user's blog.");
[WPStyleGuide configureTableViewDestructiveActionCell:cell];
[self configureDisconnectCell:cell];
}

return cell;
Expand All @@ -139,7 +185,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

if (indexPath.section == 1 && [self.publicizeConnection isBroken]) {
[self reconnectPublicizeConnection];

} else if (indexPath.section == 1 && [self.publicizeConnection mustDisconnectFacebook]) {
[self openFacebookFAQ];
} else {
[self promptToConfirmDisconnect];
}
Expand Down
2 changes: 1 addition & 1 deletion WordPress/Classes/ViewRelated/Blog/SharingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ - (void)configurePublicizeCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath

// Check if any of the connections are broken.
for (PublicizeConnection *pubConn in connections) {
if ([pubConn isBroken]) {
if ([pubConn requiresUserAction]) {
cell.accessoryView = [WPStyleGuide sharingCellWarningAccessoryImageView];
break;
}
Expand Down
2 changes: 1 addition & 1 deletion WordPress/Classes/WordPress.xcdatamodeld/.xccurrentversion
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>WordPress 76.xcdatamodel</string>
<string>WordPress 77.xcdatamodel</string>
</dict>
</plist>
Loading