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: 2 additions & 2 deletions Modules/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let package = Package(
.package(url: "https://github.com/wordpress-mobile/NSURL-IDN", revision: "b34794c9a3f32312e1593d4a3d120572afa0d010"),
.package(
url: "https://github.com/wordpress-mobile/WordPressKit-iOS",
revision: "30dadcab01a980eb16976340c1e9e8a9527ddc05" // see wpios-edition branch
revision: "ae3961ce89ac0c43a90e88d4963a04aa92008443" // see wpios-edition branch
),
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
// We can't use wordpress-rs branches nor commits here. Only tags work.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ struct ActivityLogDetailsView: View {
ScrollView {
VStack(spacing: 24) {
ActivityHeaderView(activity: activity)
if let actor = activity.actor {
makeActorCard(for: actor)
}
if activity.isRewindable {
restoreSiteCard
}
if let actor = activity.actor {
makeActorCard(for: actor)
}
}
.padding()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ struct ActivityLogsMenu: View {
Menu {
Section {
dateFilters
activityTypeFilter
if !viewModel.isBackupMode {
activityTypeFilter
}
if !viewModel.parameters.isEmpty {
resetFiltersButton
}
Expand Down
20 changes: 17 additions & 3 deletions WordPress/Classes/ViewRelated/Activity/List/ActivityLogsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ struct ActivityLogsView: View {
@ObservedObject var viewModel: ActivityLogsViewModel

var body: some View {
Group {
let content = Group {
if !viewModel.searchText.isEmpty {
ActivityLogsSearchView(viewModel: viewModel)
} else {
ActivityLogsListView(viewModel: viewModel)
}
}
.searchable(text: $viewModel.searchText)
.navigationTitle(viewModel.isBackupMode ? Strings.backupsTitle : Strings.activityTitle)

if viewModel.isBackupMode {
content
} else {
content.searchable(text: $viewModel.searchText)
}
}
}

Expand All @@ -38,7 +44,11 @@ private struct ActivityLogsListView: View {
.overlay {
if let response = viewModel.response {
if response.isEmpty {
EmptyStateView(Strings.empty, systemImage: "archivebox")
EmptyStateView(
viewModel.isBackupMode ? Strings.emptyBackups : Strings.empty,
systemImage: "archivebox",
description: viewModel.isBackupMode ? Strings.emptyBackupsSubtitle : nil
)
}
} else if viewModel.isLoading {
ProgressView()
Expand Down Expand Up @@ -127,4 +137,8 @@ private struct ActivityLogsPaginatedForEach: View {
private enum Strings {
static let empty = NSLocalizedString("activityLogs.empty", value: "No Activity", comment: "Empty state message for activity logs")
static let freePlanNotice = NSLocalizedString("activityLogs.freePlan.notice", value: "Since you're on a free plan, you'll see limited events in your Activity Log.", comment: "Notice shown to free plan users about limited activity log events")
static let activityTitle = NSLocalizedString("activityLogs.title", value: "Activity", comment: "Title for activity logs screen")
static let backupsTitle = NSLocalizedString("backups.title", value: "Backups", comment: "Title for backups screen")
static let emptyBackups = NSLocalizedString("backups.empty.title", value: "Your first backup will be ready soon", comment: "Title for the view when there aren't any Backups to display")
static let emptyBackupsSubtitle = NSLocalizedString("backups.empty.subtitle", value: "Your first backup will appear here within 24 hours and you will receive a notification once the backup has been completed", comment: "Text displayed in the view when there aren't any Backups to display")
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import WordPressKit
final class ActivityLogsViewController: UIHostingController<AnyView> {
private let viewModel: ActivityLogsViewModel

init(blog: Blog) {
self.viewModel = ActivityLogsViewModel(blog: blog)
init(blog: Blog, isBackupMode: Bool = false) {
self.viewModel = ActivityLogsViewModel(blog: blog, isBackupMode: isBackupMode)
super.init(rootView: AnyView(ActivityLogsView(viewModel: viewModel)))
self.title = Strings.title
self.title = isBackupMode ? Strings.backupsTitle : Strings.activityTitle
}

required dynamic init?(coder aDecoder: NSCoder) {
Expand All @@ -18,5 +18,6 @@ final class ActivityLogsViewController: UIHostingController<AnyView> {
}

private enum Strings {
static let title = NSLocalizedString("activity.logs.title", value: "Activity", comment: "Title for the activity logs screen")
static let activityTitle = NSLocalizedString("activity.logs.title", value: "Activity", comment: "Title for the activity logs screen")
static let backupsTitle = NSLocalizedString("backups.title", value: "Backups", comment: "Title for the backups screen")
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ typealias ActivityLogsPaginatedResponse = DataViewPaginatedResponse<ActivityLogR
@MainActor
final class ActivityLogsViewModel: ObservableObject {
let blog: Blog
let isBackupMode: Bool

@Published var searchText = ""
@Published var parameters = GetActivityLogsParameters() {
Expand All @@ -27,8 +28,9 @@ final class ActivityLogsViewModel: ObservableObject {
blog.isHostedAtWPcom && !blog.hasPaidPlan
}

init(blog: Blog) {
init(blog: Blog, isBackupMode: Bool = false) {
self.blog = blog
self.isBackupMode = isBackupMode
}

func onAppear() {
Expand Down Expand Up @@ -83,19 +85,22 @@ final class ActivityLogsViewModel: ObservableObject {
}

private func makeResponse(searchText: String?, parameters: GetActivityLogsParameters) async throws -> ActivityLogsPaginatedResponse {
try await ActivityLogsPaginatedResponse { [blog] offset in
try await ActivityLogsPaginatedResponse { [blog, isBackupMode] offset in
guard let siteID = blog.dotComID?.intValue,
let api = blog.wordPressComRestApi else {
throw NSError(domain: "ActivityLogs", code: 0, userInfo: [NSLocalizedDescriptionKey: SharedStrings.Error.generic])
}
let service = ActivityServiceRemote(wordPressComRestApi: api)
let offset = offset ?? 0
let pageSize = 32

let (activities, hasMore) = try await service.getActivities(
siteID: siteID,
offset: offset,
pageSize: 32,
pageSize: pageSize,
searchText: searchText,
parameters: parameters
parameters: parameters,
rewindable: isBackupMode ? true : nil
)
let viewModels = await makeViewModels(for: activities)
return ActivityLogsPaginatedResponse.Page(
Expand Down Expand Up @@ -142,7 +147,7 @@ struct GetActivityLogsParameters: Hashable {
}

private extension ActivityServiceRemote {
func getActivities(siteID: Int, offset: Int, pageSize: Int, searchText: String? = nil, parameters: GetActivityLogsParameters = .init()) async throws -> ([Activity], hasMore: Bool) {
func getActivities(siteID: Int, offset: Int, pageSize: Int, searchText: String? = nil, parameters: GetActivityLogsParameters = .init(), rewindable: Bool? = nil) async throws -> ([Activity], hasMore: Bool) {
return try await withCheckedThrowingContinuation { continuation in
getActivityForSite(
siteID,
Expand All @@ -151,6 +156,7 @@ private extension ActivityServiceRemote {
after: parameters.startDate,
before: parameters.endDate,
group: Array(parameters.activityTypes),
rewindable: rewindable,
searchText: searchText
) { activities, hasMore in
continuation.resume(returning: (activities, hasMore))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,21 @@ extension BlogDetailsViewController {
}

@objc public func showBackup() {
guard let backupListVC = BackupListViewController.withJPBannerForBlog(blog) else {
return wpAssertionFailure("failed to instantiate")
let controller: UIViewController

if FeatureFlag.dataViews.enabled {
controller = ActivityLogsViewController(blog: blog, isBackupMode: true)
controller.navigationItem.largeTitleDisplayMode = .never
} else {
guard let backupListVC = BackupListViewController.withJPBannerForBlog(blog) else {
return wpAssertionFailure("failed to instantiate")
}
controller = backupListVC
}
presentationDelegate?.presentBlogDetailsViewController(backupListVC)

presentationDelegate?.presentBlogDetailsViewController(controller)

WPAnalytics.track(.backupListOpened)
}

@objc public func showThemes() {
Expand Down