Skip to content

Commit

Permalink
fix: comments
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <luka@nextcloud.com>
  • Loading branch information
luka-nextcloud committed Dec 22, 2022
1 parent 3a29c9f commit ed0e34d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
1 change: 0 additions & 1 deletion cypress/e2e/workspace.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ describe('Workspace', function() {
cy.get('.files-controls').within(() => {
cy.get('.button.new').click()
cy.get('.newFileMenu a.menuitem[data-action="rich-workspace-init"]').click()
cy.get('.newFileMenu a.menuitem input.icon-confirm[type="submit"]').click()
cy.wait('@addDescription')
})

Expand Down
3 changes: 1 addition & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ Cypress.Commands.add('getActionEntry', { prevSubject: 'optional' }, (subject, na
})

Cypress.Commands.add('getActionSubEntry', (name) => {
return cy.get('div[popoverbaseclass=action-item__popper]').getActionEntry(name)
return cy.get('div[data-text-el="menubar"]').getActionEntry(name)
})

Cypress.Commands.add('getContent', { prevSubject: 'optional' }, (subject) => {
Expand Down Expand Up @@ -372,7 +372,6 @@ Cypress.Commands.add('createDescription', () => {
cy.get('.files-controls').within(() => {
cy.get('.button.new').click()
cy.get('.newFileMenu a.menuitem[data-action="rich-workspace-init"]').click()
cy.get('.newFileMenu a.menuitem input.icon-confirm[type="submit"]').click()
})
cy.wait('@addDescription')
})
25 changes: 13 additions & 12 deletions src/helpers/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

import { loadState } from '@nextcloud/initial-state'
import { subscribe } from '@nextcloud/event-bus'
import { emit, subscribe } from '@nextcloud/event-bus'
import { openMimetypes } from './mime.js'
import { getSharingToken } from './token.js'
import RichWorkspace from '../views/RichWorkspace.vue'
Expand Down Expand Up @@ -142,6 +142,7 @@ const registerFileActionFallback = () => {
const newRichWorkspaceFileMenuPlugin = {
attach(menu) {
const fileList = menu.fileList
const descriptionFile = t('text', 'Readme') + '.' + loadState('text', 'default_file_extension')
// only attach to main file list, public view is not supported yet
if (fileList.id !== 'files' && fileList.id !== 'files.public') {
return
Expand All @@ -151,18 +152,15 @@ const newRichWorkspaceFileMenuPlugin = {
menu.addMenuEntry({
id: 'rich-workspace-init',
displayName: t('text', 'Add description'),
templateName: t('text', 'Readme') + '.' + loadState('text', 'default_file_extension'),
iconClass: 'icon-filetype-text',
templateName: descriptionFile,
iconClass: 'icon-rename',
fileType: 'file',
useInput: descriptionFile,
actionHandler() {
return window.FileList
.createFile('Readme.md', { scrollTo: false, animate: false })
.then(() => {
menu.removeMenuEntry('rich-workspace-init')
})
.createFile(descriptionFile, { scrollTo: false, animate: false })
},
shouldShow() {
const descriptionFile = 'Readme.md'
if (fileList.findFile(descriptionFile)) return false
return true
},
Expand Down Expand Up @@ -197,16 +195,15 @@ const FilesWorkspacePlugin = {
addMenuRichWorkspace()
import('vue').then((module) => {
const Vue = module.default
const descriptionFile = 'Readme.md'
const descriptionFile = t('text', 'Readme') + '.' + loadState('text', 'default_file_extension')
this.el.id = 'files-workspace-wrapper'
Vue.prototype.t = window.t
Vue.prototype.n = window.n
Vue.prototype.OCA = window.OCA
const View = Vue.extend(RichWorkspace)
const vm = new View({
propsData: {
path: fileList.getCurrentDirectory(),
hasDescriptionFile: !!fileList.findFile(descriptionFile)
path: fileList.getCurrentDirectory()
},
store,
}).$mount(this.el)
Expand All @@ -222,7 +219,11 @@ const FilesWorkspacePlugin = {
vm.path = data.dir.toString()
})
fileList.$table.on('DOMSubtreeModified', () => {
vm.hasDescriptionFile = !!fileList.findFile(descriptionFile)
if (fileList.findFile(descriptionFile)) {
emit('Text::showRichWorkspace')
} else {
emit('Text::hideRichWorkspace')
}
})
})
},
Expand Down
8 changes: 1 addition & 7 deletions src/views/RichWorkspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ export default {
type: String,
required: true,
},
hasDescriptionFile: {
type: Boolean,
required: false,
},
active: {
type: Boolean,
default: true,
Expand Down Expand Up @@ -96,9 +92,6 @@ export default {
if (!newValue) {
document.querySelector('#rich-workspace .text-editor__main').scrollTo(0, 0)
}
},
hasDescriptionFile() {
this.getFileInfo()
}
},
mounted() {
Expand Down Expand Up @@ -148,6 +141,7 @@ export default {
this.file = data.file
this.editing = true
this.loaded = true
this.autofocus = true
return true
})
.catch((error) => {
Expand Down

0 comments on commit ed0e34d

Please sign in to comment.