penalize menu only appears for arbitrator in failed trades view

This commit is contained in:
woodser 2025-01-06 09:47:54 -05:00
parent 25f85f9f8d
commit e4f3d13660

View file

@ -27,6 +27,7 @@ import haveno.core.offer.Offer;
import haveno.core.trade.Contract; import haveno.core.trade.Contract;
import haveno.core.trade.HavenoUtils; import haveno.core.trade.HavenoUtils;
import haveno.core.trade.Trade; import haveno.core.trade.Trade;
import haveno.core.user.User;
import haveno.core.xmr.wallet.XmrWalletService; import haveno.core.xmr.wallet.XmrWalletService;
import haveno.desktop.common.view.ActivatableViewAndModel; import haveno.desktop.common.view.ActivatableViewAndModel;
import haveno.desktop.common.view.FxmlView; import haveno.desktop.common.view.FxmlView;
@ -98,15 +99,18 @@ public class FailedTradesView extends ActivatableViewAndModel<VBox, FailedTrades
private ChangeListener<String> filterTextFieldListener; private ChangeListener<String> filterTextFieldListener;
private Scene scene; private Scene scene;
private XmrWalletService xmrWalletService; private XmrWalletService xmrWalletService;
private User user;
private ContextMenu contextMenu; private ContextMenu contextMenu;
@Inject @Inject
public FailedTradesView(FailedTradesViewModel model, public FailedTradesView(FailedTradesViewModel model,
TradeDetailsWindow tradeDetailsWindow, TradeDetailsWindow tradeDetailsWindow,
XmrWalletService xmrWalletService) { XmrWalletService xmrWalletService,
User user) {
super(model); super(model);
this.tradeDetailsWindow = tradeDetailsWindow; this.tradeDetailsWindow = tradeDetailsWindow;
this.xmrWalletService = xmrWalletService; this.xmrWalletService = xmrWalletService;
this.user = user;
} }
@Override @Override
@ -190,17 +194,10 @@ public class FailedTradesView extends ActivatableViewAndModel<VBox, FailedTrades
tableView.setItems(sortedList); tableView.setItems(sortedList);
contextMenu = new ContextMenu(); contextMenu = new ContextMenu();
boolean isArbitrator = user.getRegisteredArbitrator() != null;
if (isArbitrator) {
MenuItem item1 = new MenuItem(Res.get("support.contextmenu.penalize.msg", Res.get("shared.maker"))); MenuItem item1 = new MenuItem(Res.get("support.contextmenu.penalize.msg", Res.get("shared.maker")));
MenuItem item2 = new MenuItem(Res.get("support.contextmenu.penalize.msg", Res.get("shared.taker"))); MenuItem item2 = new MenuItem(Res.get("support.contextmenu.penalize.msg", Res.get("shared.taker")));
contextMenu.getItems().addAll(item1, item2);
tableView.setRowFactory(tv -> {
TableRow<FailedTradesListItem> row = new TableRow<>();
row.setOnContextMenuRequested(event -> {
contextMenu.show(row, event.getScreenX(), event.getScreenY());
});
return row;
});
item1.setOnAction(event -> { item1.setOnAction(event -> {
Trade selectedFailedTrade = tableView.getSelectionModel().getSelectedItem().getTrade(); Trade selectedFailedTrade = tableView.getSelectionModel().getSelectedItem().getTrade();
@ -222,6 +219,17 @@ public class FailedTradesView extends ActivatableViewAndModel<VBox, FailedTrades
selectedFailedTrade.getTaker().getReserveTxHex()); selectedFailedTrade.getTaker().getReserveTxHex());
}); });
contextMenu.getItems().addAll(item1, item2);
}
tableView.setRowFactory(tv -> {
TableRow<FailedTradesListItem> row = new TableRow<>();
row.setOnContextMenuRequested(event -> {
contextMenu.show(row, event.getScreenX(), event.getScreenY());
});
return row;
});
numItems.setText(Res.get("shared.numItemsLabel", sortedList.size())); numItems.setText(Res.get("shared.numItemsLabel", sortedList.size()));
exportButton.setOnAction(event -> { exportButton.setOnAction(event -> {
ObservableList<TableColumn<FailedTradesListItem, ?>> tableColumns = tableView.getColumns(); ObservableList<TableColumn<FailedTradesListItem, ?>> tableColumns = tableView.getColumns();