mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-13 00:51:45 +01:00
[PM-5189] Merging in changes for requestIdleCallback polyfill
This commit is contained in:
commit
a850f0127b
@ -18,6 +18,7 @@ import {
|
||||
sendExtensionMessage,
|
||||
getAttributeBoolean,
|
||||
getPropertyOrAttribute,
|
||||
requestIdleCallbackPolyfill,
|
||||
} from "../utils";
|
||||
|
||||
import { AutofillOverlayContentService } from "./abstractions/autofill-overlay-content.service";
|
||||
@ -1024,7 +1025,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
||||
}
|
||||
|
||||
if (!this.mutationsQueue.length) {
|
||||
globalThis.requestIdleCallback(this.processMutations, { timeout: 500 });
|
||||
requestIdleCallbackPolyfill(this.processMutations, { timeout: 500 });
|
||||
}
|
||||
this.mutationsQueue.push(mutations);
|
||||
};
|
||||
@ -1161,7 +1162,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
||||
continue;
|
||||
}
|
||||
|
||||
globalThis.requestIdleCallback(
|
||||
requestIdleCallbackPolyfill(
|
||||
// We are setting this item to a -1 index because we do not know its position in the DOM.
|
||||
// This value should be updated with the next call to collect page details.
|
||||
() => void this.buildAutofillFieldItem(node as ElementWithOpId<FormFieldElement>, -1),
|
||||
|
@ -15,6 +15,20 @@ export function generateRandomChars(length: number): string {
|
||||
return randomChars.join("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Polyfills the requestIdleCallback API with a setTimeout fallback.
|
||||
*
|
||||
* @param callback - The callback function to run when the browser is idle.
|
||||
* @param options - The options to pass to the requestIdleCallback function.
|
||||
*/
|
||||
export function requestIdleCallbackPolyfill(callback: () => void, options?: Record<string, any>) {
|
||||
if ("requestIdleCallback" in globalThis) {
|
||||
return globalThis.requestIdleCallback(() => callback(), options);
|
||||
}
|
||||
|
||||
return globalThis.setTimeout(() => callback(), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a random string of characters that formatted as a custom element name.
|
||||
*/
|
||||
|
@ -2,10 +2,10 @@ import { Injectable } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { FormBuilder } from "@angular/forms";
|
||||
import {
|
||||
Observable,
|
||||
combineLatest,
|
||||
distinctUntilChanged,
|
||||
map,
|
||||
Observable,
|
||||
startWith,
|
||||
switchMap,
|
||||
tap,
|
||||
@ -104,6 +104,11 @@ export class VaultPopupListFiltersService {
|
||||
map(
|
||||
(filters) => (ciphers: CipherView[]) =>
|
||||
ciphers.filter((cipher) => {
|
||||
// Vault popup lists never shows deleted ciphers
|
||||
if (cipher.isDeleted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (filters.cipherType !== null && cipher.type !== filters.cipherType) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@bitwarden/web-vault",
|
||||
"version": "2024.6.0",
|
||||
"version": "2024.6.1",
|
||||
"scripts": {
|
||||
"build:oss": "webpack",
|
||||
"build:bit": "webpack -c ../../bitwarden_license/bit-web/webpack.config.js",
|
||||
|
@ -69,9 +69,9 @@ export class VaultCollectionRowComponent {
|
||||
if (this.collection instanceof CollectionAdminView) {
|
||||
// Only show AddAccess if unmanaged and allowAdminAccessToAllCollectionItems is disabled
|
||||
return (
|
||||
!this.organization.allowAdminAccessToAllCollectionItems &&
|
||||
!this.organization?.allowAdminAccessToAllCollectionItems &&
|
||||
this.collection.unmanaged &&
|
||||
this.organization.canEditUnmanagedCollections()
|
||||
this.organization?.canEditUnmanagedCollections()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@
|
||||
</ng-container>
|
||||
|
||||
<bit-search
|
||||
*ngIf="organization?.isProviderUser"
|
||||
*ngIf="restrictProviderAccessFlag && organization?.isProviderUser && !organization?.isMember"
|
||||
class="tw-grow"
|
||||
[ngModel]="searchText"
|
||||
(ngModelChange)="onSearchTextChanged($event)"
|
||||
|
@ -68,7 +68,7 @@ export class VaultHeaderComponent implements OnInit {
|
||||
protected organizations$ = this.organizationService.organizations$;
|
||||
|
||||
protected flexibleCollectionsV1Enabled = false;
|
||||
private restrictProviderAccessFlag = false;
|
||||
protected restrictProviderAccessFlag = false;
|
||||
|
||||
constructor(
|
||||
private organizationService: OrganizationService,
|
||||
@ -220,7 +220,11 @@ export class VaultHeaderComponent implements OnInit {
|
||||
}
|
||||
|
||||
get canCreateCipher(): boolean {
|
||||
if (this.organization?.isProviderUser && this.restrictProviderAccessFlag) {
|
||||
if (
|
||||
this.organization?.isProviderUser &&
|
||||
this.restrictProviderAccessFlag &&
|
||||
!this.organization?.isMember
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -166,7 +166,11 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
protected get hideVaultFilters(): boolean {
|
||||
return this.restrictProviderAccessEnabled && this.organization?.isProviderUser;
|
||||
return (
|
||||
this.restrictProviderAccessEnabled &&
|
||||
this.organization?.isProviderUser &&
|
||||
!this.organization?.isMember
|
||||
);
|
||||
}
|
||||
|
||||
private searchText$ = new Subject<string>();
|
||||
@ -352,6 +356,16 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
let ciphers;
|
||||
|
||||
// Restricted providers (who are not members) do not have access org cipher endpoint below
|
||||
// Return early to avoid 404 response
|
||||
if (
|
||||
this.restrictProviderAccessEnabled &&
|
||||
!organization.isMember &&
|
||||
organization.isProviderUser
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (this.flexibleCollectionsV1Enabled) {
|
||||
// Flexible collections V1 logic.
|
||||
// If the user can edit all ciphers for the organization then fetch them ALL.
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -251,7 +251,7 @@
|
||||
},
|
||||
"apps/web": {
|
||||
"name": "@bitwarden/web-vault",
|
||||
"version": "2024.6.0"
|
||||
"version": "2024.6.1"
|
||||
},
|
||||
"libs/admin-console": {
|
||||
"name": "@bitwarden/admin-console",
|
||||
|
Loading…
Reference in New Issue
Block a user