Skip to content
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
2 changes: 1 addition & 1 deletion cypress/e2e/direct.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('Direct editing (legacy)', function() {
.should('be.visible')
cy.get('.saveas-dialog input[type=text]')
.should('be.visible')
.should('have.value', 'document.rtf')
.should('have.value', '/document.rtf')

cy.get('.saveas-dialog button.button-vue--vue-primary').click()

Expand Down
19 changes: 17 additions & 2 deletions src/components/Modal/SaveAs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
{{ t('richdocuments', 'Cancel') }}
</NcButton>
<NcButton type="primary"
:disabled="!isValidName"
@click="close">
{{ t('richdocuments', 'Save') }}
</NcButton>
Expand Down Expand Up @@ -66,13 +67,13 @@ export default {
emits: ['close'],
data() {
return {
selectedPath: '',
selectedPath: null,
}
},
computed: {
newFileName: {
get() {
if (this.selectedPath !== '') {
if (this.selectedPath !== null) {
return this.selectedPath
}
const filename = this.path
Expand All @@ -84,6 +85,20 @@ export default {
this.selectedPath = value
},
},
isValidName() {
const value = this.newFileName.trim()
if (value === '') {
return false
}
const base = value.split('/').pop()
const parts = base.split('.')
let valid = true
// filename is non-empty
valid &&= base !== ''
// filename has both a name part and an extension
valid &&= parts.length >= 2 && parts.at(-2).length > 0 && parts.at(-1).length > 0
return valid
},
},
mounted() {
// prepare filename for having a separate picker for the path (.split('/').pop())
Expand Down
6 changes: 5 additions & 1 deletion src/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
const checkProxyStatus = () => {
checkingProxyStatus = true
const url = Config.get('urlsrc').slice(0, Config.get('urlsrc').indexOf('proxy.php') + 'proxy.php'.length)
$.get(url + '?status').done(function(val) {

Check warning on line 40 in src/document.js

View workflow job for this annotation

GitHub Actions / NPM lint

The global property or function $ was deprecated in Nextcloud 19.0.0
if (val && val.status && val.status !== 'OK') {
if (val.status === 'starting' || val.status === 'stopped') {
document.getElementById('proxyLoadingIcon').classList.add('icon-loading-small')
Expand Down Expand Up @@ -150,8 +150,8 @@
showViewer(fileId, title) {
// remove previous viewer, if open, and set a new one
if (documentsMain.isViewerMode) {
$('#revViewer').remove()

Check warning on line 153 in src/document.js

View workflow job for this annotation

GitHub Actions / NPM lint

The global property or function $ was deprecated in Nextcloud 19.0.0
$('#revViewerContainer').prepend($('<div id="revViewer">'))

Check warning on line 154 in src/document.js

View workflow job for this annotation

GitHub Actions / NPM lint

The global property or function $ was deprecated in Nextcloud 19.0.0

Check warning on line 154 in src/document.js

View workflow job for this annotation

GitHub Actions / NPM lint

The global property or function $ was deprecated in Nextcloud 19.0.0
}

const urlsrc = getWopiUrl({ fileId, title, readOnly: true, closeButton: !documentsMain.hideCloseButton })
Expand All @@ -176,15 +176,15 @@
// iframe that contains the Collabora Online Viewer
const frame = '<iframe data-cy="coolframe" id="loleafletframe" name="loleafletframe_viewer" allowfullscreen allow="clipboard-read *; clipboard-write *" nonce="' + btoa(getRequestToken()) + '" style="width:100%;height:100%;position:absolute;" title="' + getCapabilities().productName + '"/>'

$('#revViewer').append(form)

Check warning on line 179 in src/document.js

View workflow job for this annotation

GitHub Actions / NPM lint

The global property or function $ was deprecated in Nextcloud 19.0.0
$('#revViewer').append(frame)

Check warning on line 180 in src/document.js

View workflow job for this annotation

GitHub Actions / NPM lint

The global property or function $ was deprecated in Nextcloud 19.0.0
$('#loleafletframe_viewer').focus()

Check warning on line 181 in src/document.js

View workflow job for this annotation

GitHub Actions / NPM lint

The global property or function $ was deprecated in Nextcloud 19.0.0

// submit that
$('#loleafletform_viewer').submit()

Check warning on line 184 in src/document.js

View workflow job for this annotation

GitHub Actions / NPM lint

The global property or function $ was deprecated in Nextcloud 19.0.0
documentsMain.isViewerMode = true
// for closing revision mode
$('#revViewerContainer .closeButton').click(function(e) {

Check warning on line 187 in src/document.js

View workflow job for this annotation

GitHub Actions / NPM lint

The global property or function $ was deprecated in Nextcloud 19.0.0
e.preventDefault()
documentsMain.onCloseViewer()
})
Expand Down Expand Up @@ -470,10 +470,14 @@
}

if (msgId === 'UI_SaveAs') {
let docPath = documentsMain.fileName
if (documentsMain.fullPath && documentsMain.fullPath !== '/') {
docPath = documentsMain.fullPath
}
spawnDialog(
SaveAs,
{
path: documentsMain.fileName,
path: docPath,
format: args.format,
},
(value) => value && PostMessages.sendWOPIPostMessage('loolframe', 'Action_SaveAs', { Filename: value, Notify: true }),
Expand Down
Loading