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

[stable29] refactor: move to office.vue component #3615

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cypress/e2e/share-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,18 @@ describe('Public sharing of office documents', function() {
cy.spy(win, 'postMessage').as('postMessage')
},
})
cy.waitForCollabora(true)

cy.waitForCollabora()
cy.get('@postMessage', { timeout: 20000 }).should(spy => {
const calls = spy.getCalls()
const findMatchingCall = calls.find(call => call.args[0].indexOf('"MessageId":"App_LoadingStatus"') !== -1)
if (!findMatchingCall) {
return expect(findMatchingCall).to.not.be.undefined
}
const object = JSON.parse(findMatchingCall.args[0])
expect(object.Values).to.have.property('Status', 'Initialized')
})

cy.get('@loleafletframe').within(() => {
cy.get('#closebutton').click()
})
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/ShareLinkListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function handle(Event $event): void {
$this->initialStateService->provideCapabilities();
Util::addScript('richdocuments', 'richdocuments-files');
Util::addScript('richdocuments', 'richdocuments-viewer', 'viewer');
Util::addScript('richdocuments', 'richdocuments-public');
}
}
}
2 changes: 0 additions & 2 deletions src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ addEventListener('DOMContentLoaded', () => {
return
}

odfViewer.onEdit(document.getElementById('filename').value)

PostMessages.registerPostMessageHandler(({ parsed }) => {
console.debug('[viewer] Received post message', parsed)
const { msgId, args, deprecated } = parsed
Expand Down
17 changes: 17 additions & 0 deletions src/helpers/isDocument.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { getCapabilities } from '@nextcloud/capabilities'

/** @type Array.<String> */
const mimetypes = getCapabilities().richdocuments.mimetypes

/**
* Determines if the mimetype of the resource is supported by richdocuments
* @return {boolean}
*/
function isDocument() {
/** @type HTMLInputElement */
const mimetypeElement = document.getElementById('mimetype')

return Boolean(mimetypeElement) && mimetypes.includes(mimetypeElement.value)
}

export default isDocument
12 changes: 12 additions & 0 deletions src/helpers/isPublicPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Determines if the resource is a public share
* @return {boolean}
*/
function isPublic() {
/** @type HTMLInputElement */
const publicElement = document.getElementById('isPublic')

return Boolean(publicElement) && publicElement.value === '1'
}

export default isPublic
17 changes: 17 additions & 0 deletions src/public.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import isPublic from './helpers/isPublicPage.js'
import isDocument from './helpers/isDocument.js'

document.addEventListener('DOMContentLoaded', () => {

// Public share, but not a supported mimetype - do nothing
if (isPublic() && !isDocument()) {
return
}

// Public share, and is a supported mimetype - open viewer
if (isPublic() && isDocument()) {
if (OCA.Viewer) {
OCA.Viewer.open({ path: '/' })
}
}
})
2 changes: 1 addition & 1 deletion src/view/Office.vue
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export default {
}
this.postMessage.registerPostMessageHandler(this.postMessageHandler)

this.load()
await this.load()
},
beforeDestroy() {
this.postMessage.unregisterPostMessageHandler(this.postMessageHandler)
Expand Down
1 change: 1 addition & 0 deletions webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ webpackConfig.entry = {
admin: path.join(__dirname, 'src', 'admin.js'),
personal: path.join(__dirname, 'src', 'personal.js'),
reference: path.join(__dirname, 'src', 'reference.js'),
public: path.join(__dirname, 'src', 'public.js'),
}

webpackRules.RULE_JS.test = /\.m?js$/
Expand Down
Loading