Skip to content

Commit

Permalink
feat: hide share and close buttons on direct editing for desktop
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <luka@nextcloud.com>
  • Loading branch information
luka-nextcloud authored and juliusknorr committed Jun 23, 2023
1 parent a4a3f74 commit ee7174a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
33 changes: 3 additions & 30 deletions cypress/e2e/directediting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,68 +53,41 @@ describe('direct editing', function() {
initUserAndFiles(user, 'test.md', 'empty.md', 'empty.txt')
})

it('Open an existing file, edit and close it', () => {
it('Open an existing file, edit it', () => {
createDirectEditingLink(user, 'empty.md')
.then((token) => {
cy.logout()
cy.visit(token)
})
const closeRequestAlias = 'closeRequest'
cy.intercept({ method: 'POST', url: '**/session/close' }).as(closeRequestAlias)
cy.getContent().type('# This is a headline')
cy.getContent().type('{enter}')
cy.getContent().type('Some text')
cy.getContent().type('{enter}')

cy.get('button.icon-close').click()
cy.wait(`@${closeRequestAlias}`).then(() => {
cy.getFileContent('empty.md').then((content) => {
expect(content).to.equal('# This is a headline\n\nSome text')
})
})
})

it('Create a file, edit and close it', () => {
it('Create a file, edit it', () => {
createDirectEditingLinkForNewFile(user, 'newfile.md')
.then((token) => {
cy.logout()
cy.visit(token)
})
const closeRequestAlias = 'closeRequest'
cy.intercept({ method: 'POST', url: '**/session/close' }).as(closeRequestAlias)

cy.getContent().type('# This is a headline')
cy.getContent().type('{enter}')
cy.getContent().type('Some text')
cy.getContent().type('{enter}')

cy.get('button.icon-close').click()
cy.wait(`@${closeRequestAlias}`).then(() => {
cy.getFileContent('newfile.md').then((content) => {
expect(content).to.equal('# This is a headline\n\nSome text')
})
})
})

it('Open an existing plain text file, edit and close it', () => {
it('Open an existing plain text file, edit it', () => {
createDirectEditingLink(user, 'empty.txt')
.then((token) => {
cy.logout()
cy.visit(token)
})
const closeRequestAlias = 'closeRequest'
cy.intercept({ method: 'POST', url: '**/session/close' }).as(closeRequestAlias)

cy.getContent().type('# This is a headline')
cy.getContent().type('{enter}')
cy.getContent().type('Some text')
cy.getContent().type('{enter}')

cy.get('button.icon-close').click()
cy.wait(`@${closeRequestAlias}`).then(() => {
cy.getFileContent('empty.txt').then((content) => {
expect(content).to.equal('# This is a headline\nSome text\n')
})
})
})
})
7 changes: 6 additions & 1 deletion src/views/DirectEditing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
:mime="initial.mimetype"
:is-direct-editing="true"
@ready="loaded">
<template #header>
<template v-if="isMobile" #header>
<button class="icon-share" @click="share" />
<button class="icon-close" @click="close" />
</template>
Expand Down Expand Up @@ -103,6 +103,11 @@ export default {
initialSession() {
return JSON.parse(this.initial.session) || null
},
isMobile() {
return (window.DirectEditingMobileInterface || (window.webkit
&& window.webkit.messageHandlers
&& window.webkit.messageHandlers.DirectEditingMobileInterface))
},
},
beforeMount() {
callMobileMessage('loading')
Expand Down

0 comments on commit ee7174a

Please sign in to comment.