Skip to content

Commit 102fba2

Browse files
authored
Merge branch '4.0.0-develop' into fix-bugs-tables-editing
2 parents 847b304 + 38f5c25 commit 102fba2

File tree

11 files changed

+252
-3
lines changed

11 files changed

+252
-3
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@
4343

4444
1. Check out this repository
4545
1. Open a folder with the project in the IntelliJ Ultimate using the `open` action button.
46-
1. Make sure that you on the latest develop branch (e.g `1.0.0-develop`)
47-
1. Right-click on the `build.gradle` file, choose "Import Gradle project" (you need to have Gradle plugin installed)
46+
1. Make sure that you on the latest develop branch (e.g `4.0.0-develop`)
47+
1. Right-click on the `build.gradle` file, choose "Import Gradle project" (if this is not exist look for "Build module '<root folder name>'") (you need to have Gradle plugin installed)
48+
1. Check if the right SDK version is used for the project.
49+
- Current Java version for the project is **java 11**, so you should additionally download **SDK 11** and choose it in the module settings: `Right click by the project root > Open Module Settings > Project Settings > Project > Project SDK`
50+
- Check if right SDK version is used for the Gradle plugin: `Intellij IDEA > Preferences... > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM` and choose your JDK.
4851
1. When the Gradle sections appeared in the right bar, navigate there and right-click `magento-2-php-storm-plugin > Tasks -> Intellij -> runIde`
4952
1. Click `Run "magento-2-php-storm-plugin"` to run the plugin. You should see a new instance of IntelliJ launched with the plugin installed. Make sure the plugin is enabled in IntelliJ settings and indexing is finished. Plugin features should be accessible at this point.
5053

gradle-tasks/checkstyle/checkstyle.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,8 @@
330330
</module>
331331
</module>
332332
<module name="SuppressWarningsFilter"/>
333+
<module name="RegexpHeader">
334+
<property name="header" value="^\/\*\n \* Copyright © Magento, Inc."/>
335+
<property name="fileExtensions" value="java"/>
336+
</module>
333337
</module>

resources/META-INF/plugin.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@
246246
<defaultLiveTemplates file="/liveTemplates/MagentoPWA.xml"/>
247247

248248
<postStartupActivity implementation="com.magento.idea.magento2plugin.project.startup.CheckIfMagentoPathIsValidActivity"/>
249+
250+
<errorHandler implementation="com.magento.idea.magento2plugin.project.diagnostic.DefaultErrorReportSubmitter"/>
249251
</extensions>
250252

251253
<extensions defaultExtensionNs="com.jetbrains.php">
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
**Describe the bug** (*)
2+
3+
${BUG_DESCRIPTION}
4+
5+
```
6+
${STACK_TRACE}
7+
```
8+
9+
**To Reproduce** (*)
10+
11+
Steps to reproduce the behavior:
12+
1. Go to '...'
13+
2. Click on '....'
14+
3. Scroll down to '....'
15+
4. See error
16+
17+
**Expected behavior** (*)
18+
19+
A clear and concise description of what you expected to happen.
20+
21+
**Screenshots**
22+
23+
If applicable, add screenshots to help explain your problem.
24+
25+
**Please complete the following information:** (*)
26+
27+
- OS: [e.g. MacOS or Ubuntu Linux 20.04]
28+
- PhpStorm/Intellij version: [e.g. 2019.3.3]
29+
- Plugin Version: [e.g. 1.0.0]
30+
31+
**Additional context**
32+
33+
Add any other context about the problem here.

resources/fileTemplates/code/GitHub New Bug Issue Body Template.txt.html

Whitespace-only changes.

resources/magento2/common.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,7 @@ common.template.id=Template ID
6868
common.template.label=Template Label
6969
common.template.filename=Template File Name
7070
common.template.subject=Email Subject
71-
common.template.type=Email Type
71+
common.template.type=Email Type
72+
common.diagnostic.reportButtonText=Report Me
73+
common.diagnostic.reportSubmittedTitle=The report is successfully submitted!
74+
common.diagnostic.reportSubmittedMessage=Thank you for submitting your report! We will check it as soon as possible.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.project.diagnostic;
7+
8+
import com.intellij.ide.BrowserUtil;
9+
import com.intellij.ide.DataManager;
10+
import com.intellij.openapi.actionSystem.CommonDataKeys;
11+
import com.intellij.openapi.actionSystem.DataContext;
12+
import com.intellij.openapi.application.ApplicationManager;
13+
import com.intellij.openapi.diagnostic.ErrorReportSubmitter;
14+
import com.intellij.openapi.diagnostic.IdeaLoggingEvent;
15+
import com.intellij.openapi.diagnostic.SubmittedReportInfo;
16+
import com.intellij.openapi.project.Project;
17+
import com.intellij.openapi.util.NlsActions;
18+
import com.intellij.util.Consumer;
19+
import com.magento.idea.magento2plugin.bundles.CommonBundle;
20+
import com.magento.idea.magento2plugin.project.diagnostic.github.GitHubNewIssueBodyBuilderUtil;
21+
import com.magento.idea.magento2plugin.project.diagnostic.github.GitHubNewIssueUrlBuilderUtil;
22+
import java.awt.Component;
23+
import java.time.LocalDateTime;
24+
import java.time.format.DateTimeFormatter;
25+
import javax.swing.JOptionPane;
26+
import org.jetbrains.annotations.NotNull;
27+
import org.jetbrains.annotations.Nullable;
28+
29+
public class DefaultErrorReportSubmitter extends ErrorReportSubmitter {
30+
31+
private static final String DEFAULT_ISSUE_TITLE = "Bug Report %date";
32+
private static final String DEFAULT_ISSUE_DESCRIPTION
33+
= "A clear and concise description of what the bug is.";
34+
private final CommonBundle commonBundle;
35+
36+
/**
37+
* Default error report submitter.
38+
*/
39+
public DefaultErrorReportSubmitter() {
40+
super();
41+
commonBundle = new CommonBundle();
42+
}
43+
44+
/**
45+
* Open GitHub link with creation of the new bug report issue.
46+
*
47+
* @param events IdeaLoggingEvent[]
48+
* @param additionalInfo String
49+
* @param parentComponent Component
50+
* @param consumer Consumer
51+
*
52+
* @return boolean
53+
*/
54+
@Override
55+
public boolean submit(
56+
final @NotNull IdeaLoggingEvent[] events,
57+
final @Nullable String additionalInfo,
58+
final @NotNull Component parentComponent,
59+
final @NotNull Consumer<? super SubmittedReportInfo> consumer
60+
) {
61+
final DataContext context = DataManager.getInstance().getDataContext(parentComponent);
62+
final Project project = CommonDataKeys.PROJECT.getData(context);
63+
64+
if (project == null) {
65+
return false;
66+
}
67+
final StringBuilder stackTrace = new StringBuilder();
68+
69+
for (final IdeaLoggingEvent event : events) {
70+
stackTrace.append(event.getThrowableText()).append("\r\n");
71+
}
72+
73+
final String bugReportBody = GitHubNewIssueBodyBuilderUtil.buildNewBugReportBody(
74+
project,
75+
additionalInfo == null ? DEFAULT_ISSUE_DESCRIPTION : additionalInfo,
76+
stackTrace.toString()
77+
);
78+
79+
BrowserUtil.browse(
80+
GitHubNewIssueUrlBuilderUtil.buildNewBugIssueUrl(
81+
getDefaultIssueTitle(),
82+
bugReportBody
83+
)
84+
);
85+
86+
ApplicationManager.getApplication().invokeLater(() -> {
87+
JOptionPane.showMessageDialog(
88+
parentComponent,
89+
commonBundle.message("common.diagnostic.reportSubmittedMessage"),
90+
commonBundle.message("common.diagnostic.reportSubmittedTitle"),
91+
JOptionPane.INFORMATION_MESSAGE
92+
);
93+
consumer.consume(
94+
new SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.NEW_ISSUE)
95+
);
96+
});
97+
98+
return true;
99+
}
100+
101+
@Override
102+
public @NlsActions.ActionText @NotNull String getReportActionText() {
103+
return commonBundle.message("common.diagnostic.reportButtonText");
104+
}
105+
106+
/**
107+
* Get default bug issue title.
108+
*
109+
* @return String
110+
*/
111+
private String getDefaultIssueTitle() {
112+
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
113+
114+
return DEFAULT_ISSUE_TITLE.replace("%date", formatter.format(LocalDateTime.now()));
115+
}
116+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.project.diagnostic.github;
7+
8+
import com.intellij.ide.fileTemplates.FileTemplate;
9+
import com.intellij.ide.fileTemplates.FileTemplateManager;
10+
import com.intellij.openapi.project.Project;
11+
import java.io.IOException;
12+
import java.util.Properties;
13+
import org.jetbrains.annotations.NotNull;
14+
15+
public final class GitHubNewIssueBodyBuilderUtil {
16+
17+
private static final String BUR_REPORT_TEMPLATE = "GitHub New Bug Issue Body Template";
18+
19+
private GitHubNewIssueBodyBuilderUtil() {}
20+
21+
/**
22+
* Build BUG report body.
23+
*
24+
* @param project Project
25+
* @param bugDescription String
26+
* @param stackTrace String
27+
*
28+
* @return String
29+
*/
30+
public static String buildNewBugReportBody(
31+
final @NotNull Project project,
32+
final @NotNull String bugDescription,
33+
final @NotNull String stackTrace
34+
) {
35+
final FileTemplateManager templateManager = FileTemplateManager.getInstance(project);
36+
final FileTemplate errorReportTemplate =
37+
templateManager.getCodeTemplate(BUR_REPORT_TEMPLATE);
38+
39+
final Properties properties = new Properties();
40+
properties.setProperty("BUG_DESCRIPTION", bugDescription);
41+
properties.setProperty("STACK_TRACE", stackTrace);
42+
43+
try {
44+
return errorReportTemplate.getText(properties);
45+
} catch (IOException exception) {
46+
return "";
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)