Final changes for Room Moderation (#2576)
* Add confirmation that the user would like to discard unsaved changes. * Update string on permissions screen. * Fix UI tests and update snapshots. * Fix integration tests. * Run periphery for Moderation feature.
This commit is contained in:
@@ -499,7 +499,7 @@
|
||||
"screen_room_attachment_text_formatting" = "Text Formatting";
|
||||
"screen_room_change_permissions_administrators" = "Admins only";
|
||||
"screen_room_change_permissions_ban_people" = "Ban people";
|
||||
"screen_room_change_permissions_delete_messages" = "Delete messages";
|
||||
"screen_room_change_permissions_delete_messages" = "Remove messages";
|
||||
"screen_room_change_permissions_invite_people" = "Invite people";
|
||||
"screen_room_change_permissions_moderators" = "Admins and moderators";
|
||||
"screen_room_change_permissions_remove_people" = "Remove people";
|
||||
|
||||
@@ -50,6 +50,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private let analytics: AnalyticsService
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
// periphery:ignore - used to avoid deallocation
|
||||
private var rolesAndPermissionsFlowCoordinator: RoomRolesAndPermissionsFlowCoordinator?
|
||||
|
||||
private let stateMachine: StateMachine<State, Event> = .init(state: .initial)
|
||||
|
||||
@@ -1215,7 +1215,7 @@ internal enum L10n {
|
||||
internal static var screenRoomChangePermissionsAdministrators: String { return L10n.tr("Localizable", "screen_room_change_permissions_administrators") }
|
||||
/// Ban people
|
||||
internal static var screenRoomChangePermissionsBanPeople: String { return L10n.tr("Localizable", "screen_room_change_permissions_ban_people") }
|
||||
/// Delete messages
|
||||
/// Remove messages
|
||||
internal static var screenRoomChangePermissionsDeleteMessages: String { return L10n.tr("Localizable", "screen_room_change_permissions_delete_messages") }
|
||||
/// Everyone
|
||||
internal static var screenRoomChangePermissionsEveryone: String { return L10n.tr("Localizable", "screen_room_change_permissions_everyone") }
|
||||
|
||||
@@ -43,6 +43,8 @@ struct RoomChangePermissionsScreenViewStateBindings: BindableState {
|
||||
}
|
||||
|
||||
enum RoomChangePermissionsScreenAlertType {
|
||||
/// A confirmation that the user would like to discard any unsaved changes.
|
||||
case discardChanges
|
||||
/// The generic error message.
|
||||
case generic
|
||||
}
|
||||
@@ -50,6 +52,8 @@ enum RoomChangePermissionsScreenAlertType {
|
||||
enum RoomChangePermissionsScreenViewAction {
|
||||
/// Save the permissions.
|
||||
case save
|
||||
/// Discard any changes and hide the screen.
|
||||
case cancel
|
||||
}
|
||||
|
||||
extension RoomChangePermissionsScreenViewState {
|
||||
|
||||
@@ -49,6 +49,8 @@ class RoomChangePermissionsScreenViewModel: RoomChangePermissionsScreenViewModel
|
||||
switch viewAction {
|
||||
case .save:
|
||||
Task { await save() }
|
||||
case .cancel:
|
||||
confirmDiscardChanges()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +85,14 @@ class RoomChangePermissionsScreenViewModel: RoomChangePermissionsScreenViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private func confirmDiscardChanges() {
|
||||
state.bindings.alertInfo = AlertInfo(id: .discardChanges,
|
||||
title: L10n.screenRoomChangeRoleUnsavedChangesTitle,
|
||||
message: L10n.screenRoomChangeRoleUnsavedChangesDescription,
|
||||
primaryButton: .init(title: L10n.actionSave) { Task { await self.save() } },
|
||||
secondaryButton: .init(title: L10n.actionDiscard, role: .cancel) { self.actionsSubject.send(.complete) })
|
||||
}
|
||||
|
||||
// MARK: Loading indicator
|
||||
|
||||
private static let indicatorID = "SavingRoomPermissions"
|
||||
|
||||
@@ -35,6 +35,7 @@ struct RoomChangePermissionsScreen: View {
|
||||
.compoundList()
|
||||
.navigationTitle(context.viewState.title)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationBarBackButtonHidden(context.viewState.hasChanges)
|
||||
.toolbar { toolbar }
|
||||
.alert(item: $context.alertInfo)
|
||||
}
|
||||
@@ -47,6 +48,14 @@ struct RoomChangePermissionsScreen: View {
|
||||
}
|
||||
.disabled(!context.viewState.hasChanges)
|
||||
}
|
||||
|
||||
if context.viewState.hasChanges {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button(L10n.actionCancel) {
|
||||
context.send(viewAction: .cancel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,8 @@ struct RoomChangeRolesScreenViewStateBindings {
|
||||
enum RoomChangeRolesScreenAlertType {
|
||||
/// A warning that a particular promotion can't be undone.
|
||||
case promotionWarning
|
||||
/// A confirmation that the user would like to discard any unsaved changes.
|
||||
case discardChanges
|
||||
/// The generic error message.
|
||||
case error
|
||||
}
|
||||
@@ -100,4 +102,6 @@ enum RoomChangeRolesScreenViewAction {
|
||||
case demoteMember(RoomMemberDetails)
|
||||
/// Save all the changes that the user has made.
|
||||
case save
|
||||
/// Discard any changes and hide the screen.
|
||||
case cancel
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ class RoomChangeRolesScreenViewModel: RoomChangeRolesScreenViewModelType, RoomCh
|
||||
} else {
|
||||
Task { await save() }
|
||||
}
|
||||
case .cancel:
|
||||
confirmDiscardChanges()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +150,14 @@ class RoomChangeRolesScreenViewModel: RoomChangeRolesScreenViewModelType, RoomCh
|
||||
}
|
||||
}
|
||||
|
||||
private func confirmDiscardChanges() {
|
||||
state.bindings.alertInfo = AlertInfo(id: .discardChanges,
|
||||
title: L10n.screenRoomChangeRoleUnsavedChangesTitle,
|
||||
message: L10n.screenRoomChangeRoleUnsavedChangesDescription,
|
||||
primaryButton: .init(title: L10n.actionSave) { Task { await self.save() } },
|
||||
secondaryButton: .init(title: L10n.actionDiscard, role: .cancel) { self.actionsSubject.send(.complete) })
|
||||
}
|
||||
|
||||
// MARK: Loading indicator
|
||||
|
||||
private static let indicatorID = "SavingRoomRoles"
|
||||
|
||||
@@ -61,15 +61,6 @@ struct RoomChangeRolesScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var noResultsContent: some View {
|
||||
Text(L10n.commonNoResults)
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.frame(maxWidth: .infinity)
|
||||
.listRowBackground(Color.clear)
|
||||
.accessibilityIdentifier(A11yIdentifiers.startChatScreen.searchNoResults)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var membersSection: some View {
|
||||
if !context.viewState.visibleMembers.isEmpty {
|
||||
@@ -123,6 +114,14 @@ struct RoomChangeRolesScreen: View {
|
||||
}
|
||||
.disabled(!context.viewState.hasChanges)
|
||||
}
|
||||
|
||||
if context.viewState.hasChanges {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button(L10n.actionCancel) {
|
||||
context.send(viewAction: .cancel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class RoomRolesAndPermissionsScreenViewModel: RoomRolesAndPermissionsScreenViewM
|
||||
case .editRoles(let role):
|
||||
actionsSubject.send(.editRoles(role))
|
||||
case .editOwnUserRole:
|
||||
state.bindings.alertInfo = AlertInfo(id: .resetConfirmation,
|
||||
state.bindings.alertInfo = AlertInfo(id: .editOwnRole,
|
||||
title: L10n.screenRoomRolesAndPermissionsChangeMyRole,
|
||||
message: L10n.screenRoomChangeRoleConfirmDemoteSelfDescription,
|
||||
primaryButton: .init(title: L10n.actionCancel, role: .cancel) { },
|
||||
|
||||
@@ -18,7 +18,7 @@ import XCTest
|
||||
|
||||
extension XCUIApplication {
|
||||
func login(currentTestCase: XCTestCase) {
|
||||
let getStartedButton = buttons[A11yIdentifiers.onboardingScreen.signIn]
|
||||
let getStartedButton = buttons[A11yIdentifiers.authenticationStartScreen.signIn]
|
||||
|
||||
XCTAssertTrue(getStartedButton.waitForExistence(timeout: 10.0))
|
||||
getStartedButton.tap()
|
||||
@@ -128,7 +128,7 @@ extension XCUIApplication {
|
||||
alertLogoutButton.tap()
|
||||
|
||||
// Check that we're back on the login screen
|
||||
let getStartedButton = buttons[A11yIdentifiers.onboardingScreen.signIn]
|
||||
let getStartedButton = buttons[A11yIdentifiers.authenticationStartScreen.signIn]
|
||||
XCTAssertTrue(getStartedButton.waitForExistence(timeout: 10.0))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3a65b0ae7ecaf2479ca6615154b59c613bb7c0a0c457c0660a285285732b8f6d
|
||||
size 157299
|
||||
oid sha256:88fd16ff426bf0a0d611aac81f9f7a7b0e88051ca992a0ce0d6a268e53cdd10d
|
||||
size 158559
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e6f9ff85795b3adf88a5aa68a1c3fc38f38e5520c7996f105d4616bddcf0799d
|
||||
size 213902
|
||||
oid sha256:b8503be3cd71675cc2b9014ca2aed33fac140fdeb14b060b86847e9ca7ed8b15
|
||||
size 215884
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:77a8e52fa0472c7526891562f29441e932ca9eb12a2a2929875c4cdeb9ccddac
|
||||
size 105619
|
||||
oid sha256:e30b22313140bc11e9bb17ce3c973f2f8a5056a55427efe6ac05fd2280a2e5b0
|
||||
size 106733
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5014e5e525409afbafeafd3e5a0cc9d87739a4124167a21f288bcd8a3d6d7673
|
||||
size 154115
|
||||
oid sha256:67338270442eb5c113765956d6c8522ab2ee7a1010edc9c9261061294090d060
|
||||
size 155977
|
||||
|
||||
@@ -23,7 +23,7 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase {
|
||||
let app = Application.launch(.authenticationFlow)
|
||||
|
||||
// Splash Screen: Tap get started button
|
||||
app.buttons[A11yIdentifiers.onboardingScreen.signIn].tap()
|
||||
app.buttons[A11yIdentifiers.authenticationStartScreen.signIn].tap()
|
||||
|
||||
// Server Confirmation: Tap continue button
|
||||
app.buttons[A11yIdentifiers.serverConfirmationScreen.continue].tap()
|
||||
@@ -45,7 +45,7 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase {
|
||||
let app = Application.launch(.authenticationFlow)
|
||||
|
||||
// Splash Screen: Tap get started button
|
||||
app.buttons[A11yIdentifiers.onboardingScreen.signIn].tap()
|
||||
app.buttons[A11yIdentifiers.authenticationStartScreen.signIn].tap()
|
||||
|
||||
// Server Confirmation: Tap continue button
|
||||
app.buttons[A11yIdentifiers.serverConfirmationScreen.continue].tap()
|
||||
@@ -69,7 +69,7 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase {
|
||||
let app = Application.launch(.authenticationFlow)
|
||||
|
||||
// Splash Screen: Tap get started button
|
||||
app.buttons[A11yIdentifiers.onboardingScreen.signIn].tap()
|
||||
app.buttons[A11yIdentifiers.authenticationStartScreen.signIn].tap()
|
||||
|
||||
// Server Confirmation: Tap change server button
|
||||
app.buttons[A11yIdentifiers.serverConfirmationScreen.changeServer].tap()
|
||||
|
||||
@@ -19,7 +19,7 @@ import XCTest
|
||||
@MainActor
|
||||
class AuthenticationStartScreenUITests: XCTestCase {
|
||||
func testInitialStateComponents() async throws {
|
||||
let app = Application.launch(.onboarding)
|
||||
try await app.assertScreenshot(.onboarding)
|
||||
let app = Application.launch(.authenticationStartScreen)
|
||||
try await app.assertScreenshot(.authenticationStartScreen)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:635a5752e1bf1f0ee91688b59e853b1537db70c7cf67eda9dd5c6d6e1c29bd6e
|
||||
size 1273769
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b0df6a86517b6c8c5e45d7a77ad323c7730178fdc6523f52068748b5d81eca3b
|
||||
size 1276372
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6c25af572834b339745080f03d4ce2318a30f5f79ad37144b522aaa2b32d6833
|
||||
size 95336
|
||||
oid sha256:9c28498ab66df551d50e211b046ec39767c650b29825c026f83f3b3bd234b217
|
||||
size 96303
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d20dfc70cf78d1ad362a9e3081fd1011183af14aaf4644b5547dbf801f142eb1
|
||||
size 999538
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:279e06e9fbfb8670fecd2ad88f6486402067e5eb1788a5db2f7420a88adaf2d4
|
||||
size 1000272
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:be5ada770c951e7483f2b1c101774e7e2077cc844eaf2013f2113ee3f3cab558
|
||||
size 109500
|
||||
oid sha256:d2eb0ec552742a8d22d3808c7479b32d36a224a32f22c67aaf0d30e225cdbd4b
|
||||
size 112700
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f3cc3f4ecd03b5a651792c3fdea276b0e984edc6eec2689cece5f3e2a519a4c4
|
||||
size 1296859
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d2de5fced9093eeef584c2c1ee3b2296e9201cb0c8132672bce778389bbae036
|
||||
size 1298519
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:37640f16e3b52c138bffd571ef0567d673384131cc9c2a7a3fa703662b9dc58e
|
||||
size 99735
|
||||
oid sha256:b3fccd3407b2ceeaa781d21c958448fa08e5dd327528508eee01a3280fec0236
|
||||
size 101238
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a7d223d25fce1e943f24df2d1ad595c63a0b3c3ae2a71b9dfb1be0a6ddef0e5c
|
||||
size 1026703
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b829d6b34f1bb1600e5ccefbf4f7c04fba4b1fad73671cf648ab72ae49e012de
|
||||
size 1025995
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0ddce2faa0548cb422fa3204725e96fbc1414f065e1b444fcf8cdac1e6df02c2
|
||||
size 124452
|
||||
oid sha256:546d0d7b9d6779d36fdf0d6c1eab3fa3e846854b9439a7f3d88c00ede2b8d7d3
|
||||
size 125838
|
||||
|
||||
Reference in New Issue
Block a user