Skip to content

Commit

Permalink
Merge pull request #2355 from acterglobal/ben-more-power-levels
Browse files Browse the repository at this point in the history
Expose further power levels in Space Settings
  • Loading branch information
gnunicorn authored Nov 11, 2024
2 parents 299cbfa + b2c015c commit 41a723e
Show file tree
Hide file tree
Showing 10 changed files with 1,218 additions and 254 deletions.
1 change: 1 addition & 0 deletions .changes/2355-permissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Access all the permissions of the space in the settings, including ban, invite, kick, redact, for comments, attachments and rsvps
41 changes: 32 additions & 9 deletions app/lib/features/space/actions/update_feature_power_level.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ Future<bool> updateFeatureLevelChangeDialog(
Space space,
RoomPowerLevels powerLevels,
String levelKey,
String featureName,
) async {
String featureName, {
bool isGlobal = false,
}) async {
final lang = L10n.of(context);
final newPowerLevel = await showDialog<int?>(
context: context,
builder: (BuildContext context) => _ChangePowerLevelDialog(
featureName: featureName,
isGlobal: isGlobal,
currentPowerLevelName:
maxPowerLevel == 100 ? powerLevelName(currentPw) : 'Custom',
currentPowerLevel: currentPw,
Expand All @@ -40,6 +42,7 @@ Future<bool> updateFeatureLevelChangeDialog(
levelKey,
featureName,
newPowerLevel,
isGlobal: isGlobal,
);
}

Expand All @@ -48,14 +51,30 @@ Future<bool> updateFeatureLevel(
Space space,
String levelKey,
String featureName,
int? newPowerLevel,
) async {
int? newPowerLevel, {
bool isGlobal = false,
}) async {
EasyLoading.show(status: lang.changingSettingOf(featureName));
try {
final res = await space.updateFeaturePowerLevels(
levelKey,
newPowerLevel,
);
bool res;
if (isGlobal) {
if (newPowerLevel == null) {
EasyLoading.showError(
'You must provide a powerlevel',
duration: const Duration(seconds: 3),
);
return false;
}
res = await space.updateRegularPowerLevels(
levelKey,
newPowerLevel,
);
} else {
res = await space.updateFeaturePowerLevels(
levelKey,
newPowerLevel,
);
}
EasyLoading.showToast(lang.powerLevelSubmitted(featureName));
return res;
} catch (e, s) {
Expand All @@ -72,11 +91,13 @@ class _ChangePowerLevelDialog extends StatefulWidget {
final String featureName;
final int? currentPowerLevel;
final String currentPowerLevelName;
final bool isGlobal;

const _ChangePowerLevelDialog({
required this.featureName,
required this.currentPowerLevelName,
this.currentPowerLevel,
this.isGlobal = false,
});

@override
Expand Down Expand Up @@ -128,7 +149,9 @@ class __ChangePowerLevelDialogState extends State<_ChangePowerLevelDialog> {
)
: lang.updateFeaturePowerLevelDialogFromDefaultTo;
return AlertDialog(
title: Text(lang.updateFeaturePowerLevelDialogTitle(widget.featureName)),
title: widget.isGlobal
? Text('Update of ${widget.featureName}')
: Text(lang.updateFeaturePowerLevelDialogTitle(widget.featureName)),
content: Form(
key: _formKey,
child: Column(
Expand Down
Loading

0 comments on commit 41a723e

Please sign in to comment.