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,
|
sendExtensionMessage,
|
||||||
getAttributeBoolean,
|
getAttributeBoolean,
|
||||||
getPropertyOrAttribute,
|
getPropertyOrAttribute,
|
||||||
|
requestIdleCallbackPolyfill,
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
|
|
||||||
import { AutofillOverlayContentService } from "./abstractions/autofill-overlay-content.service";
|
import { AutofillOverlayContentService } from "./abstractions/autofill-overlay-content.service";
|
||||||
@ -1024,7 +1025,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.mutationsQueue.length) {
|
if (!this.mutationsQueue.length) {
|
||||||
globalThis.requestIdleCallback(this.processMutations, { timeout: 500 });
|
requestIdleCallbackPolyfill(this.processMutations, { timeout: 500 });
|
||||||
}
|
}
|
||||||
this.mutationsQueue.push(mutations);
|
this.mutationsQueue.push(mutations);
|
||||||
};
|
};
|
||||||
@ -1161,7 +1162,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
globalThis.requestIdleCallback(
|
requestIdleCallbackPolyfill(
|
||||||
// We are setting this item to a -1 index because we do not know its position in the DOM.
|
// 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.
|
// This value should be updated with the next call to collect page details.
|
||||||
() => void this.buildAutofillFieldItem(node as ElementWithOpId<FormFieldElement>, -1),
|
() => void this.buildAutofillFieldItem(node as ElementWithOpId<FormFieldElement>, -1),
|
||||||
|
@ -15,6 +15,20 @@ export function generateRandomChars(length: number): string {
|
|||||||
return randomChars.join("");
|
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.
|
* 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 { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||||
import { FormBuilder } from "@angular/forms";
|
import { FormBuilder } from "@angular/forms";
|
||||||
import {
|
import {
|
||||||
Observable,
|
|
||||||
combineLatest,
|
combineLatest,
|
||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
map,
|
map,
|
||||||
|
Observable,
|
||||||
startWith,
|
startWith,
|
||||||
switchMap,
|
switchMap,
|
||||||
tap,
|
tap,
|
||||||
@ -104,6 +104,11 @@ export class VaultPopupListFiltersService {
|
|||||||
map(
|
map(
|
||||||
(filters) => (ciphers: CipherView[]) =>
|
(filters) => (ciphers: CipherView[]) =>
|
||||||
ciphers.filter((cipher) => {
|
ciphers.filter((cipher) => {
|
||||||
|
// Vault popup lists never shows deleted ciphers
|
||||||
|
if (cipher.isDeleted) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (filters.cipherType !== null && cipher.type !== filters.cipherType) {
|
if (filters.cipherType !== null && cipher.type !== filters.cipherType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@bitwarden/web-vault",
|
"name": "@bitwarden/web-vault",
|
||||||
"version": "2024.6.0",
|
"version": "2024.6.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:oss": "webpack",
|
"build:oss": "webpack",
|
||||||
"build:bit": "webpack -c ../../bitwarden_license/bit-web/webpack.config.js",
|
"build:bit": "webpack -c ../../bitwarden_license/bit-web/webpack.config.js",
|
||||||
|
@ -69,9 +69,9 @@ export class VaultCollectionRowComponent {
|
|||||||
if (this.collection instanceof CollectionAdminView) {
|
if (this.collection instanceof CollectionAdminView) {
|
||||||
// Only show AddAccess if unmanaged and allowAdminAccessToAllCollectionItems is disabled
|
// Only show AddAccess if unmanaged and allowAdminAccessToAllCollectionItems is disabled
|
||||||
return (
|
return (
|
||||||
!this.organization.allowAdminAccessToAllCollectionItems &&
|
!this.organization?.allowAdminAccessToAllCollectionItems &&
|
||||||
this.collection.unmanaged &&
|
this.collection.unmanaged &&
|
||||||
this.organization.canEditUnmanagedCollections()
|
this.organization?.canEditUnmanagedCollections()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<bit-search
|
<bit-search
|
||||||
*ngIf="organization?.isProviderUser"
|
*ngIf="restrictProviderAccessFlag && organization?.isProviderUser && !organization?.isMember"
|
||||||
class="tw-grow"
|
class="tw-grow"
|
||||||
[ngModel]="searchText"
|
[ngModel]="searchText"
|
||||||
(ngModelChange)="onSearchTextChanged($event)"
|
(ngModelChange)="onSearchTextChanged($event)"
|
||||||
|
@ -68,7 +68,7 @@ export class VaultHeaderComponent implements OnInit {
|
|||||||
protected organizations$ = this.organizationService.organizations$;
|
protected organizations$ = this.organizationService.organizations$;
|
||||||
|
|
||||||
protected flexibleCollectionsV1Enabled = false;
|
protected flexibleCollectionsV1Enabled = false;
|
||||||
private restrictProviderAccessFlag = false;
|
protected restrictProviderAccessFlag = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private organizationService: OrganizationService,
|
private organizationService: OrganizationService,
|
||||||
@ -220,7 +220,11 @@ export class VaultHeaderComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get canCreateCipher(): boolean {
|
get canCreateCipher(): boolean {
|
||||||
if (this.organization?.isProviderUser && this.restrictProviderAccessFlag) {
|
if (
|
||||||
|
this.organization?.isProviderUser &&
|
||||||
|
this.restrictProviderAccessFlag &&
|
||||||
|
!this.organization?.isMember
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -166,7 +166,11 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected get hideVaultFilters(): boolean {
|
protected get hideVaultFilters(): boolean {
|
||||||
return this.restrictProviderAccessEnabled && this.organization?.isProviderUser;
|
return (
|
||||||
|
this.restrictProviderAccessEnabled &&
|
||||||
|
this.organization?.isProviderUser &&
|
||||||
|
!this.organization?.isMember
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private searchText$ = new Subject<string>();
|
private searchText$ = new Subject<string>();
|
||||||
@ -352,6 +356,16 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
let ciphers;
|
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) {
|
if (this.flexibleCollectionsV1Enabled) {
|
||||||
// Flexible collections V1 logic.
|
// Flexible collections V1 logic.
|
||||||
// If the user can edit all ciphers for the organization then fetch them ALL.
|
// 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": {
|
"apps/web": {
|
||||||
"name": "@bitwarden/web-vault",
|
"name": "@bitwarden/web-vault",
|
||||||
"version": "2024.6.0"
|
"version": "2024.6.1"
|
||||||
},
|
},
|
||||||
"libs/admin-console": {
|
"libs/admin-console": {
|
||||||
"name": "@bitwarden/admin-console",
|
"name": "@bitwarden/admin-console",
|
||||||
|
Loading…
Reference in New Issue
Block a user