Skip to content

Commit f891fcf

Browse files
committed
add an initial state for 'browser_setting' variable.
After the file browsersettings.json is uploaded, it’s necessary to create an initial state for the user’s browser preference settings. This enables the Collabora iframe to include the POST variable and serve preprocessed HTML with accessibility features enabled, for example. Signed-off-by: Henry Castro <hcastro@collabora.com>
1 parent 597b203 commit f891fcf

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/Service/InitialStateService.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OCA\Richdocuments\TemplateManager;
1515
use OCA\Theming\ImageManager;
1616
use OCP\AppFramework\Services\IInitialState;
17+
use OCA\Richdocuments\Service\SettingsService;
1718
use OCP\Defaults;
1819
use OCP\IConfig;
1920
use OCP\IURLGenerator;
@@ -31,6 +32,7 @@ public function __construct(
3132
private Defaults $themingDefaults,
3233
private IConfig $config,
3334
private ?string $userId,
35+
private SettingsService $settingsService,
3436
) {
3537
}
3638

@@ -110,5 +112,12 @@ private function provideOptions(): void {
110112

111113
$this->initialState->provideInitialState('theming-customLogo', $logo);
112114
$this->initialState->provideInitialState('open_local_editor', $this->config->getAppValue(Application::APPNAME, 'open_local_editor', 'yes') === 'yes');
115+
$fileName = $this->config->getUserValue($this->userId, Application::APPNAME, 'browsersetting');
116+
if ($fileName) {
117+
$browserSetting = $this->settingsService->getSettingsFile('userconfig/' . $this->userId,
118+
'browsersetting',
119+
$fileName);
120+
$this->initialState->provideInitialState('browsersetting', $browserSetting->getContent());
121+
}
113122
}
114123
}

lib/Service/SettingsService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ public function uploadFile(SettingsUrl $settingsUrl, string $fileData, string $u
102102
$fileUri = $this->generateFileUri($settingsUrl->getType(), $settingsUrl->getCategory(), $fileName, $token['token']);
103103
$this->refreshFolderEtag($settingsUrl->getType());
104104

105+
if ($settingsUrl->getType() === 'userconfig' && $settingsUrl->getCategory() === 'browsersetting') {
106+
$this->config->setUserValue($userId, 'richdocuments', 'browsersetting', $fileName);
107+
}
105108
return [
106109
'stamp' => $newFile->getETag(),
107110
'uri' => $fileUri,

src/view/Office.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<input name="theme" :value="formData.theme" type="hidden">
5656
<input name="buy_product" value="https://nextcloud.com/pricing" type="hidden">
5757
<input name="host_session_id" :value="formData.hostSessionID" type="hidden">
58+
<input name="browser_setting" :value="formData.browserSetting" type="hidden">
5859
</form>
5960
<iframe :id="iframeId"
6061
ref="documentFrame"
@@ -198,6 +199,7 @@ export default {
198199
cssVariables: generateCSSVarTokens(),
199200
theme: getCollaboraTheme(),
200201
hostSessionID: 'nextcloud ' + OC.config.version + ' - richdocuments ' + getCapabilities().version,
202+
browserSetting: loadState('richdocuments', 'browsersetting', ''),
201203
},
202204
}
203205
},

0 commit comments

Comments
 (0)