mirror of
https://github.com/bitwarden/browser
synced 2025-12-22 11:13:46 +00:00
* Migrate callouts to the CL ones * Add folder/collection selection * Use bitTypography as page header/title * Migrate submit button to CL * Migrate fileSelector and fileContents * Add ability to import into an existing folder/collection Extended import.service and abstraction to receive importTarget on import() Pass selectedImportTarget to importService.import() Wrote unit tests * Added vault selector, folders/collections selection logic and component library to the import * Revert changes to the already migrated CL fileSelector, fileContents and header/title * Fix fileContents input and spacing to submit button * Use id's instead of name for tghe targetSelector * Remove unneeded empty line * Fix import into existing folder/collection Map ciphers with no folder/no collection to the new rootFolder when selected by the user Modified and added unit tests * Added CL to fileSelector and fileInput on vault import * Added reactive forms and new selector logic to import vault * Added new texts on Import Vault * Corrected logic on enable targetSelector * Removing target selector from being required * Fixed imports after messing up a merge conflict * Set No-Folder as default * Show icons (folder/collection) on targetSelector * Add icons to vaultSelector * Set `My Vault` as default of the vaultSelector * Updates labels based on feedback from design * Set `My Vault` as default of the vaultSelector pt2 * Improvements to reactive forms on import.component * Only disabling individual vault import on PersonalOwnership policy * Use import destination instead of import location * Add hint to folder/collection dropdown * Removed required attribute as provided by formGroup * Display no collection option same as no folder * Show error on org import with unassigned items Only admins can have unassigned items (items with no collection) If these are present in a export/backup file, they should still be imported, to not break existing behaviour. This is limited to admins. When a member of an org does not set a root collection (no collection option) and any items are unassigned an error message is shown and the import is aborted. * Removed for-attribute from bit-labels * Removed bitInput from bit-selects * Updates to messages.json after PR feedback * Removed name-attribute from bit-selects * Removed unneeded variables * Removed unneeded line break * Migrate form to use bitSubmit Rename old submit() to performImport() Create submit arrow function calling performImport() (which can be overridden/called by org-import.component) Remove #form and ngNativeValidate Add bitSubmit and bitFormButton directives Remove now unneeded loading variable * Added await to super.performImport() * Move form check into submit * AC-1558 - Enable org import with remove individual vault policy Hide the `My Vault` entry when policy is active Always check if the policy applies and disable the formGroup if no vault-target is selectable * [AC-1549] Import page design updates (#5933) * Display select folder/collection in targetSelector Filter the no-folder entry from the folderViews-observable Add labels for the targetSelector placeholders * Update importTargetHint and remove importTargetOrgHint * Update language on importUnassignedItemsError * Add help icon with link to the import documentation --------- Co-authored-by: Andre Rosado <arosado@bitwarden.com>
99 lines
3.2 KiB
TypeScript
99 lines
3.2 KiB
TypeScript
import { map, Observable } from "rxjs";
|
|
|
|
import { I18nService } from "../../../platform/abstractions/i18n.service";
|
|
import { Utils } from "../../../platform/misc/utils";
|
|
import { OrganizationData } from "../../models/data/organization.data";
|
|
import { Organization } from "../../models/domain/organization";
|
|
|
|
export function canAccessVaultTab(org: Organization): boolean {
|
|
return org.canViewAssignedCollections || org.canViewAllCollections || org.canManageGroups;
|
|
}
|
|
|
|
export function canAccessSettingsTab(org: Organization): boolean {
|
|
return (
|
|
org.isOwner ||
|
|
org.canManagePolicies ||
|
|
org.canManageSso ||
|
|
org.canManageScim ||
|
|
org.canAccessImportExport ||
|
|
org.canManageDeviceApprovals
|
|
);
|
|
}
|
|
|
|
export function canAccessMembersTab(org: Organization): boolean {
|
|
return org.canManageUsers || org.canManageUsersPassword;
|
|
}
|
|
|
|
export function canAccessGroupsTab(org: Organization): boolean {
|
|
return org.canManageGroups;
|
|
}
|
|
|
|
export function canAccessReportingTab(org: Organization): boolean {
|
|
return org.canAccessReports || org.canAccessEventLogs;
|
|
}
|
|
|
|
export function canAccessBillingTab(org: Organization): boolean {
|
|
return org.isOwner;
|
|
}
|
|
|
|
export function canAccessOrgAdmin(org: Organization): boolean {
|
|
return (
|
|
canAccessMembersTab(org) ||
|
|
canAccessGroupsTab(org) ||
|
|
canAccessReportingTab(org) ||
|
|
canAccessBillingTab(org) ||
|
|
canAccessSettingsTab(org) ||
|
|
canAccessVaultTab(org)
|
|
);
|
|
}
|
|
|
|
export function getOrganizationById(id: string) {
|
|
return map<Organization[], Organization | undefined>((orgs) => orgs.find((o) => o.id === id));
|
|
}
|
|
|
|
export function canAccessAdmin(i18nService: I18nService) {
|
|
return map<Organization[], Organization[]>((orgs) =>
|
|
orgs.filter(canAccessOrgAdmin).sort(Utils.getSortFunction(i18nService, "name"))
|
|
);
|
|
}
|
|
|
|
export function canAccessImportExport(i18nService: I18nService) {
|
|
return map<Organization[], Organization[]>((orgs) =>
|
|
orgs.filter((org) => org.canAccessImportExport).sort(Utils.getSortFunction(i18nService, "name"))
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Returns `true` if a user is a member of an organization (rather than only being a ProviderUser)
|
|
* @deprecated Use organizationService.memberOrganizations$ instead
|
|
*/
|
|
export function isMember(org: Organization): boolean {
|
|
return org.isMember;
|
|
}
|
|
|
|
export abstract class OrganizationService {
|
|
organizations$: Observable<Organization[]>;
|
|
|
|
/**
|
|
* Organizations that the user is a member of (excludes organizations that they only have access to via a provider)
|
|
*/
|
|
memberOrganizations$: Observable<Organization[]>;
|
|
|
|
get$: (id: string) => Observable<Organization | undefined>;
|
|
get: (id: string) => Organization;
|
|
getByIdentifier: (identifier: string) => Organization;
|
|
getAll: (userId?: string) => Promise<Organization[]>;
|
|
/**
|
|
* @deprecated For the CLI only
|
|
* @param id id of the organization
|
|
*/
|
|
getFromState: (id: string) => Promise<Organization>;
|
|
canManageSponsorships: () => Promise<boolean>;
|
|
hasOrganizations: () => boolean;
|
|
}
|
|
|
|
export abstract class InternalOrganizationServiceAbstraction extends OrganizationService {
|
|
replace: (organizations: { [id: string]: OrganizationData }) => Promise<void>;
|
|
upsert: (OrganizationData: OrganizationData | OrganizationData[]) => Promise<void>;
|
|
}
|