Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hide share and close buttons on direct editing for desktop #4346

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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