mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-08 01:43:13 +00:00
refactor: Remove backblaze page from installation wizard
This commit is contained in:
parent
eb92a8ee56
commit
a6e6833efb
|
@ -237,13 +237,8 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
|||
print(e);
|
||||
}
|
||||
}
|
||||
finishRecoveryProcess(backblazeCredential);
|
||||
return;
|
||||
}
|
||||
emit(
|
||||
(state as ServerInstallationNotFinished)
|
||||
.copyWith(backblazeCredential: backblazeCredential),
|
||||
);
|
||||
}
|
||||
|
||||
void setDomain(final ServerDomain serverDomain) async {
|
||||
|
@ -756,14 +751,12 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
|||
provider: dnsProviderType,
|
||||
),
|
||||
dnsApiToken: token,
|
||||
currentStep: RecoveryStep.backblazeToken,
|
||||
),
|
||||
);
|
||||
finishRecoveryProcess();
|
||||
}
|
||||
|
||||
void finishRecoveryProcess(
|
||||
final BackupsCredential backblazeCredential,
|
||||
) async {
|
||||
void finishRecoveryProcess() async {
|
||||
await repository.saveIsServerStarted(true);
|
||||
await repository.saveIsServerResetedFirstTime(true);
|
||||
await repository.saveIsServerResetedSecondTime(true);
|
||||
|
@ -778,7 +771,6 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
|||
await repository.saveRootUser(mainUser);
|
||||
final ServerInstallationRecovery updatedState =
|
||||
(state as ServerInstallationRecovery).copyWith(
|
||||
backblazeCredential: backblazeCredential,
|
||||
rootUser: mainUser,
|
||||
serverTypeIdentificator: serverType.data!.identifier,
|
||||
);
|
||||
|
@ -845,7 +837,6 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
|||
providerApiToken: state.providerApiToken,
|
||||
serverDomain: state.serverDomain,
|
||||
dnsApiToken: state.dnsApiToken,
|
||||
backblazeCredential: state.backblazeCredential,
|
||||
rootUser: state.rootUser,
|
||||
serverDetails: null,
|
||||
isServerStarted: false,
|
||||
|
|
|
@ -45,8 +45,6 @@ class ServerInstallationRepository {
|
|||
final DnsProviderType? dnsProvider = getIt<ApiConfigModel>().dnsProvider;
|
||||
final ServerProviderType? serverProvider =
|
||||
getIt<ApiConfigModel>().serverProvider;
|
||||
final BackupsCredential? backblazeCredential =
|
||||
getIt<ApiConfigModel>().backblazeCredential;
|
||||
final ServerHostingDetails? serverDetails =
|
||||
getIt<ApiConfigModel>().serverDetails;
|
||||
|
||||
|
@ -87,7 +85,6 @@ class ServerInstallationRepository {
|
|||
serverTypeIdentificator: finalServerType.data!.identifier,
|
||||
dnsApiToken: dnsApiToken!,
|
||||
serverDomain: serverDomain!,
|
||||
backblazeCredential: backblazeCredential!,
|
||||
serverDetails: serverDetails,
|
||||
rootUser: box.get(BNames.rootUser),
|
||||
isServerStarted: box.get(BNames.isServerStarted, defaultValue: false),
|
||||
|
@ -103,7 +100,6 @@ class ServerInstallationRepository {
|
|||
serverTypeIdentificator: serverTypeIdentificator!,
|
||||
dnsApiToken: dnsApiToken!,
|
||||
serverDomain: serverDomain!,
|
||||
backblazeCredential: backblazeCredential!,
|
||||
serverDetails: serverDetails!,
|
||||
rootUser: box.get(BNames.rootUser),
|
||||
isServerStarted: box.get(BNames.isServerStarted, defaultValue: false),
|
||||
|
@ -122,7 +118,6 @@ class ServerInstallationRepository {
|
|||
dnsApiToken: dnsApiToken,
|
||||
serverDomain: serverDomain,
|
||||
serverTypeIdentificator: serverTypeIdentificator,
|
||||
backblazeCredential: backblazeCredential,
|
||||
serverDetails: serverDetails,
|
||||
rootUser: box.get(BNames.rootUser),
|
||||
currentStep: _getCurrentRecoveryStep(
|
||||
|
@ -140,7 +135,6 @@ class ServerInstallationRepository {
|
|||
dnsApiToken: dnsApiToken,
|
||||
serverDomain: serverDomain,
|
||||
serverTypeIdentificator: serverTypeIdentificator,
|
||||
backblazeCredential: backblazeCredential,
|
||||
serverDetails: serverDetails,
|
||||
rootUser: box.get(BNames.rootUser),
|
||||
isServerStarted: box.get(BNames.isServerStarted, defaultValue: false),
|
||||
|
@ -162,9 +156,6 @@ class ServerInstallationRepository {
|
|||
if (serverDetails != null) {
|
||||
if (serverProviderToken != null) {
|
||||
if (serverDetails.provider != ServerProviderType.unknown) {
|
||||
if (serverDomain.provider != DnsProviderType.unknown) {
|
||||
return RecoveryStep.backblazeToken;
|
||||
}
|
||||
return RecoveryStep.dnsProviderToken;
|
||||
}
|
||||
return RecoveryStep.serverSelection;
|
||||
|
|
|
@ -5,7 +5,6 @@ abstract class ServerInstallationState extends Equatable {
|
|||
required this.providerApiToken,
|
||||
required this.serverTypeIdentificator,
|
||||
required this.dnsApiToken,
|
||||
required this.backblazeCredential,
|
||||
required this.serverDomain,
|
||||
required this.rootUser,
|
||||
required this.serverDetails,
|
||||
|
@ -20,7 +19,6 @@ abstract class ServerInstallationState extends Equatable {
|
|||
providerApiToken,
|
||||
serverTypeIdentificator,
|
||||
dnsApiToken,
|
||||
backblazeCredential,
|
||||
serverDomain,
|
||||
rootUser,
|
||||
serverDetails,
|
||||
|
@ -32,7 +30,6 @@ abstract class ServerInstallationState extends Equatable {
|
|||
final String? providerApiToken;
|
||||
final String? dnsApiToken;
|
||||
final String? serverTypeIdentificator;
|
||||
final BackupsCredential? backblazeCredential;
|
||||
final ServerDomain? serverDomain;
|
||||
final User? rootUser;
|
||||
final ServerHostingDetails? serverDetails;
|
||||
|
@ -44,7 +41,6 @@ abstract class ServerInstallationState extends Equatable {
|
|||
bool get isServerProviderApiKeyFilled => providerApiToken != null;
|
||||
bool get isServerTypeFilled => serverTypeIdentificator != null;
|
||||
bool get isDnsProviderFilled => dnsApiToken != null;
|
||||
bool get isBackupsProviderFilled => backblazeCredential != null;
|
||||
bool get isDomainSelected => serverDomain != null;
|
||||
bool get isPrimaryUserFilled => rootUser != null;
|
||||
bool get isServerCreated => serverDetails != null;
|
||||
|
@ -68,7 +64,6 @@ abstract class ServerInstallationState extends Equatable {
|
|||
isServerProviderApiKeyFilled,
|
||||
isServerTypeFilled,
|
||||
isDnsProviderFilled,
|
||||
isBackupsProviderFilled,
|
||||
isDomainSelected,
|
||||
isPrimaryUserFilled,
|
||||
isServerCreated,
|
||||
|
@ -91,7 +86,6 @@ class TimerState extends ServerInstallationNotFinished {
|
|||
providerApiToken: dataState.providerApiToken,
|
||||
serverTypeIdentificator: dataState.serverTypeIdentificator,
|
||||
dnsApiToken: dataState.dnsApiToken,
|
||||
backblazeCredential: dataState.backblazeCredential,
|
||||
serverDomain: dataState.serverDomain,
|
||||
rootUser: dataState.rootUser,
|
||||
serverDetails: dataState.serverDetails,
|
||||
|
@ -119,7 +113,6 @@ enum ServerSetupProgress {
|
|||
serverProviderFilled,
|
||||
servertTypeFilled,
|
||||
dnsProviderFilled,
|
||||
backblazeFilled,
|
||||
domainFilled,
|
||||
userFilled,
|
||||
serverCreated,
|
||||
|
@ -138,7 +131,6 @@ class ServerInstallationNotFinished extends ServerInstallationState {
|
|||
super.providerApiToken,
|
||||
super.serverTypeIdentificator,
|
||||
super.dnsApiToken,
|
||||
super.backblazeCredential,
|
||||
super.serverDomain,
|
||||
super.rootUser,
|
||||
super.serverDetails,
|
||||
|
@ -152,7 +144,6 @@ class ServerInstallationNotFinished extends ServerInstallationState {
|
|||
providerApiToken,
|
||||
serverTypeIdentificator,
|
||||
dnsApiToken,
|
||||
backblazeCredential,
|
||||
serverDomain,
|
||||
rootUser,
|
||||
serverDetails,
|
||||
|
@ -167,7 +158,6 @@ class ServerInstallationNotFinished extends ServerInstallationState {
|
|||
final String? providerApiToken,
|
||||
final String? serverTypeIdentificator,
|
||||
final String? dnsApiToken,
|
||||
final BackupsCredential? backblazeCredential,
|
||||
final ServerDomain? serverDomain,
|
||||
final User? rootUser,
|
||||
final ServerHostingDetails? serverDetails,
|
||||
|
@ -183,7 +173,6 @@ class ServerInstallationNotFinished extends ServerInstallationState {
|
|||
serverTypeIdentificator:
|
||||
serverTypeIdentificator ?? this.serverTypeIdentificator,
|
||||
dnsApiToken: dnsApiToken ?? this.dnsApiToken,
|
||||
backblazeCredential: backblazeCredential ?? this.backblazeCredential,
|
||||
serverDomain: serverDomain ?? this.serverDomain,
|
||||
rootUser: rootUser ?? this.rootUser,
|
||||
serverDetails: serverDetails ?? this.serverDetails,
|
||||
|
@ -202,7 +191,6 @@ class ServerInstallationNotFinished extends ServerInstallationState {
|
|||
providerApiToken: providerApiToken!,
|
||||
serverTypeIdentificator: serverTypeIdentificator!,
|
||||
dnsApiToken: dnsApiToken!,
|
||||
backblazeCredential: backblazeCredential!,
|
||||
serverDomain: serverDomain!,
|
||||
rootUser: rootUser!,
|
||||
serverDetails: serverDetails!,
|
||||
|
@ -219,7 +207,6 @@ class ServerInstallationEmpty extends ServerInstallationNotFinished {
|
|||
providerApiToken: null,
|
||||
serverTypeIdentificator: null,
|
||||
dnsApiToken: null,
|
||||
backblazeCredential: null,
|
||||
serverDomain: null,
|
||||
rootUser: null,
|
||||
serverDetails: null,
|
||||
|
@ -237,7 +224,6 @@ class ServerInstallationFinished extends ServerInstallationState {
|
|||
required String super.providerApiToken,
|
||||
required String super.serverTypeIdentificator,
|
||||
required String super.dnsApiToken,
|
||||
required BackupsCredential super.backblazeCredential,
|
||||
required ServerDomain super.serverDomain,
|
||||
required User super.rootUser,
|
||||
required ServerHostingDetails super.serverDetails,
|
||||
|
@ -252,7 +238,6 @@ class ServerInstallationFinished extends ServerInstallationState {
|
|||
providerApiToken,
|
||||
serverTypeIdentificator,
|
||||
dnsApiToken,
|
||||
backblazeCredential,
|
||||
serverDomain,
|
||||
rootUser,
|
||||
serverDetails,
|
||||
|
@ -270,7 +255,6 @@ enum RecoveryStep {
|
|||
serverProviderToken,
|
||||
serverSelection,
|
||||
dnsProviderToken,
|
||||
backblazeToken,
|
||||
}
|
||||
|
||||
enum ServerRecoveryCapabilities {
|
||||
|
@ -292,7 +276,6 @@ class ServerInstallationRecovery extends ServerInstallationState {
|
|||
super.providerApiToken,
|
||||
super.serverTypeIdentificator,
|
||||
super.dnsApiToken,
|
||||
super.backblazeCredential,
|
||||
super.serverDomain,
|
||||
super.rootUser,
|
||||
super.serverDetails,
|
||||
|
@ -310,7 +293,6 @@ class ServerInstallationRecovery extends ServerInstallationState {
|
|||
providerApiToken,
|
||||
serverTypeIdentificator,
|
||||
dnsApiToken,
|
||||
backblazeCredential,
|
||||
serverDomain,
|
||||
rootUser,
|
||||
serverDetails,
|
||||
|
@ -324,7 +306,6 @@ class ServerInstallationRecovery extends ServerInstallationState {
|
|||
final String? providerApiToken,
|
||||
final String? serverTypeIdentificator,
|
||||
final String? dnsApiToken,
|
||||
final BackupsCredential? backblazeCredential,
|
||||
final ServerDomain? serverDomain,
|
||||
final User? rootUser,
|
||||
final ServerHostingDetails? serverDetails,
|
||||
|
@ -336,7 +317,6 @@ class ServerInstallationRecovery extends ServerInstallationState {
|
|||
serverTypeIdentificator:
|
||||
serverTypeIdentificator ?? this.serverTypeIdentificator,
|
||||
dnsApiToken: dnsApiToken ?? this.dnsApiToken,
|
||||
backblazeCredential: backblazeCredential ?? this.backblazeCredential,
|
||||
serverDomain: serverDomain ?? this.serverDomain,
|
||||
rootUser: rootUser ?? this.rootUser,
|
||||
serverDetails: serverDetails ?? this.serverDetails,
|
||||
|
@ -348,7 +328,6 @@ class ServerInstallationRecovery extends ServerInstallationState {
|
|||
providerApiToken: providerApiToken!,
|
||||
serverTypeIdentificator: serverTypeIdentificator!,
|
||||
dnsApiToken: dnsApiToken!,
|
||||
backblazeCredential: backblazeCredential!,
|
||||
serverDomain: serverDomain!,
|
||||
rootUser: rootUser!,
|
||||
serverDetails: serverDetails!,
|
||||
|
|
|
@ -15,6 +15,7 @@ import 'package:selfprivacy/ui/components/jobs_content/server_job_card.dart';
|
|||
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
||||
import 'package:selfprivacy/ui/helpers/modals.dart';
|
||||
import 'package:selfprivacy/ui/pages/backups/backup_provider_picker.dart';
|
||||
import 'package:selfprivacy/ui/pages/backups/change_period_modal.dart';
|
||||
import 'package:selfprivacy/ui/pages/backups/change_rotation_quotas_modal.dart';
|
||||
import 'package:selfprivacy/ui/pages/backups/copy_encryption_key_modal.dart';
|
||||
|
@ -75,9 +76,7 @@ class BackupDetailsPage extends StatelessWidget {
|
|||
BrandButton.rised(
|
||||
onPressed: preventActions
|
||||
? null
|
||||
: () async {
|
||||
await context.read<BackupsCubit>().initializeBackups();
|
||||
},
|
||||
: () => context.pushRoute(BackupProviderPicker()),
|
||||
text: 'backup.initialize'.tr(),
|
||||
),
|
||||
],
|
||||
|
|
65
lib/ui/pages/backups/backup_provider_picker.dart
Normal file
65
lib/ui/pages/backups/backup_provider_picker.dart
Normal file
|
@ -0,0 +1,65 @@
|
|||
import 'package:cubit_form/cubit_form.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:selfprivacy/logic/cubit/forms/setup/initializing/backblaze_form_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/support_system/support_system_cubit.dart';
|
||||
import 'package:selfprivacy/ui/components/buttons/brand_button.dart';
|
||||
import 'package:selfprivacy/ui/layouts/responsive_layout_with_infobox.dart';
|
||||
|
||||
class BackupProviderPicker extends StatelessWidget {
|
||||
const BackupProviderPicker({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(final BuildContext context) => ResponsiveLayoutWithInfobox(
|
||||
topChild: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${'initializing.connect_to_server_provider'.tr()}Backblaze',
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
primaryColumn: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CubitFormTextField(
|
||||
autofocus: true,
|
||||
formFieldCubit: context.read<BackblazeFormCubit>().keyId,
|
||||
textAlign: TextAlign.center,
|
||||
scrollPadding: const EdgeInsets.only(bottom: 70),
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'KeyID',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
CubitFormTextField(
|
||||
formFieldCubit: context.read<BackblazeFormCubit>().applicationKey,
|
||||
textAlign: TextAlign.center,
|
||||
scrollPadding: const EdgeInsets.only(bottom: 70),
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Master Application Key',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
BrandButton.rised(
|
||||
onPressed: () => context.read<BackblazeFormCubit>().trySubmit(),
|
||||
text: 'basis.connect'.tr(),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BrandButton.text(
|
||||
onPressed: () {
|
||||
context.read<SupportSystemCubit>().showArticle(
|
||||
article: 'how_backblaze',
|
||||
context: context,
|
||||
);
|
||||
Scaffold.of(context).openEndDrawer();
|
||||
},
|
||||
title: 'initializing.how'.tr(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
|
@ -42,7 +42,6 @@ class InitializingPage extends StatelessWidget {
|
|||
() => _stepServerProviderToken(cubit),
|
||||
() => _stepServerType(cubit),
|
||||
() => _stepDnsProviderToken(cubit),
|
||||
() => _stepBackblaze(cubit),
|
||||
() => _stepDomain(cubit),
|
||||
() => _stepUser(cubit),
|
||||
() => _stepServer(cubit),
|
||||
|
@ -254,69 +253,6 @@ class InitializingPage extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
|
||||
Widget _stepBackblaze(final ServerInstallationCubit initializingCubit) =>
|
||||
BlocProvider(
|
||||
create: (final context) => BackblazeFormCubit(initializingCubit),
|
||||
child: Builder(
|
||||
builder: (final context) {
|
||||
final formCubitState = context.watch<BackblazeFormCubit>().state;
|
||||
return ResponsiveLayoutWithInfobox(
|
||||
topChild: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${'initializing.connect_to_server_provider'.tr()}Backblaze',
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
primaryColumn: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CubitFormTextField(
|
||||
autofocus: true,
|
||||
formFieldCubit: context.read<BackblazeFormCubit>().keyId,
|
||||
textAlign: TextAlign.center,
|
||||
scrollPadding: const EdgeInsets.only(bottom: 70),
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'KeyID',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
CubitFormTextField(
|
||||
formFieldCubit:
|
||||
context.read<BackblazeFormCubit>().applicationKey,
|
||||
textAlign: TextAlign.center,
|
||||
scrollPadding: const EdgeInsets.only(bottom: 70),
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Master Application Key',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
BrandButton.rised(
|
||||
onPressed: formCubitState.isSubmitting
|
||||
? null
|
||||
: () => context.read<BackblazeFormCubit>().trySubmit(),
|
||||
text: 'basis.connect'.tr(),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BrandButton.text(
|
||||
onPressed: () {
|
||||
context.read<SupportSystemCubit>().showArticle(
|
||||
article: 'how_backblaze',
|
||||
context: context,
|
||||
);
|
||||
Scaffold.of(context).openEndDrawer();
|
||||
},
|
||||
title: 'initializing.how'.tr(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
Widget _stepDomain(final ServerInstallationCubit initializingCubit) =>
|
||||
BlocProvider(
|
||||
create: (final context) => DomainSetupCubit(initializingCubit)..load(),
|
||||
|
|
|
@ -11,7 +11,6 @@ import 'package:selfprivacy/ui/pages/root_route.dart';
|
|||
import 'package:selfprivacy/ui/pages/setup/recovering/recover_by_old_token.dart';
|
||||
import 'package:selfprivacy/ui/pages/setup/recovering/recover_by_recovery_key.dart';
|
||||
import 'package:selfprivacy/ui/pages/setup/recovering/recover_by_new_device_key.dart';
|
||||
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_confirm_backblaze.dart';
|
||||
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_confirm_dns.dart';
|
||||
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_confirm_server.dart';
|
||||
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_server_provider_connected.dart';
|
||||
|
@ -58,9 +57,6 @@ class RecoveryRouting extends StatelessWidget {
|
|||
case RecoveryStep.dnsProviderToken:
|
||||
currentPage = const RecoveryConfirmDns();
|
||||
break;
|
||||
case RecoveryStep.backblazeToken:
|
||||
currentPage = const RecoveryConfirmBackblaze();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue