diff --git a/core/lexicon/en/dashboards.inc.php b/core/lexicon/en/dashboards.inc.php index c7eab7bf0b..e27f87976e 100644 --- a/core/lexicon/en/dashboards.inc.php +++ b/core/lexicon/en/dashboards.inc.php @@ -107,6 +107,6 @@ // Temporarily match old keys to new ones to ensure compatibility $_lang['dashboard_desc_customizable'] = $_lang['dashboard_customizable_desc']; -$_lang['dashboard_desc_name'] = $_lang['dashboard_name_desc']; $_lang['dashboard_desc_description'] = $_lang['dashboard_description_desc']; $_lang['dashboard_desc_hide_trees'] = $_lang['dashboard_hide_trees_desc']; +$_lang['dashboard_desc_name'] = $_lang['dashboard_name_desc']; diff --git a/core/src/Revolution/Processors/Security/Access/Policy/GetList.php b/core/src/Revolution/Processors/Security/Access/Policy/GetList.php index 0dcdfe5998..3c8ff3ef71 100644 --- a/core/src/Revolution/Processors/Security/Access/Policy/GetList.php +++ b/core/src/Revolution/Processors/Security/Access/Policy/GetList.php @@ -236,8 +236,9 @@ public function prepareRow(xPDOObject $object) ]; $policyData = $object->toArray(); $policyName = $object->get('name'); + $policyPermissions = $object->get('data'); $isCorePolicy = $object->isCorePolicy($policyName); - $this->setActivePermissionsCount($policyData, $object->get('data')); + $this->setActivePermissionsCount($policyData, $policyPermissions); $policyData['reserved'] = ['name' => $this->corePolicies]; $policyData['isProtected'] = $isCorePolicy; @@ -246,6 +247,7 @@ public function prepareRow(xPDOObject $object) unset($permissions['delete']); } $policyData['permissions'] = $permissions; + $policyData['policyPermissions'] = array_keys($policyPermissions, 1); $policyData['description_trans'] = $this->modx->lexicon($policyData['description']); unset($policyData['data']); @@ -273,7 +275,7 @@ protected function setActivePermissionsCount(array &$policy, array $data) /** * @param xPDOObject|modAccessPolicy $object - * @deprecated as of 3.1 + * @deprecated as of MODX 3.1.0 * @return string */ protected function prepareRowClasses(xPDOObject $object) diff --git a/manager/assets/modext/widgets/security/modx.grid.access.policy.js b/manager/assets/modext/widgets/security/modx.grid.access.policy.js index a368b6ad61..c5d5cf9626 100644 --- a/manager/assets/modext/widgets/security/modx.grid.access.policy.js +++ b/manager/assets/modext/widgets/security/modx.grid.access.policy.js @@ -70,7 +70,6 @@ MODx.grid.AccessPolicy = function(config = {}) { columns: [this.sm, { header: _('policy_name'), dataIndex: 'name', - id: 'modx-policy--name', width: 200, editor: { xtype: 'textfield', @@ -94,7 +93,6 @@ MODx.grid.AccessPolicy = function(config = {}) { }, { header: _('description'), dataIndex: 'description', - id: 'modx-policy--description', width: 375, editor: { xtype: 'textarea' @@ -134,15 +132,21 @@ MODx.grid.AccessPolicy = function(config = {}) { editable: false }], tbar: [ + this.getCreateButton('policy', 'createPolicy'), { - text: _('create'), - cls: 'primary-button', - scope: this, - handler: this.createPolicy - }, { text: _('import'), scope: this, - handler: this.importPolicy + handler: this.importPolicy, + listeners: { + render: { + fn: function(btn) { + if (!this.userCanCreate) { + btn.hide(); + } + }, + scope: this + } + } }, this.getBulkActionsButton('policy', 'Security/Access/Policy/RemoveMultiple'), '->', @@ -161,13 +165,8 @@ MODx.grid.AccessPolicy = function(config = {}) { this.setShowActionsMenu(); this.on({ - render: function(grid) { - this.setEditableColumnAccess( - ['modx-policy--name', 'modx-policy--description'] - ); - }, beforeedit: function(e) { - if (e.record.json.isProtected || !this.userCanEditRecord(e.record)) { + if (!this.userCanEdit || e.record.json.isProtected || !this.userCanEditRecord(e.record)) { return false; } }, @@ -179,14 +178,18 @@ MODx.grid.AccessPolicy = function(config = {}) { Ext.extend(MODx.grid.AccessPolicy, MODx.grid.Grid, { getMenu: function() { const - record = this.getSelectionModel().getSelected(), + model = this.getSelectionModel(), + record = model.getSelected(), menu = [] ; - if (this.getSelectionModel().getCount() > 1) { - menu.push({ - text: _('selected_remove'), - handler: this.removeSelected - }); + if (model.getCount() > 1) { + const records = model.getSelections(); + if (this.userCanDelete && this.userCanDeleteRecords(records)) { + menu.push({ + text: _('selected_remove'), + handler: this.removeSelected.bind(this, 'policy', 'Security/Access/Policy/RemoveMultiple') + }); + } } else { if (this.userCanEdit && this.userCanEditRecord(record)) { menu.push({ @@ -217,10 +220,7 @@ Ext.extend(MODx.grid.AccessPolicy, MODx.grid.Grid, { }); } } - - if (menu.length > 0) { - this.addContextMenuItem(menu); - } + return menu; }, editPolicy: function(itm, e) { diff --git a/manager/assets/modext/widgets/security/modx.grid.access.policy.template.js b/manager/assets/modext/widgets/security/modx.grid.access.policy.template.js index 32d4f45bad..fa5ac26711 100644 --- a/manager/assets/modext/widgets/security/modx.grid.access.policy.template.js +++ b/manager/assets/modext/widgets/security/modx.grid.access.policy.template.js @@ -68,7 +68,6 @@ MODx.grid.AccessPolicyTemplate = function(config = {}) { columns: [this.sm, { header: _('name'), dataIndex: 'name', - id: 'modx-policy-template--name', width: 200, editor: { xtype: 'textfield', @@ -92,7 +91,6 @@ MODx.grid.AccessPolicyTemplate = function(config = {}) { }, { header: _('description'), dataIndex: 'description', - id: 'modx-policy-template--description', width: 375, editor: { xtype: 'textarea' @@ -126,15 +124,21 @@ MODx.grid.AccessPolicyTemplate = function(config = {}) { this.getCreatorColumnConfig('policy-template') ], tbar: [ + this.getCreateButton('policy_template', 'createPolicyTemplate'), { - text: _('create'), - cls: 'primary-button', - scope: this, - handler: this.createPolicyTemplate - }, { text: _('import'), scope: this, - handler: this.importPolicyTemplate + handler: this.importPolicyTemplate, + listeners: { + render: { + fn: function(btn) { + if (!this.userCanCreate) { + btn.hide(); + } + }, + scope: this + } + } }, { /* * Note: Using local this.removeSelected method instead of shared base this.getBulkActionsButton() method here, @@ -188,13 +192,8 @@ MODx.grid.AccessPolicyTemplate = function(config = {}) { this.setShowActionsMenu(); this.on({ - render: function(grid) { - this.setEditableColumnAccess( - ['modx-policy-template--name', 'modx-policy-template--description'] - ); - }, beforeedit: function(e) { - if (e.record.json.isProtected || !this.userCanEditRecord(e.record)) { + if (!this.userCanEdit || e.record.json.isProtected || !this.userCanEditRecord(e.record)) { return false; } }, @@ -206,15 +205,19 @@ MODx.grid.AccessPolicyTemplate = function(config = {}) { Ext.extend(MODx.grid.AccessPolicyTemplate, MODx.grid.Grid, { getMenu: function() { const - record = this.getSelectionModel().getSelected(), + model = this.getSelectionModel(), + record = model.getSelected(), menu = [] ; - if (this.getSelectionModel().getCount() > 1) { - menu.push({ - text: _('selected_remove'), - handler: this.removeSelected - }); + if (model.getCount() > 1) { + const records = model.getSelections(); + if (this.userCanDelete && this.userCanDeleteRecords(records)) { + menu.push({ + text: _('selected_remove'), + handler: this.removeSelected + }); + } } else { if (this.userCanEdit && this.userCanEditRecord(record)) { menu.push({ @@ -255,10 +258,7 @@ Ext.extend(MODx.grid.AccessPolicyTemplate, MODx.grid.Grid, { }); } } - - if (menu.length > 0) { - this.addContextMenuItem(menu); - } + return menu; }, createPolicyTemplate: function(btn, e) { diff --git a/manager/assets/modext/widgets/security/modx.grid.role.js b/manager/assets/modext/widgets/security/modx.grid.role.js index db0bc9350c..a32c20def6 100644 --- a/manager/assets/modext/widgets/security/modx.grid.role.js +++ b/manager/assets/modext/widgets/security/modx.grid.role.js @@ -33,7 +33,6 @@ MODx.grid.Role = function(config = {}) { }, { header: _('name'), dataIndex: 'name', - id: 'modx-role--name', width: 150, sortable: true, editor: { @@ -65,7 +64,6 @@ MODx.grid.Role = function(config = {}) { }, { header: _('description'), dataIndex: 'description', - id: 'modx-role--description', width: 350, editor: { xtype: 'textarea' @@ -83,7 +81,6 @@ MODx.grid.Role = function(config = {}) { { header: _('authority'), dataIndex: 'authority', - id: 'modx-role--authority', width: 60, align: 'center', sortable: true, @@ -110,7 +107,7 @@ MODx.grid.Role = function(config = {}) { selectedRecord = grid.getSelectionModel().getSelected(), roleIsAssigned = selectedRecord.json.isAssigned === 1 ; - if (roleIsAssigned) { + if (!selectedRecord.json.isProtected && roleIsAssigned) { Ext.Msg.show({ title: _('warning'), msg: _('role_warn_authority_locked'), @@ -124,22 +121,7 @@ MODx.grid.Role = function(config = {}) { } } }], - tbar: [{ - text: _('create'), - cls: 'primary-button', - handler: this.createRole, - scope: this, - listeners: { - render: { - fn: function(btn) { - if (!this.userCanCreate) { - btn.hide(); - } - }, - scope: this - } - } - }], + tbar: [this.getCreateButton('role', 'createRole')], viewConfig: this.getViewConfig(false, false) }); MODx.grid.Role.superclass.constructor.call(this, config); @@ -152,13 +134,8 @@ MODx.grid.Role = function(config = {}) { this.setShowActionsMenu(); this.on({ - render: function() { - this.setEditableColumnAccess( - ['modx-role--name', 'modx-role--description', 'modx-role--authority'] - ); - }, beforeedit: function(e) { - if (e.record.json.isProtected) { + if (!this.userCanEdit || e.record.json.isProtected || (e.field === 'authority' && e.record.json.isAssigned)) { return false; } } @@ -169,10 +146,9 @@ Ext.extend(MODx.grid.Role, MODx.grid.Grid, { getMenu: function() { const record = this.getSelectionModel().getSelected(), - { permissions } = record.json || '', menu = [] ; - if (permissions.delete) { + if (this.userCanDeleteRecord(record)) { menu.push({ text: _('delete'), handler: this.remove.createDelegate(this, ['role_remove_confirm', 'Security/Role/Remove']) diff --git a/manager/assets/modext/widgets/security/modx.grid.user.js b/manager/assets/modext/widgets/security/modx.grid.user.js index e123fe5235..d273cfd19b 100644 --- a/manager/assets/modext/widgets/security/modx.grid.user.js +++ b/manager/assets/modext/widgets/security/modx.grid.user.js @@ -101,7 +101,6 @@ MODx.grid.User = function(config = {}) { }, { header: _('user_full_name'), dataIndex: 'fullname', - id: 'modx-user--fullname', width: 180, sortable: true, editor: { xtype: 'textfield' }, @@ -116,7 +115,6 @@ MODx.grid.User = function(config = {}) { }, { header: _('email'), dataIndex: 'email', - id: 'modx-user--email', width: 180, sortable: true, editor: { @@ -133,7 +131,6 @@ MODx.grid.User = function(config = {}) { }, { header: _('active'), dataIndex: 'active', - id: 'modx-user--active', width: 80, sortable: true, editor: { @@ -154,7 +151,6 @@ MODx.grid.User = function(config = {}) { }, { header: _('user_block'), dataIndex: 'blocked', - id: 'modx-user--blocked', width: 80, sortable: true, editor: { @@ -174,22 +170,7 @@ MODx.grid.User = function(config = {}) { } }], tbar: [ - { - text: _('create'), - cls: 'primary-button', - handler: this.createUser, - scope: this, - listeners: { - render: { - fn: function(btn) { - if (!this.userCanCreate) { - btn.hide(); - } - }, - scope: this - } - } - }, + this.getCreateButton('user', 'createUser'), this.getBulkActionsButton('user', 'Security/User/RemoveMultiple', 'int', 'activate', 'deactivate'), '->', { @@ -225,18 +206,8 @@ MODx.grid.User = function(config = {}) { this.setShowActionsMenu(); this.on({ - render: function(grid) { - this.setEditableColumnAccess( - [ - 'modx-user--fullname', - 'modx-user--email', - 'modx-user--active', - 'modx-user--blocked' - ] - ); - }, beforeedit: function(e) { - if (!this.userCanEditRecord(e.record)) { + if (!this.userCanEdit || !this.userCanEditRecord(e.record)) { return false; } } @@ -246,21 +217,23 @@ Ext.extend(MODx.grid.User, MODx.grid.Grid, { getMenu: function() { const menu = []; if (this.getSelectionModel().getCount() > 1) { - menu.push({ - text: _('selected_activate'), - handler: this.activateSelected, - scope: this - }); - menu.push({ - text: _('selected_deactivate'), - handler: this.deactivateSelected, - scope: this - }); + if (this.userCanEdit) { + menu.push({ + text: _('selected_activate'), + handler: this.activateSelected, + scope: this + }); + menu.push({ + text: _('selected_deactivate'), + handler: this.deactivateSelected, + scope: this + }); + } if (this.userCanDelete) { menu.push('-'); menu.push({ text: _('selected_remove'), - handler: this.removeSelected + handler: this.removeSelected.bind(this, 'user', 'Security/User/RemoveMultiple') }); } } else { @@ -285,9 +258,7 @@ Ext.extend(MODx.grid.User, MODx.grid.Grid, { }); } } - if (menu.length > 0) { - this.addContextMenuItem(menu); - } + return menu; }, createUser: function() { diff --git a/manager/assets/modext/widgets/source/modx.panel.sources.js b/manager/assets/modext/widgets/source/modx.panel.sources.js index 48e8a59865..11ccc6c481 100644 --- a/manager/assets/modext/widgets/source/modx.panel.sources.js +++ b/manager/assets/modext/widgets/source/modx.panel.sources.js @@ -87,7 +87,6 @@ MODx.grid.Sources = function(config = {}) { }, { header: _('name'), dataIndex: 'name', - id: 'modx-source--name', width: 150, sortable: true, editor: { @@ -124,7 +123,6 @@ MODx.grid.Sources = function(config = {}) { }, { header: _('description'), dataIndex: 'description', - id: 'modx-source--description', width: 300, editor: { xtype: 'textarea' @@ -140,28 +138,15 @@ MODx.grid.Sources = function(config = {}) { }, this.getCreatorColumnConfig('source') ], - tbar: [{ - text: _('create'), - cls: 'primary-button', - handler: { + tbar: [ + this.getCreateButton('source', { xtype: 'modx-window-source-create', blankValues: true - }, - listeners: { - render: { - fn: function(btn) { - if (!this.userCanCreate) { - btn.hide(); - } - }, - scope: this - } - } - }, - this.getBulkActionsButton('source', 'Source/RemoveMultiple'), - '->', - this.getQueryFilterField(), - this.getClearFiltersButton() + }), + this.getBulkActionsButton('source', 'Source/RemoveMultiple'), + '->', + this.getQueryFilterField(), + this.getClearFiltersButton() ], viewConfig: this.getViewConfig() }); @@ -175,11 +160,6 @@ MODx.grid.Sources = function(config = {}) { this.setShowActionsMenu(); this.on({ - render: function(grid) { - this.setEditableColumnAccess( - ['modx-source--name', 'modx-source--description'] - ); - }, beforeedit: function(e) { if (e.record.json.isProtected || !this.userCanEditRecord(e.record)) { return false; @@ -218,10 +198,6 @@ Ext.extend(MODx.grid.Sources, MODx.grid.Grid, { return menu; }, - createSource: function() { - MODx.loadPage('system/source/create'); - }, - updateSource: function() { MODx.loadPage('source/update', `id=${this.menu.record.id}`); }, diff --git a/manager/assets/modext/widgets/system/modx.grid.content.type.js b/manager/assets/modext/widgets/system/modx.grid.content.type.js index f7d4cc46c1..289f1672ca 100644 --- a/manager/assets/modext/widgets/system/modx.grid.content.type.js +++ b/manager/assets/modext/widgets/system/modx.grid.content.type.js @@ -80,7 +80,6 @@ MODx.grid.ContentType = function(config = {}) { sortable: true }, { header: _('name'), - id: 'modx-content-type--name', dataIndex: 'name', sortable: true, editor: { xtype: 'textfield' }, @@ -94,7 +93,6 @@ MODx.grid.ContentType = function(config = {}) { } }, { header: _('description'), - id: 'modx-content-type--description', dataIndex: 'description', width: 200, editor: { xtype: 'textfield' }, @@ -108,7 +106,6 @@ MODx.grid.ContentType = function(config = {}) { } }, { header: _('mime_type'), - id: 'modx-content-type--mime', dataIndex: 'mime_type', width: 80, sortable: true, @@ -158,15 +155,6 @@ MODx.grid.ContentType = function(config = {}) { beforerender: function(grid) { grid.view = new Ext.grid.GridView(grid.getViewConfig(false)); }, - render: function() { - this.setEditableColumnAccess( - [ - 'modx-content-type--name', - 'modx-content-type--description', - 'modx-content-type--mime' - ] - ); - }, beforeedit: function(e) { const skipProtectionFieldList = ['file_extensions', 'icon']; if ((e.record.json.isProtected && !skipProtectionFieldList.includes(e.field)) || !this.userCanEditRecord(e.record)) { @@ -235,7 +223,7 @@ MODx.window.CreateContentType = function(config = {}) { items: [{ xtype: 'modx-description', id: 'modx-content-type-general-desc', - hidden: !config.record.json?.isProtected, + hidden: !config.isUpdate || !config.record?.json?.isProtected, html: _('content_type_reserved_general_desc') }, { layout: 'column', diff --git a/manager/assets/modext/widgets/system/modx.grid.context.js b/manager/assets/modext/widgets/system/modx.grid.context.js index bf14b497c3..eaf658e831 100644 --- a/manager/assets/modext/widgets/system/modx.grid.context.js +++ b/manager/assets/modext/widgets/system/modx.grid.context.js @@ -76,7 +76,6 @@ MODx.grid.Context = function(config = {}) { }, { header: _('name'), dataIndex: 'name', - id: 'modx-context--name', width: 150, sortable: true, editor: { @@ -116,7 +115,6 @@ MODx.grid.Context = function(config = {}) { }, { header: _('description'), dataIndex: 'description', - id: 'modx-context--description', width: 575, sortable: false, editor: { @@ -135,7 +133,6 @@ MODx.grid.Context = function(config = {}) { { header: _('rank'), dataIndex: 'rank', - id: 'modx-context--rank', width: 100, align: 'center', sortable: true, @@ -152,12 +149,7 @@ MODx.grid.Context = function(config = {}) { } }], tbar: [ - { - text: _('create'), - cls: 'primary-button', - handler: this.create, - scope: this - }, + this.getCreateButton('context'), '->', this.getQueryFilterField(), this.getClearFiltersButton() @@ -174,13 +166,8 @@ MODx.grid.Context = function(config = {}) { this.setShowActionsMenu(); this.on({ - render: function() { - this.setEditableColumnAccess( - ['modx-context--name', 'modx-context--description', 'modx-context--rank'] - ); - }, beforeedit: function(e) { - if (e.record.json.key === 'mgr' || !this.userCanEditRecord(e.record)) { + if (!this.userCanEdit || e.record.json.key === 'mgr' || !this.userCanEditRecord(e.record)) { return false; } } diff --git a/manager/assets/modext/widgets/system/modx.grid.dashboard.widgets.js b/manager/assets/modext/widgets/system/modx.grid.dashboard.widgets.js index 8bcb304c1f..eec0924a04 100644 --- a/manager/assets/modext/widgets/system/modx.grid.dashboard.widgets.js +++ b/manager/assets/modext/widgets/system/modx.grid.dashboard.widgets.js @@ -85,12 +85,7 @@ MODx.grid.DashboardWidgets = function(config = {}) { this.getCreatorColumnConfig('dashboard') ], tbar: [ - { - text: _('create'), - cls: 'primary-button', - handler: this.createDashboard, - scope: this - }, + this.getCreateButton('dashboard', 'createDashboard'), this.getBulkActionsButton('widget', 'System/Dashboard/Widget/RemoveMultiple'), '->', this.getQueryFilterField(`filter-query-dashboardWidgets:${queryValue}`), @@ -143,9 +138,7 @@ Ext.extend(MODx.grid.DashboardWidgets, MODx.grid.Grid, { }); } } - if (menu.length > 0) { - this.addContextMenuItem(menu); - } + return menu; }, createDashboard: function() { diff --git a/manager/assets/modext/widgets/system/modx.panel.dashboards.js b/manager/assets/modext/widgets/system/modx.panel.dashboards.js index 2a0a440775..99b5f47c06 100644 --- a/manager/assets/modext/widgets/system/modx.panel.dashboards.js +++ b/manager/assets/modext/widgets/system/modx.panel.dashboards.js @@ -80,7 +80,6 @@ MODx.grid.Dashboards = function(config = {}) { }, { header: _('name'), dataIndex: 'name', - id: 'modx-dashboard--name', width: 150, sortable: true, editor: { @@ -117,7 +116,6 @@ MODx.grid.Dashboards = function(config = {}) { }, { header: _('description'), dataIndex: 'description', - id: 'modx-dashboard--description', width: 300, sortable: false, editor: { @@ -135,12 +133,7 @@ MODx.grid.Dashboards = function(config = {}) { this.getCreatorColumnConfig('dashboard') ], tbar: [ - { - text: _('create'), - cls: 'primary-button', - handler: this.createDashboard, - scope: this - }, + this.getCreateButton('dashboard', 'createDashboard'), this.getBulkActionsButton('dashboard', 'System/Dashboard/RemoveMultiple'), '->', { diff --git a/manager/assets/modext/workspace/lexicon/lexicon.grid.js b/manager/assets/modext/workspace/lexicon/lexicon.grid.js index d616d0e91a..8eaa1053c5 100644 --- a/manager/assets/modext/workspace/lexicon/lexicon.grid.js +++ b/manager/assets/modext/workspace/lexicon/lexicon.grid.js @@ -57,16 +57,21 @@ MODx.grid.Lexicon = function(config = {}) { tbar: { cls: 'has-nested-filters', items: [ + this.getCreateButton('lexicon', 'createEntry'), { - xtype: 'button', - text: _('create'), - cls: 'primary-button', - handler: this.createEntry, - scope: this - }, { text: _('lexicon_revert'), handler: this.reloadFromBase, - scope: this + scope: this, + listeners: { + render: { + fn: function(btn) { + if (!this.userCanEdit) { + btn.hide(); + } + }, + scope: this + } + } }, '->', { @@ -225,7 +230,9 @@ MODx.grid.Lexicon = function(config = {}) { this.gridMenuActions = ['edit']; // Note there are currently no action-specific permissions for Lexicons + this.setUserCanCreate(['lexicons']); this.setUserCanEdit(['lexicons']); + this.setUserCanDelete(['lexicons']); this.setShowActionsMenu(); }; Ext.extend(MODx.grid.Lexicon, MODx.grid.Grid, { diff --git a/manager/assets/modext/workspace/namespace/modx.namespace.panel.js b/manager/assets/modext/workspace/namespace/modx.namespace.panel.js index d92bbcae31..f86cad9ec6 100644 --- a/manager/assets/modext/workspace/namespace/modx.namespace.panel.js +++ b/manager/assets/modext/workspace/namespace/modx.namespace.panel.js @@ -75,7 +75,6 @@ MODx.grid.Namespace = function(config = {}) { columns: [this.sm, { header: _('name'), dataIndex: 'name', - id: 'modx-namespace--name', width: 200, sortable: true, // because PK is name, allowing edit is tricky as implemented; leave for now @@ -92,7 +91,6 @@ MODx.grid.Namespace = function(config = {}) { }, { header: _('namespace_path'), dataIndex: 'path', - id: 'modx-namespace--path', width: 500, sortable: false, editor: { @@ -114,7 +112,6 @@ MODx.grid.Namespace = function(config = {}) { }, { header: _('namespace_assets_path'), dataIndex: 'assets_path', - id: 'modx-namespace--assets_path', width: 500, sortable: false, editor: { @@ -136,19 +133,15 @@ MODx.grid.Namespace = function(config = {}) { }, this.getCreatorColumnConfig('namespace') ], - tbar: [{ - text: _('create'), - handler: { + tbar: [ + this.getCreateButton('namespace', { xtype: 'modx-window-namespace-create', blankValues: true - }, - cls: 'primary-button', - scope: this - }, - this.getBulkActionsButton('namespace', 'Workspace/PackageNamespace/RemoveMultiple', 'string'), - '->', - this.getQueryFilterField(), - this.getClearFiltersButton() + }), + this.getBulkActionsButton('namespace', 'Workspace/PackageNamespace/RemoveMultiple', 'string'), + '->', + this.getQueryFilterField(), + this.getClearFiltersButton() ], viewConfig: this.getViewConfig() }); @@ -163,13 +156,10 @@ MODx.grid.Namespace = function(config = {}) { this.setShowActionsMenu(); this.on({ - render: function() { - this.setEditableColumnAccess( - ['modx-namespace--path', 'modx-namespace--assets_path'] - ); - }, beforeedit: function(e) { - return !(e.record.json.isProtected || e.record.json.isExtrasNamespace); + if (!this.userCanEditRecord(e.record) || e.record.json.isProtected || e.record.json.isExtrasNamespace) { + return false; + } } }); }; @@ -185,7 +175,7 @@ Ext.extend(MODx.grid.Namespace, MODx.grid.Grid, { handler: this.updateNamespace }); } - if (this.userCanDelete && !record.json.isProtected) { + if (this.userCanDelete && this.userCanEditRecord(record)) { if (menu.length > 0) { menu.push('-'); } diff --git a/manager/assets/modext/workspace/package/package.versions.grid.js b/manager/assets/modext/workspace/package/package.versions.grid.js index 8b690b142b..3a4287ce4f 100644 --- a/manager/assets/modext/workspace/package/package.versions.grid.js +++ b/manager/assets/modext/workspace/package/package.versions.grid.js @@ -56,7 +56,17 @@ MODx.grid.PackageVersions = function(config = {}) { autosave: true, tbar: [{ text: _('package_versions_purge'), - handler: this.purgePackageVersions + handler: this.purgePackageVersions, + listeners: { + render: { + fn: function(btn) { + if (!this.userCanDelete) { + btn.hide(); + } + }, + scope: this + } + } }] }); MODx.grid.PackageVersions.superclass.constructor.call(this, config);