Show React icon to hosted web users
This commit is contained in:
parent
5b2e3af1ba
commit
2fb7945f23
|
|
@ -10,10 +10,12 @@ const String kMinServerVersion = '5.0.4';
|
||||||
const String kAppName = 'Invoice Ninja';
|
const String kAppName = 'Invoice Ninja';
|
||||||
const String kSiteUrl = 'https://invoiceninja.com';
|
const String kSiteUrl = 'https://invoiceninja.com';
|
||||||
const String kAppProductionUrl = 'https://invoicing.co';
|
const String kAppProductionUrl = 'https://invoicing.co';
|
||||||
|
const String kAppReactUrl = 'https://app.invoicing.co';
|
||||||
const String kAppStagingUrl = 'https://staging.invoicing.co';
|
const String kAppStagingUrl = 'https://staging.invoicing.co';
|
||||||
const String kAppStagingNetUrl = 'https://invoiceninja.net';
|
const String kAppStagingNetUrl = 'https://invoiceninja.net';
|
||||||
const String kAppLargeTestUrl = 'https://testv5.invoicing.co';
|
const String kAppLargeTestUrl = 'https://testv5.invoicing.co';
|
||||||
const String kAppDemoUrl = 'https://demo.invoiceninja.com';
|
const String kFlutterDemoUrl = 'https://demo.invoiceninja.com';
|
||||||
|
const String kReactDemoUrl = 'https://react.invoicing.co/demo';
|
||||||
const String kWhiteLabelUrl =
|
const String kWhiteLabelUrl =
|
||||||
'https://app.invoiceninja.com/buy_now/?account_key=AsFmBAeLXF0IKf7tmi0eiyZfmWW9hxMT&product_id=3';
|
'https://app.invoiceninja.com/buy_now/?account_key=AsFmBAeLXF0IKf7tmi0eiyZfmWW9hxMT&product_id=3';
|
||||||
const String kPrivacyPolicyURL = 'https://www.invoiceninja.com/privacy-policy';
|
const String kPrivacyPolicyURL = 'https://www.invoiceninja.com/privacy-policy';
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,7 @@ Middleware<AppState> _createLoadState(
|
||||||
String? token;
|
String? token;
|
||||||
|
|
||||||
if (Config.DEMO_MODE ||
|
if (Config.DEMO_MODE ||
|
||||||
cleanApiUrl(store.state.authState.url) == kAppDemoUrl) {
|
cleanApiUrl(store.state.authState.url) == kFlutterDemoUrl) {
|
||||||
token = 'TOKEN';
|
token = 'TOKEN';
|
||||||
} else {
|
} else {
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
|
|
||||||
|
|
@ -833,7 +833,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
||||||
|
|
||||||
bool get isSelfHosted => !isHosted;
|
bool get isSelfHosted => !isHosted;
|
||||||
|
|
||||||
bool get isDemo => cleanApiUrl(authState.url) == kAppDemoUrl;
|
bool get isDemo => cleanApiUrl(authState.url) == kFlutterDemoUrl;
|
||||||
|
|
||||||
bool get isStaging => cleanApiUrl(authState.url) == kAppStagingUrl;
|
bool get isStaging => cleanApiUrl(authState.url) == kAppStagingUrl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ abstract class AuthState implements Built<AuthState, AuthStateBuilder> {
|
||||||
|
|
||||||
if ([
|
if ([
|
||||||
kAppProductionUrl,
|
kAppProductionUrl,
|
||||||
kAppDemoUrl,
|
kFlutterDemoUrl,
|
||||||
kAppStagingUrl,
|
kAppStagingUrl,
|
||||||
kAppStagingNetUrl,
|
kAppStagingNetUrl,
|
||||||
].contains(cleanUrl)) {
|
].contains(cleanUrl)) {
|
||||||
|
|
|
||||||
|
|
@ -259,14 +259,18 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||||
),
|
),
|
||||||
if (!kReleaseMode ||
|
if (!kReleaseMode ||
|
||||||
(kIsWeb &&
|
(kIsWeb &&
|
||||||
state.isSelfHosted &&
|
(state.isHosted ||
|
||||||
state.userCompany.isAdmin &&
|
(state.isSelfHosted && state.userCompany.isAdmin))))
|
||||||
!state.isDemo))
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 10),
|
padding: const EdgeInsets.only(right: 10),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
tooltip: localization!.enableReactApp,
|
tooltip: localization!.enableReactApp,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
if (state.isDemo) {
|
||||||
|
launchUrl(Uri.parse(kReactDemoUrl));
|
||||||
|
} else if (state.isHosted) {
|
||||||
|
launchUrl(Uri.parse(kAppReactUrl));
|
||||||
|
} else {
|
||||||
confirmCallback(
|
confirmCallback(
|
||||||
context: context,
|
context: context,
|
||||||
message: localization.enableReactApp,
|
message: localization.enableReactApp,
|
||||||
|
|
@ -274,7 +278,8 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||||
final credentials = state.credentials;
|
final credentials = state.credentials;
|
||||||
final account = state.account
|
final account = state.account
|
||||||
.rebuild((b) => b..setReactAsDefaultAP = true);
|
.rebuild((b) => b..setReactAsDefaultAP = true);
|
||||||
final url = '${credentials.url}/accounts/${account.id}';
|
final url =
|
||||||
|
'${credentials.url}/accounts/${account.id}';
|
||||||
final data = serializers.serializeWith(
|
final data = serializers.serializeWith(
|
||||||
AccountEntity.serializer, account);
|
AccountEntity.serializer, account);
|
||||||
|
|
||||||
|
|
@ -293,6 +298,7 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||||
showErrorDialog(message: error as String?);
|
showErrorDialog(message: error as String?);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
icon: Icon(MdiIcons.react),
|
icon: Icon(MdiIcons.react),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue