Skip to content

Commit

Permalink
update disabled domain terminology to blocked domain terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
jprusik committed Nov 11, 2024
1 parent eb677c8 commit 9d01a4d
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 54 deletions.
12 changes: 6 additions & 6 deletions apps/browser/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2330,8 +2330,8 @@
"message": "Domains",
"description": "A category title describing the concept of web domains"
},
"disabledDomains": {
"message": "Disabled domains"
"blockedDomains": {
"message": "Blocked domains"
},
"excludedDomains": {
"message": "Excluded domains"
Expand All @@ -2342,10 +2342,10 @@
"excludedDomainsDescAlt": {
"message": "Bitwarden will not ask to save login details for these domains for all logged in accounts. You must refresh the page for changes to take effect."
},
"disabledDomainsDesc": {
"blockedDomainsDesc": {
"message": "Bitwarden will be disabled for these domains. You must refresh the page for changes to take effect."
},
"disabledDomainsDescAlt": {
"blockedDomainsDescAlt": {
"message": "Bitwarden will be disabled for these domains on all logged in accounts. You must refresh the page for changes to take effect."
},
"websiteItemLabel": {
Expand All @@ -2366,8 +2366,8 @@
}
}
},
"disabledDomainsSavedSuccess": {
"message": "Excluded domain changes saved"
"blockedDomainsSavedSuccess": {
"message": "Blocked domain changes saved"
},
"excludedDomainsSavedSuccess": {
"message": "Excluded domain changes saved"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ <h2 class="box-header">{{ "additionalOptions" | i18n }}</h2>
<button
type="button"
class="box-content-row box-content-row-flex text-default"
routerLink="/disabled-domains"
routerLink="/blocked-domains"
>
<div class="row-main">{{ "disabledDomains" | i18n }}</div>
<div class="row-main">{{ "blockedDomains" | i18n }}</div>
<i class="bwi bwi-angle-right bwi-lg row-sub-icon" aria-hidden="true"></i>
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ <h2 bitTypography="h6">{{ "additionalOptions" | i18n }}</h2>
</bit-section>
<bit-section>
<bit-item>
<a bit-item-content routerLink="/disabled-domains">{{ "disabledDomains" | i18n }}</a>
<a bit-item-content routerLink="/blocked-domains">{{ "blockedDomains" | i18n }}</a>
<i slot="end" class="bwi bwi-angle-right bwi-lg row-sub-icon" aria-hidden="true"></i>
</bit-item>
</bit-section>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<popup-page>
<popup-header slot="header" pageTitle="{{ 'disabledDomains' | i18n }}" showBackButton>
<popup-header slot="header" pageTitle="{{ 'blockedDomains' | i18n }}" showBackButton>
<ng-container slot="end">
<app-pop-out></app-pop-out>
</ng-container>
Expand All @@ -8,18 +8,18 @@
<div class="tw-bg-background-alt">
<p>
{{
accountSwitcherEnabled ? ("disabledDomainsDescAlt" | i18n) : ("disabledDomainsDesc" | i18n)
accountSwitcherEnabled ? ("blockedDomainsDescAlt" | i18n) : ("blockedDomainsDesc" | i18n)
}}
</p>
<bit-section *ngIf="!isLoading">
<bit-section-header>
<h2 bitTypography="h6">{{ "domainsTitle" | i18n }}</h2>
<span bitTypography="body2" slot="end">{{ disabledDomainsState?.length || 0 }}</span>
<span bitTypography="body2" slot="end">{{ blockedDomainsState?.length || 0 }}</span>
</bit-section-header>

<ng-container *ngIf="disabledDomainsState">
<ng-container *ngIf="blockedDomainsState">
<bit-item
*ngFor="let domain of disabledDomainsState; let i = index; trackBy: trackByFunction"
*ngFor="let domain of blockedDomainsState; let i = index; trackBy: trackByFunction"
>
<bit-item-content>
<bit-label *ngIf="i >= fieldsEditThreshold">{{
Expand All @@ -35,7 +35,7 @@ <h2 bitTypography="h6">{{ "domainsTitle" | i18n }}</h2>
name="excludedDomain{{ i }}"
type="text"
(change)="fieldChange()"
[(ngModel)]="disabledDomainsState[i]"
[(ngModel)]="blockedDomainsState[i]"
/>
<div id="excludedDomain{{ i }}" *ngIf="i < fieldsEditThreshold">{{ domain }}</div>
</bit-item-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import { PopupHeaderComponent } from "../../../platform/popup/layout/popup-heade
import { PopupPageComponent } from "../../../platform/popup/layout/popup-page.component";

@Component({
selector: "app-disabled-domains",
templateUrl: "disabled-domains.component.html",
selector: "app-blocked-domains",
templateUrl: "blocked-domains.component.html",
standalone: true,
imports: [
ButtonModule,
Expand All @@ -59,14 +59,14 @@ import { PopupPageComponent } from "../../../platform/popup/layout/popup-page.co
TypographyModule,
],
})
export class DisabledDomainsComponent implements AfterViewInit, OnDestroy {
export class BlockedDomainsComponent implements AfterViewInit, OnDestroy {
@ViewChildren("uriInput") uriInputElements: QueryList<ElementRef<HTMLInputElement>>;

accountSwitcherEnabled = false;
dataIsPristine = true;
isLoading = false;
disabledDomainsState: string[] = [];
storedDisabledDomains: string[] = [];
blockedDomainsState: string[] = [];
storedBlockedDomains: string[] = [];
// How many fields should be non-editable before editable fields
fieldsEditThreshold: number = 0;

Expand All @@ -81,7 +81,7 @@ export class DisabledDomainsComponent implements AfterViewInit, OnDestroy {
}

async ngAfterViewInit() {
this.domainSettingsService.disabledInteractionsUris$
this.domainSettingsService.blockedInteractionsUris$
.pipe(takeUntil(this.destroy$))
.subscribe((neverDomains: NeverDomains) => this.handleStateUpdate(neverDomains));

Expand All @@ -97,13 +97,13 @@ export class DisabledDomainsComponent implements AfterViewInit, OnDestroy {

handleStateUpdate(neverDomains: NeverDomains) {
if (neverDomains) {
this.storedDisabledDomains = Object.keys(neverDomains);
this.storedBlockedDomains = Object.keys(neverDomains);
}

this.disabledDomainsState = [...this.storedDisabledDomains];
this.blockedDomainsState = [...this.storedBlockedDomains];

// Do not allow the first x (pre-existing) fields to be edited
this.fieldsEditThreshold = this.storedDisabledDomains.length;
this.fieldsEditThreshold = this.storedBlockedDomains.length;

this.dataIsPristine = true;
this.isLoading = false;
Expand All @@ -117,13 +117,13 @@ export class DisabledDomainsComponent implements AfterViewInit, OnDestroy {

async addNewDomain() {
// add empty field to the Domains list interface
this.disabledDomainsState.push("");
this.blockedDomainsState.push("");

await this.fieldChange();
}

async removeDomain(i: number) {
this.disabledDomainsState.splice(i, 1);
this.blockedDomainsState.splice(i, 1);

// If a pre-existing field was dropped, lower the edit threshold
if (i < this.fieldsEditThreshold) {
Expand All @@ -146,10 +146,10 @@ export class DisabledDomainsComponent implements AfterViewInit, OnDestroy {

this.isLoading = true;

const newDisabledDomainsSaveState: NeverDomains = {};
const uniqueDisabledDomains = new Set(this.disabledDomainsState);
const newBlockedDomainsSaveState: NeverDomains = {};
const uniqueBlockedDomains = new Set(this.blockedDomainsState);

for (const uri of uniqueDisabledDomains) {
for (const uri of uniqueBlockedDomains) {
if (uri && uri !== "") {
const validatedHost = Utils.getHostname(uri);

Expand All @@ -165,33 +165,33 @@ export class DisabledDomainsComponent implements AfterViewInit, OnDestroy {
return;
}

newDisabledDomainsSaveState[validatedHost] = null;
newBlockedDomainsSaveState[validatedHost] = null;
}
}

try {
const existingState = new Set(this.storedDisabledDomains);
const newState = new Set(Object.keys(newDisabledDomainsSaveState));
const existingState = new Set(this.storedBlockedDomains);
const newState = new Set(Object.keys(newBlockedDomainsSaveState));
const stateIsUnchanged =
existingState.size === newState.size &&
new Set([...existingState, ...newState]).size === existingState.size;

// The subscriber updates don't trigger if `setNeverDomains` sets an equivalent state
if (stateIsUnchanged) {
// Reset UI state directly
const constructedNeverDomainsState = this.storedDisabledDomains.reduce(
const constructedNeverDomainsState = this.storedBlockedDomains.reduce(
(neverDomains, uri) => ({ ...neverDomains, [uri]: null }),
{},
);
this.handleStateUpdate(constructedNeverDomainsState);
} else {
await this.domainSettingsService.setDisabledInteractionsUris(newDisabledDomainsSaveState);
await this.domainSettingsService.setBlockedInteractionsUris(newBlockedDomainsSaveState);
}

this.platformUtilsService.showToast(
"success",
null,
this.i18nService.t("disabledDomainsSavedSuccess"),
this.i18nService.t("blockedDomainsSavedSuccess"),
);
} catch {
this.platformUtilsService.showToast("error", null, this.i18nService.t("unexpectedError"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from "./abstractions/script-injector.service";

export class BrowserScriptInjectorService extends ScriptInjectorService {
disabledDomains: Set<string> = null;
blockedDomains: Set<string> = null;

private destroy$ = new Subject<void>();

Expand All @@ -25,10 +25,10 @@ export class BrowserScriptInjectorService extends ScriptInjectorService {
) {
super();

this.domainSettingsService.disabledInteractionsUris$
this.domainSettingsService.blockedInteractionsUris$
.pipe(takeUntil(this.destroy$))
.subscribe(
(neverDomains: NeverDomains) => (this.disabledDomains = new Set(Object.keys(neverDomains))),
(neverDomains: NeverDomains) => (this.blockedDomains = new Set(Object.keys(neverDomains))),
);
}

Expand All @@ -48,10 +48,10 @@ export class BrowserScriptInjectorService extends ScriptInjectorService {
// Check if the tab URI is on the disabled URIs list
const tab = await BrowserApi.getTab(tabId);
const tabURL = tab.url ? new URL(tab.url) : null;
const injectionAllowedInTab = !(tabURL && this.disabledDomains?.has(tabURL.hostname));
const injectionAllowedInTab = !(tabURL && this.blockedDomains?.has(tabURL.hostname));

if (!injectionAllowedInTab) {
throw new Error("This URI of this tab is on the disabled domains list.");
throw new Error("This URI of this tab is on the blocked domains list.");
}

const injectionDetails = this.buildInjectionDetails(injectDetails, file);
Expand Down
8 changes: 4 additions & 4 deletions apps/browser/src/popup/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import { Fido2V1Component } from "../autofill/popup/fido2/fido2-v1.component";
import { Fido2Component } from "../autofill/popup/fido2/fido2.component";
import { AutofillV1Component } from "../autofill/popup/settings/autofill-v1.component";
import { AutofillComponent } from "../autofill/popup/settings/autofill.component";
import { DisabledDomainsComponent } from "../autofill/popup/settings/disabled-domains.component";
import { BlockedDomainsComponent } from "../autofill/popup/settings/blocked-domains.component";
import { ExcludedDomainsV1Component } from "../autofill/popup/settings/excluded-domains-v1.component";
import { ExcludedDomainsComponent } from "../autofill/popup/settings/excluded-domains.component";
import { NotificationsSettingsV1Component } from "../autofill/popup/settings/notifications-v1.component";
Expand Down Expand Up @@ -362,10 +362,10 @@ const routes: Routes = [
data: { state: "sync" } satisfies RouteDataProperties,
},
{
path: "disabled-domains",
component: DisabledDomainsComponent,
path: "blocked-domains",
component: BlockedDomainsComponent,
canActivate: [authGuard],
data: { state: "disabled-domains" } satisfies RouteDataProperties,
data: { state: "blocked-domains" } satisfies RouteDataProperties,
},
...extensionRefreshSwap(ExcludedDomainsV1Component, ExcludedDomainsComponent, {
path: "excluded-domains",
Expand Down
21 changes: 11 additions & 10 deletions libs/common/src/autofill/services/domain-settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ const NEVER_DOMAINS = new KeyDefinition(DOMAIN_SETTINGS_DISK, "neverDomains", {
deserializer: (value: NeverDomains) => value ?? null,
});

const DISABLED_INTERACTIONS_URIS = new KeyDefinition(
// Domain exclusion list for content script injections
const BLOCKED_INTERACTIONS_URIS = new KeyDefinition(
DOMAIN_SETTINGS_DISK,
"disabledInteractionsUris",
"blockedInteractionsUris",
{
deserializer: (value: NeverDomains) => value ?? null,
},
Expand All @@ -53,8 +54,8 @@ export abstract class DomainSettingsService {
setShowFavicons: (newValue: boolean) => Promise<void>;
neverDomains$: Observable<NeverDomains>;
setNeverDomains: (newValue: NeverDomains) => Promise<void>;
disabledInteractionsUris$: Observable<NeverDomains>;
setDisabledInteractionsUris: (newValue: NeverDomains) => Promise<void>;
blockedInteractionsUris$: Observable<NeverDomains>;
setBlockedInteractionsUris: (newValue: NeverDomains) => Promise<void>;
equivalentDomains$: Observable<EquivalentDomains>;
setEquivalentDomains: (newValue: EquivalentDomains, userId: UserId) => Promise<void>;
defaultUriMatchStrategy$: Observable<UriMatchStrategySetting>;
Expand All @@ -69,8 +70,8 @@ export class DefaultDomainSettingsService implements DomainSettingsService {
private neverDomainsState: GlobalState<NeverDomains>;
readonly neverDomains$: Observable<NeverDomains>;

private disabledInteractionsUrisState: GlobalState<NeverDomains>;
readonly disabledInteractionsUris$: Observable<NeverDomains>;
private blockedInteractionsUrisState: GlobalState<NeverDomains>;
readonly blockedInteractionsUris$: Observable<NeverDomains>;

private equivalentDomainsState: ActiveUserState<EquivalentDomains>;
readonly equivalentDomains$: Observable<EquivalentDomains>;
Expand All @@ -85,8 +86,8 @@ export class DefaultDomainSettingsService implements DomainSettingsService {
this.neverDomainsState = this.stateProvider.getGlobal(NEVER_DOMAINS);
this.neverDomains$ = this.neverDomainsState.state$.pipe(map((x) => x ?? null));

this.disabledInteractionsUrisState = this.stateProvider.getGlobal(DISABLED_INTERACTIONS_URIS);
this.disabledInteractionsUris$ = this.disabledInteractionsUrisState.state$.pipe(
this.blockedInteractionsUrisState = this.stateProvider.getGlobal(BLOCKED_INTERACTIONS_URIS);
this.blockedInteractionsUris$ = this.blockedInteractionsUrisState.state$.pipe(
map((x) => x ?? null),
);

Expand All @@ -107,8 +108,8 @@ export class DefaultDomainSettingsService implements DomainSettingsService {
await this.neverDomainsState.update(() => newValue);
}

async setDisabledInteractionsUris(newValue: NeverDomains): Promise<void> {
await this.disabledInteractionsUrisState.update(() => newValue);
async setBlockedInteractionsUris(newValue: NeverDomains): Promise<void> {
await this.blockedInteractionsUrisState.update(() => newValue);
}

async setEquivalentDomains(newValue: EquivalentDomains, userId: UserId): Promise<void> {
Expand Down

0 comments on commit 9d01a4d

Please sign in to comment.