Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final changes for Room Moderation #2576

Merged
merged 5 commits into from
Mar 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ElementX/Sources/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ 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
}

enum RoomChangePermissionsScreenViewAction {
/// Save the permissions.
case save
/// Discard any changes and hide the screen.
case cancel
}

extension RoomChangePermissionsScreenViewState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class RoomChangePermissionsScreenViewModel: RoomChangePermissionsScreenViewModel
switch viewAction {
case .save:
Task { await save() }
case .cancel:
confirmDiscardChanges()
}
}

Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct RoomChangePermissionsScreen: View {
.compoundList()
.navigationTitle(context.viewState.title)
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(context.viewState.hasChanges)
.toolbar { toolbar }
.alert(item: $context.alertInfo)
}
Expand All @@ -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)
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class RoomChangeRolesScreenViewModel: RoomChangeRolesScreenViewModelType, RoomCh
} else {
Task { await save() }
}
case .cancel:
confirmDiscardChanges()
}
}

Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) { },
Expand Down
4 changes: 2 additions & 2 deletions IntegrationTests/Sources/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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))
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions UITests/Sources/AuthenticationFlowCoordinatorUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions UITests/Sources/AuthenticationStartScreenUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading