Skip to content

add app/design path #2527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/uitests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,16 @@ jobs:
./gradlew test -PexcludeTests="**/reference/**,**/linemarker/**,**/inspections/**,**/completion/**,**/actions/**"

# Uncomment if investigation is needed:

#
# - name: Capture Test Artifacts on Failure
# if: failure() && matrix.os == 'windows-latest'
# if: failure() && matrix.os == 'ubuntu-latest'
# run: tar -cvzf video.tgz ./video
# shell: bash
#
# - name: Upload Test Video Artifact
# if: failure() && matrix.os == 'windows-latest'
# if: failure() && matrix.os == 'ubuntu-latest'
# uses: actions/upload-artifact@v4
# with:
# name: latest-test-video
# path: video.tgz
# overwrite: true

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).

## 2025.1.1

### Fixed

- The themes select is empty [#2527](https://github.com/magento/magento2-phpstorm-plugin/pull/2527)
- PS.MarkRootGroup isn't registered so the action won't be added to it [#2527](https://github.com/magento/magento2-phpstorm-plugin/pull/2527)

## 2025.1.0

### Added
Expand Down
28 changes: 0 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,8 @@
<strong>PhpStorm IDE Plugin</strong> for a better Magento 2 development workflow.
</caption>
<thead>
<tr style="background-color: #f4f4f4;">
<td colspan="3" style="padding: 10px; font-size: 1.2em;">
<strong>Version 2025.0.0 - Contributors</strong>
</td>
</tr>
</thead>
<tbody>
<tr>
<td align="center" style="padding: 15px;">
<a href="https://github.com/YevhenZvieriev" style="text-decoration: none;">
<img src="https://avatars.githubusercontent.com/u/43544955?v=4" width="120px" height="120px" style="border-radius: 50%;" alt="Yevhen Zvieriev"/>
<br/>
<sub style="font-size: 1em;"><b>Yevhen Zvieriev</b></sub>
</a>
</td>
<td align="center" style="padding: 15px;">
<a href="https://github.com/SilinMykola" style="text-decoration: none;">
<img src="https://avatars.githubusercontent.com/u/15772032?v=4" width="120px" height="120px" style="border-radius: 50%;" alt="Mykola Silin"/>
<br/>
<sub style="font-size: 1em;"><b>Mykola Silin</b></sub>
</a>
</td>
<td align="center" style="padding: 15px;">
<a href="https://github.com/VitaliyBoyko" style="text-decoration: none;">
<img src="https://avatars.githubusercontent.com/u/20116393?v=4" width="120px" height="120px" style="border-radius: 50%;" alt="Vitalii Boiko"/>
<br/>
<sub style="font-size: 1em;"><b>Vitalii Boiko</b></sub>
</a>
</td>
</tr>
</tbody>
<tfoot>
<tr style="background-color: #f9f9f9;">
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pluginGroup = com.magento.idea.magento2plugin
pluginName = Magento PhpStorm
pluginRepositoryUrl = https://github.com/magento/magento2-phpstorm-plugin
pluginVersion = 2025.1.0
pluginVersion = 2025.1.1
pluginSinceBuild = 243.3
pluginUntilBuild = 258.*
platformType = PS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class Package { //NOPMD
public static final String V_FILE_SEPARATOR = "/";
public static String packagesRoot = "app/code";
public static String packagesDesignRoot = "app/design";
public static String libWebRoot = "lib/web";
public static String frameworkRootComposer = "vendor/magento/framework";
public static String frameworkRootGit = "lib/internal/Magento/Framework";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.magento.idea.magento2plugin.project.Settings;
import java.util.ArrayList;
import java.util.List;

public final class IsFileInEditableModuleUtil {
Expand All @@ -29,37 +30,33 @@ public static boolean execute(final PsiFile file) {
}

/**
* Validates if a given virtual file is located within editable paths defined by Magento project structure.
* Validates if a given virtual file is located within editable paths.
*
* @param project the current project containing the virtual file
* @param virtualFile the file to check against editable module directories
* @return true if the file is in an editable module directory, false otherwise
*/
public static boolean execute(final Project project, final VirtualFile virtualFile) {
final Settings settings = Settings.getInstance(project);
List<String> magentoToFolders = settings.getMagentoFolders();
final String magentoPathUrl = MagentoPathUrlUtil.execute(project);
if (magentoPathUrl != null) {
if (magentoToFolders == null) {
magentoToFolders = List.of(
magentoPathUrl
);
} else {
magentoToFolders.add(
magentoPathUrl
);
}
final String magentoRootPath = MagentoPathUrlUtil.execute(project);
if (magentoRootPath == null) {
return false;
}

final Settings settings = Settings.getInstance(project);
List<String> editablePaths = settings.getMagentoFolders();
if (editablePaths == null) {
editablePaths = new ArrayList<>();
}


if (magentoToFolders == null) {
return false;
editablePaths.add(magentoRootPath);
final String magentoDesignPath = MagentoPathUrlUtil.getDesignPath(project);
if (magentoDesignPath != null) {
editablePaths.add(magentoDesignPath);
}

final String filePath = virtualFile.getUrl();
for (final String editablePath : magentoToFolders) {
if (normalizeUrl(filePath).startsWith(normalizeUrl(editablePath))) {
final String currentFilePath = virtualFile.getUrl();
for (final String editablePath : editablePaths) {
if (normalizeUrl(currentFilePath).startsWith(normalizeUrl(editablePath))) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@
import com.magento.idea.magento2plugin.magento.packages.Package;
import com.magento.idea.magento2plugin.project.Settings;

public class MagentoPathUrlUtil {
public final class MagentoPathUrlUtil {

/**
* Private constructor to prevent instantiation of utility class.
*/
private MagentoPathUrlUtil() {
}

/**
* Constructs a file URL for the Magento packages root, based on the project settings.
*
* @param project the project instance
* @return the constructed file URL
*/
public static String execute(Project project) {
String magentoPath = Settings.getMagentoPath(project);
public static String execute(final Project project) {
final String magentoPath = Settings.getMagentoPath(project);
if (magentoPath != null) {
return VirtualFileManager.constructUrl(
"file",
Expand All @@ -31,4 +38,24 @@ public static String execute(Project project) {

return null;
}

/**
* Constructs a file URL for the Magento packages root, based on the project settings.
*
* @param project the project instance
* @return the constructed file URL
*/
public static String getDesignPath(final Project project) {
final String magentoPath = Settings.getMagentoPath(project);
if (magentoPath != null) {
return VirtualFileManager.constructUrl(
"file",
magentoPath
+ File.separator
+ Package.packagesDesignRoot
);
}

return null;
}
}
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<idea-plugin require-restart="true">
<id>com.magento.idea.magento2plugin</id>
<name>Magento PhpStorm</name>
<version>2025.1.0</version>
<version>2025.1.1</version>
<vendor url="https://github.com/magento/magento2-phpstorm-plugin">Magento Inc.</vendor>

<description><![CDATA[
Expand Down Expand Up @@ -176,10 +176,10 @@
</group>

<action id="AddMagentoContentRoot" class="com.magento.idea.magento2plugin.actions.content.root.MarkDirectoryAsMagentoContentRot" text="Mark Directory As Magento Code Root" description="Adds Magento code root">
<add-to-group group-id="PS.MarkRootGroup" anchor="last"/>
<add-to-group group-id="MarkRootGroup" anchor="last"/>
</action>
<action id="RemoveMagentoContentRoot" class="com.magento.idea.magento2plugin.actions.content.root.UnmarkDirectoryAsMagentoContentRot" text="Unmark Directory As Magento Code Root" description="Removes Magento code root">
<add-to-group group-id="PS.MarkRootGroup" anchor="last"/>
<add-to-group group-id="MarkRootGroup" anchor="last"/>
</action>
</actions>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import com.intellij.remoterobot.RemoteRobot
import com.intellij.remoterobot.data.RemoteComponent
import com.intellij.remoterobot.fixtures.*
import com.intellij.remoterobot.search.locators.byXpath
import com.intellij.remoterobot.utils.keyboard
import java.awt.event.KeyEvent.VK_ALT
import java.awt.event.KeyEvent.VK_1
import java.time.Duration


Expand All @@ -25,7 +28,14 @@ class IdeaFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) :
get() = actionLink(byXpath("//div[@accessiblename='Enable Magento support for this project?' and @class='JEditorPane']"))

val projectViewTree
get() = find<ContainerFixture>(byXpath("//div[@class='ProjectViewTree']"))
get() = try {
find<ContainerFixture>(byXpath("//div[@class='ProjectViewTree']"))
} catch (e: Exception) {
keyboard {
hotKey(VK_ALT, VK_1)
}
find<ContainerFixture>(byXpath("//div[@class='ProjectViewTree']"))
}

fun isProjectViewVisible(): Boolean {
return try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ class SharedSteps(private val remoteRobot: RemoteRobot) {
DialogFixture::class.java, byXpath("//div[@class='MyDialog']")
)
dialog.button("Close").click()
closeBrowser()

try {
Thread.sleep(10000)
} catch (e: InterruptedException) {
Thread.currentThread().interrupt()
throw RuntimeException(e)
}

closeBrowser()
} else {
closeBrowser()
val dialog = remoteRobot.find(
DialogFixture::class.java, byXpath("//div[@class='MyDialog']")
)
Expand Down Expand Up @@ -196,6 +196,7 @@ class SharedSteps(private val remoteRobot: RemoteRobot) {
} else if (os.contains("nix") || os.contains("nux")) {
// For Linux-based systems: Kill typical browser processes
Runtime.getRuntime().exec("killall -9 firefox")
Runtime.getRuntime().exec("killall -9 chrome")
}
} catch (e: IOException) {
e.printStackTrace()
Expand Down
Loading