feat: put behind feature flag

This commit is contained in:
Mathias Mogensen 2024-06-10 12:40:45 +02:00
parent 0496cc4478
commit 89f6056592
7 changed files with 67 additions and 49 deletions

View File

@ -1,9 +1,10 @@
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/workspace/presentation/home/toast.dart'; import 'package:appflowy/workspace/presentation/home/toast.dart';
import 'package:appflowy_backend/log.dart'; import 'package:appflowy_backend/log.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:string_validator/string_validator.dart'; import 'package:string_validator/string_validator.dart';
import 'package:url_launcher/url_launcher.dart' as launcher; import 'package:url_launcher/url_launcher.dart' as launcher;

View File

@ -32,6 +32,9 @@ enum FeatureFlag {
// used for the search feature // used for the search feature
search, search,
// used for controlling whether to show plan+billing options in settings
planBilling,
// used for ignore the conflicted feature flag // used for ignore the conflicted feature flag
unknown; unknown;
@ -104,6 +107,7 @@ enum FeatureFlag {
switch (this) { switch (this) {
case FeatureFlag.collaborativeWorkspace: case FeatureFlag.collaborativeWorkspace:
case FeatureFlag.membersSettings: case FeatureFlag.membersSettings:
case FeatureFlag.planBilling:
case FeatureFlag.unknown: case FeatureFlag.unknown:
return false; return false;
case FeatureFlag.search: case FeatureFlag.search:
@ -125,6 +129,8 @@ enum FeatureFlag {
return 'if it\'s on, the collaborators will show in the database'; return 'if it\'s on, the collaborators will show in the database';
case FeatureFlag.search: case FeatureFlag.search:
return 'if it\'s on, the command palette and search button will be available'; return 'if it\'s on, the command palette and search button will be available';
case FeatureFlag.planBilling:
return 'if it\'s on, plan and billing pages will be available in Settings';
case FeatureFlag.unknown: case FeatureFlag.unknown:
return ''; return '';
} }

View File

@ -50,6 +50,9 @@ class SettingsBillingView extends StatelessWidget {
return ErrorWidget.withDetails(message: 'Something went wrong!'); return ErrorWidget.withDetails(message: 'Something went wrong!');
}, },
ready: (state) { ready: (state) {
final billingPortalEnabled = state.billingPortal != null &&
state.billingPortal!.url.isNotEmpty;
return SettingsBody( return SettingsBody(
title: LocaleKeys.settings_billingPage_title.tr(), title: LocaleKeys.settings_billingPage_title.tr(),
children: [ children: [
@ -67,34 +70,37 @@ class SettingsBillingView extends StatelessWidget {
.settings_billingPage_plan_planButtonLabel .settings_billingPage_plan_planButtonLabel
.tr(), .tr(),
), ),
SingleSettingAction( if (billingPortalEnabled)
onPressed: () => SingleSettingAction(
afLaunchUrlString(state.billingPortal!.url), onPressed: () =>
label: LocaleKeys afLaunchUrlString(state.billingPortal!.url),
.settings_billingPage_plan_billingPeriod label: LocaleKeys
.tr(), .settings_billingPage_plan_billingPeriod
buttonLabel: LocaleKeys .tr(),
.settings_billingPage_plan_periodButtonLabel buttonLabel: LocaleKeys
.tr(), .settings_billingPage_plan_periodButtonLabel
), .tr(),
], ),
),
SettingsCategory(
title: LocaleKeys.settings_billingPage_paymentDetails_title
.tr(),
children: [
SingleSettingAction(
onPressed: () =>
afLaunchUrlString(state.billingPortal!.url),
label: LocaleKeys
.settings_billingPage_paymentDetails_methodLabel
.tr(),
buttonLabel: LocaleKeys
.settings_billingPage_paymentDetails_methodButtonLabel
.tr(),
),
], ],
), ),
if (billingPortalEnabled)
SettingsCategory(
title: LocaleKeys
.settings_billingPage_paymentDetails_title
.tr(),
children: [
SingleSettingAction(
onPressed: () =>
afLaunchUrlString(state.billingPortal!.url),
label: LocaleKeys
.settings_billingPage_paymentDetails_methodLabel
.tr(),
buttonLabel: LocaleKeys
.settings_billingPage_paymentDetails_methodButtonLabel
.tr(),
),
],
),
], ],
); );
}, },

View File

@ -318,8 +318,8 @@ class _PlanUsageSummary extends StatelessWidget {
usage.memberCountLimit.toString(), usage.memberCountLimit.toString(),
], ],
), ),
value: usage.totalBlobBytes.toInt() / value:
usage.totalBlobBytesLimit.toInt(), usage.memberCount.toInt() / usage.memberCountLimit.toInt(),
), ),
), ),
], ],

View File

@ -1,8 +1,9 @@
import 'package:flutter/material.dart';
import 'package:appflowy/shared/feature_flags.dart'; import 'package:appflowy/shared/feature_flags.dart';
import 'package:appflowy/startup/startup.dart'; import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/workspace/presentation/settings/shared/settings_body.dart'; import 'package:appflowy/workspace/presentation/settings/shared/settings_body.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
class FeatureFlagsPage extends StatelessWidget { class FeatureFlagsPage extends StatelessWidget {
const FeatureFlagsPage({ const FeatureFlagsPage({
@ -49,8 +50,10 @@ class _FeatureFlagItemState extends State<_FeatureFlagItem> {
subtitle: FlowyText.small(widget.featureFlag.description, maxLines: 3), subtitle: FlowyText.small(widget.featureFlag.description, maxLines: 3),
trailing: Switch.adaptive( trailing: Switch.adaptive(
value: widget.featureFlag.isOn, value: widget.featureFlag.isOn,
onChanged: (value) => onChanged: (value) async {
setState(() async => widget.featureFlag.update(value)), await widget.featureFlag.update(value);
setState(() {});
},
), ),
); );
} }

View File

@ -99,20 +99,22 @@ class SettingsMenu extends StatelessWidget {
icon: const Icon(Icons.cut), icon: const Icon(Icons.cut),
changeSelectedPage: changeSelectedPage, changeSelectedPage: changeSelectedPage,
), ),
SettingsMenuElement( if (FeatureFlag.planBilling.isOn) ...[
page: SettingsPage.plan, SettingsMenuElement(
selectedPage: currentPage, page: SettingsPage.plan,
label: LocaleKeys.settings_planPage_menuLabel.tr(), selectedPage: currentPage,
icon: const FlowySvg(FlowySvgs.settings_plan_m), label: LocaleKeys.settings_planPage_menuLabel.tr(),
changeSelectedPage: changeSelectedPage, icon: const FlowySvg(FlowySvgs.settings_plan_m),
), changeSelectedPage: changeSelectedPage,
SettingsMenuElement( ),
page: SettingsPage.billing, SettingsMenuElement(
selectedPage: currentPage, page: SettingsPage.billing,
label: LocaleKeys.settings_billingPage_menuLabel.tr(), selectedPage: currentPage,
icon: const FlowySvg(FlowySvgs.settings_billing_m), label: LocaleKeys.settings_billingPage_menuLabel.tr(),
changeSelectedPage: changeSelectedPage, icon: const FlowySvg(FlowySvgs.settings_billing_m),
), changeSelectedPage: changeSelectedPage,
),
],
if (kDebugMode) if (kDebugMode)
SettingsMenuElement( SettingsMenuElement(
// no need to translate this page // no need to translate this page

View File

@ -122,8 +122,8 @@ lto = false
incremental = false incremental = false
[patch.crates-io] [patch.crates-io]
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "3f55cea9ca386875a1668ef30600c83cd6a1ffe2" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d0467e7e2e8ee4b925556b5510fb6ed7322dde8c" }
shared-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "3f55cea9ca386875a1668ef30600c83cd6a1ffe2" } shared-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d0467e7e2e8ee4b925556b5510fb6ed7322dde8c" }
# TODO(Lucas.Xu) Upgrade to the latest version of RocksDB once PR(https://github.com/rust-rocksdb/rust-rocksdb/pull/869) is merged. # TODO(Lucas.Xu) Upgrade to the latest version of RocksDB once PR(https://github.com/rust-rocksdb/rust-rocksdb/pull/869) is merged.
# Currently, using the following revision id. This commit is patched to fix the 32-bit build issue and it's checked out from 0.21.0, not 0.22.0. # Currently, using the following revision id. This commit is patched to fix the 32-bit build issue and it's checked out from 0.21.0, not 0.22.0.