mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 09:31:13 +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,
|
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
|
@override
|
||||||
List<Object?> get props => [_hashCode];
|
List<Object?> get props => [_hashCode];
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,9 @@ class JobsContent extends StatelessWidget {
|
||||||
final bool hasRemovableJobs =
|
final bool hasRemovableJobs =
|
||||||
context.watch<ServerJobsBloc>().state.hasRemovableJobs;
|
context.watch<ServerJobsBloc>().state.hasRemovableJobs;
|
||||||
|
|
||||||
|
final bool hasBlockingJobs =
|
||||||
|
context.watch<ServerJobsBloc>().state.hasJobsBlockingRebuild;
|
||||||
|
|
||||||
return BlocBuilder<JobsCubit, JobsState>(
|
return BlocBuilder<JobsCubit, JobsState>(
|
||||||
builder: (final context, final state) {
|
builder: (final context, final state) {
|
||||||
late List<Widget> widgets;
|
late List<Widget> widgets;
|
||||||
|
@ -422,7 +425,9 @@ class JobsContent extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
BrandButton.rised(
|
BrandButton.rised(
|
||||||
onPressed: () => context.read<JobsCubit>().applyAll(),
|
onPressed: hasBlockingJobs
|
||||||
|
? null
|
||||||
|
: () => context.read<JobsCubit>().applyAll(),
|
||||||
text: 'jobs.start'.tr(),
|
text: 'jobs.start'.tr(),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue