diff --git a/.upgrade.yml b/.upgrade.yml index f2ffe8a6..1d4cbe17 100644 --- a/.upgrade.yml +++ b/.upgrade.yml @@ -4,8 +4,6 @@ mappings: CMSBatchAction_Archive: SilverStripe\CMS\BatchActions\CMSBatchAction_Archive CMSBatchAction_Restore: SilverStripe\CMS\BatchActions\CMSBatchAction_Restore CMSBatchAction_Delete: SilverStripe\CMS\BatchActions\CMSBatchAction_Delete - AssetAdmin: SilverStripe\CMS\Controllers\AssetAdmin - AssetAdmin_DeleteBatchAction: SilverStripe\CMS\Controllers\AssetAdmin_DeleteBatchAction CMSMain: SilverStripe\CMS\Controllers\CMSMain CMSPageAddController: SilverStripe\CMS\Controllers\CMSPageAddController CMSPageEditController: SilverStripe\CMS\Controllers\CMSPageEditController diff --git a/client/dist/js/AssetAdmin.js b/client/dist/js/AssetAdmin.js deleted file mode 100644 index 38f586e5..00000000 --- a/client/dist/js/AssetAdmin.js +++ /dev/null @@ -1,107 +0,0 @@ -(function (global, factory) { - if (typeof define === "function" && define.amd) { - define('ss.AssetAdmin', ['jQuery', 'i18n'], factory); - } else if (typeof exports !== "undefined") { - factory(require('jQuery'), require('i18n')); - } else { - var mod = { - exports: {} - }; - factory(global.jQuery, global.i18n); - global.ssAssetAdmin = mod.exports; - } -})(this, function (_jQuery, _i18n) { - 'use strict'; - - var _jQuery2 = _interopRequireDefault(_jQuery); - - var _i18n2 = _interopRequireDefault(_i18n); - - function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { - default: obj - }; - } - - _jQuery2.default.entwine('ss', function ($) { - $('.AssetAdmin.cms-edit-form .ss-gridfield-item').entwine({ - onclick: function onclick(e) { - if ($(e.target).closest('.action').length) { - this._super(e); - return; - } - - var grid = this.closest('.grid-field'); - if (this.data('class') == 'Folder') { - var url = grid.data('urlFolderTemplate').replace('%s', this.data('id')); - $('.cms-container').loadPanel(url); - return false; - } - - this._super(e); - } - }); - - $('.AssetAdmin.cms-edit-form .grid-field .grid-field__col-compact .action.gridfield-button-delete, .AssetAdmin.cms-edit-form .btn-toolbar button.action.action-delete').entwine({ - onclick: function onclick(e) { - var msg; - if (this.closest('.ss-gridfield-item').data('class') == 'Folder') { - msg = _i18n2.default._t('AssetAdmin.ConfirmDelete'); - } else { - msg = _i18n2.default._t('TABLEFIELD.DELETECONFIRMMESSAGE'); - } - if (!confirm(msg)) return false; - - this.getGridField().reload({ data: [{ name: this.attr('name'), value: this.val() }] }); - e.preventDefault(); - return false; - } - }); - - $('.AssetAdmin.cms-edit-form :submit[name=action_delete]').entwine({ - onclick: function onclick(e) { - if (!confirm(_i18n2.default._t('AssetAdmin.ConfirmDelete'))) return false;else this._super(e); - } - }); - - $('.AssetAdmin .cms-add-folder-link').entwine({ - onclick: function onclick(e) { - var name = prompt(_i18n2.default._t('Folder.Name')); - if (!name) return false; - - this.closest('.cms-container').loadPanel(this.data('url') + '&Name=' + name); - return false; - } - }); - - $('#Form_SyncForm').entwine({ - onsubmit: function onsubmit(e) { - var button = jQuery(this).find(':submit:first'); - button.addClass('loading'); - $.ajax({ - url: jQuery(this).attr('action'), - data: this.serializeArray(), - success: function success() { - button.removeClass('loading'); - - var currNode = $('.cms-tree')[0].firstSelected(); - if (currNode) { - var url = $(currNode).find('a').attr('href'); - $('.cms-content').loadPanel(url); - } - $('.cms-tree')[0].setCustomURL('admin/assets/getsubtree'); - $('.cms-tree')[0].reload({ onSuccess: function onSuccess() {} }); - } - }); - - return false; - } - }); - - $('.AssetAdmin.cms-edit-form .ss-uploadfield-item-progress').entwine({ - onunmatch: function onunmatch() { - $('.AssetAdmin.cms-edit-form .grid-field').reload(); - } - }); - }); -}); \ No newline at end of file diff --git a/client/dist/js/CMSMain.Tree.js b/client/dist/js/CMSMain.Tree.js index e4120966..e018ba3d 100644 --- a/client/dist/js/CMSMain.Tree.js +++ b/client/dist/js/CMSMain.Tree.js @@ -60,8 +60,8 @@ 'items': function items(node) { var menuitems = { - 'edit': { - 'label': _i18n2.default._t('Tree.EditPage', 'Edit page', 100, 'Used in the context menu when right-clicking on a page node in the CMS tree'), + edit: { + 'label': node.hasClass('edit-disabled') ? _i18n2.default._t('Tree.EditPage', 'Edit page', 100, 'Used in the context menu when right-clicking on a page node in the CMS tree') : _i18n2.default._t('Tree.ViewPage', 'View page', 100, 'Used in the context menu when right-clicking on a page node in the CMS tree'), 'action': function action(obj) { $('.cms-container').entwine('.ss').loadPanel(_i18n2.default.sprintf(self.data('urlEditpage'), obj.data('id'))); } @@ -101,20 +101,22 @@ }; } - menuitems['duplicate'] = { - 'label': _i18n2.default._t('Tree.Duplicate'), - 'submenu': [{ - 'label': _i18n2.default._t('Tree.ThisPageOnly'), - 'action': function action(obj) { - $('.cms-container').entwine('.ss').loadPanel($.path.addSearchParams(_i18n2.default.sprintf(self.data('urlDuplicate'), obj.data('id')), self.data('extraParams'))); - } - }, { - 'label': _i18n2.default._t('Tree.ThisPageAndSubpages'), - 'action': function action(obj) { - $('.cms-container').entwine('.ss').loadPanel($.path.addSearchParams(_i18n2.default.sprintf(self.data('urlDuplicatewithchildren'), obj.data('id')), self.data('extraParams'))); - } - }] - }; + if (!node.hasClass('edit-disabled')) { + menuitems['duplicate'] = { + 'label': _i18n2.default._t('Tree.Duplicate'), + 'submenu': [{ + 'label': _i18n2.default._t('Tree.ThisPageOnly'), + 'action': function action(obj) { + $('.cms-container').entwine('.ss').loadPanel($.path.addSearchParams(_i18n2.default.sprintf(self.data('urlDuplicate'), obj.data('id')), self.data('extraParams'))); + } + }, { + 'label': _i18n2.default._t('Tree.ThisPageAndSubpages'), + 'action': function action(obj) { + $('.cms-container').entwine('.ss').loadPanel($.path.addSearchParams(_i18n2.default.sprintf(self.data('urlDuplicatewithchildren'), obj.data('id')), self.data('extraParams'))); + } + }] + }; + } return menuitems; } diff --git a/client/dist/js/bundle-legacy.js b/client/dist/js/bundle-legacy.js index 070aa291..d017df7c 100644 --- a/client/dist/js/bundle-legacy.js +++ b/client/dist/js/bundle-legacy.js @@ -1,2 +1,2 @@ -!function t(e,n,i){function a(r,s){if(!n[r]){if(!e[r]){var d="function"==typeof require&&require;if(!s&&d)return d(r,!0);if(o)return o(r,!0);var l=new Error("Cannot find module '"+r+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[r]={exports:{}};e[r][0].call(c.exports,function(t){var n=e[r][1][t];return a(n?n:t)},c,c.exports,t,e,n,i)}return n[r].exports}for(var o="function"==typeof require&&require,r=0;r0&&(e._addActions(),this.bind("change",function(n){var o=e.data("OrigVal"),r=e.val();e.data("OrigVal",r),0===i.val().indexOf(i.data("defaultUrl"))&&""==a.val()?e.updateURLSegment(r):t(".update",e.parent()).show(),e.updateRelatedFields(r,o),e.updateBreadcrumbLabel(r)})),this._super()},onunmatch:function(){this._super()},updateRelatedFields:function(e,n){this.parents("form").find("input[name=MetaTitle], input[name=MenuTitle]").each(function(){var i=t(this);i.val()==n&&(i.val(e),i.updatedRelatedFields&&i.updatedRelatedFields())})},updateURLSegment:function(e){var n=t("input:text[name=URLSegment]",this.closest("form")),i=n.closest(".field.urlsegment"),a=t(".update",this.parent());i.update(e),a.is(":visible")&&a.hide()},updateBreadcrumbLabel:function(e){var n=(t(".cms-edit-form input[name=ID]").val(),t("span.cms-panel-link.crumb"));e&&""!=e&&n.text(e)},_addActions:function(){var e,n=this;e=t(" - -
- -
- - <% end_with %> - <% end_if %> - - -
- $Top.Tools - -
- $forTemplate -
-
- <% end_with %> - - diff --git a/templates/SilverStripe/CMS/Controllers/Includes/AssetAdmin_EditForm.ss b/templates/SilverStripe/CMS/Controllers/Includes/AssetAdmin_EditForm.ss deleted file mode 100644 index f3f087a9..00000000 --- a/templates/SilverStripe/CMS/Controllers/Includes/AssetAdmin_EditForm.ss +++ /dev/null @@ -1,30 +0,0 @@ -
- - <% if $Message %> -

$Message

- <% else %> - - <% end_if %> - -
- <% if $Legend %>$Legend<% end_if %> - <% loop $Fields %> - $FieldHolder - <% end_loop %> -
-
- - <% if $Actions %> -
- <% loop $Actions %> - $Field - <% end_loop %> - <% if $CurrentPage.LinkPreview %> - - <% _t('LeftAndMain.PreviewButton', 'Preview') %> » - - <% end_if %> -
- <% end_if %> - -
diff --git a/templates/SilverStripe/CMS/Controllers/Includes/AssetAdmin_Tools.ss b/templates/SilverStripe/CMS/Controllers/Includes/AssetAdmin_Tools.ss deleted file mode 100644 index 596a6530..00000000 --- a/templates/SilverStripe/CMS/Controllers/Includes/AssetAdmin_Tools.ss +++ /dev/null @@ -1,3 +0,0 @@ -
- $SearchForm -
diff --git a/templates/SilverStripe/CMS/Controllers/Includes/AssetAdmin_UploadContent.ss b/templates/SilverStripe/CMS/Controllers/Includes/AssetAdmin_UploadContent.ss deleted file mode 100644 index 64a65ddd..00000000 --- a/templates/SilverStripe/CMS/Controllers/Includes/AssetAdmin_UploadContent.ss +++ /dev/null @@ -1,28 +0,0 @@ -
- - - -
-
- $UploadForm -
-
- Not implemented yet -
-
- -
diff --git a/tests/behat/features/manage-files.feature b/tests/behat/features/manage-files.feature deleted file mode 100644 index 37b0b0ab..00000000 --- a/tests/behat/features/manage-files.feature +++ /dev/null @@ -1,82 +0,0 @@ -@javascript @assets -Feature: Manage files - As a cms author - I want to upload and manage files within the CMS - So that I can insert them into my content efficiently - - Background: - Given a "image" "folder1/file1.jpg" was created "2012-01-01 12:00:00" - And a "image" "folder1/folder1-1/file2.jpg" was created "2010-01-01 12:00:00" - And a "folder" "folder2" - And I am logged in with "ADMIN" permissions - And I go to "/admin/assets" - - @modal - Scenario: I can add a new folder - Given I press the "Add folder" button - And I type "newfolder" into the dialog - And I confirm the dialog - Then the "Files" table should contain "newfolder" - - Scenario: I can list files in a folder - Given I click on "folder1" in the "Files" table - Then the "folder1" table should contain "file1" - And the "folder1" table should not contain "file1-1" - - Scenario: I can upload a file to a folder - Given I click on "folder1" in the "Files" table - And I attach the file "testfile.jpg" to "AssetUploadField" with HTML5 - And I wait for 5 seconds - Then the "folder1" table should contain "testfile" - - Scenario: I can edit a file - Given I click on "folder1" in the "Files" table - And I click on "file1" in the "folder1" table - And I fill in "renamedfile" for "Title" - And I press the "Save" button - And I follow "folder1" - Then the "folder1" table should not contain "testfile" - And the "folder1" table should contain "renamedfile" - - Scenario: I can delete a file - Given I click on "folder1" in the "Files" table - And I click on "file1" in the "folder1" table - And I press the "Archive" button - Then the "folder1" table should not contain "file1" - - Scenario: I can change the folder of a file - Given I click on "folder1" in the "Files" table - And I click on "file1" in the "folder1" table - And I fill in "folder2" for the "Folder" dropdown - And I press the "Save" button - And I click "Files" in the ".breadcrumbs-wrapper" element - And I click on "folder2" in the "Files" table - And the "folder2" table should contain "file1" - - Scenario: I can see allowed extensions help - When I go to "/admin/assets/" - And I click "Show allowed extensions" in the ".ss-uploadfield-view-allowed-extensions" element - Then I should see "png," - - Scenario: I can filter the files list view using name - Given I expand the content filters - And I fill in "Name" with "file1" - And I press the "Search" button - Then the "Files" table should contain "file1" - And the "Files" table should not contain "file2" - - Scenario: I can filter the files list view using filetype - Given a "file" "document.pdf" - And I expand the content filters - And I select "Image" from "File type" with javascript - And I press the "Search" button - Then the "Files" table should contain "file1" - And the "Files" table should not contain "document" - - Scenario: I can filter out files that don't match the date range - Given I expand the content filters - And I fill in "From" with "2003-01-01" - And I fill in "To" with "2011-01-01" - And I press the "Search" button - And the "Files" table should contain "file2" - And the "Files" table should not contain "file1" diff --git a/tests/controller/AssetAdminTest.php b/tests/controller/AssetAdminTest.php deleted file mode 100644 index 2d1c8194..00000000 --- a/tests/controller/AssetAdminTest.php +++ /dev/null @@ -1,119 +0,0 @@ -filter('ClassName', 'Folder') as $folder) { - /** @var Folder $folder */ - $folder->publishSingle(); - } - - // Create a test files for each of the fixture references - $content = str_repeat('x',1000000); - foreach(File::get()->exclude('ClassName', 'Folder') as $file) { - /** @var File $file */ - $file->setFromString($content, $file->generateFilename()); - $file->publishSingle(); - } - } - - public function tearDown() { - parent::tearDown(); - - // Remove the test files that we've created - $fileIDs = $this->allFixtureIDs('File'); - foreach($fileIDs as $fileID) { - $file = DataObject::get_by_id('File', $fileID); - if($file && file_exists(BASE_PATH."/$file->Filename")) unlink(BASE_PATH."/$file->Filename"); - } - - // Remove the test folders that we've crated - $folderIDs = $this->allFixtureIDs('Folder'); - foreach($folderIDs as $folderID) { - $folder = DataObject::get_by_id('Folder', $folderID); - if($folder && file_exists(BASE_PATH."/$folder->Filename")) { - Filesystem::removeFolder(BASE_PATH."/$folder->Filename"); - } - } - - // Remove left over folders and any files that may exist - if(file_exists(ASSETS_PATH.'/AssetAdminTest')) { - Filesystem::removeFolder(ASSETS_PATH.'/AssetAdminTest'); - } - } - - /** - * Mock a file search using AssetAdmin - * - * @param string $name - * @param string $from Created from date - * @param string $to Createi to date - * @param string $category - * @return SS_List - */ - protected function getResultsForSearch($name = '', $from = '', $to = '', $category = '') { - $request = new SS_HTTPRequest(null, 'admin/assets/show', array( - 'q' => array( - 'Name' => $name, - 'CreatedFrom' => $from, - 'CreatedTo' => $to, - 'AppCategory' => $category - ), - 'action_doSearch' => 'Apply Filter' - )); - $admin = new AssetAdmin(); - $admin->setRequest($request); - return $admin->getList(); - } - - /** - * Tests filtering between date ranges - */ - public function testDateFromToLastSameDate() { - $file1 = $this->objFromFixture('File', 'file1'); - $file2 = $this->objFromFixture('File', 'file2'); - - // Force creation times - $file1->Created = '2014-01-05 23:11:39'; - $file1->write(); - $file2->Created = '2014-01-06 12:00:00'; - $file2->write(); - - // Mock searches for 4th Jan - $results = $this->getResultsForSearch(null, '2014-01-04', '2014-01-04'); - $this->assertEmpty($results->column('Title')); - - // Mock searches for 5th Jan - $results = $this->getResultsForSearch(null, '2014-01-05', '2014-01-05'); - $this->assertEquals(array('File1'), $results->column('Title')); - - // Mock searches for 5th-6th Jan - $results = $this->getResultsForSearch(null, '2014-01-05', '2014-01-06'); - $this->assertEquals(array('File1', 'File2'), $results->sort('Title')->column('Title')); - - // Mock searches for 6th Jan - $results = $this->getResultsForSearch(null, '2014-01-06', '2014-01-06'); - $this->assertEquals(array('File2'), $results->column('Title')); - - // Mock searches for 7th Jan - $results = $this->getResultsForSearch(null, '2014-01-07', '2014-01-07'); - $this->assertEmpty($results->column('Title')); - } -} diff --git a/tests/controller/AssetAdminTest.yml b/tests/controller/AssetAdminTest.yml deleted file mode 100644 index 8529be9f..00000000 --- a/tests/controller/AssetAdminTest.yml +++ /dev/null @@ -1,12 +0,0 @@ -Folder: - folder1: - Name: AssetAdminTest -File: - file1: - Title: File1 - Name: file1.txt - ParentID: =>Folder.folder1 - file2: - Title: File2 - Name: file2.txt - ParentID: =>Folder.folder1 diff --git a/tests/controller/CMSMainTest.yml b/tests/controller/CMSMainTest.yml index 3a75b8b0..fbe2ed61 100644 --- a/tests/controller/CMSMainTest.yml +++ b/tests/controller/CMSMainTest.yml @@ -105,9 +105,6 @@ SilverStripe\Security\Member: Email: admin@example.com Password: ZXXlkwecxz2390232233 Groups: =>SilverStripe\Security\Group.admin - assetsonlyuser: - Email: assetsonlyuser@test.com - Groups: =>SilverStripe\Security\Group.assetsonly allcmssectionsuser: Email: allcmssectionsuser@test.com Groups: =>SilverStripe\Security\Group.allcmssections @@ -118,9 +115,6 @@ SilverStripe\Security\Permission: admin: Code: ADMIN GroupID: =>SilverStripe\Security\Group.admin - assetsonly: - Code: CMS_ACCESS_AssetAdmin - GroupID: =>SilverStripe\Security\Group.assetsonly allcmssections: Code: CMS_ACCESS_LeftAndMain GroupID: =>SilverStripe\Security\Group.allcmssections diff --git a/tests/controller/SilverStripeNavigatorTest.php b/tests/controller/SilverStripeNavigatorTest.php index 96afd96f..e2212fbc 100644 --- a/tests/controller/SilverStripeNavigatorTest.php +++ b/tests/controller/SilverStripeNavigatorTest.php @@ -32,11 +32,10 @@ class SilverStripeNavigatorTest extends SapphireTest { public function testCanView() { $page = $this->objFromFixture('Page', 'page1'); $admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin'); - $author = $this->objFromFixture('SilverStripe\\Security\\Member', 'assetsonlyuser'); $navigator = new SilverStripeNavigator($page); // TODO Shouldn't be necessary but SapphireTest logs in as ADMIN by default - $this->logInWithPermission('CMS_ACCESS_AssetAdmin'); + $this->logInWithPermission('CMS_ACCESS_CMSMain'); $items = $navigator->getItems(); $classes = array_map('get_class', $items->toArray()); $this->assertNotContains('SilverStripeNavigatorTest_ProtectedTestItem', $classes);