Skip to content
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

File manager - Fix possibility to specify toolbar items by option full name #12749

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
16 changes: 12 additions & 4 deletions js/ui/file_manager/ui.file_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,19 @@ class FileManager extends Widget {
case 'toolbar':
{
const toolbarOptions = {};
if(args.value.items) {
toolbarOptions.generalItems = args.value.items;
if(args.fullName === 'toolbar') {
if(args.value.items) {
toolbarOptions.generalItems = args.value.items;
}
if(args.value.fileSelectionItems) {
toolbarOptions.fileItems = args.value.fileSelectionItems;
}
}
if(args.value.fileSelectionItems) {
toolbarOptions.fileItems = args.value.fileSelectionItems;
if(args.fullName === 'toolbar.items') {
toolbarOptions.generalItems = args.value;
}
if(args.fullName === 'toolbar.fileSelectionItems') {
toolbarOptions.fileItems = args.value;
}
this._toolbar.option(toolbarOptions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -849,4 +849,49 @@ QUnit.module('Toolbar', moduleConfig, () => {
assert.strictEqual($afterItems.length, 0, 'there is no items in after group');
});

test('toolbar items can be specified by option full name', function(assert) {
createFileManager(false);
this.clock.tick(400);

const fileManager = this.wrapper.getInstance();
fileManager.option('toolbar.items', [
'create',
{
widget: 'dxButton',
options: {
text: 'item 1'
},
locateInMenu: 'never'
},
'upload']);
this.clock.tick(400);
fileManager.option('toolbar.fileSelectionItems', [
'move',
{
widget: 'dxButton',
options: {
text: 'item 2'
},
locateInMenu: 'never'
},
'rename']);
this.clock.tick(400);

const $generalToolbarElements = this.wrapper.getGeneralToolbarElements();
assert.strictEqual($generalToolbarElements.length, 3, 'there are three elements in general toolbar');
assert.strictEqual($generalToolbarElements.eq(0).text(), 'New directory', 'fisrt general element correct');
assert.strictEqual($generalToolbarElements.eq(1).text(), 'item 1', 'second general element correct');
assert.strictEqual($generalToolbarElements.eq(2).text(), 'Upload files', 'third general element correct');

const $item = this.wrapper.findDetailsItem('File 1.txt');
$item.trigger('dxclick');
this.clock.tick(400);

const $fileToolbarElements = this.wrapper.getFileSelectionToolbarElements();
assert.strictEqual($fileToolbarElements.length, 3, 'there are three elements in file toolbar');
assert.strictEqual($fileToolbarElements.eq(0).text(), 'Move to', 'fisrt file element correct');
assert.strictEqual($fileToolbarElements.eq(1).text(), 'item 2', 'second file element correct');
assert.strictEqual($fileToolbarElements.eq(2).text(), 'Rename', 'third file element correct');
});

});