Skip to content

Commit

Permalink
Prevents the sidebar from being shown when creating a new directory
Browse files Browse the repository at this point in the history
Signed-off-by: Kavita Sonawane <kavita.sonawane@t-systems.com>
  • Loading branch information
TSI-kavitasonawane authored and skjnldsv committed Mar 2, 2022
1 parent 9847d4a commit 89dbe05
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
19 changes: 12 additions & 7 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@
}

if (options.scrollTo) {
this.scrollTo(fileData.name);
this.scrollTo(fileData.name, options.showDetailsView !== undefined ? options.showDetailsView : true);
}

// defaults to true if not defined
Expand Down Expand Up @@ -3060,7 +3060,7 @@
*
* @since 8.2
*/
createDirectory: function(name) {
createDirectory: function(name, options) {
var self = this;
var deferred = $.Deferred();
var promise = deferred.promise();
Expand All @@ -3076,7 +3076,8 @@

this.filesClient.createDirectory(targetPath)
.done(function() {
self.addAndFetchFileInfo(targetPath, '', {scrollTo:true}).then(function(status, data) {
options = _.extend({scrollTo: true}, options || {});
self.addAndFetchFileInfo(targetPath, '', options).then(function(status, data) {
deferred.resolve(status, data);
}, function() {
OC.Notification.show(t('files', 'Could not create folder "{dir}"',
Expand All @@ -3087,8 +3088,9 @@
.fail(function(createStatus) {
// method not allowed, folder might exist already
if (createStatus === 405) {
options = _.extend({scrollTo: true}, options || {});
// add it to the list, for completeness
self.addAndFetchFileInfo(targetPath, '', {scrollTo:true})
self.addAndFetchFileInfo(targetPath, '', options)
.done(function(status, data) {
OC.Notification.show(t('files', 'Could not create folder "{dir}" because it already exists',
{dir: name}), {type: 'error'}
Expand Down Expand Up @@ -3326,11 +3328,11 @@
this.$el.find('.mask').remove();
this.$table.removeClass('hidden');
},
scrollTo:function(file) {
scrollTo:function(file, showDetailsView = true) {
if (!_.isArray(file)) {
file = [file];
}
if (file.length === 1) {
if (file.length === 1 && showDetailsView) {
_.defer(function() {
this.showDetailsView(file[0]);
}.bind(this));
Expand Down Expand Up @@ -3546,7 +3548,10 @@
},

getUniqueName: function(name) {
if (this.findFileEl(name).exists()) {
var fileNamesOld = this.files.findIndex(function(el) {
return el.name === name
})
if (fileNamesOld !== -1) {
var numMatch;
var parts=name.split('.');
var extension = "";
Expand Down
8 changes: 4 additions & 4 deletions apps/files/js/newfilemenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
iconClass: 'icon-folder',
fileType: 'folder',
actionHandler: function(name) {
const uniqueName = self.fileList.getUniqueName(name);
let tempPromise = self.fileList.createDirectory(uniqueName);
const uniqueName = self.fileList.getUniqueName(name)
let tempPromise = self.fileList.createDirectory(uniqueName, { showDetailsView: false })
Promise.all([tempPromise]).then(() => {
self.fileList.rename(uniqueName);
});
self.fileList.rename(uniqueName)
})
}
}];

Expand Down
3 changes: 2 additions & 1 deletion apps/files/src/views/TemplatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ export default {
const fileInfo = response.data.ocs.data
this.logger.debug('Created new file', fileInfo)
await fileList?.addAndFetchFileInfo(this.name)
const options = _.extend({ scrollTo: true }, { showDetailsView: false } || {})
await fileList?.addAndFetchFileInfo(this.name, undefined, options)
fileList.rename(this.name)
this.close()
} catch (error) {
Expand Down

0 comments on commit 89dbe05

Please sign in to comment.