Skip to content

Commit e174bd2

Browse files
committed
pm-13428 Fix PR comments
1 parent f9044cc commit e174bd2

File tree

4 files changed

+5
-15
lines changed

4 files changed

+5
-15
lines changed

BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditItemProcessor.swift

-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ final class AddEditItemProcessor: StateProcessor<// swiftlint:disable:this type_
287287

288288
state.isPersonalOwnershipDisabled = isPersonalOwnershipDisabled
289289
state.ownershipOptions = ownershipOptions
290-
state.hasOrganizations = state.ownershipOptions.contains { !$0.isPersonal }
291290
if isPersonalOwnershipDisabled, state.organizationId == nil {
292291
// Only set the owner if personal ownership is disabled and there isn't already an
293292
// organization owner set. This prevents overwriting a preset owner when adding a

BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditItemState.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protocol AddEditItemState: Sendable {
4646
var guidedTourViewState: GuidedTourViewState { get set }
4747

4848
/// Whether the user belongs to any organization.
49-
var hasOrganizations: Bool { get set }
49+
var hasOrganizations: Bool { get }
5050

5151
/// The state for a identity type item.
5252
var identityState: IdentityItemState { get set }

BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditItemViewTests.swift

-4
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ class AddEditItemViewTests: BitwardenTestCase { // swiftlint:disable:this type_b
228228
CipherOwner.personal(email: "user@bitwarden.com"),
229229
organizationOwner,
230230
]
231-
processor.state.hasOrganizations = true
232231
let menu = try subject.inspect().find(bitwardenMenuField: Localizations.owner)
233232
try menu.select(newValue: organizationOwner)
234233
XCTAssertEqual(processor.dispatchedActions.last, .ownerChanged(organizationOwner))
@@ -682,7 +681,6 @@ class AddEditItemViewTests: BitwardenTestCase { // swiftlint:disable:this type_b
682681
processor.state.ownershipOptions.append(.organization(id: "1", name: "Organization"))
683682
processor.state.owner = .organization(id: "1", name: "Organization")
684683
processor.state.collectionIds = ["2"]
685-
processor.state.hasOrganizations = true
686684

687685
assertSnapshot(of: subject.navStackWrapped, as: .tallPortrait)
688686
}
@@ -691,7 +689,6 @@ class AddEditItemViewTests: BitwardenTestCase { // swiftlint:disable:this type_b
691689
func test_snapshot_add_login_collectionsNone() {
692690
processor.state.ownershipOptions.append(.organization(id: "1", name: "Organization"))
693691
processor.state.owner = .organization(id: "1", name: "Organization")
694-
processor.state.hasOrganizations = true
695692

696693
assertSnapshot(of: subject.navStackWrapped, as: .tallPortrait)
697694
}
@@ -762,7 +759,6 @@ class AddEditItemViewTests: BitwardenTestCase { // swiftlint:disable:this type_b
762759
func test_snapshot_add_personalOwnershipPolicy() {
763760
processor.state.ownershipOptions.append(.organization(id: "1", name: "Organization"))
764761
processor.state.owner = .organization(id: "1", name: "Organization")
765-
processor.state.hasOrganizations = true
766762
processor.state.isPersonalOwnershipDisabled = true
767763
processor.state.allUserCollections = [
768764
.fixture(id: "1", name: "Default collection", organizationId: "1"),

BitwardenShared/UI/Vault/VaultItem/CipherItemState.swift

+4-9
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ struct CipherItemState: Equatable { // swiftlint:disable:this type_body_length
6767
]
6868
)
6969

70-
/// Whether the user has organizations.
71-
var hasOrganizations: Bool
72-
7370
/// The base url used to fetch icons.
7471
var iconBaseURL: URL?
7572

@@ -140,6 +137,10 @@ struct CipherItemState: Equatable { // swiftlint:disable:this type_body_length
140137
self
141138
}
142139

140+
var hasOrganizations: Bool {
141+
cipher.organizationId != nil || ownershipOptions.contains { !$0.isPersonal }
142+
}
143+
143144
/// Whether or not this item can be assigned to collections.
144145
var canAssignToCollection: Bool {
145146
guard !collectionIds.isEmpty else { return true }
@@ -271,7 +272,6 @@ struct CipherItemState: Equatable { // swiftlint:disable:this type_body_length
271272
configuration: Configuration,
272273
customFields: [CustomFieldState],
273274
folderId: String?,
274-
hasOrganizations: Bool,
275275
iconBaseURL: URL?,
276276
identityState: IdentityItemState,
277277
isFavoriteOn: Bool,
@@ -292,7 +292,6 @@ struct CipherItemState: Equatable { // swiftlint:disable:this type_body_length
292292
allUserCollections = []
293293
customFieldsState = AddEditCustomFieldsState(cipherType: type, customFields: customFields)
294294
self.folderId = folderId
295-
self.hasOrganizations = hasOrganizations
296295
self.iconBaseURL = iconBaseURL
297296
self.identityState = identityState
298297
self.isFavoriteOn = isFavoriteOn
@@ -317,7 +316,6 @@ struct CipherItemState: Equatable { // swiftlint:disable:this type_body_length
317316
collectionIds: [String] = [],
318317
customFields: [CustomFieldState] = [],
319318
folderId: String? = nil,
320-
hasOrganizations: Bool = false,
321319
hasPremium: Bool,
322320
name: String? = nil,
323321
organizationId: String? = nil,
@@ -333,7 +331,6 @@ struct CipherItemState: Equatable { // swiftlint:disable:this type_body_length
333331
configuration: .add,
334332
customFields: customFields,
335333
folderId: folderId,
336-
hasOrganizations: hasOrganizations,
337334
iconBaseURL: nil,
338335
identityState: .init(),
339336
isFavoriteOn: false,
@@ -364,7 +361,6 @@ struct CipherItemState: Equatable { // swiftlint:disable:this type_body_length
364361
configuration: .add,
365362
customFields: cipherView.customFields,
366363
folderId: cipherView.folderId,
367-
hasOrganizations: cipherView.organizationId != nil,
368364
iconBaseURL: nil,
369365
identityState: cipherView.identityItemState(),
370366
isFavoriteOn: cipherView.favorite,
@@ -396,7 +392,6 @@ struct CipherItemState: Equatable { // swiftlint:disable:this type_body_length
396392
configuration: .existing(cipherView: cipherView),
397393
customFields: cipherView.customFields,
398394
folderId: cipherView.folderId,
399-
hasOrganizations: cipherView.organizationId != nil,
400395
iconBaseURL: iconBaseURL,
401396
identityState: cipherView.identityItemState(),
402397
isFavoriteOn: cipherView.favorite,

0 commit comments

Comments
 (0)