1
0
mirror of https://github.com/bitwarden/web synced 2025-12-06 00:03:28 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Matt Gibson
e96e3cefd1 Add string replacement feature flagging 2022-01-18 10:56:39 -05:00
13 changed files with 55 additions and 50 deletions

View File

@@ -3,10 +3,6 @@ const { AngularWebpackPlugin } = require("@ngtools/webpack");
const webpackConfig = require("../webpack.config");
webpackConfig.entry["app/main"] = "./bitwarden_license/src/app/main.ts";
webpackConfig.plugins[webpackConfig.plugins.length - 1] = new AngularWebpackPlugin({
tsConfigPath: "tsconfig.json",
entryModule: "bitwarden_license/src/app/app.module#AppModule",
sourceMap: true,
});
webpackConfig.plugins[webpackConfig.plugins.length - 1].entryModule = "bitwarden_license/src/app/app.module#AppModule";
module.exports = webpackConfig;

View File

@@ -30,7 +30,24 @@ function loadConfig(configName) {
}
}
function generateSubstitutions(configObj) {
let result = {};
Object.keys(configObj.compileFlags ?? {}).forEach(key => {
result = { ...result, ...generateSubstitutionsForFlag(key) };
});
return result;
}
function generateSubstitutionsForFlag(flagName) {
return {
"featureFlag: (.*)[\\s\\S]*?\\/\\/ endFeatureFlag": ""
};
}
module.exports = {
load,
log,
generateSubstitutions,
};

View File

@@ -7,5 +7,8 @@
"proxyIdentity": "http://localhost:33656",
"proxyEvents": "http://localhost:46273",
"proxyNotifications": "http://localhost:61840"
},
"compileFlags": {
"Test": false
}
}

0
config/empty.ts Normal file
View File

2
jslib

Submodule jslib updated: 54c6a4b3c3...e4cd0af2f9

4
package-lock.json generated
View File

