Skip to content

Commit

Permalink
fix(patch): Fix patch description
Browse files Browse the repository at this point in the history
- In info (sidebar), truncate if too long (>100 with ellipsis)
- In timeline, use latest non-empty,
not only the one in the last revision
- Change "View Timeline" to "Open in Editor"

Signed-off-by: jchrist <[email protected]>
  • Loading branch information
JChrist committed May 20, 2024
1 parent 8d6ac83 commit 0ac2164
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
import com.intellij.collaboration.ui.CollaborationToolsUIUtil;
import com.intellij.collaboration.ui.SingleValueModel;
import com.intellij.collaboration.ui.codereview.BaseHtmlEditorPane;
import com.intellij.collaboration.ui.codereview.ReturnToListComponent;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vcs.changes.ui.CurrentBranchComponent;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.JBColor;
import com.intellij.ui.OnePixelSplitter;
import com.intellij.ui.SideBorder;
import com.intellij.ui.components.ActionLink;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBTextField;
import com.intellij.ui.components.labels.LinkLabel;
import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.ui.scale.JBUIScale;
import com.intellij.ui.tabs.TabInfo;
Expand All @@ -23,12 +25,12 @@
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UI;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.components.BorderLayoutPanel;
import git4idea.GitUtil;
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryChangeListener;
import icons.CollaborationToolsIcons;
import icons.DvcsImplIcons;
import kotlin.Unit;
import net.miginfocom.layout.CC;
import net.miginfocom.layout.LC;
import net.miginfocom.swing.MigLayout;
Expand Down Expand Up @@ -128,12 +130,15 @@ public JComponent createViewPatchProposalPanel() {
}

protected JComponent createReturnToListSideComponent() {
return ReturnToListComponent.INSTANCE.createReturnToListSideComponent(RadicleBundle.message("backToList"),
() -> {
this.messageBusConnection.disconnect();
controller.createPanel();
return Unit.INSTANCE;
});
// taken from: ReturnToListComponent.INSTANCE.createReturnToListSideComponent
var panel = new BorderLayoutPanel();
final var label = new LinkLabel<>(UIUtil.leftArrow() + " " + RadicleBundle.message("backToList"), null, (source, data) -> {
this.messageBusConnection.disconnect();
controller.createPanel();
});
label.setBorder(JBUI.Borders.emptyRight(8));
panel.addToRight(label).andTransparent().withBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
return panel;
}

protected JComponent createInfoComponent() {
Expand Down Expand Up @@ -184,14 +189,18 @@ private JComponent descriptionComponent() {
var titlePane = new BaseHtmlEditorPane();

Check notice on line 189 in src/main/java/network/radicle/jetbrains/radiclejetbrainsplugin/patches/PatchProposalPanel.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Method can be extracted

It's possible to extract method returning 'titlePane' from a long surrounding method

Check warning on line 189 in src/main/java/network/radicle/jetbrains/radiclejetbrainsplugin/patches/PatchProposalPanel.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'com.intellij.collaboration.ui.codereview.BaseHtmlEditorPane' is declared in unstable package 'com.intellij.collaboration.ui.codereview' marked with @ApiStatus.Experimental

Check warning on line 189 in src/main/java/network/radicle/jetbrains/radiclejetbrainsplugin/patches/PatchProposalPanel.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'BaseHtmlEditorPane()' is declared in unstable package 'com.intellij.collaboration.ui.codereview' marked with @ApiStatus.Experimental

Check notice on line 189 in src/main/java/network/radicle/jetbrains/radiclejetbrainsplugin/patches/PatchProposalPanel.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Method can be extracted

It's possible to extract method returning 'titlePane' from a long surrounding method

Check warning on line 189 in src/main/java/network/radicle/jetbrains/radiclejetbrainsplugin/patches/PatchProposalPanel.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'com.intellij.collaboration.ui.codereview.BaseHtmlEditorPane' is declared in unstable package 'com.intellij.collaboration.ui.codereview' marked with @ApiStatus.Experimental
//titlePane.setFont(titlePane.getFont().deriveFont((float) (titlePane.getFont().getSize() * 1.2)));

Check notice on line 190 in src/main/java/network/radicle/jetbrains/radiclejetbrainsplugin/patches/PatchProposalPanel.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Commented out code

Commented out code (2 lines)

Check notice on line 190 in src/main/java/network/radicle/jetbrains/radiclejetbrainsplugin/patches/PatchProposalPanel.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Commented out code

Commented out code (2 lines)
//HtmlEditorPaneUtilKt.setHtmlBody(titlePane, patch.getLatestNonEmptyRevisionDescription());
titlePane.setBody(patch.getLatestNonEmptyRevisionDescription());
var latestDescription = patch.getLatestNonEmptyRevisionDescription();
if (latestDescription.length() > 100) {
latestDescription = latestDescription.substring(0, 100) + "...";
}
titlePane.setBody(latestDescription);

Check warning on line 196 in src/main/java/network/radicle/jetbrains/radiclejetbrainsplugin/patches/PatchProposalPanel.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Deprecated API usage

'setBody(java.lang.String)' is deprecated

Check warning on line 196 in src/main/java/network/radicle/jetbrains/radiclejetbrainsplugin/patches/PatchProposalPanel.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'setBody(java.lang.String)' is declared in unstable package 'com.intellij.collaboration.ui.codereview' marked with @ApiStatus.Experimental

Check warning on line 196 in src/main/java/network/radicle/jetbrains/radiclejetbrainsplugin/patches/PatchProposalPanel.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Deprecated API usage

'setBody(java.lang.String)' is deprecated
var nonOpaquePanel = new NonOpaquePanel(new MigLayout(new LC().insets("0").gridGap("0", "0").noGrid().flowY()));
nonOpaquePanel.add(titlePane, new CC().gapBottom(String.valueOf(UI.scale(8))));
final var viewTimelineLink = new ActionLink(RadicleBundle.message("view.timeline"), e -> {
final var openInEditorLink = new ActionLink(RadicleBundle.message("open.in.editor"), e -> {
controller.openPatchTimelineOnEditor(patchModel, this, false);
});
viewTimelineLink.setBorder(JBUI.Borders.emptyTop(4));
nonOpaquePanel.add(viewTimelineLink, new CC().gapBottom(String.valueOf(UI.scale(8))));
openInEditorLink.setBorder(JBUI.Borders.emptyTop(4));
nonOpaquePanel.add(openInEditorLink, new CC().gapBottom(String.valueOf(UI.scale(8))));

var checkoutAction = new AbstractAction() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ public TimelineComponentFactory(PatchProposalPanel patchProposalPanel, SingleVal
}

public JComponent createDescSection() {
var description = !Strings.isNullOrEmpty(patch.getLatestRevision().description()) ? patch.getLatestRevision().description() :
RadicleBundle.message("noDescription");
var description = patch.getLatestNonEmptyRevisionDescription();
if (Strings.isNullOrEmpty(description)) {
description = RadicleBundle.message("noDescription");
}
var editorPane = new MarkDownEditorPaneFactory(description, patch.project, patch.radProject.id, file);
descSection = Utils.descriptionPanel(editorPane, patch.project);
return descSection;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/messages/RadicleBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ trusted=Trusted
all=All
track=Track
issues=Issues
view.timeline=View Timeline
open.in.editor=Open in Editor
patch.proposal.change.title=Change Title
patch.proposal.submit.hint={0} to {1}
patch.comment=Comment
Expand Down

0 comments on commit 0ac2164

Please sign in to comment.