mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 17:11:14 +00:00
refactor: Remove binds migration
This commit is contained in:
parent
24e5c8baee
commit
332e31b655
|
@ -4,8 +4,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:ionicons/ionicons.dart';
|
||||
import 'package:selfprivacy/config/brand_theme.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_volumes/server_volume_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/services/services_cubit.dart';
|
||||
import 'package:selfprivacy/ui/components/cards/filled_card.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
||||
|
@ -21,9 +19,6 @@ class MorePage extends StatelessWidget {
|
|||
final bool isReady = context.watch<ServerInstallationCubit>().state
|
||||
is ServerInstallationFinished;
|
||||
|
||||
final bool? usesBinds =
|
||||
context.watch<ApiServerVolumeCubit>().state.usesBinds;
|
||||
|
||||
return Scaffold(
|
||||
appBar: Breakpoints.small.isActive(context)
|
||||
? PreferredSize(
|
||||
|
@ -39,31 +34,6 @@ class MorePage extends StatelessWidget {
|
|||
padding: paddingH15V0,
|
||||
child: Column(
|
||||
children: [
|
||||
if (isReady && usesBinds != null && !usesBinds)
|
||||
_MoreMenuItem(
|
||||
title: 'storage.start_migration_button'.tr(),
|
||||
iconData: Icons.drive_file_move_outline,
|
||||
goTo: () => ServicesMigrationRoute(
|
||||
diskStatus:
|
||||
context.read<ApiServerVolumeCubit>().state.diskStatus,
|
||||
services: context
|
||||
.read<ServicesCubit>()
|
||||
.state
|
||||
.services
|
||||
.where(
|
||||
(final service) =>
|
||||
service.id == 'bitwarden' ||
|
||||
service.id == 'gitea' ||
|
||||
service.id == 'pleroma' ||
|
||||
service.id == 'mailserver' ||
|
||||
service.id == 'nextcloud',
|
||||
)
|
||||
.toList(),
|
||||
isMigration: true,
|
||||
),
|
||||
subtitle: 'storage.data_migration_notice'.tr(),
|
||||
accent: true,
|
||||
),
|
||||
if (!isReady)
|
||||
_MoreMenuItem(
|
||||
title: 'more_page.configuration_wizard'.tr(),
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_jobs/server_jobs_cubit.dart';
|
||||
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
||||
import 'package:selfprivacy/ui/components/buttons/brand_button.dart';
|
||||
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_linear_indicator/brand_linear_indicator.dart';
|
||||
import 'package:selfprivacy/ui/pages/root_route.dart';
|
||||
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
||||
|
||||
class MigrationProcessPage extends StatefulWidget {
|
||||
const MigrationProcessPage({super.key});
|
||||
|
||||
@override
|
||||
State<MigrationProcessPage> createState() => _MigrationProcessPageState();
|
||||
}
|
||||
|
||||
class _MigrationProcessPageState extends State<MigrationProcessPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(final BuildContext context) {
|
||||
ServerJob? job;
|
||||
String? subtitle = '';
|
||||
double value = 0.0;
|
||||
List<Widget> children = [];
|
||||
|
||||
final serverJobsState = context.watch<ServerJobsCubit>().state;
|
||||
if (serverJobsState.migrationJobUid != null) {
|
||||
job = context.read<ServerJobsCubit>().getServerJobByUid(
|
||||
serverJobsState.migrationJobUid!,
|
||||
);
|
||||
}
|
||||
|
||||
if (job == null) {
|
||||
subtitle = 'basis.loading'.tr();
|
||||
} else {
|
||||
value = job.progress == null ? 0.0 : job.progress! / 100;
|
||||
subtitle = job.statusText;
|
||||
children = [
|
||||
...children,
|
||||
const SizedBox(height: 16),
|
||||
if (job.finishedAt != null)
|
||||
Text(
|
||||
job.result!,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
if (job.finishedAt != null) const SizedBox(height: 16),
|
||||
if (job.finishedAt != null)
|
||||
BrandButton.filled(
|
||||
child: Text('storage.migration_done'.tr()),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
materialRoute(const RootPage()),
|
||||
(final predicate) => false,
|
||||
);
|
||||
},
|
||||
),
|
||||
];
|
||||
}
|
||||
return BrandHeroScreen(
|
||||
hasBackButton: false,
|
||||
heroTitle: 'storage.migration_process'.tr(),
|
||||
heroSubtitle: subtitle,
|
||||
children: [
|
||||
BrandLinearIndicator(
|
||||
value: value,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
backgroundColor: Theme.of(context).colorScheme.surfaceVariant,
|
||||
height: 4.0,
|
||||
),
|
||||
...children,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
|
@ -18,13 +18,11 @@ class ServicesMigrationPage extends StatefulWidget {
|
|||
const ServicesMigrationPage({
|
||||
required this.services,
|
||||
required this.diskStatus,
|
||||
required this.isMigration,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final DiskStatus diskStatus;
|
||||
final List<Service> services;
|
||||
final bool isMigration;
|
||||
|
||||
@override
|
||||
State<ServicesMigrationPage> createState() => _ServicesMigrationPageState();
|
||||
|
@ -171,22 +169,16 @@ class _ServicesMigrationPageState extends State<ServicesMigrationPage> {
|
|||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (widget.isMigration || (!widget.isMigration && isVolumePicked))
|
||||
if (isVolumePicked)
|
||||
BrandButton.filled(
|
||||
child: Text('storage.start_migration_button'.tr()),
|
||||
onPressed: () {
|
||||
if (widget.isMigration) {
|
||||
context.read<ServerJobsCubit>().migrateToBinds(
|
||||
serviceToDisk,
|
||||
);
|
||||
} else {
|
||||
for (final service in widget.services) {
|
||||
if (serviceToDisk[service.id] != null) {
|
||||
context.read<ServicesCubit>().moveService(
|
||||
service.id,
|
||||
serviceToDisk[service.id]!,
|
||||
);
|
||||
}
|
||||
for (final service in widget.services) {
|
||||
if (serviceToDisk[service.id] != null) {
|
||||
context.read<ServicesCubit>().moveService(
|
||||
service.id,
|
||||
serviceToDisk[service.id]!,
|
||||
);
|
||||
}
|
||||
}
|
||||
context.router.popUntilRoot();
|
||||
|
|
|
@ -118,7 +118,6 @@ class _ServicePageState extends State<ServicePage> {
|
|||
services: [service],
|
||||
diskStatus:
|
||||
context.read<ApiServerVolumeCubit>().state.diskStatus,
|
||||
isMigration: false,
|
||||
),
|
||||
),
|
||||
leading: const Icon(Icons.drive_file_move_outlined),
|
||||
|
|
|
@ -159,7 +159,6 @@ abstract class _$RootRouter extends RootStackRouter {
|
|||
child: ServicesMigrationPage(
|
||||
services: args.services,
|
||||
diskStatus: args.diskStatus,
|
||||
isMigration: args.isMigration,
|
||||
key: args.key,
|
||||
),
|
||||
);
|
||||
|
@ -576,7 +575,6 @@ class ServicesMigrationRoute extends PageRouteInfo<ServicesMigrationRouteArgs> {
|
|||
ServicesMigrationRoute({
|
||||
required List<Service> services,
|
||||
required DiskStatus diskStatus,
|
||||
required bool isMigration,
|
||||
Key? key,
|
||||
List<PageRouteInfo>? children,
|
||||
}) : super(
|
||||
|
@ -584,7 +582,6 @@ class ServicesMigrationRoute extends PageRouteInfo<ServicesMigrationRouteArgs> {
|
|||
args: ServicesMigrationRouteArgs(
|
||||
services: services,
|
||||
diskStatus: diskStatus,
|
||||
isMigration: isMigration,
|
||||
key: key,
|
||||
),
|
||||
initialChildren: children,
|
||||
|
@ -600,7 +597,6 @@ class ServicesMigrationRouteArgs {
|
|||
const ServicesMigrationRouteArgs({
|
||||
required this.services,
|
||||
required this.diskStatus,
|
||||
required this.isMigration,
|
||||
this.key,
|
||||
});
|
||||
|
||||
|
@ -608,13 +604,11 @@ class ServicesMigrationRouteArgs {
|
|||
|
||||
final DiskStatus diskStatus;
|
||||
|
||||
final bool isMigration;
|
||||
|
||||
final Key? key;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServicesMigrationRouteArgs{services: $services, diskStatus: $diskStatus, isMigration: $isMigration, key: $key}';
|
||||
return 'ServicesMigrationRouteArgs{services: $services, diskStatus: $diskStatus, key: $key}';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue