Skip to content

Commit

Permalink
refactor: some code cleanups
Browse files Browse the repository at this point in the history
Signed-off-by: codewithvk <[email protected]>
  • Loading branch information
codewithvk committed Feb 4, 2025
1 parent b5da9f5 commit 26b1a9d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 34 deletions.
2 changes: 0 additions & 2 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,6 @@ public function getFontFileOverview(string $name): DataDisplayResponse {

/**
* @NoAdminRequired
* @PublicPage
* @NoCSRFRequired
*
* @param string $type - Type is 'admin' or 'user'
* @return DataResponse
Expand Down
24 changes: 9 additions & 15 deletions src/components/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,13 @@
</div>
</NcModal>

<div id="admin-cool-frame-section" class="section">
<CoolFrame v-if="tokenGenerated"
:iframe-type="'admin'"
:public-wopi-url="settings.public_wopi_url"
:access-token="accessToken"
:access-token-t-t-l="accessTokenTTL"
:wopi-setting-base-url="wopiSettingBaseUrl" />
</div>
<CoolFrame v-if="tokenGenerated"
class="section"
:iframe-type="'admin'"
:public-wopi-url="settings.public_wopi_url"
:access-token="accessToken"
:access-token-t-t-l="accessTokenTTL"
:wopi-setting-base-url="wopiSettingBaseUrl" />

<div v-if="isSetup" id="advanced-settings" class="section">
<h2>{{ t('richdocuments', 'Advanced settings') }}</h2>
Expand Down Expand Up @@ -432,10 +431,7 @@ import SettingsExternalApps from './SettingsExternalApps.vue'
import SettingsInputFile from './SettingsInputFile.vue'
import SettingsFontList from './SettingsFontList.vue'
import GlobalTemplates from './AdminSettings/GlobalTemplates.vue'
import {
getCurrentUser,
getGuestNickname,
} from '@nextcloud/auth'
import { getCurrentUser } from '@nextcloud/auth'

import { isPublicShare, getSharingToken } from '@nextcloud/sharing/public'

Expand Down Expand Up @@ -531,7 +527,7 @@ export default {
},
accessToken: '',
accessTokenTTL: '',
userId: '',
userId: getCurrentUser()?.uid,
tokenGenerated: false,
wopiSettingBaseUrl: '',
}
Expand Down Expand Up @@ -644,8 +640,6 @@ export default {
this.accessToken = data.token
this.accessTokenTTL = data.token_ttl
console.debug('Admin settings WOPI token generated:', this.accessToken, this.accessTokenTTL)
} else if (data.federatedUrl) {
console.error('Federated URL returned, not expected for admin settings.')
} else {
console.error('Failed to generate token for admin settings')
}
Expand Down
18 changes: 7 additions & 11 deletions src/components/PersonalSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@
</p>

<!-- user settings iframe -->
<div id="user-cool-frame-section">
<CoolFrame v-if="tokenGenerated"
:iframe-type="'user'"
:public-wopi-url="public_wopi_url"
:access-token="accessToken"
:access-token-t-t-l="accessTokenTTL"
:wopi-setting-base-url="wopiSettingBaseUrl" />
</div>
<CoolFrame v-if="tokenGenerated"
:iframe-type="'user'"
:public-wopi-url="public_wopi_url"
:access-token="accessToken"
:access-token-t-t-l="accessTokenTTL"
:wopi-setting-base-url="wopiSettingBaseUrl" />

<!-- Zotero -->
<div class="zotero-section">
Expand Down Expand Up @@ -168,7 +166,7 @@ export default {
tokenGenerated: false,
accessToken: '',
accessTokenTTL: '',
userId: '',
userId: getCurrentUser()?.uid,
wopiSettingBaseUrl: '',
public_wopi_url: this.initial.publicWopiUrl || '',
}
Expand Down Expand Up @@ -199,8 +197,6 @@ export default {
this.accessToken = data.token
this.accessTokenTTL = data.token_ttl
console.debug('Admin settings WOPI token generated:', this.accessToken, this.accessTokenTTL)
} else if (data.federatedUrl) {
console.error('Federated URL returned, not expected for admin settings.')
} else {
console.error('Failed to generate token for admin settings')
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const getDocumentUrlForFile = (fileDir, fileId) => {
}

export const getConfigFileUrl = () => {
return getCallbackBaseUrl() + '/index.php/apps/richdocuments/wopi/settings'
return getCallbackBaseUrl() + generateUrl('apps/richdocuments/wopi/settings')
}

const getNextcloudUrl = () => {
Expand Down
5 changes: 0 additions & 5 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,4 @@
<code><![CDATA[$result && count($result) > 0]]></code>
</RedundantCondition>
</file>
<file src="lib/WOPI/SettingsUrl.php">
<RedundantCondition>
<code><![CDATA[$result && count($result) > 0]]></code>
</RedundantCondition>
</file>
</files>

0 comments on commit 26b1a9d

Please sign in to comment.