Commit a8ebadb6 authored by Jochen Roth's avatar Jochen Roth Committed by Oliver Bartsch
Browse files

[TASK] Remove duplicated button in Edit File dialog

The button "save and close" is removed because
"save" button does exactly the same thing.
To streamline behavior the save button also
returns to edit file view instead of returning
file list view.

On top of that add a test to cover such redirect
issues in the future.

Resolves: #94481
Resolves: #91840
Releases: master
Change-Id: I5656cdbdc31444f632e05577c34cee50daed71e5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69717


Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent 971a62cf
......@@ -226,7 +226,7 @@ class ExtendedFileUtility extends BasicFileUtility
}
// Check if there were new folder names expected, but non given
if ($this->fileCmdMap['newfolder']) {
if ($this->fileCmdMap['newfolder'] ?? false) {
foreach ($this->fileCmdMap['newfolder'] as $key => $cmdArr) {
if (empty($cmdArr['data'])) {
unset($this->fileCmdMap['newfolder'][$key]);
......
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\FileList;
use TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester;
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
/**
* Cases concerning sys_file_metadata records
*/
class FileOperationsCest
{
/**
* @param BackendTester $I
*/
public function _before(BackendTester $I)
{
$I->useExistingSession('admin');
$I->amOnPage('/typo3/module/file/FilelistList');
$I->switchToContentFrame();
}
/**
* @param BackendTester $I
*/
public function fileCrud(BackendTester $I, ModalDialog $modalDialog)
{
$fileTextareaSelector = 'textarea[name="data[editfile][0][data]"]';
$fileName = 'typo3-test.txt';
$flashMessageSelector = '.typo3-messages';
// Create file
$I->amGoingTo('create a file with content');
$I->click('.module-docheader .btn[title="New"]');
$I->wait(0.2);
$I->see('New file or folder', 'h1');
$I->fillField('#newfile', $fileName);
$I->wait(0.2);
$I->click('Create file');
$I->see('File created:', $flashMessageSelector);
$I->fillField($fileTextareaSelector, 'Some Text');
// Save file
$I->amGoingTo('save the file');
$I->click('.module-docheader button[name="_save"]');
$textareaValue = $I->grabValueFrom($fileTextareaSelector);
$I->assertEquals('Some Text', $textareaValue);
$I->see('File saved to', $flashMessageSelector);
// Save file
$I->amGoingTo('close the file and return to the list view');
$I->click('.module-docheader .btn[title="Cancel"]');
$I->see($fileName, '.col-title');
// Delete file
$I->amGoingTo('delete the file');
$I->click('a[data-identifier="1:/' . $fileName . '"]');
$modalDialog->canSeeDialog();
$modalDialog->clickButtonInDialog('Yes, delete this file');
$I->waitForElementNotVisible('a[data-identifier="1:/' . $fileName . '"]');
$I->switchToContentFrame();
$I->see('File deleted', $flashMessageSelector);
$I->dontSee($fileName, '.col-title');
}
}
......@@ -201,13 +201,16 @@ class EditFileController
throw new \Exception('Files with that extension are not editable. Allowed extensions are: ' . $extList, 1476050135);
}
$fullIdentifier= $this->fileObject->getCombinedIdentifier();
$returnUrl = (string)$this->uriBuilder->buildUriFromRoute('file_edit', ['target' => $fullIdentifier]);
// Making the formfields
$formData = [
'databaseRow' => [
'uid' => 0,
'data' => $this->fileObject->getContents(),
'target' => $this->fileObject->getUid(),
'redirect' => $this->returnUrl,
'redirect' => $returnUrl,
],
'tableName' => 'editfile',
'processedTca' => [
......@@ -300,24 +303,10 @@ class EditFileController
->setName('_save')
->setValue('1')
->setForm('EditFileController')
->setShowLabelText(true)
->setTitle($lang->sL('LLL:EXT:filelist/Resources/Private/Language/locallang.xlf:file_edit.php.submit'))
->setIcon($this->iconFactory->getIcon('actions-document-save', Icon::SIZE_SMALL));
// Save and Close button
$saveAndCloseButton = $buttonBar->makeInputButton()
->setName('_saveandclosedok')
->setValue('1')
->setForm('EditFileController')
->setTitle($lang->sL('LLL:EXT:filelist/Resources/Private/Language/locallang.xlf:file_edit.php.saveAndClose'))
->setIcon($this->iconFactory->getIcon(
'actions-document-save-close',
Icon::SIZE_SMALL
));
$splitButton = $buttonBar->makeSplitButton()
->addItem($saveButton)
->addItem($saveAndCloseButton);
$buttonBar->addButton($splitButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
$buttonBar->addButton($saveButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
// Cancel button
$closeButton = $buttonBar->makeLinkButton()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment