Skip to content

Commit 8e2e3be

Browse files
author
Vitaliy
authored
Merge branch '2.0.0-develop' into fixed-usage-of-JavaScriptFileType
2 parents 274d1f0 + ac186e3 commit 8e2e3be

File tree

21 files changed

+795
-57
lines changed

21 files changed

+795
-57
lines changed

resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
<internalFileTemplate name="Magento Php Form Button Block Class"/>
209209
<internalFileTemplate name="Magento Routes Xml"/>
210210
<internalFileTemplate name="Magento Module Layout Xml"/>
211+
<internalFileTemplate name="Magento Module ACL XML"/>
211212

212213
<postStartupActivity implementation="com.magento.idea.magento2plugin.project.startup.CheckIfMagentoPathIsValidActivity"/>
213214
</extensions>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
3+
</config>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html lang="en">
8+
<body>
9+
<font face="verdana" size="-1">
10+
<p>
11+
The acl.xml file is the place where module's ACL rules are declared to authorize the users to access menus, controllers, API endpoints and conditionally render layout blocks.
12+
</p>
13+
<p>
14+
Read more about <a href="https://devdocs.magento.com/guides/v2.4/ext-best-practices/tutorials/create-access-control-list-rule.html">Access Control List rules</a>.
15+
</p>
16+
</font>
17+
</body>
18+
</html>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.generation.data;
7+
8+
public class AclXmlData {
9+
private final String parentResourceId;
10+
private final String resourceId;
11+
private final String resourceTitle;
12+
13+
/**
14+
* ACL XML data.
15+
*
16+
* @param parentResourceId String
17+
* @param resourceId String
18+
* @param resourceTitle String
19+
*/
20+
public AclXmlData(
21+
final String parentResourceId,
22+
final String resourceId,
23+
final String resourceTitle
24+
) {
25+
this.parentResourceId = parentResourceId;
26+
this.resourceId = resourceId;
27+
this.resourceTitle = resourceTitle;
28+
}
29+
30+
public String getParentResourceId() {
31+
return parentResourceId;
32+
}
33+
34+
public String getResourceId() {
35+
return resourceId;
36+
}
37+
38+
public String getResourceTitle() {
39+
return resourceTitle;
40+
}
41+
}

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="12" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="10" left="10" bottom="10" right="10"/>
55
<constraints>
6-
<xy x="48" y="54" width="840" height="657"/>
6+
<xy x="48" y="54" width="888" height="657"/>
77
</constraints>
88
<properties>
99
<preferredSize width="400" height="600"/>
@@ -367,77 +367,107 @@
367367
<text value="Name"/>
368368
</properties>
369369
</component>
370-
<component id="4e6cb" class="javax.swing.JTextField" binding="formName">
370+
<component id="d41b5" class="javax.swing.JTextField" binding="route">
371371
<constraints>
372-
<grid row="0" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
372+
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
373373
<preferred-size width="150" height="-1"/>
374374
</grid>
375375
</constraints>
376376
<properties>
377377
<text value=""/>
378378
</properties>
379379
</component>
380-
<component id="3eed0" class="javax.swing.JLabel" binding="aclLabel">
380+
<component id="9bed8" class="javax.swing.JLabel" binding="routeLabel">
381381
<constraints>
382382
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
383383
</constraints>
384384
<properties>
385-
<text value="ACL"/>
385+
<text value="Route"/>
386386
</properties>
387387
</component>
388-
<component id="8ab6a" class="javax.swing.JTextField" binding="acl">
388+
<component id="4e6cb" class="javax.swing.JTextField" binding="formName">
389389
<constraints>
390-
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
390+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
391+
<preferred-size width="150" height="-1"/>
392+
</grid>
393+
</constraints>
394+
<properties>
395+
<text value=""/>
396+
</properties>
397+
</component>
398+
<component id="34ea4" class="javax.swing.JTextField" binding="formLabel">
399+
<constraints>
400+
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
391401
<preferred-size width="150" height="-1"/>
392402
</grid>
393403
</constraints>
394404
<properties/>
395405
</component>
406+
<component id="e8b2c" class="javax.swing.JLabel" binding="formLabelLabel">
407+
<constraints>
408+
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
409+
</constraints>
410+
<properties>
411+
<text value="Label"/>
412+
</properties>
413+
</component>
396414
</children>
397415
</grid>
398416
</children>
399417
</grid>
400-
<grid id="bbce2" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
418+
<grid id="b8234" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
401419
<margin top="0" left="0" bottom="0" right="0"/>
402420
<constraints>
403421
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
404422
</constraints>
405423
<properties/>
406424
<border type="none"/>
407425
<children>
408-
<component id="d41b5" class="javax.swing.JTextField" binding="route">
426+
<component id="8ab6a" class="javax.swing.JTextField" binding="acl">
409427
<constraints>
410-
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
428+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
411429
<preferred-size width="150" height="-1"/>
412430
</grid>
413431
</constraints>
432+
<properties/>
433+
</component>
434+
<component id="3eed0" class="javax.swing.JLabel" binding="aclLabel">
435+
<constraints>
436+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
437+
</constraints>
414438
<properties>
415-
<text value=""/>
439+
<text value="ACL ID"/>
416440
</properties>
417441
</component>
418-
<component id="34ea4" class="javax.swing.JTextField" binding="formLabel">
442+
<component id="5940c" class="javax.swing.JLabel">
419443
<constraints>
420-
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
444+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
445+
</constraints>
446+
<properties>
447+
<text value="Parent ACL ID"/>
448+
</properties>
449+
</component>
450+
<component id="4d7d5" class="javax.swing.JTextField" binding="aclTitle">
451+
<constraints>
452+
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
421453
<preferred-size width="150" height="-1"/>
422454
</grid>
423455
</constraints>
424456
<properties/>
425457
</component>
426-
<component id="e8b2c" class="javax.swing.JLabel" binding="formLabelLabel">
458+
<component id="7fac6" class="javax.swing.JLabel">
427459
<constraints>
428-
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
460+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
429461
</constraints>
430462
<properties>
431-
<text value="Label"/>
463+
<text value="ACL Title"/>
432464
</properties>
433465
</component>
434-
<component id="9bed8" class="javax.swing.JLabel" binding="routeLabel">
466+
<component id="3d9d9" class="com.magento.idea.magento2plugin.ui.FilteredComboBox" binding="parentAcl" custom-create="true">
435467
<constraints>
436-
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
468+
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
437469
</constraints>
438-
<properties>
439-
<text value="Route"/>
440-
</properties>
470+
<properties/>
441471
</component>
442472
</children>
443473
</grid>

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.intellij.psi.PsiDirectory;
1111
import com.intellij.psi.PsiFile;
1212
import com.magento.idea.magento2plugin.actions.generation.NewUiComponentFormAction;
13+
import com.magento.idea.magento2plugin.actions.generation.data.AclXmlData;
1314
import com.magento.idea.magento2plugin.actions.generation.data.ControllerFileData;
1415
import com.magento.idea.magento2plugin.actions.generation.data.LayoutXmlData;
1516
import com.magento.idea.magento2plugin.actions.generation.data.RoutesXmlData;
@@ -32,6 +33,7 @@
3233
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.ui.component.FormButtonsValidator;
3334
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.ui.component.FormFieldsValidator;
3435
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.ui.component.FormFieldsetsValidator;
36+
import com.magento.idea.magento2plugin.actions.generation.generator.AclXmlGenerator;
3537
import com.magento.idea.magento2plugin.actions.generation.generator.LayoutXmlGenerator;
3638
import com.magento.idea.magento2plugin.actions.generation.generator.ModuleControllerClassGenerator;
3739
import com.magento.idea.magento2plugin.actions.generation.generator.RoutesXmlGenerator;
@@ -49,6 +51,7 @@
4951
import com.magento.idea.magento2plugin.ui.table.ComboBoxEditor;
5052
import com.magento.idea.magento2plugin.ui.table.DeleteRowButton;
5153
import com.magento.idea.magento2plugin.ui.table.TableButton;
54+
import com.magento.idea.magento2plugin.util.magento.GetAclResourcesListUtil;
5255
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
5356
import java.awt.Dimension;
5457
import java.awt.event.ActionEvent;
@@ -159,6 +162,10 @@ public class NewUiComponentFormDialog extends AbstractDialog {
159162

160163
@FieldValidation(rule = RuleRegistry.ACL_RESOURCE_ID, message = {AclResourceIdRule.MESSAGE})
161164
private JTextField acl;
165+
@FieldValidation(rule = RuleRegistry.ACL_RESOURCE_ID, message = {AclResourceIdRule.MESSAGE})
166+
private FilteredComboBox parentAcl;
167+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, "Acl Title"})
168+
private JTextField aclTitle;
162169

