Skip to content

Commit

Permalink
Merge pull request #4209 from nextcloud/feat/start-presentation-param…
Browse files Browse the repository at this point in the history
…eter

feat: `startPresentation` URL parameter
  • Loading branch information
elzody authored Nov 21, 2024
2 parents 1bed118 + d3fa91f commit 1cfedbc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/Listener/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
namespace OCA\Richdocuments\Listener;

use OCA\Richdocuments\Service\CapabilitiesService;
use OCA\Richdocuments\Service\InitialStateService;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IRequest;

/** @template-implements IEventListener<BeforeTemplateRenderedEvent|Event> */
class BeforeTemplateRenderedListener implements IEventListener {
public function __construct(
private CapabilitiesService $capabilitiesService,
private InitialStateService $initialStateService,
private IRequest $request,
) {
}

Expand All @@ -28,5 +32,8 @@ public function handle(Event $event): void {
$event->getResponse()->addHeader('Cross-Origin-Opener-Policy', 'same-origin');
$event->getResponse()->addHeader('Cross-Origin-Embedder-Policy', 'require-corp');
}

$startPresentation = $this->request->getParam('startPresentation') === 'true';
$this->initialStateService->providePresentation($startPresentation);
}
}
4 changes: 4 additions & 0 deletions lib/Service/InitialStateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public function provideDocument(Wopi $wopi, array $params): void {
$this->provideOptions();
}

public function providePresentation(bool $startPresentation = false): void {
$this->initialState->provideInitialState('startPresentation', $startPresentation);
}

public function provideAdminSettings(): void {
$this->initialState->provideInitialState('adminSettings', [
'templatesAvailable' => $this->capabilitiesService->hasTemplateSource(),
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const getWopiSrc = (fileId) => {
return wopiurl
}

const getWopiUrl = ({ fileId, title, readOnly, closeButton, revisionHistory, target = undefined }) => {
const getWopiUrl = ({ fileId, title, readOnly, closeButton, revisionHistory, target = undefined, startPresentation = false }) => {
// Only set the revision history parameter if the versions app is enabled
revisionHistory = revisionHistory && window?.oc_appswebroots?.files_versions

Expand All @@ -45,6 +45,7 @@ const getWopiUrl = ({ fileId, title, readOnly, closeButton, revisionHistory, tar
+ (revisionHistory ? '&revisionhistory=1' : '')
+ (readOnly ? '&permission=readonly' : '')
+ (target ? '&target=' + encodeURIComponent(target) : '')
+ (startPresentation ? '&startPresentation=1' : '')
}

const getDocumentUrlFromTemplate = (templateId, fileName, fileDir, fillWithTemplate) => {
Expand Down
2 changes: 2 additions & 0 deletions src/view/Office.vue
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export default {
Config.update('urlsrc', data.urlSrc)
Config.update('wopi_callback_url', loadState('richdocuments', 'wopi_callback_url', ''))
Config.update('startPresentation', loadState('richdocuments', 'startPresentation', false))
const forceReadOnly = this.isEmbedded && !this.hasWidgetEditingEnabled
Expand All @@ -327,6 +328,7 @@ export default {
readOnly: forceReadOnly || version > 0,
revisionHistory: !this.isPublic,
closeButton: !Config.get('hideCloseButton') && !this.isEmbedded,
startPresentation: Config.get('startPresentation'),
})
this.$set(this.formData, 'action', action)
this.$set(this.formData, 'accessToken', data.token)
Expand Down

0 comments on commit 1cfedbc

Please sign in to comment.