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: startPresentation URL parameter #4209

Merged
merged 1 commit into from
Nov 21, 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
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
Loading