Skip to content

Commit

Permalink
Don't fetch groups if user doesn't have permission
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 authored and Brutus5000 committed Oct 10, 2021
1 parent 93e027b commit 092f623
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Expand Up @@ -117,6 +117,7 @@ public class UserManagementController implements Controller<SplitPane> {
public Button takeAvatarButton;
public TextField expiresAtTextfield;
public Button setExpiresAtButton;
public Button removeGroupButton;

public TableView<GamePlayerStatsFX> userLastGamesTable;
public ChoiceBox<FeaturedModFX> featuredModFilterChoiceBox;
Expand Down Expand Up @@ -186,6 +187,7 @@ public FeaturedModFX fromString(String string) {
expiresAtTextfield.disableProperty().bind(userAvatarsTableView.getSelectionModel().selectedItemProperty().isNull());
setExpiresAtButton.disableProperty().bind(userAvatarsTableView.getSelectionModel().selectedItemProperty().isNull());
takeAvatarButton.disableProperty().bind(userAvatarsTableView.getSelectionModel().selectedItemProperty().isNull());
removeGroupButton.disableProperty().bind(userGroupsTableView.getSelectionModel().selectedItemProperty().isNull());

userSearchTableView.getSelectionModel().selectedItemProperty().addListener(this::onSelectedUser);
editBanButton.disableProperty().bind(userBansTableView.getSelectionModel().selectedItemProperty().isNull());
Expand Down Expand Up @@ -247,10 +249,12 @@ private void onSelectedUser(ObservableValue<? extends PlayerFX> observable, Play
nameRecords.addAll(newValue.getNames());
bans.addAll(newValue.getBans());
avatarAssignments.addAll(newValue.getAvatarAssignments());
permissionService.getPlayersUserGroups(newValue).thenAccept(playerGroups -> {
userGroups.addAll(playerGroups);
groupPermissions.addAll(playerGroups.stream().flatMap(userGroupFX -> userGroupFX.getPermissions().stream()).distinct().collect(Collectors.toList()));
});
if (!userGroupsTab.isDisable()) {
permissionService.getPlayersUserGroups(newValue).thenAccept(playerGroups -> {
userGroups.addAll(playerGroups);
groupPermissions.addAll(playerGroups.stream().flatMap(userGroupFX -> userGroupFX.getPermissions().stream()).distinct().collect(Collectors.toList()));
});
}

userGamesPage = 1;
loadMoreGamesRunnable = () -> CompletableFuture.supplyAsync(() -> gamePlayerStatsMapper.map(userService.getLastHundredPlayedGamesByFeaturedMod(newValue.getId(), userGamesPage, featuredModFilterChoiceBox.getSelectionModel().getSelectedItem())))
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/ui/main_window/userManagement.fxml
Expand Up @@ -183,7 +183,7 @@
</HBox>
<HBox VBox.vgrow="NEVER" maxHeight="50" spacing="10.0" alignment="CENTER">
<Button text="Add User To Group" onAction="#openGroupDialog"/>
<Button text="Remove User from Group" onAction="#onRemoveGroup"/>
<Button fx:id="removeGroupButton" text="Remove User from Group" onAction="#onRemoveGroup"/>
</HBox>
</children>
</VBox>
Expand Down

0 comments on commit 092f623

Please sign in to comment.