2022-03-23 14:07:52 +00:00
|
|
|
part of 'ssh_keys.dart';
|
|
|
|
|
|
|
|
class _NewSshKey extends StatelessWidget {
|
2022-05-24 18:55:39 +00:00
|
|
|
const _NewSshKey(this.user);
|
2022-06-05 22:40:34 +00:00
|
|
|
final User user;
|
2022-03-23 14:07:52 +00:00
|
|
|
|
|
|
|
@override
|
2022-06-05 22:40:34 +00:00
|
|
|
Widget build(final BuildContext context) => BrandBottomSheet(
|
|
|
|
child: BlocProvider(
|
|
|
|
create: (final context) {
|
|
|
|
final jobCubit = context.read<JobsCubit>();
|
|
|
|
final jobState = jobCubit.state;
|
|
|
|
if (jobState is JobsStateWithJobs) {
|
|
|
|
final jobs = jobState.jobList;
|
|
|
|
for (final job in jobs) {
|
|
|
|
if (job is CreateSSHKeyJob && job.user.login == user.login) {
|
|
|
|
user.sshKeys.add(job.publicKey);
|
|
|
|
}
|
2022-03-23 14:07:52 +00:00
|
|
|
}
|
2022-05-24 18:55:39 +00:00
|
|
|
}
|
2022-06-05 22:40:34 +00:00
|
|
|
return SshFormCubit(
|
|
|
|
jobsCubit: jobCubit,
|
|
|
|
user: user,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Builder(
|
|
|
|
builder: (final context) {
|
|
|
|
final formCubitState = context.watch<SshFormCubit>().state;
|
2022-03-23 14:07:52 +00:00
|
|
|
|
2022-06-05 22:40:34 +00:00
|
|
|
return BlocListener<SshFormCubit, FormCubitState>(
|
|
|
|
listener: (final context, final state) {
|
|
|
|
if (state.isSubmitted) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
BrandHeader(
|
|
|
|
title: user.login,
|
|
|
|
),
|
|
|
|
const SizedBox(width: 14),
|
|
|
|
Padding(
|
|
|
|
padding: paddingH15V0,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
IntrinsicHeight(
|
|
|
|
child: CubitFormTextField(
|
|
|
|
formFieldCubit: context.read<SshFormCubit>().key,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
labelText: 'ssh.input_label'.tr(),
|
|
|
|
),
|
|
|
|
),
|
2022-03-23 14:07:52 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
const SizedBox(height: 30),
|
|
|
|
BrandButton.rised(
|
|
|
|
onPressed: formCubitState.isSubmitting
|
|
|
|
? null
|
|
|
|
: () =>
|
|
|
|
context.read<SshFormCubit>().trySubmit(),
|
|
|
|
text: 'ssh.create'.tr(),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 30),
|
|
|
|
],
|
2022-03-23 14:07:52 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
],
|
2022-03-23 14:07:52 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2022-03-23 14:07:52 +00:00
|
|
|
}
|