mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: put behind feature flag
This commit is contained in:
parent
0496cc4478
commit
89f6056592
@ -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/workspace/presentation/home/toast.dart';
|
||||
import 'package:appflowy_backend/log.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:url_launcher/url_launcher.dart' as launcher;
|
||||
|
||||
|
@ -32,6 +32,9 @@ enum FeatureFlag {
|
||||
// used for the search feature
|
||||
search,
|
||||
|
||||
// used for controlling whether to show plan+billing options in settings
|
||||
planBilling,
|
||||
|
||||
// used for ignore the conflicted feature flag
|
||||
unknown;
|
||||
|
||||
@ -104,6 +107,7 @@ enum FeatureFlag {
|
||||
switch (this) {
|
||||
case FeatureFlag.collaborativeWorkspace:
|
||||
case FeatureFlag.membersSettings:
|
||||
case FeatureFlag.planBilling:
|
||||
case FeatureFlag.unknown:
|
||||
return false;
|
||||
case FeatureFlag.search:
|
||||
@ -125,6 +129,8 @@ enum FeatureFlag {
|
||||
return 'if it\'s on, the collaborators will show in the database';
|
||||
case FeatureFlag.search:
|
||||
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:
|
||||
return '';
|
||||
}
|
||||
|
@ -50,6 +50,9 @@ class SettingsBillingView extends StatelessWidget {
|
||||
return ErrorWidget.withDetails(message: 'Something went wrong!');
|
||||
},
|
||||
ready: (state) {
|
||||
final billingPortalEnabled = state.billingPortal != null &&
|
||||
state.billingPortal!.url.isNotEmpty;
|
||||
|
||||
return SettingsBody(
|
||||
title: LocaleKeys.settings_billingPage_title.tr(),
|
||||
children: [
|
||||
@ -67,34 +70,37 @@ class SettingsBillingView extends StatelessWidget {
|
||||
.settings_billingPage_plan_planButtonLabel
|
||||
.tr(),
|
||||
),
|
||||
SingleSettingAction(
|
||||
onPressed: () =>
|
||||
afLaunchUrlString(state.billingPortal!.url),
|
||||
label: LocaleKeys
|
||||
.settings_billingPage_plan_billingPeriod
|
||||
.tr(),
|
||||
buttonLabel: LocaleKeys
|
||||
.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)
|
||||
SingleSettingAction(
|
||||
onPressed: () =>
|
||||
afLaunchUrlString(state.billingPortal!.url),
|
||||
label: LocaleKeys
|
||||
.settings_billingPage_plan_billingPeriod
|
||||
.tr(),
|
||||
buttonLabel: LocaleKeys
|
||||
.settings_billingPage_plan_periodButtonLabel
|
||||
.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(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -318,8 +318,8 @@ class _PlanUsageSummary extends StatelessWidget {
|
||||
usage.memberCountLimit.toString(),
|
||||
],
|
||||
),
|
||||
value: usage.totalBlobBytes.toInt() /
|
||||
usage.totalBlobBytesLimit.toInt(),
|
||||
value:
|
||||
usage.memberCount.toInt() / usage.memberCountLimit.toInt(),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -1,8 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:appflowy/shared/feature_flags.dart';
|
||||
import 'package:appflowy/startup/startup.dart';
|
||||
import 'package:appflowy/workspace/presentation/settings/shared/settings_body.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FeatureFlagsPage extends StatelessWidget {
|
||||
const FeatureFlagsPage({
|
||||
@ -49,8 +50,10 @@ class _FeatureFlagItemState extends State<_FeatureFlagItem> {
|
||||
subtitle: FlowyText.small(widget.featureFlag.description, maxLines: 3),
|
||||
trailing: Switch.adaptive(
|
||||
value: widget.featureFlag.isOn,
|
||||
onChanged: (value) =>
|
||||
setState(() async => widget.featureFlag.update(value)),
|
||||
onChanged: (value) async {
|
||||
await widget.featureFlag.update(value);
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -99,20 +99,22 @@ class SettingsMenu extends StatelessWidget {
|
||||
icon: const Icon(Icons.cut),
|
||||
changeSelectedPage: changeSelectedPage,
|
||||
),
|
||||
SettingsMenuElement(
|
||||
page: SettingsPage.plan,
|
||||
selectedPage: currentPage,
|
||||
label: LocaleKeys.settings_planPage_menuLabel.tr(),
|
||||
icon: const FlowySvg(FlowySvgs.settings_plan_m),
|
||||
changeSelectedPage: changeSelectedPage,
|
||||
),
|
||||
SettingsMenuElement(
|
||||
page: SettingsPage.billing,
|
||||
selectedPage: currentPage,
|
||||
label: LocaleKeys.settings_billingPage_menuLabel.tr(),
|
||||
icon: const FlowySvg(FlowySvgs.settings_billing_m),
|
||||
changeSelectedPage: changeSelectedPage,
|
||||
),
|
||||
if (FeatureFlag.planBilling.isOn) ...[
|
||||
SettingsMenuElement(
|
||||
page: SettingsPage.plan,
|
||||
selectedPage: currentPage,
|
||||
label: LocaleKeys.settings_planPage_menuLabel.tr(),
|
||||
icon: const FlowySvg(FlowySvgs.settings_plan_m),
|
||||
changeSelectedPage: changeSelectedPage,
|
||||
),
|
||||
SettingsMenuElement(
|
||||
page: SettingsPage.billing,
|
||||
selectedPage: currentPage,
|
||||
label: LocaleKeys.settings_billingPage_menuLabel.tr(),
|
||||
icon: const FlowySvg(FlowySvgs.settings_billing_m),
|
||||
changeSelectedPage: changeSelectedPage,
|
||||
),
|
||||
],
|
||||
if (kDebugMode)
|
||||
SettingsMenuElement(
|
||||
// no need to translate this page
|
||||
|
@ -122,8 +122,8 @@ lto = false
|
||||
incremental = false
|
||||
|
||||
[patch.crates-io]
|
||||
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "3f55cea9ca386875a1668ef30600c83cd6a1ffe2" }
|
||||
shared-entity = { 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 = "d0467e7e2e8ee4b925556b5510fb6ed7322dde8c" }
|
||||
|
||||
# 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.
|
||||
|
Loading…
Reference in New Issue
Block a user