Skip to content
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ module.exports = {
'jsdoc/require-property-description': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'vue/no-v-model-argument': 'off',
}
}
3 changes: 2 additions & 1 deletion .github/workflows/cypress-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ jobs:
with:
persist-credentials: false
repository: nextcloud/files_pdfviewer
ref: ${{ matrix.server-versions }}
# TODO: revert to ${{ matrix.server-versions }} once nextcloud/files_pdfviewer#1586 is merged
ref: feature/nextcloud-viewer-package
path: apps/files_pdfviewer

- name: Checkout ${{ env.APP_NAME }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ cypress/screenshots/
## VSCode
.vscode/
*.code-workspace

cypress/downloads/
2 changes: 1 addition & 1 deletion cypress/e2e/direct.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ describe('Direct editing (legacy)', function() {
.should('be.visible')
.should('have.value', '/document.rtf')

cy.get('.saveas-dialog button.button-vue--vue-primary').click()
cy.get('.saveas-dialog button.button-vue--primary').click()

cy.waitForPostMessage('Action_Save_Resp', { success: true, fileName: 'document.rtf' })
cy.closeDirectDocument()
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('Nextcloud integration', function() {
.should('be.visible')
.should('have.value', `/${exportFilename}`)

cy.get('.saveas-dialog button.button-vue--vue-primary').click()
cy.get('.saveas-dialog button.button-vue--primary').click()

// Wait for confirmation from Collabora that the file was saved
cy.waitForPostMessage('Action_Save_Resp', { success: true, fileName: exportFilename })
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/new.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('New file menu', function() {
cy.get('form[data-cy-upload-picker=""]')
.click()

cy.get('li[data-cy-upload-picker-menu-entry="upload-file"]')
.should('not.be.visible')
cy.contains('button[role="menuitem"]', 'Document')
.should('not.exist')
})

describe('Creates a new file', function() {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/open.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Open existing office files', function() {

cy.waitForPostMessage('App_LoadingStatus', { Status: 'Document_Loaded' })

cy.get('#viewer .modal-header')
cy.get('.viewer__modal .modal-header')
.should('exist')
.and('not.be.visible')
.and('have.css', 'display', 'none')
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('Open existing office files', function() {
cy.waitForViewer()
cy.waitForCollabora()

cy.get('#viewer .modal-header')
cy.get('.viewer__modal .modal-header')
.should('exist')
.and('not.be.visible')
.and('have.css', 'display', 'none')
Expand Down
8 changes: 2 additions & 6 deletions cypress/e2e/settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ describe('Office admin settings', function() {
.clear()
.type((usesHttps ? 'https' : 'http') + '://invalid.example.com{enter}')
cy.wait('@updateSettings').its('response.statusCode').should('equal', 500)
cy.get('.notecard')
.first()
cy.contains('.notecard', 'Could not establish connection to the Collabora Online server.')
.scrollIntoView()
.should('be.visible')
.should('contain.text', 'Could not establish connection to the Collabora Online server.')
cy.screenshot()
})

Expand All @@ -51,11 +49,9 @@ describe('Office admin settings', function() {
.clear()
.type(collaboraUrl + '{enter}')
cy.wait('@updateSettings').its('response.statusCode').should('equal', 200)
cy.get('.notecard')
.first()
cy.contains('.notecard', 'Collabora Online server is reachable.')
.scrollIntoView()
.should('be.visible')
.should('contain.text', 'Collabora Online server is reachable.')
cy.screenshot()

cy.get('#advanced-settings')
Expand Down
5 changes: 3 additions & 2 deletions cypress/e2e/share-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ describe('Public sharing of office documents', () => {
cy.newFileFromMenu('document', 'MyNewFile')
waitForCollabora()

// Make sure the document is still in the correct subfolder
cy.reload()
// Make sure the document is still in the correct subfolder.
// Not a reload: server master serves no /s/{token}/{fileid} URL the files app navigates to
cy.visit(`/s/${token}?dir=/Subfolder`)
cy.get('tr[data-cy-files-list-row-name="MyNewFile.odt"]')
.should('be.visible')
})
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/talk.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ describe('Talk integraiton integration', function() {
cy.login(randUser)
})

it('Can share a file to a talk room and open it', function() {
// TODO: unskip once Talk no longer calls OCA.Viewer.registerHandler
it.skip('Can share a file to a talk room and open it', function() {
cy.createTalkRoom(randUser, {
roomName: 'Test room',
}).then(room => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/templates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Global templates', function() {
mimeType: 'application/vnd.oasis.opendocument.presentation-template',
})

cy.get('.toast-error').contains('Template "systemtemplate.otp" already exists').should('be.visible')
cy.contains('[role="alert"]', 'Template "systemtemplate.otp" already exists').should('be.visible')
})

it('Can be deleted', function() {
Expand Down
6 changes: 3 additions & 3 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ Cypress.Commands.add('nextcloudTestingAppConfigSet', (appId, configKey, configVa
})

Cypress.Commands.add('waitForViewer', () => {
cy.get('#viewer', { timeout: 50000 })
cy.get('.viewer__modal', { timeout: 50000 })
.should('be.visible')
.and('have.class', 'modal-mask')
.and('not.have.class', 'icon-loading')
})

Cypress.Commands.add('waitForViewerClose', () => {
cy.get('#viewer', { timeout: 30000 })
cy.get('.viewer__modal', { timeout: 30000 })
.should('not.exist')
})

Expand Down Expand Up @@ -336,7 +336,7 @@ Cypress.Commands.add('closeDocument', () => {
cy.get('#closebutton').click()
})

cy.get('#viewer', { timeout: 5000 }).should('not.exist')
cy.get('.viewer__modal', { timeout: 5000 }).should('not.exist')
})

Cypress.Commands.add('closeDirectDocument', () => {
Expand Down
5 changes: 2 additions & 3 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
use OCA\Richdocuments\Listener\BeforeTemplateRenderedListener;
use OCA\Richdocuments\Listener\FileCreatedFromTemplateListener;
use OCA\Richdocuments\Listener\LoadAdditionalListener;
use OCA\Richdocuments\Listener\LoadViewerListener;
use OCA\Richdocuments\Listener\OverwritePublicSharePropertiesListener;
use OCA\Richdocuments\Listener\ReferenceListener;
use OCA\Richdocuments\Listener\RegisterDirectEditorListener;
use OCA\Richdocuments\Listener\RegisterTemplateFileCreatorListener;
use OCA\Richdocuments\Listener\ShareLinkListener;
use OCA\Richdocuments\Listener\ViewerListener;
use OCA\Richdocuments\Middleware\WOPIMiddleware;
use OCA\Richdocuments\Notification\Notifier;
use OCA\Richdocuments\Preview\EMF;
Expand All @@ -49,7 +49,6 @@
use OCA\Richdocuments\TaskProcessing\TextToSpreadsheetTaskType;
use OCA\Richdocuments\Template\CollaboraTemplateProvider;
use OCA\Talk\Events\OverwritePublicSharePropertiesEvent;
use OCA\Viewer\Event\LoadViewer;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
Expand Down Expand Up @@ -90,7 +89,7 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(AddContentSecurityPolicyEvent::class, AddContentSecurityPolicyListener::class);
$context->registerEventListener(AddFeaturePolicyEvent::class, AddFeaturePolicyListener::class);
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class);
$context->registerEventListener(LoadViewer::class, LoadViewerListener::class);
$context->registerEventListener(BeforeTemplateRenderedEvent::class, ViewerListener::class);
$context->registerEventListener(ShareLinkAccessedEvent::class, ShareLinkListener::class);
$context->registerEventListener(BeforePreviewFetchedEvent::class, BeforeFetchPreviewListener::class);
$context->registerEventListener(RenderReferenceEvent::class, ReferenceListener::class);
Expand Down
4 changes: 2 additions & 2 deletions lib/Listener/ShareLinkListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function handle(Event $event): void {
$this->initialStateService->provideCapabilities();

Util::addInitScript(Application::APPNAME, Application::APPNAME . '-init-viewer');
Util::addScript(Application::APPNAME, Application::APPNAME . '-viewer', 'viewer');
Util::addScript(Application::APPNAME, Application::APPNAME . '-public', 'viewer');
Util::addScript(Application::APPNAME, Application::APPNAME . '-viewer');
Util::addScript(Application::APPNAME, Application::APPNAME . '-public');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
use OCA\Richdocuments\AppInfo\Application;
use OCA\Richdocuments\PermissionManager;
use OCA\Richdocuments\Service\InitialStateService;
use OCA\Viewer\Event\LoadViewer;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Collaboration\Reference\RenderReferenceEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;

/** @template-implements IEventListener<Event|LoadViewer> */
class LoadViewerListener implements IEventListener {
/** @template-implements IEventListener<Event|BeforeTemplateRenderedEvent> */
class ViewerListener implements IEventListener {
public function __construct(
private PermissionManager $permissionManager,
private InitialStateService $initialStateService,
Expand All @@ -31,13 +32,14 @@ public function __construct(

#[\Override]
public function handle(Event $event): void {
if (!$event instanceof LoadViewer) {
if (!$event instanceof BeforeTemplateRenderedEvent
|| $event->getResponse()->getRenderAs() === TemplateResponse::RENDER_AS_ERROR) {
return;
}
if ($this->permissionManager->isEnabledForUser() && $this->userId !== null) {
$this->initialStateService->provideCapabilities();
Util::addInitScript(Application::APPNAME, Application::APPNAME . '-init-viewer');
Util::addScript(Application::APPNAME, Application::APPNAME . '-viewer', 'viewer');
Util::addScript(Application::APPNAME, Application::APPNAME . '-viewer');
$this->eventDispatcher->dispatchTyped(new RenderReferenceEvent());
}
}
Expand Down
Loading
Loading