{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments/31848993","id":31848993,"diff_hunk":"@@ -13,160 +13,393 @@ import XCGLogger\n // TODO: same comment as for SyncAuthState.swift!\n private let log = XCGLogger.defaultInstance()\n \n-\n private struct RemoteTabsPanelUX {\n     static let HeaderHeight: CGFloat = SiteTableViewControllerUX.RowHeight // Not HeaderHeight!\n     static let RowHeight: CGFloat = SiteTableViewControllerUX.RowHeight\n     static let HeaderBackgroundColor = UIColor(rgb: 0xf8f8f8)\n+\n+    static let EmptyStateTitleFont = UIFont.boldSystemFontOfSize(15)\n+    static let EmptyStateTitleTextColor = UIColor.darkGrayColor()\n+    static let EmptyStateInstructionsFont = UIFont.systemFontOfSize(15)\n+    static let EmptyStateInstructionsTextColor = UIColor.grayColor()\n+    static let EmptyStateInstructionsWidth = 256\n+    static let EmptyStateTopPaddingInBetweenItems: CGFloat = 8 // UX TODO I set this to 8 so that it all fits on landscape\n+    static let EmptyStateSignInButtonColor = UIColor(red: 0.259, green: 0.49, blue: 0.831, alpha: 1.0)\n+    static let EmptyStateSignInButtonTitleFont = UIFont.systemFontOfSize(20)\n+    static let EmptyStateSignInButtonTitleColor = UIColor.whiteColor()\n+    static let EmptyStateSignInButtonCornerRadius: CGFloat = 6\n+    static let EmptyStateSignInButtonHeight = 56\n+    static let EmptyStateSignInButtonWidth = 272\n+    static let EmptyStateCreateAccountButtonFont = UIFont.systemFontOfSize(12)\n }\n \n private let RemoteClientIdentifier = \"RemoteClient\"\n private let RemoteTabIdentifier = \"RemoteTab\"\n \n-/**\n- * Display a tree hierarchy of remote clients and tabs, like:\n- * client\n- *   tab\n- *   tab\n- * client\n- *   tab\n- *   tab\n- * This is not a SiteTableViewController because it is inherently tree-like and not list-like;\n- * a technical detail is that STVC is backed by a Cursor and this is backed by a richer data\n- * structure.  However, the styling here should agree with STVC where possible.\n- */\n class RemoteTabsPanel: UITableViewController, HomePanel {\n     weak var homePanelDelegate: HomePanelDelegate? = nil\n     var profile: Profile!\n \n-    private var clientAndTabs: [ClientAndTabs]?\n-\n-    private func tabAtIndexPath(indexPath: NSIndexPath) -> RemoteTab? {\n-        return self.clientAndTabs?[indexPath.section].tabs[indexPath.item]\n-    }\n-\n     override func viewDidLoad() {\n         super.viewDidLoad()\n+\n         tableView.registerClass(TwoLineHeaderFooterView.self, forHeaderFooterViewReuseIdentifier: RemoteClientIdentifier)\n         tableView.registerClass(TwoLineTableViewCell.self, forCellReuseIdentifier: RemoteTabIdentifier)\n+\n         tableView.rowHeight = RemoteTabsPanelUX.RowHeight\n         tableView.separatorInset = UIEdgeInsetsZero\n \n-        view.backgroundColor = AppConstants.PanelBackgroundColor\n+        tableView.delegate = nil\n+        tableView.dataSource = nil\n \n         refreshControl = UIRefreshControl()\n         refreshControl?.addTarget(self, action: \"SELrefresh\", forControlEvents: UIControlEvents.ValueChanged)\n+\n+        view.backgroundColor = AppConstants.PanelBackgroundColor\n     }\n \n     override func viewWillAppear(animated: Bool) {\n         super.viewWillAppear(animated)\n-        self.SELrefresh()\n+        refresh()\n     }\n \n-    @objc private func SELrefresh() {\n-        self.refreshControl?.beginRefreshing()\n+    var tableViewDelegate: RemoteTabsPanelDataSource? {\n+        didSet {\n+            self.tableView.delegate = tableViewDelegate\n+            self.tableView.dataSource = tableViewDelegate\n+        }\n+    }\n \n-        self.profile.getClientsAndTabs().upon({ tabs in\n-            if let tabs = tabs.successValue {\n-                log.info(\"\\(tabs.count) tabs fetched.\")\n-                self.clientAndTabs = tabs.filter { $0.tabs.count > 0 }\n-\n-                // Maybe show a background view.\n-                let tableView = self.tableView\n-                if let clientAndTabs = self.clientAndTabs where clientAndTabs.count > 0 {\n-                    tableView.backgroundView = nil\n-                    // Show dividing lines.\n-                    tableView.separatorStyle = UITableViewCellSeparatorStyle.SingleLine\n-                } else {\n-                    // TODO: Bug 1144760 - Populate background view with UX-approved content.\n-                    tableView.backgroundView = UIView()\n-                    tableView.backgroundView?.frame = tableView.frame\n-                    tableView.backgroundView?.backgroundColor = UIColor.redColor()\n+    func refresh() {\n+        tableView.scrollEnabled = false\n+        tableView.allowsSelection = false\n+        tableView.tableFooterView = UIView(frame: CGRectZero)\n+\n+        // Short circuit if the user is not logged in\n+        if profile.getAccount() == nil {\n+            self.tableViewDelegate = RemoteTabsPanelErrorDataSource(homePanel: self, error: .NotLoggedIn)\n+            self.tableView.reloadData()\n+            return\n+        }\n \n-                    // Hide dividing lines.\n-                    tableView.separatorStyle = UITableViewCellSeparatorStyle.None\n+        // Otherwise, fetch the tabs cloud\n+        self.profile.getClientsAndTabs().upon({ result in\n+            self.refreshControl?.endRefreshing()\n+\n+            if let clientAndTabs = result.successValue {\n+                if clientAndTabs.count == 0 {\n+                    self.tableViewDelegate = RemoteTabsPanelErrorDataSource(homePanel: self, error: .NoClients)\n+                } else {\n+                    let nonEmptyClientAndTabs = clientAndTabs.filter { $0.tabs.count > 0 }\n+                    if nonEmptyClientAndTabs.count == 0 {\n+                        self.tableViewDelegate = RemoteTabsPanelErrorDataSource(homePanel: self, error: .NoTabs)\n+                    } else {\n+                        self.tableViewDelegate = RemoteTabsPanelClientAndTabsDataSource(homePanel: self, clientAndTabs: nonEmptyClientAndTabs)\n+                        self.tableView.allowsSelection = true\n+                    }\n                 }\n-                tableView.reloadData()\n             } else {\n-                log.error(\"Failed to fetch tabs.\")\n+                self.tableViewDelegate = RemoteTabsPanelErrorDataSource(homePanel: self, error: .FailedToSync)","path":"Client/Frontend/Home/RemoteTabsPanel.swift","position":133,"original_position":133,"commit_id":"15f700012f87ed2008fd40cbb13cb9c30e6c95b4","original_commit_id":"15f700012f87ed2008fd40cbb13cb9c30e6c95b4","user":{"login":"rnewman","id":91722,"avatar_url":"https://avatars.githubusercontent.com/u/91722?v=3","gravatar_id":"","url":"https://api.github.com/users/rnewman","html_url":"https://github.com/rnewman","followers_url":"https://api.github.com/users/rnewman/followers","following_url":"https://api.github.com/users/rnewman/following{/other_user}","gists_url":"https://api.github.com/users/rnewman/gists{/gist_id}","starred_url":"https://api.github.com/users/rnewman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnewman/subscriptions","organizations_url":"https://api.github.com/users/rnewman/orgs","repos_url":"https://api.github.com/users/rnewman/repos","events_url":"https://api.github.com/users/rnewman/events{/privacy}","received_events_url":"https://api.github.com/users/rnewman/received_events","type":"User","site_admin":false},"body":"Also this failure might be a `ServerInBackoffError`, which perhaps we want to handle specially…","created_at":"2015-06-05T20:34:19Z","updated_at":"2015-06-05T20:34:19Z","html_url":"https://github.com/mozilla/firefox-ios/pull/563#discussion_r31848993","pull_request_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/563","_links":{"self":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments/31848993"},"html":{"href":"https://github.com/mozilla/firefox-ios/pull/563#discussion_r31848993"},"pull_request":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/563"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/563","id":36965757,"html_url":"https://github.com/mozilla/firefox-ios/pull/563","diff_url":"https://github.com/mozilla/firefox-ios/pull/563.diff","patch_url":"https://github.com/mozilla/firefox-ios/pull/563.patch","issue_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/563","number":563,"state":"open","locked":false,"title":"Fixes 1171599 - Remote Tabs Home Panel needs a 'not logged in' state","user":{"login":"st3fan","id":28052,"avatar_url":"https://avatars.githubusercontent.com/u/28052?v=3","gravatar_id":"","url":"https://api.github.com/users/st3fan","html_url":"https://github.com/st3fan","followers_url":"https://api.github.com/users/st3fan/followers","following_url":"https://api.github.com/users/st3fan/following{/other_user}","gists_url":"https://api.github.com/users/st3fan/gists{/gist_id}","starred_url":"https://api.github.com/users/st3fan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/st3fan/subscriptions","organizations_url":"https://api.github.com/users/st3fan/orgs","repos_url":"https://api.github.com/users/st3fan/repos","events_url":"https://api.github.com/users/st3fan/events{/privacy}","received_events_url":"https://api.github.com/users/st3fan/received_events","type":"User","site_admin":false},"body":"This bug is about displaying https://bug1144760.bugzilla.mozilla.org/attachment.cgi?id=8593086 on the Remote Tabs Home Panel when the user is not logged in.\r\n\r\nThis patch actually also shows three addition states:\r\n\r\n* When the sync of tabs failed\r\n* When the sync was good but the user has no other devices with open tabs\r\n* When the sync was good but the user has no other devices at all\r\n\r\nIt was easier to combine all these empty states in a single change.\r\n\r\nTo keep this code simple, I have implemented this with custom `UITableViewCell` instances.\r\n\r\nAlso, instead of doing a lot of conditional work in the UITableViewDataSource, like we do in `ClientPickerViewController`, I have chosen to instead make a few separate datasource/delegate subclasses that are swapped in and out depending on the state.\r\n\r\nThis keeps the main `RemoteTabsPanel` class relatively small and moves the logic for each state case into a much smaller and independent classes.\r\n\r\n*Update* This also contains a fix for some string changes as part of bug 1168403 ","created_at":"2015-06-04T18:50:37Z","updated_at":"2015-06-05T20:34:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f5f176a59dffb2e85f918c2d2859ab97ef786671","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/563/commits","review_comments_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/563/comments","review_comment_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/563/comments","statuses_url":"https://api.github.com/repos/mozilla/firefox-ios/statuses/15f700012f87ed2008fd40cbb13cb9c30e6c95b4","head":{"label":"mozilla:st3fan/Bug1171599RemoteTabsNotLoggedInState","ref":"st3fan/Bug1171599RemoteTabsNotLoggedInState","sha":"15f700012f87ed2008fd40cbb13cb9c30e6c95b4","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":26133979,"name":"firefox-ios","full_name":"mozilla/firefox-ios","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/firefox-ios","description":"Firefox for iOS","fork":false,"url":"https://api.github.com/repos/mozilla/firefox-ios","forks_url":"https://api.github.com/repos/mozilla/firefox-ios/forks","keys_url":"https://api.github.com/repos/mozilla/firefox-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/firefox-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/firefox-ios/teams","hooks_url":"https://api.github.com/repos/mozilla/firefox-ios/hooks","issue_events_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/firefox-ios/events","assignees_url":"https://api.github.com/repos/mozilla/firefox-ios/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/firefox-ios/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/firefox-ios/tags","blobs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/firefox-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/firefox-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/firefox-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/firefox-ios/languages","stargazers_url":"https://api.github.com/repos/mozilla/firefox-ios/stargazers","contributors_url":"https://api.github.com/repos/mozilla/firefox-ios/contributors","subscribers_url":"https://api.github.com/repos/mozilla/firefox-ios/subscribers","subscription_url":"https://api.github.com/repos/mozilla/firefox-ios/subscription","commits_url":"https://api.github.com/repos/mozilla/firefox-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/firefox-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/firefox-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/firefox-ios/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/firefox-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/firefox-ios/merges","archive_url":"https://api.github.com/repos/mozilla/firefox-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/firefox-ios/downloads","issues_url":"https://api.github.com/repos/mozilla/firefox-ios/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/firefox-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/firefox-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/firefox-ios/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/firefox-ios/releases{/id}","created_at":"2014-11-03T19:07:02Z","updated_at":"2015-06-05T18:06:06Z","pushed_at":"2015-06-05T20:24:53Z","git_url":"git://github.com/mozilla/firefox-ios.git","ssh_url":"git@github.com:mozilla/firefox-ios.git","clone_url":"https://github.com/mozilla/firefox-ios.git","svn_url":"https://github.com/mozilla/firefox-ios","homepage":"","size":130183,"stargazers_count":3259,"watchers_count":3259,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":540,"mirror_url":null,"open_issues_count":37,"forks":540,"open_issues":37,"watchers":3259,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"01bce837c5d4c83ee4a9f8b283cc060a20df5f5b","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":26133979,"name":"firefox-ios","full_name":"mozilla/firefox-ios","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/firefox-ios","description":"Firefox for iOS","fork":false,"url":"https://api.github.com/repos/mozilla/firefox-ios","forks_url":"https://api.github.com/repos/mozilla/firefox-ios/forks","keys_url":"https://api.github.com/repos/mozilla/firefox-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/firefox-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/firefox-ios/teams","hooks_url":"https://api.github.com/repos/mozilla/firefox-ios/hooks","issue_events_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/firefox-ios/events","assignees_url":"https://api.github.com/repos/mozilla/firefox-ios/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/firefox-ios/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/firefox-ios/tags","blobs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/firefox-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/firefox-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/firefox-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/firefox-ios/languages","stargazers_url":"https://api.github.com/repos/mozilla/firefox-ios/stargazers","contributors_url":"https://api.github.com/repos/mozilla/firefox-ios/contributors","subscribers_url":"https://api.github.com/repos/mozilla/firefox-ios/subscribers","subscription_url":"https://api.github.com/repos/mozilla/firefox-ios/subscription","commits_url":"https://api.github.com/repos/mozilla/firefox-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/firefox-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/firefox-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/firefox-ios/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/firefox-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/firefox-ios/merges","archive_url":"https://api.github.com/repos/mozilla/firefox-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/firefox-ios/downloads","issues_url":"https://api.github.com/repos/mozilla/firefox-ios/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/firefox-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/firefox-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/firefox-ios/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/firefox-ios/releases{/id}","created_at":"2014-11-03T19:07:02Z","updated_at":"2015-06-05T18:06:06Z","pushed_at":"2015-06-05T20:24:53Z","git_url":"git://github.com/mozilla/firefox-ios.git","ssh_url":"git@github.com:mozilla/firefox-ios.git","clone_url":"https://github.com/mozilla/firefox-ios.git","svn_url":"https://github.com/mozilla/firefox-ios","homepage":"","size":130183,"stargazers_count":3259,"watchers_count":3259,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":540,"mirror_url":null,"open_issues_count":37,"forks":540,"open_issues":37,"watchers":3259,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/563"},"html":{"href":"https://github.com/mozilla/firefox-ios/pull/563"},"issue":{"href":"https://api.github.com/repos/mozilla/firefox-ios/issues/563"},"comments":{"href":"https://api.github.com/repos/mozilla/firefox-ios/issues/563/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/563/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/563/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/firefox-ios/statuses/15f700012f87ed2008fd40cbb13cb9c30e6c95b4"}}}}