Skip to content

Commit

Permalink
Merge pull request #3276 from HenrikJannsen/add-mediation-case-detail…
Browse files Browse the repository at this point in the history
…s-popup

Add mediation case details popup
  • Loading branch information
HenrikJannsen authored Mar 8, 2025
2 parents 80daa71 + 1cdc48b commit ee8f4a5
Show file tree
Hide file tree
Showing 13 changed files with 505 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@

package bisq.desktop.main.content.authorized_role.mediator;

import bisq.bisq_easy.NavigationTarget;
import bisq.chat.ChatService;
import bisq.chat.bisq_easy.open_trades.BisqEasyOpenTradeChannel;
import bisq.chat.bisq_easy.open_trades.BisqEasyOpenTradeChannelService;
import bisq.chat.priv.LeavePrivateChatManager;
import bisq.common.data.Triple;
import bisq.desktop.ServiceProvider;
import bisq.desktop.common.view.Navigation;
import bisq.desktop.components.containers.Spacer;
import bisq.desktop.components.overlay.Popup;
import bisq.desktop.main.content.authorized_role.mediator.details.MediationCaseDetailsController;
import bisq.desktop.main.content.components.UserProfileDisplay;
import bisq.i18n.Res;
import bisq.settings.DontShowAgainService;
Expand Down Expand Up @@ -150,6 +153,11 @@ void onRemoveCase() {
}
}

void onShowDetails() {
MediationCaseListItem item = model.getMediationCaseListItem().get();
Navigation.navigateTo(NavigationTarget.MEDIATION_CASE_DETAILS, new MediationCaseDetailsController.InitData(item));
}

private void deRemoveCase() {
MediationCaseListItem listItem = model.getMediationCaseListItem().get();
if (listItem != null) {
Expand Down Expand Up @@ -208,7 +216,7 @@ private static class View extends bisq.desktop.common.view.View<HBox, Model, Con
private final Triple<Text, Text, VBox> tradeId;
private final UserProfileDisplay makerProfileDisplay, takerProfileDisplay;
private final Label directionalTitle;
private final Button openCloseButton, leaveButton, removeButton;
private final Button openCloseButton, leaveButton, removeButton, detailsButton;
private Subscription mediationCaseListItemPin, showClosedCasesPin;

private View(Model model, Controller controller) {
Expand Down Expand Up @@ -247,14 +255,19 @@ private View(Model model, Controller controller) {
removeButton.setMinWidth(120);
removeButton.setStyle("-fx-padding: 5 16 5 16");

detailsButton = new Button(Res.get("authorizedRole.mediator.mediationCaseDetails.show"));
detailsButton.getStyleClass().addAll("grey-transparent-outlined-button");
detailsButton.setMinWidth(160);

Region spacer = Spacer.fillHBox();
HBox.setMargin(spacer, new Insets(0, -50, 0, 0));
HBox.setMargin(directionalTitle, new Insets(10, -20, 0, -20));
HBox.setMargin(leaveButton, new Insets(0, -20, 0, 0));
HBox.setMargin(removeButton, new Insets(0, -20, 0, 0));
HBox.setMargin(detailsButton, new Insets(0, -20, 0, 0));
HBox.setMargin(openCloseButton, new Insets(0, -20, 0, 0));
root.getChildren().addAll(maker.getThird(), directionalTitle, taker.getThird(), tradeId.getThird(), spacer,
removeButton, leaveButton, openCloseButton);
detailsButton, removeButton, leaveButton, openCloseButton);
}

@Override
Expand Down Expand Up @@ -306,6 +319,7 @@ protected void onViewAttached() {
openCloseButton.setOnAction(e -> controller.onToggleOpenClose());
leaveButton.setOnAction(e -> controller.onLeaveChannel());
removeButton.setOnAction(e -> controller.onRemoveCase());
detailsButton.setOnAction(e -> controller.onShowDetails());
}

@Override
Expand All @@ -315,6 +329,7 @@ protected void onViewDetached() {
openCloseButton.setOnAction(null);
leaveButton.setOnAction(null);
removeButton.setOnAction(null);
detailsButton.setOnAction(null);

makerProfileDisplay.dispose();
takerProfileDisplay.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private long getNumNotifications(UserProfile userProfile) {

@Getter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
static class Trader {
public static class Trader {
@EqualsAndHashCode.Include
private final UserProfile userProfile;
private final String userName;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop.main.content.authorized_role.mediator.details;

import bisq.bisq_easy.NavigationTarget;
import bisq.chat.bisq_easy.open_trades.BisqEasyOpenTradeChannel;
import bisq.contract.bisq_easy.BisqEasyContract;
import bisq.desktop.ServiceProvider;
import bisq.desktop.common.view.Controller;
import bisq.desktop.common.view.InitWithDataController;
import bisq.desktop.common.view.NavigationController;
import bisq.desktop.main.content.authorized_role.mediator.MediationCaseListItem;
import bisq.desktop.overlay.OverlayController;
import bisq.i18n.Res;
import bisq.offer.bisq_easy.BisqEasyOffer;
import bisq.offer.price.spec.FixPriceSpec;
import bisq.offer.price.spec.PriceSpecFormatter;
import bisq.presentation.formatters.DateFormatter;
import bisq.presentation.formatters.PriceFormatter;
import bisq.support.mediation.MediationCase;
import bisq.support.mediation.MediationRequest;
import bisq.trade.bisq_easy.BisqEasyTradeFormatter;
import bisq.trade.bisq_easy.BisqEasyTradeUtils;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

import java.util.Optional;

@Slf4j
public class MediationCaseDetailsController extends NavigationController implements InitWithDataController<MediationCaseDetailsController.InitData> {
@Getter
@EqualsAndHashCode
@ToString
public static class InitData {
private final MediationCaseListItem mediationCaseListItem;

public InitData(MediationCaseListItem mediationCaseListItem) {
this.mediationCaseListItem = mediationCaseListItem;
}
}

@Getter
private final MediationCaseDetailsModel model;
@Getter
private final MediationCaseDetailsView view;


public MediationCaseDetailsController(ServiceProvider serviceProvider) {
super(NavigationTarget.MEDIATION_CASE_DETAILS);

model = new MediationCaseDetailsModel();
view = new MediationCaseDetailsView(model, this);
}

@Override
public void initWithData(InitData initData) {
model.setMediationCaseListItem(initData.mediationCaseListItem);
}

@Override
public void onActivate() {
MediationCaseListItem mediationCaseListItem = model.getMediationCaseListItem();
BisqEasyOpenTradeChannel channel = mediationCaseListItem.getChannel();
MediationCase mediationCase = mediationCaseListItem.getMediationCase();
MediationRequest mediationRequest = mediationCase.getMediationRequest();
BisqEasyContract contract = mediationRequest.getContract();
BisqEasyOffer offer = contract.getOffer();
String tradeId = mediationRequest.getTradeId();

model.setTradeDate(DateFormatter.formatDateTime(contract.getTakeOfferDate()));

model.setOfferType(offer.getDirection().isBuy()
? Res.get("bisqEasy.openTrades.tradeDetails.offerTypeAndMarket.buyOffer")
: Res.get("bisqEasy.openTrades.tradeDetails.offerTypeAndMarket.sellOffer"));
model.setMarket(Res.get("bisqEasy.openTrades.tradeDetails.offerTypeAndMarket.fiatMarket",
offer.getMarket().getQuoteCurrencyCode()));
model.setFiatAmount(BisqEasyTradeFormatter.formatQuoteSideAmount(contract));
model.setFiatCurrency(offer.getMarket().getQuoteCurrencyCode());
model.setBtcAmount(BisqEasyTradeFormatter.formatBaseSideAmount(contract));
model.setPrice(PriceFormatter.format(BisqEasyTradeUtils.getPriceQuote(contract)));
model.setPriceCodes(offer.getMarket().getMarketCodes());
model.setPriceSpec(offer.getPriceSpec() instanceof FixPriceSpec
? ""
: String.format("(%s)", PriceSpecFormatter.getFormattedPriceSpec(offer.getPriceSpec(), true)));
model.setPaymentMethod(contract.getQuoteSidePaymentMethodSpec().getShortDisplayString());
model.setSettlementMethod(contract.getBaseSidePaymentMethodSpec().getShortDisplayString());
model.setTradeId(tradeId);

MediationCaseListItem.Trader maker = mediationCaseListItem.getMaker();
MediationCaseListItem.Trader taker = mediationCaseListItem.getTaker();
MediationCaseListItem.Trader buyer = offer.getDirection().isBuy() ? maker : taker;
MediationCaseListItem.Trader seller = offer.getDirection().isSell() ? maker : taker;
model.setBuyerUserName(buyer.getUserName());
model.setSellerUserName(seller.getUserName());
model.setBuyerNetworkAddress(buyer.getUserProfile().getAddressByTransportDisplayString(50));
model.setSellerNetworkAddress(seller.getUserProfile().getAddressByTransportDisplayString(50));
}

@Override
public void onDeactivate() {
}

@Override
protected Optional<? extends Controller> createController(NavigationTarget navigationTarget) {
return Optional.empty();
}

void onClose() {
OverlayController.hide();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop.main.content.authorized_role.mediator.details;

import bisq.bisq_easy.NavigationTarget;
import bisq.desktop.common.view.NavigationModel;
import bisq.desktop.main.content.authorized_role.mediator.MediationCaseListItem;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Getter
@Setter
public class MediationCaseDetailsModel extends NavigationModel {
private MediationCaseListItem mediationCaseListItem;
private String tradeDate;
private String offerType;
private String market;
private String fiatAmount;
private String fiatCurrency;
private String btcAmount;
private String price;
private String priceCodes;
private String priceSpec;
private String paymentMethod;
private String settlementMethod;
private String tradeId;
private String buyerUserName;
private String sellerUserName;
private String buyerNetworkAddress;
private String sellerNetworkAddress;

@Override
public NavigationTarget getDefaultNavigationTarget() {
return NavigationTarget.MEDIATION_CASE_DETAILS;
}
}
Loading

0 comments on commit ee8f4a5

Please sign in to comment.