Merge pull request #6674 from nextcloud/backport/6671/stable27

[stable27] fix: Properly show attachment extension
This commit is contained in:
Julius Knorr
2025-04-29 09:16:06 +02:00
committed by GitHub
5 changed files with 22 additions and 8 deletions

View File

@@ -37,7 +37,7 @@ jobs:
uname -a uname -a
RUST_BACKTRACE=1 krankerl --version RUST_BACKTRACE=1 krankerl --version
RUST_BACKTRACE=1 krankerl package RUST_BACKTRACE=1 krankerl package
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
with: with:
name: Deck app tarball name: Deck app tarball
path: build/artifacts/deck.tar.gz path: build/artifacts/deck.tar.gz

View File

@@ -108,7 +108,7 @@ jobs:
npm_package_name: ${{ env.APP_NAME }} npm_package_name: ${{ env.APP_NAME }}
- name: Upload test failure screenshots - name: Upload test failure screenshots
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
if: failure() if: failure()
with: with:
name: Upload screenshots name: Upload screenshots
@@ -116,7 +116,7 @@ jobs:
retention-days: 5 retention-days: 5
- name: Upload nextcloud logs - name: Upload nextcloud logs
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
if: failure() if: failure()
with: with:
name: Upload nextcloud log name: Upload nextcloud log

View File

@@ -114,7 +114,8 @@ describe('Card', function() {
cy.get('.file-picker__main [data-filename="welcome.txt"]').should('be.visible') cy.get('.file-picker__main [data-filename="welcome.txt"]').should('be.visible')
.click() .click()
cy.get('.dialog__actions button.button-vue--vue-primary').click() cy.get('.dialog__actions button.button-vue--vue-primary').click()
cy.get('.attachment-list .basename').contains('welcome.txt') cy.get('.attachment-list .filename').contains('welcome')
cy.get('.attachment-list .filename .extension').contains('txt')
}) })
it('Shows the modal with the editor', () => { it('Shows the modal with the editor', () => {

View File

@@ -41,7 +41,8 @@
<div class="details"> <div class="details">
<a> <a>
<div class="filename"> <div class="filename">
<span class="basename">{{ attachment.name }}</span> <span>{{ attachmentBasename(attachment) }}</span>
<span class="extension">.{{ attachmentExtension(attachment) }}</span>
</div> </div>
<progress :value="attachment.progress" max="100" /> <progress :value="attachment.progress" max="100" />
</a> </a>
@@ -58,7 +59,8 @@
<div class="details"> <div class="details">
<a :href="internalLink(attachment)" @click.prevent="showViewer(attachment)"> <a :href="internalLink(attachment)" @click.prevent="showViewer(attachment)">
<div class="filename"> <div class="filename">
<span class="basename">{{ attachment.data }}</span> <span>{{ attachmentBasename(attachment) }}</span>
<span class="extension">.{{ attachmentExtension(attachment) }}</span>
</div> </div>
<div v-if="attachment.deletedAt === 0"> <div v-if="attachment.deletedAt === 0">
<span class="filesize">{{ formattedFileSize(attachment.extendedData.filesize) }}</span> <span class="filesize">{{ formattedFileSize(attachment.extendedData.filesize) }}</span>
@@ -200,6 +202,14 @@ export default {
return t('deck', 'Drop your files to upload') return t('deck', 'Drop your files to upload')
} }
}, },
attachmentBasename() {
return (attachment) => attachment?.extendedData?.info.filename
?? (attachment?.name ?? attachment.data).replace(/\.[^/.]+$/, '')
},
attachmentExtension() {
return (attachment) => attachment?.extendedData?.info?.extension
?? (attachment?.name ?? attachment.data).split('.').pop()
},
}, },
watch: { watch: {
cardId: { cardId: {

View File

@@ -255,15 +255,18 @@ export default {
}, },
addAttachment(attachment) { addAttachment(attachment) {
const asImage = (attachment.type === 'file' && attachment.extendedData.hasPreview) || attachment.extendedData.mimetype.includes('image') const asImage = (attachment.type === 'file' && attachment.extendedData.hasPreview) || attachment.extendedData.mimetype.includes('image')
// We need to strip those as text does not support rtl yet, so we cannot insert them separately
const stripRTLO = (text) => text.replaceAll('\u202e', '')
const fileName = stripRTLO(attachment.extendedData.info.filename) + '.' + stripRTLO(attachment.extendedData.info.extension)
if (this.editor) { if (this.editor) {
this.editor.insertAtCursor( this.editor.insertAtCursor(
asImage asImage
? `<a href="${this.attachmentPreview(attachment)}"><img src="${this.attachmentPreview(attachment)}" alt="${attachment.data}" /></a>` ? `<a href="${this.attachmentPreview(attachment)}"><img src="${this.attachmentPreview(attachment)}" alt="${attachment.data}" /></a>`
: `<a href="${this.attachmentPreview(attachment)}">${attachment.data}</a>`, : `<a href="${this.attachmentPreview(attachment)}">${fileName}</a>`,
) )
return return
} else { } else {
const attachmentString = (asImage ? '!' : '') + '[📎 ' + attachment.data + '](' + this.attachmentPreview(attachment) + ')' const attachmentString = (asImage ? '!' : '') + '[📎 ' + fileName + '](' + this.attachmentPreview(attachment) + ')'
const descString = this.$refs.markdownEditor.easymde.value() const descString = this.$refs.markdownEditor.easymde.value()
const newContent = descString + '\n' + attachmentString const newContent = descString + '\n' + attachmentString
this.$refs.markdownEditor.easymde.value(newContent) this.$refs.markdownEditor.easymde.value(newContent)