Sign out of all other sessions

This commit is contained in:
paleksandrs
2022-10-31 17:21:53 +02:00
parent 1fa2ab1604
commit 2025a46a3b
4 changed files with 35 additions and 13 deletions
@@ -29,10 +29,10 @@ class UserSessionsOverviewUITests: MockScreenTestCase {
func testCurrentSessionVerified() {
app.goToScreenWithIdentifier(MockUserSessionsOverviewScreenState.currentSessionVerified.title)
XCTAssertFalse(app.buttons["userSessionCardVerifyButton"].exists)
XCTAssertTrue(app.staticTexts["userSessionCardViewDetails"].exists)
app.buttons["MoreOptionsMenu"].tap()
XCTAssertTrue(app.buttons["Sign out of all other sessions"].exists)
verifyLinkDeviceButtonStatus(true)
}
@@ -59,7 +59,8 @@ class UserSessionsOverviewUITests: MockScreenTestCase {
XCTAssertFalse(app.staticTexts["userSessionsOverviewSecurityRecommendationsSection"].exists)
XCTAssertFalse(app.staticTexts["userSessionsOverviewOtherSection"].exists)
app.buttons["MoreOptionsMenu"].tap()
XCTAssertFalse(app.buttons["Sign out of all other sessions"].exists)
verifyLinkDeviceButtonStatus(false)
}
@@ -127,16 +127,18 @@ struct UserSessionsOverview: View {
Button { viewModel.send(viewAction: .renameCurrentSession) } label: {
Label(VectorL10n.manageSessionRename, systemImage: "pencil")
}
if #available(iOS 15, *) {
Button(role: .destructive) { viewModel.send(viewAction: .logoutOfCurrentSession) } label: {
Label(VectorL10n.signOut, systemImage: "rectangle.portrait.and.arrow.right.fill")
}
} else {
Button { viewModel.send(viewAction: .logoutOfCurrentSession) } label: {
Label(VectorL10n.signOut, systemImage: "rectangle.righthalf.inset.fill.arrow.right")
}
}
}
if #available(iOS 15, *) {
Button(role: .destructive) { viewModel.send(viewAction: .logoutOfCurrentSession) } label: {
Label(VectorL10n.signOut, systemImage: "rectangle.portrait.and.arrow.right.fill")
}
} else {
Button { viewModel.send(viewAction: .logoutOfCurrentSession) } label: {
Label(VectorL10n.signOut, systemImage: "rectangle.righthalf.inset.fill.arrow.right")
}
if viewModel.viewState.otherSessionsViewData.count > 0 {
signOutOtherSessionsButton
}
} label: {
Image(systemName: "ellipsis")
@@ -144,6 +146,7 @@ struct UserSessionsOverview: View {
.padding(.horizontal, 8)
.padding(.vertical, 12)
}
.accessibilityIdentifier("MoreOptionsMenu")
.offset(x: 8) // Re-align the symbol after applying padding.
}
@@ -233,6 +236,20 @@ struct UserSessionsOverview: View {
}
}
}
@ViewBuilder
private var signOutOtherSessionsButton: some View {
let label = Label(VectorL10n.manageSessionSignOutOtherSessions, systemImage: "rectangle.portrait.and.arrow.forward.fill")
if #available(iOS 15, *) {
Button(role: .destructive) { viewModel.send(viewAction: .logoutOtherSessions) } label: {
label
}
} else {
Button { viewModel.send(viewAction: .logoutOtherSessions) } label: {
label
}
}
}
}
// MARK: - Previews