make test optional
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:
@@ -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)
|
||||||
|
@@ -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,18 +70,16 @@ 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: constants.providerTypeList
|
||||||
items:
|
.map<DropdownMenuItem<String>>((item) {
|
||||||
constants.providerTypeList
|
return DropdownMenuItem<String>(
|
||||||
.map<DropdownMenuItem<String>>((item) {
|
value: item,
|
||||||
return DropdownMenuItem<String>(
|
child: Text(item),
|
||||||
value: item,
|
);
|
||||||
child: Text(item),
|
})
|
||||||
);
|
.toList(),
|
||||||
})
|
|
||||||
.toList(),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -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,70 +131,68 @@ 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('Test'),
|
||||||
label: const Text('Add'),
|
icon: const Icon(Icons.check),
|
||||||
icon: const Icon(Icons.add),
|
onPressed: _handleProviderTest,
|
||||||
onPressed: () async {
|
),
|
||||||
final mountList = Provider.of<MountList>(context);
|
const SizedBox(width: constants.padding),
|
||||||
|
ElevatedButton.icon(
|
||||||
|
label: const Text('Add'),
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
onPressed: () async {
|
||||||
|
final mountList = Provider.of<MountList>(context);
|
||||||
|
|
||||||
List<String> failed = [];
|
List<String> failed = [];
|
||||||
if (!validateSettings(
|
if (!validateSettings(
|
||||||
_settings[_mountType]!,
|
_settings[_mountType]!,
|
||||||
failed,
|
failed,
|
||||||
)) {
|
)) {
|
||||||
for (var key in failed) {
|
for (var key in failed) {
|
||||||
displayErrorMessage(
|
displayErrorMessage(
|
||||||
context,
|
|
||||||
"Setting '$key' is not valid",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mountList.hasConfigName(
|
|
||||||
_mountNameController.text,
|
|
||||||
)) {
|
|
||||||
return displayErrorMessage(
|
|
||||||
context,
|
context,
|
||||||
"Configuration name '${_mountNameController.text}' already exists",
|
"Setting '$key' is not valid",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_mountType == "Sia" || _mountType == "S3") {
|
if (mountList.hasConfigName(
|
||||||
final bucket =
|
_mountNameController.text,
|
||||||
_settings[_mountType]!["${_mountType}Config"]["Bucket"]
|
)) {
|
||||||
as String;
|
return displayErrorMessage(
|
||||||
if (mountList.hasBucketName(_mountType, bucket)) {
|
context,
|
||||||
return displayErrorMessage(
|
"Configuration name '${_mountNameController.text}' already exists",
|
||||||
context,
|
|
||||||
"Bucket '$bucket' already exists",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final success = await mountList.add(
|
|
||||||
_mountType,
|
|
||||||
_mountType == 'Remote'
|
|
||||||
? '${_settings[_mountType]!['RemoteConfig']['HostNameOrIp']}_${_settings[_mountType]!['RemoteConfig']['ApiPort']}'
|
|
||||||
: _mountNameController.text,
|
|
||||||
_settings[_mountType]!,
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!success || !context.mounted) {
|
if (_mountType == "Sia" || _mountType == "S3") {
|
||||||
return;
|
final bucket =
|
||||||
|
_settings[_mountType]!["${_mountType}Config"]["Bucket"]
|
||||||
|
as String;
|
||||||
|
if (mountList.hasBucketName(_mountType, bucket)) {
|
||||||
|
return displayErrorMessage(
|
||||||
|
context,
|
||||||
|
"Bucket '$bucket' already exists",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Navigator.pop(context);
|
final success = await mountList.add(
|
||||||
},
|
_mountType,
|
||||||
),
|
_mountType == 'Remote'
|
||||||
],
|
? '${_settings[_mountType]!['RemoteConfig']['HostNameOrIp']}_${_settings[_mountType]!['RemoteConfig']['ApiPort']}'
|
||||||
if (!_allowAdd)
|
: _mountNameController.text,
|
||||||
ElevatedButton.icon(
|
_settings[_mountType]!,
|
||||||
label: const Text('Test'),
|
);
|
||||||
icon: const Icon(Icons.check),
|
|
||||||
onPressed: _handleProviderTest,
|
if (!success || !context.mounted) {
|
||||||
),
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -221,19 +215,18 @@ 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,
|
MountConfig(
|
||||||
MountConfig(
|
name: _mountNameController.text,
|
||||||
name: _mountNameController.text,
|
settings: _settings[mountType],
|
||||||
settings: _settings[mountType],
|
type: mountType,
|
||||||
type: mountType,
|
),
|
||||||
),
|
null,
|
||||||
null,
|
isAdd: true,
|
||||||
isAdd: true,
|
);
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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!",
|
||||||
|
Reference in New Issue
Block a user