163170
private JLabel formButtonsLabel;//NOPMD
164171
private JLabel formNameLabel;//NOPMD
@@ -422,6 +429,7 @@ private void onOK() {
422429
generateDataProviderFile();
423430
generateLayoutFile();
424431
generateFormFile();
432+
generateAclXmlFile();
425433
this.setVisible(false);
426434
}
427435

@@ -516,6 +524,14 @@ private PsiFile generateLayoutFile() {
516524
), project).generate(NewUiComponentFormAction.ACTION_NAME, false);
517525
}
518526

527+
private PsiFile generateAclXmlFile() {
528+
return new AclXmlGenerator(new AclXmlData(
529+
getParentAcl(),
530+
getAcl(),
531+
getAclTitle()
532+
), getModuleName(), project).generate(NewUiComponentFormAction.ACTION_NAME, false);
533+
}
534+
519535
@Override
520536
protected void onCancel() {
521537
dispose();
@@ -530,9 +546,14 @@ private List<String> getAreaList() {
530546
);
531547
}
532548

549+
private List<String> getAclResourcesList() {
550+
return GetAclResourcesListUtil.execute(project);
551+
}
552+
533553
@SuppressWarnings({"PMD.UnusedPrivateMethod"})
534554
private void createUIComponents() {
535555
this.formAreaSelect = new FilteredComboBox(getAreaList());
556+
this.parentAcl = new FilteredComboBox(getAclResourcesList());
536557
}
537558

538559
private String getModuleName() {
@@ -696,6 +717,14 @@ public String getAcl() {
696717
return acl.getText().trim();
697718
}
698719

720+
public String getParentAcl() {
721+
return parentAcl.getSelectedItem().toString().trim();
722+
}
723+
724+
public String getAclTitle() {
725+
return aclTitle.getText().trim();
726+
}
727+
699728
private String getControllerDirectory() {
700729
final String area = getArea();
701730
final String directory = area.equals(Areas.adminhtml.toString())

0 commit comments

Comments
 (0)