make test optional
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2025-07-20 08:37:32 -05:00
parent 7a9ac2f063
commit 40409fcc4a
2 changed files with 79 additions and 89 deletions

View File

@@ -119,7 +119,10 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
reinterpret_cast<const char *>(&enable), sizeof(enable)); reinterpret_cast<const char *>(&enable), sizeof(enable));
#else // !defined(_WIN32) #else // !defined(_WIN32)
linger opt{1, 0}; linger opt{
.l_onoff = 1,
.l_linger = 0,
};
setsockopt(sock, SOL_SOCKET, SO_LINGER, setsockopt(sock, SOL_SOCKET, SO_LINGER,
reinterpret_cast<const char *>(&opt), sizeof(opt)); reinterpret_cast<const char *>(&opt), sizeof(opt));
#endif // defined(_WIN32) #endif // defined(_WIN32)

View File

@@ -21,7 +21,6 @@ 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 = {
"": {}, "": {},
@@ -71,11 +70,9 @@ class _AddMountScreenState extends State<AddMountScreen> {
DropdownButton<String>( DropdownButton<String>(
autofocus: true, autofocus: true,
value: _mountType, value: _mountType,
onChanged: onChanged: (mountType) =>
(mountType) =>
_handleChange(auth, mountType ?? ''), _handleChange(auth, mountType ?? ''),
items: items: constants.providerTypeList
constants.providerTypeList
.map<DropdownMenuItem<String>>((item) { .map<DropdownMenuItem<String>>((item) {
return DropdownMenuItem<String>( return DropdownMenuItem<String>(
value: item, value: item,
@@ -125,7 +122,6 @@ 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,
), ),
@@ -135,7 +131,12 @@ class _AddMountScreenState extends State<AddMountScreen> {
const SizedBox(height: constants.padding), const SizedBox(height: constants.padding),
Row( Row(
children: [ children: [
if (_allowAdd) ...[ ElevatedButton.icon(
label: const Text('Test'),
icon: const Icon(Icons.check),
onPressed: _handleProviderTest,
),
const SizedBox(width: constants.padding),
ElevatedButton.icon( ElevatedButton.icon(
label: const Text('Add'), label: const Text('Add'),
icon: const Icon(Icons.add), icon: const Icon(Icons.add),
@@ -193,13 +194,6 @@ class _AddMountScreenState extends State<AddMountScreen> {
}, },
), ),
], ],
if (!_allowAdd)
ElevatedButton.icon(
label: const Text('Test'),
icon: const Icon(Icons.check),
onPressed: _handleProviderTest,
),
],
), ),
], ],
], ],
@@ -221,8 +215,7 @@ class _AddMountScreenState extends State<AddMountScreen> {
_mountNameController.text = mountType == 'Sia' ? 'default' : ''; _mountNameController.text = mountType == 'Sia' ? 'default' : '';
} }
_mount = _mount = (_mountNameController.text.isEmpty)
(_mountNameController.text.isEmpty)
? null ? null
: Mount( : Mount(
auth, auth,
@@ -242,17 +235,11 @@ 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!",