mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 17:11:14 +00:00
feat(jobs): Block starting client-side jobs when server is rebuilding or moving a service
This commit is contained in:
parent
ff2b6b8f03
commit
b2384a5635
|
@ -36,6 +36,15 @@ sealed class ServerJobsState extends Equatable {
|
|||
job.status == JobStatusEnum.error,
|
||||
);
|
||||
|
||||
bool get hasJobsBlockingRebuild => serverJobList.any(
|
||||
(final job) =>
|
||||
(job.status == JobStatusEnum.running ||
|
||||
job.status == JobStatusEnum.created) &&
|
||||
(job.typeId.contains('system.nixos.rebuild') ||
|
||||
job.typeId.contains('system.nixos.upgrade') ||
|
||||
job.typeId.contains('move')),
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [_hashCode];
|
||||
}
|
||||
|
|
|
@ -53,6 +53,9 @@ class JobsContent extends StatelessWidget {
|
|||
final bool hasRemovableJobs =
|
||||
context.watch<ServerJobsBloc>().state.hasRemovableJobs;
|
||||
|
||||
final bool hasBlockingJobs =
|
||||
context.watch<ServerJobsBloc>().state.hasJobsBlockingRebuild;
|
||||
|
||||
return BlocBuilder<JobsCubit, JobsState>(
|
||||
builder: (final context, final state) {
|
||||
late List<Widget> widgets;
|
||||
|
@ -422,7 +425,9 @@ class JobsContent extends StatelessWidget {
|
|||
),
|
||||
const SizedBox(height: 16),
|
||||
BrandButton.rised(
|
||||
onPressed: () => context.read<JobsCubit>().applyAll(),
|
||||
onPressed: hasBlockingJobs
|
||||
? null
|
||||
: () => context.read<JobsCubit>().applyAll(),
|
||||
text: 'jobs.start'.tr(),
|
||||
),
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue