Skip to content

Commit

Permalink
feat: bring back cypress command createDescription through UI
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <[email protected]>
  • Loading branch information
luka-nextcloud committed Nov 6, 2023
1 parent 0876bb0 commit f414725
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
10 changes: 9 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,16 @@ Cypress.Commands.add('showHiddenFiles', (value = true) => {
})

Cypress.Commands.add('createDescription', (folder) => {
cy.uploadFile('empty.md', 'text/markdown', `${folder}/Readme.md`)
const url = '**/remote.php/dav/files/**'
cy.intercept({ method: 'PUT', url })
.as('addDescription')

cy.visit(`apps/files?dir=/${encodeURIComponent(folder)}`)
cy.get('[data-cy-files-list] tr[data-cy-files-list-row-name="Readme.md"]').should('not.exist')
cy.get('[data-cy-upload-picker] button.action-item__menutoggle').click()
cy.get('li.upload-picker__menu-entry button').contains('Add description').click()

cy.wait('@addDescription')
})

Cypress.on(
Expand Down
2 changes: 1 addition & 1 deletion src/components/Menu/ToolBarLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default defineComponent({
watch: {
visibleEntries() {
this.$nextTick(() => {
if (this.activeMenuEntry > this.visibleEntries.length || this.visibleEntries[this.activeMenuEntry].disabled) {
if (this.activeMenuEntry > this.visibleEntries.length || this.visibleEntries[this.activeMenuEntry]?.disabled) {
this.setNextMenuEntry()
}
})
Expand Down
11 changes: 6 additions & 5 deletions src/helpers/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const registerFileActionFallback = () => {

}

const addMenuRichWorkspace = () => {
export const addMenuRichWorkspace = () => {
const descriptionFile = t('text', 'Readme') + '.' + loadState('text', 'default_file_extension')
addNewFileMenuEntry({
id: 'rich-workspace-init',
Expand Down Expand Up @@ -177,19 +177,21 @@ const addMenuRichWorkspace = () => {
})
const fileid = parseInt(response.headers['oc-fileid'])
const file = new File({
source,
source: context.source + '/' + encodeURIComponent(descriptionFile),
id: fileid,
mtime: new Date(),
mime: 'text/markdown',
owner: getCurrentUser()?.uid || null,
permissions: Permission.ALL,
root: context?.root || '/files/' + getCurrentUser()?.uid,
})
context._children.push(file.fileid)

showSuccess(t('text', 'Created "{name}"', { name: descriptionFile }))

emit('files:node:created', file)
emit('Text::showRichWorkspace', { autofocus: true })
setTimeout(() => {
emit('Text::showRichWorkspace', { autofocus: true })
}, 200)
},
})
}
Expand All @@ -205,7 +207,6 @@ export const FilesWorkspaceHeader = new Header({
},

render(el, folder, view) {
addMenuRichWorkspace()
const hasRichWorkspace = !!folder.attributes['rich-workspace-file']

import('vue').then((module) => {
Expand Down
3 changes: 2 additions & 1 deletion src/init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { registerFileListHeaders, registerDavProperty } from '@nextcloud/files'
import { loadState } from '@nextcloud/initial-state'
import { FilesWorkspaceHeader } from './helpers/files.js'
import { addMenuRichWorkspace, FilesWorkspaceHeader } from './helpers/files.js'
import { linkTo } from '@nextcloud/router'

__webpack_nonce__ = window.btoa(OC.requestToken) // eslint-disable-line
Expand All @@ -12,5 +12,6 @@ registerDavProperty('nc:rich-workspace', { nc: 'http://nextcloud.org/ns' })
registerDavProperty('nc:rich-workspace-file', { nc: 'http://nextcloud.org/ns' })

if (workspaceAvailable) {
addMenuRichWorkspace()
registerFileListHeaders(FilesWorkspaceHeader)
}
6 changes: 3 additions & 3 deletions src/views/RichWorkspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

<template>
<div v-if="enabled"
v-show="hasRichWorkspace"
id="rich-workspace"
:class="{'focus': focus, 'dark': darkTheme }">
<RichTextReader v-if="!loaded || !ready" :content="content" class="rich-workspace--preview" />
Expand Down Expand Up @@ -89,7 +88,7 @@ export default {
autofocus: false,
autohide: true,
darkTheme: OCA.Accessibility && OCA.Accessibility.theme === 'dark',
enabled: OCA.Text.RichWorkspaceEnabled,
enabled: OCA.Text.RichWorkspaceEnabled && this.hasRichWorkspace,
}
},
computed: {
Expand Down Expand Up @@ -144,9 +143,10 @@ export default {
})
},
getFileInfo(autofocus) {
if (!this.hasRichWorkspace) {
if (!this.enabled) {
return
}
this.file = null
this.ready = false
this.loaded = true
this.autofocus = false
Expand Down

0 comments on commit f414725

Please sign in to comment.