mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-28 19:56:50 +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_project": "About us",
|
||||||
"about_app": "About application",
|
"about_app": "About application",
|
||||||
"onboarding": "Onboarding",
|
"onboarding": "Onboarding",
|
||||||
"create_ssh_key": "Create ssh key",
|
"create_ssh_key": "Create SSH key",
|
||||||
"generate_key": "Generate key",
|
"generate_key": "Generate key",
|
||||||
"generate_key_text": "You can generate ssh key",
|
"generate_key_text": "You can generate ssh key",
|
||||||
"console": "Console",
|
"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/backblaze.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/server.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/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/hive/backblaze_bucket.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/backup.dart';
|
import 'package:selfprivacy/logic/models/json/backup.dart';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:cubit_form/cubit_form.dart';
|
import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.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/hive/server_domain.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/dns_records.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/api_maps/server.dart';
|
||||||
import 'package:selfprivacy/logic/common_enum/common_enum.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/app_config_dependent/authentication_dependend_cubit.dart';
|
||||||
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
|
|
||||||
part 'services_state.dart';
|
part 'services_state.dart';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:selfprivacy/config/hive_config.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/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 'package:selfprivacy/logic/models/hive/user.dart';
|
||||||
|
|
||||||
import '../../api_maps/server.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/brand_theme.dart';
|
||||||
import 'package:selfprivacy/config/get_it_config.dart';
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.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/action_button/action_button.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
|
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
|
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
|
||||||
|
@ -19,11 +20,17 @@ class JobsContent extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<JobsCubit, JobsState>(
|
return BlocBuilder<JobsCubit, JobsState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
late final List<Widget> widgets;
|
late List<Widget> widgets;
|
||||||
|
var installationState = context.read<ServerInstallationCubit>().state;
|
||||||
if (state is JobsStateEmpty) {
|
if (state is JobsStateEmpty) {
|
||||||
widgets = [
|
widgets = [
|
||||||
SizedBox(height: 80),
|
SizedBox(height: 80),
|
||||||
Center(child: BrandText.body1('jobs.empty'.tr())),
|
Center(child: BrandText.body1('jobs.empty'.tr())),
|
||||||
|
];
|
||||||
|
|
||||||
|
if (installationState is ServerInstallationFinished) {
|
||||||
|
widgets = [
|
||||||
|
...widgets,
|
||||||
SizedBox(height: 80),
|
SizedBox(height: 80),
|
||||||
BrandButton.rised(
|
BrandButton.rised(
|
||||||
onPressed: () => context.read<JobsCubit>().upgradeServer(),
|
onPressed: () => context.read<JobsCubit>().upgradeServer(),
|
||||||
|
@ -51,6 +58,7 @@ class JobsContent extends StatelessWidget {
|
||||||
title: 'jobs.rebootServer'.tr(),
|
title: 'jobs.rebootServer'.tr(),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
}
|
||||||
} else if (state is JobsStateLoading) {
|
} else if (state is JobsStateLoading) {
|
||||||
widgets = [
|
widgets = [
|
||||||
SizedBox(height: 80),
|
SizedBox(height: 80),
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:ionicons/ionicons.dart';
|
import 'package:ionicons/ionicons.dart';
|
||||||
import 'package:selfprivacy/config/brand_colors.dart';
|
import 'package:selfprivacy/config/brand_colors.dart';
|
||||||
import 'package:selfprivacy/config/brand_theme.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_divider/brand_divider.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
||||||
|
@ -70,6 +71,8 @@ class MorePage extends StatelessWidget {
|
||||||
goTo: Console(),
|
goTo: Console(),
|
||||||
),
|
),
|
||||||
_NavItem(
|
_NavItem(
|
||||||
|
isEnabled: context.read<ServerInstallationCubit>().state
|
||||||
|
is ServerInstallationFinished,
|
||||||
title: 'more.create_ssh_key'.tr(),
|
title: 'more.create_ssh_key'.tr(),
|
||||||
iconData: Ionicons.key_outline,
|
iconData: Ionicons.key_outline,
|
||||||
goTo: SshKeysPage(
|
goTo: SshKeysPage(
|
||||||
|
@ -87,6 +90,7 @@ class MorePage extends StatelessWidget {
|
||||||
class _NavItem extends StatelessWidget {
|
class _NavItem extends StatelessWidget {
|
||||||
const _NavItem({
|
const _NavItem({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
this.isEnabled = true,
|
||||||
required this.iconData,
|
required this.iconData,
|
||||||
required this.goTo,
|
required this.goTo,
|
||||||
required this.title,
|
required this.title,
|
||||||
|
@ -95,15 +99,18 @@ class _NavItem extends StatelessWidget {
|
||||||
final IconData iconData;
|
final IconData iconData;
|
||||||
final Widget goTo;
|
final Widget goTo;
|
||||||
final String title;
|
final String title;
|
||||||
|
final bool isEnabled;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => Navigator.of(context).push(materialRoute(goTo)),
|
onTap: isEnabled
|
||||||
|
? () => Navigator.of(context).push(materialRoute(goTo))
|
||||||
|
: null,
|
||||||
child: _MoreMenuItem(
|
child: _MoreMenuItem(
|
||||||
iconData: iconData,
|
iconData: iconData,
|
||||||
title: title,
|
title: title,
|
||||||
isActive: true,
|
isActive: isEnabled,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue