[ui] Implement provider test button #49
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
parent
3c8e1d5986
commit
45a46650a2
@ -21,6 +21,8 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
Mount? _mount;
|
Mount? _mount;
|
||||||
final _mountNameController = TextEditingController();
|
final _mountNameController = TextEditingController();
|
||||||
String _mountType = "";
|
String _mountType = "";
|
||||||
|
bool _allowAdd = false;
|
||||||
|
|
||||||
final Map<String, Map<String, dynamic>> _settings = {
|
final Map<String, Map<String, dynamic>> _settings = {
|
||||||
"": {},
|
"": {},
|
||||||
"Encrypt": createDefaultSettings("Encrypt"),
|
"Encrypt": createDefaultSettings("Encrypt"),
|
||||||
@ -123,6 +125,7 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
child: MountSettingsWidget(
|
child: MountSettingsWidget(
|
||||||
isAdd: true,
|
isAdd: true,
|
||||||
mount: _mount!,
|
mount: _mount!,
|
||||||
|
onChanged: () => setState(() => _allowAdd = false),
|
||||||
settings: _settings[_mountType]!,
|
settings: _settings[_mountType]!,
|
||||||
showAdvanced: false,
|
showAdvanced: false,
|
||||||
),
|
),
|
||||||
@ -132,6 +135,7 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
const SizedBox(height: constants.padding),
|
const SizedBox(height: constants.padding),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
|
if (_allowAdd) ...[
|
||||||
ElevatedButton.icon(
|
ElevatedButton.icon(
|
||||||
label: const Text('Add'),
|
label: const Text('Add'),
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
@ -188,7 +192,8 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(width: constants.padding),
|
],
|
||||||
|
if (!_allowAdd)
|
||||||
ElevatedButton.icon(
|
ElevatedButton.icon(
|
||||||
label: const Text('Test'),
|
label: const Text('Test'),
|
||||||
icon: const Icon(Icons.check),
|
icon: const Icon(Icons.check),
|
||||||
@ -237,14 +242,20 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_allowAdd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final success = await _mount!.test();
|
final success = await _mount!.test();
|
||||||
if (!mounted) {
|
if (!mounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setState(() => _allowAdd = success);
|
||||||
|
|
||||||
displayErrorMessage(
|
displayErrorMessage(
|
||||||
context,
|
context,
|
||||||
success ? "Success!" : "Provider settings are invalid!",
|
success ? "Success" : "Provider settings are invalid!",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,9 +18,11 @@ class MountSettingsWidget extends StatefulWidget {
|
|||||||
final bool showAdvanced;
|
final bool showAdvanced;
|
||||||
final Mount mount;
|
final Mount mount;
|
||||||
final Map<String, dynamic> settings;
|
final Map<String, dynamic> settings;
|
||||||
|
final Function? onChanged;
|
||||||
const MountSettingsWidget({
|
const MountSettingsWidget({
|
||||||
super.key,
|
super.key,
|
||||||
this.isAdd = false,
|
this.isAdd = false,
|
||||||
|
this.onChanged,
|
||||||
required this.mount,
|
required this.mount,
|
||||||
required this.settings,
|
required this.settings,
|
||||||
required this.showAdvanced,
|
required this.showAdvanced,
|
||||||
@ -1020,6 +1022,10 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (widget.onChanged != null) {
|
||||||
|
widget.onChanged!();
|
||||||
|
}
|
||||||
|
|
||||||
super.setState(fn);
|
super.setState(fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user