@@ -1,11 +1,11 @@
{
"name": "@bitwarden/web-vault",
"name": "bitwarden-web",
"version": "2.25.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@bitwarden/web-vault",
"name": "bitwarden-web",
"version": "2.25.1",
"hasInstallScript": true,
"license": "GPL-3.0",

View File

@@ -1,5 +1,5 @@
{
"name": "@bitwarden/web-vault",
"name": "bitwarden-web",
"version": "2.25.1",
"license": "GPL-3.0",
"repository": "https://github.com/bitwarden/web",

View File

@@ -12,8 +12,6 @@ import { OrganizationService } from "jslib-common/abstractions/organization.serv
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { PlanType } from "jslib-common/enums/planType";
import { StateService } from "jslib-common/abstractions/state.service";
import { ProductType } from "jslib-common/enums/productType";
@Component({
selector: "app-org-subscription",
@@ -29,7 +27,6 @@ export class OrganizationSubscriptionComponent implements OnInit {
adjustStorageAdd = true;
showAdjustStorage = false;
showUpdateLicense = false;
canDownloadLicense = false;
showDownloadLicense = false;
showChangePlan = false;
sub: OrganizationSubscriptionResponse;
@@ -45,7 +42,6 @@ export class OrganizationSubscriptionComponent implements OnInit {
private apiService: ApiService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private stateService: StateService,
private messagingService: MessagingService,
private route: ActivatedRoute,
private organizationService: OrganizationService,
@@ -70,13 +66,6 @@ export class OrganizationSubscriptionComponent implements OnInit {
this.loading = true;
this.userOrg = await this.organizationService.get(this.organizationId);
this.sub = await this.apiService.getOrganizationSubscription(this.organizationId);
const orgs = await this.stateService.getOrganizations();
const isAllowedOrgType = Object.values(orgs).some(org => org.planProductType === (ProductType.Enterprise | ProductType.Families));
const canDownload = (this.sub.planType !== PlanType.Free && this.subscription == null) ||
(this.subscription != null && !this.subscription.cancelled);
this.canDownloadLicense = canDownload && isAllowedOrgType;
this.loading = false;
}
@@ -215,22 +204,14 @@ export class OrganizationSubscriptionComponent implements OnInit {
);
}
get subscriptionMarkedForCancel() {
get subscriptionMarkedForCancel() {
return (
this.subscription != null && !this.subscription.cancelled && this.subscription.cancelAtEndDate
);
}
get subscription() {
const now = new Date();
const fiveDays = now.setDate(now.getDate() + 5);
if(this.sub === null) return null;
if(this.sub.subscription == null) {
this.sub.subscription = ({ cancelled: true, cancelAtEndDate: (fiveDays as any)} as any);
this.sub.subscription.items = new Array({sponsoredSubscriptionItem: false} as any);
}
return this.sub.subscription;
return this.sub != null ? this.sub.subscription : null;
}
get nextInvoice() {
@@ -276,6 +257,13 @@ export class OrganizationSubscriptionComponent implements OnInit {
return this.sub.subscription?.items.some((i) => i.sponsoredSubscriptionItem);
}
get canDownloadLicense() {
return (
(this.sub.planType !== PlanType.Free && this.subscription == null) ||
(this.subscription != null && !this.subscription.cancelled)
);
}
get subscriptionDesc() {
if (this.sub.planType === PlanType.Free) {
return this.i18nService.t("subscriptionFreePlan", this.sub.seats.toString());

View File

@@ -52,10 +52,6 @@ import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from "jslib-com
import { ThemeType } from "jslib-common/enums/themeType";
import { AccountFactory } from "jslib-common/models/domain/account";
import { Account } from "../../models/account";
export function initFactory(
window: Window,
storageService: StorageServiceAbstraction,
@@ -182,19 +178,7 @@ export function initFactory(
},
{
provide: StateServiceAbstraction,
useFactory: (
storageService: StorageServiceAbstraction,
secureStorageService: StorageServiceAbstraction,
logService: LogService,
stateMigrationService: StateMigrationServiceAbstraction
) =>
new StateService(
storageService,
secureStorageService,
logService,
stateMigrationService,
new AccountFactory(Account)
),
useClass: StateService,
deps: [
StorageServiceAbstraction,
"SECURE_STORAGE",

View File

@@ -37,6 +37,9 @@ import { SyncService } from "jslib-common/abstractions/sync.service";
import { TokenService } from "jslib-common/abstractions/token.service";
import { ModalService } from "jslib-angular/services/modal.service";
// featureFlag: Test
import { TestService } from 'jslib-common/services/test.service';
// endFeatureFlag
const BroadcasterSubscriptionId = "VaultComponent";
@@ -89,10 +92,12 @@ export class VaultComponent implements OnInit, OnDestroy {
private ngZone: NgZone,
private stateService: StateService,
private organizationService: OrganizationService,
private providerService: ProviderService
private providerService: ProviderService,
/* featureFlag: Test */private testService: TestService, // endFeatureFlag
) {}
async ngOnInit() {
/** featureFlag: Test */ this.testService.Print("test service was loaded"); // endFeatureFlag
this.showVerifyEmail = !(await this.tokenService.getEmailVerified());
this.showBrowserOutdated = window.navigator.userAgent.indexOf("MSIE") !== -1;
this.trashCleanupWarning = this.i18nService.t(

View File

@@ -3164,7 +3164,7 @@
"description": "A 'fingerprint phrase' is a unique word phrase (similar to a passphrase) that a user can use to authenticate their public key with another user, for the purposes of sharing."
},
"dontAskFingerprintAgain": {
"message": "Never prompt to verify fingerprint phrases for invited users (Not recommended)",
"message": "Don't ask to verify fingerprint phrase again",
"description": "A 'fingerprint phrase' is a unique word phrase (similar to a passphrase) that a user can use to authenticate their public key with another user, for the purposes of sharing."
},
"free": {

View File

@@ -1,6 +1,13 @@
{
"extends": "./jslib/shared/tsconfig",
"compilerOptions": {
"moduleResolution": "node",
"noImplicitAny": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"target": "es2015",
"lib": ["es5", "es6", "dom"],
"sourceMap": true,
"baseUrl": ".",
"paths": {
"tldjs": ["jslib/common/src/misc/tldjs.noop"],

View File

@@ -17,6 +17,9 @@ const NODE_ENV = process.env.NODE_ENV == null ? "development" : process.env.NODE
const envConfig = config.load(ENV);
config.log(envConfig);
const fileReplacements = {};
const substitutions = config.generateSubstitutions(envConfig);
const moduleRules = [
{
test: /\.ts$/,
@@ -155,6 +158,8 @@ const plugins = [
tsConfigPath: "tsconfig.json",
entryModule: "src/app/app.module#AppModule",
sourceMap: true,
fileReplacements: fileReplacements,
substitutions: substitutions,
}),
];