|
|
|
|
@ -5,9 +5,14 @@ import { CollectionView } from "@bitwarden/admin-console/common";
@@ -5,9 +5,14 @@ import { CollectionView } from "@bitwarden/admin-console/common";
|
|
|
|
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; |
|
|
|
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; |
|
|
|
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; |
|
|
|
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; |
|
|
|
|
import { CipherType } from "@bitwarden/common/vault/enums"; |
|
|
|
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; |
|
|
|
|
|
|
|
|
|
import { |
|
|
|
|
convertToPermission, |
|
|
|
|
getPermissionList, |
|
|
|
|
} from "./../../../admin-console/organizations/shared/components/access-selector/access-selector.models"; |
|
|
|
|
import { VaultItemEvent } from "./vault-item-event"; |
|
|
|
|
import { RowHeightClass } from "./vault-items.component"; |
|
|
|
|
|
|
|
|
|
@ -43,9 +48,20 @@ export class VaultCipherRowComponent implements OnInit {
@@ -43,9 +48,20 @@ export class VaultCipherRowComponent implements OnInit {
|
|
|
|
|
@Output() checkedToggled = new EventEmitter<void>(); |
|
|
|
|
|
|
|
|
|
protected CipherType = CipherType; |
|
|
|
|
private permissionList = getPermissionList(); |
|
|
|
|
private permissionPriority = [ |
|
|
|
|
"canManage", |
|
|
|
|
"canEdit", |
|
|
|
|
"canEditExceptPass", |
|
|
|
|
"canView", |
|
|
|
|
"canViewExceptPass", |
|
|
|
|
]; |
|
|
|
|
protected organization?: Organization; |
|
|
|
|
|
|
|
|
|
constructor(private configService: ConfigService) {} |
|
|
|
|
constructor( |
|
|
|
|
private configService: ConfigService, |
|
|
|
|
private i18nService: I18nService, |
|
|
|
|
) {} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Lifecycle hook for component initialization. |
|
|
|
|
@ -91,6 +107,40 @@ export class VaultCipherRowComponent implements OnInit {
@@ -91,6 +107,40 @@ export class VaultCipherRowComponent implements OnInit {
|
|
|
|
|
return this.cipher.type === this.CipherType.Login && !this.cipher.isDeleted; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected get permissionText() { |
|
|
|
|
if (!this.cipher.organizationId || this.cipher.collectionIds.length === 0) { |
|
|
|
|
return this.i18nService.t("canManage"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const filteredCollections = this.collections.filter((collection) => { |
|
|
|
|
if (collection.assigned) { |
|
|
|
|
return this.cipher.collectionIds.find((id) => { |
|
|
|
|
if (collection.id === id) { |
|
|
|
|
return collection; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (filteredCollections?.length === 1) { |
|
|
|
|
return this.i18nService.t( |
|
|
|
|
this.permissionList.find((p) => p.perm === convertToPermission(filteredCollections[0])) |
|
|
|
|
?.labelId, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (filteredCollections?.length > 1) { |
|
|
|
|
const labels = filteredCollections.map((collection) => { |
|
|
|
|
return this.permissionList.find((p) => p.perm === convertToPermission(collection))?.labelId; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const highestPerm = this.permissionPriority.find((perm) => labels.includes(perm)); |
|
|
|
|
return this.i18nService.t(highestPerm); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return this.i18nService.t("noAccess"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected get showCopyPassword(): boolean { |
|
|
|
|
return this.isNotDeletedLoginCipher && this.cipher.viewPassword; |
|
|
|
|
} |
|
|
|
|
|