fix #353: WebDAV file creation

This commit is contained in:
antelle 2017-11-27 22:11:00 +01:00
parent 33519c7c60
commit f390b690a7
9 changed files with 49 additions and 11 deletions

View File

@ -430,8 +430,6 @@
"setFileUnsavedBody": "There are unsaved changes in this file",
"setFileCloseNoSave": "Close and lose changes",
"setFileDontClose": "Don't close",
"setFileNoWebDavUpload": "Cannot save to WebDAV",
"setFileNoWebDavUploadBody": "Adding new files to WebDAV is currently not supported. Please upload your file manually and open in the app.",
"setShTitle": "Shortcuts",
"setShShowAll": "show all items",

View File

@ -75,12 +75,18 @@ const StorageWebDav = StorageBase.extend({
this._request(_.defaults({
op: 'Save:stat', method: 'HEAD'
}, saveOpts), (err, xhr, stat) => {
if (err) { return cb(err); }
if (stat.rev !== rev) {
let useTmpPath = this.appSettings.get('webdavSaveMethod') !== 'put';
if (err) {
if (!err.notFound) {
return cb(err);
} else {
that.logger.debug('Save: not found, creating');
useTmpPath = false;
}
} else if (stat.rev !== rev) {
that.logger.debug('Save error', path, 'rev conflict', stat.rev, rev);
return cb({ revConflict: true }, xhr, stat);
}
const useTmpPath = this.appSettings.get('webdavSaveMethod') !== 'put';
if (useTmpPath) {
that._request(_.defaults({
op: 'Save:put', method: 'PUT', path: tmpPath, data: data, nostat: true

View File

@ -26,6 +26,9 @@ const ModalView = Backbone.View.extend({
KeyHandler.offKey(Keys.DOM_VK_ESCAPE, this.escPressed, this);
KeyHandler.offKey(Keys.DOM_VK_RETURN, this.enterPressed, this);
KeyHandler.setModal(null);
if (this.model.view) {
this.model.view.remove();
}
Backbone.View.prototype.remove.apply(this, arguments);
},

View File

@ -701,7 +701,8 @@ const OpenView = Backbone.View.extend({
const config = _.extend({
id: storage.name,
name: Locale[storage.name] || storage.name,
icon: storage.icon
icon: storage.icon,
buttons: true
}, storage.getOpenConfig());
this.views.openConfig = new OpenConfigView({ el: this.$el.find('.open__config-wrap'), model: config }).render();
this.views.openConfig.on('cancel', this.closeConfig.bind(this));

View File

@ -1,4 +1,5 @@
const Backbone = require('backbone');
const OpenConfigView = require('../open-config-view');
const FeatureDetector = require('../../util/feature-detector');
const PasswordGenerator = require('../../util/password-generator');
const Alerts = require('../../comp/alerts');
@ -227,11 +228,33 @@ const SettingsFileView = Backbone.View.extend({
this.save();
} else {
if (!storage.list) {
if (storage.name === 'webdav') {
Alerts.info({
if (storage.getOpenConfig) {
const config = _.extend({
id: storage.name,
name: Locale[storage.name] || storage.name,
icon: storage.icon,
header: Locale.setFileNoWebDavUpload,
body: Locale.setFileNoWebDavUploadBody
buttons: false
}, storage.getOpenConfig());
const openConfigView = new OpenConfigView({ model: config });
Alerts.alert({
header: '',
body: '',
icon: storage.icon || 'files-o',
buttons: [Alerts.buttons.ok, Alerts.buttons.cancel],
esc: '',
opaque: true,
view: openConfigView,
success: () => {
const storageConfig = openConfigView.getData();
if (!storageConfig) {
return;
}
const opts = _.omit(storageConfig, ['path', 'storage']);
if (opts && Object.keys(opts).length) {
this.model.set('opts', opts);
}
this.save({ storage: storageName, path: storageConfig.path, opts });
}
});
} else {
Alerts.notImplemented();

View File

@ -9,6 +9,10 @@
@include th { background-color: th(modal-background-color-tr); }
}
&.modal--opaque {
@include th { background-color: th(background-color); }
}
&__content {
@include size(100%);
display: flex;

View File

@ -1,4 +1,4 @@
<div class="modal modal--hidden">
<div class="modal modal--hidden {{#if opaque}}modal--opaque{{/if}}">
<div class="modal__content">
<i class="modal__icon fa fa-{{icon}}"></i>
<div class="modal__header">{{{header}}}</div>

View File

@ -14,6 +14,7 @@
{{/each}}
</div>
<div class="open__config-error error-color"></div>
{{#if buttons}}
<div class="open__config-buttons">
<button class="btn-silent open__config-btn-cancel">{{res 'alertCancel'}}</button>
<button class="open__config-btn-ok">
@ -21,4 +22,5 @@
<i class="open__config-btn-ok-spinner fa fa-spinner fa-spin"></i>
</button>
</div>
{{/if}}
</div>

View File

@ -4,6 +4,7 @@ Release notes
`+` desktop apps integrity protection
`+` auto-lock on computer lock
`+` redesigned Dropbox chooser
`+` WebDAV file creation
`+` safari tab icons
`*` prevent master password autocomplete
`*` build with node.js 8