mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-26 18:56:38 +00:00
Disable unavailable functionality when server is not created
- Remove create and upgrade server jobs when server is not there - Disable root SSH panel page when server is not there
This commit is contained in:
parent
20f6e8156c
commit
2d96b4505e
|
@ -36,7 +36,7 @@
|
|||
"about_project": "About us",
|
||||
"about_app": "About application",
|
||||
"onboarding": "Onboarding",
|
||||
"create_ssh_key": "Create ssh key",
|
||||
"create_ssh_key": "Create SSH key",
|
||||
"generate_key": "Generate key",
|
||||
"generate_key_text": "You can generate ssh key",
|
||||
"console": "Console",
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:selfprivacy/config/get_it_config.dart';
|
|||
import 'package:selfprivacy/logic/api_maps/backblaze.dart';
|
||||
import 'package:selfprivacy/logic/api_maps/server.dart';
|
||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart';
|
||||
import 'package:selfprivacy/logic/models/json/backup.dart';
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:cubit_form/cubit_form.dart';
|
||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:selfprivacy/logic/api_maps/server.dart';
|
||||
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||
|
||||
part 'services_state.dart';
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:hive/hive.dart';
|
||||
import 'package:selfprivacy/config/hive_config.dart';
|
||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||
|
||||
import '../../api_maps/server.dart';
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:selfprivacy/config/brand_colors.dart';
|
|||
import 'package:selfprivacy/config/brand_theme.dart';
|
||||
import 'package:selfprivacy/config/get_it_config.dart';
|
||||
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||
import 'package:selfprivacy/ui/components/action_button/action_button.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
|
||||
|
@ -19,38 +20,45 @@ class JobsContent extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<JobsCubit, JobsState>(
|
||||
builder: (context, state) {
|
||||
late final List<Widget> widgets;
|
||||
late List<Widget> widgets;
|
||||
var installationState = context.read<ServerInstallationCubit>().state;
|
||||
if (state is JobsStateEmpty) {
|
||||
widgets = [
|
||||
SizedBox(height: 80),
|
||||
Center(child: BrandText.body1('jobs.empty'.tr())),
|
||||
SizedBox(height: 80),
|
||||
BrandButton.rised(
|
||||
onPressed: () => context.read<JobsCubit>().upgradeServer(),
|
||||
text: 'jobs.upgradeServer'.tr(),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
BrandButton.text(
|
||||
onPressed: () {
|
||||
var nav = getIt<NavigationService>();
|
||||
nav.showPopUpDialog(BrandAlert(
|
||||
title: 'jobs.rebootServer'.tr(),
|
||||
contentText: 'modals.3'.tr(),
|
||||
actions: [
|
||||
ActionButton(
|
||||
text: 'basis.cancel'.tr(),
|
||||
),
|
||||
ActionButton(
|
||||
onPressed: () =>
|
||||
{context.read<JobsCubit>().rebootServer()},
|
||||
text: 'modals.9'.tr(),
|
||||
)
|
||||
],
|
||||
));
|
||||
},
|
||||
title: 'jobs.rebootServer'.tr(),
|
||||
),
|
||||
];
|
||||
|
||||
if (installationState is ServerInstallationFinished) {
|
||||
widgets = [
|
||||
...widgets,
|
||||
SizedBox(height: 80),
|
||||
BrandButton.rised(
|
||||
onPressed: () => context.read<JobsCubit>().upgradeServer(),
|
||||
text: 'jobs.upgradeServer'.tr(),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
BrandButton.text(
|
||||
onPressed: () {
|
||||
var nav = getIt<NavigationService>();
|
||||
nav.showPopUpDialog(BrandAlert(
|
||||
title: 'jobs.rebootServer'.tr(),
|
||||
contentText: 'modals.3'.tr(),
|
||||
actions: [
|
||||
ActionButton(
|
||||
text: 'basis.cancel'.tr(),
|
||||
),
|
||||
ActionButton(
|
||||
onPressed: () =>
|
||||
{context.read<JobsCubit>().rebootServer()},
|
||||
text: 'modals.9'.tr(),
|
||||
)
|
||||
],
|
||||
));
|
||||
},
|
||||
title: 'jobs.rebootServer'.tr(),
|
||||
),
|
||||
];
|
||||
}
|
||||
} else if (state is JobsStateLoading) {
|
||||
widgets = [
|
||||
SizedBox(height: 80),
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:ionicons/ionicons.dart';
|
||||
import 'package:selfprivacy/config/brand_colors.dart';
|
||||
import 'package:selfprivacy/config/brand_theme.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_divider/brand_divider.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
||||
|
@ -70,6 +71,8 @@ class MorePage extends StatelessWidget {
|
|||
goTo: Console(),
|
||||
),
|
||||
_NavItem(
|
||||
isEnabled: context.read<ServerInstallationCubit>().state
|
||||
is ServerInstallationFinished,
|
||||
title: 'more.create_ssh_key'.tr(),
|
||||
iconData: Ionicons.key_outline,
|
||||
goTo: SshKeysPage(
|
||||
|
@ -87,6 +90,7 @@ class MorePage extends StatelessWidget {
|
|||
class _NavItem extends StatelessWidget {
|
||||
const _NavItem({
|
||||
Key? key,
|
||||
this.isEnabled = true,
|
||||
required this.iconData,
|
||||
required this.goTo,
|
||||
required this.title,
|
||||
|
@ -95,15 +99,18 @@ class _NavItem extends StatelessWidget {
|
|||
final IconData iconData;
|
||||
final Widget goTo;
|
||||
final String title;
|
||||
final bool isEnabled;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => Navigator.of(context).push(materialRoute(goTo)),
|
||||
onTap: isEnabled
|
||||
? () => Navigator.of(context).push(materialRoute(goTo))
|
||||
: null,
|
||||
child: _MoreMenuItem(
|
||||
iconData: iconData,
|
||||
title: title,
|
||||
isActive: true,
|
||||
isActive: isEnabled,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue