Skip to content

Commit 813bdf6

Browse files
committed
Remake website property saving with Vue
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent edbce9e commit 813bdf6

File tree

5 files changed

+58
-46
lines changed

5 files changed

+58
-46
lines changed

apps/settings/js/federationsettingsview.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@
130130
field === 'avatar' ||
131131
field === 'email' ||
132132
field === 'displayname' ||
133-
field === 'twitter'
133+
field === 'twitter' ||
134+
field === 'website'
134135
) {
135136
return;
136137
}

apps/settings/lib/Settings/Personal/PersonalInfo.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ public function getForm(): TemplateResponse {
151151
'phoneScope' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getScope(),
152152
'address' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getValue(),
153153
'addressScope' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getScope(),
154-
'website' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getValue(),
155-
'websiteScope' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getScope(),
156-
'websiteVerification' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getVerified(),
157154
'groups' => $this->getGroups($user),
158155
'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
159156
'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
@@ -162,6 +159,7 @@ public function getForm(): TemplateResponse {
162159
$personalInfoParameters = [
163160
'userId' => $uid,
164161
'displayName' => $this->getProperty($account, IAccountManager::PROPERTY_DISPLAYNAME),
162+
'website' => $this->getProperty($account, IAccountManager::PROPERTY_WEBSITE),
165163
'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
166164
'emailMap' => $this->getEmailMap($account),
167165
'languageMap' => $this->getLanguageMap($user),
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!--
2+
- @copyright 2022 Christopher Ng <chrng8@gmail.com>
3+
-
4+
- @author Christopher Ng <chrng8@gmail.com>
5+
-
6+
- @license AGPL-3.0-or-later
7+
-
8+
- This program is free software: you can redistribute it and/or modify
9+
- it under the terms of the GNU Affero General Public License as
10+
- published by the Free Software Foundation, either version 3 of the
11+
- License, or (at your option) any later version.
12+
-
13+
- This program is distributed in the hope that it will be useful,
14+
- but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
- GNU Affero General Public License for more details.
17+
-
18+
- You should have received a copy of the GNU Affero General Public License
19+
- along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
-
21+
-->
22+
23+
<template>
24+
<AccountPropertySection :property="website"
25+
:placeholder="t('settings', 'Your website')"
26+
type="url" />
27+
</template>
28+
29+
<script>
30+
import { loadState } from '@nextcloud/initial-state'
31+
32+
import AccountPropertySection from './shared/AccountPropertySection.vue'
33+
34+
import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
35+
36+
const { website } = loadState('settings', 'personalInfoParameters', {})
37+
38+
export default {
39+
name: 'WebsiteSection',
40+
41+
components: {
42+
AccountPropertySection,
43+
},
44+
45+
data() {
46+
return {
47+
website: { ...website, readable: NAME_READABLE_ENUM[website.name] },
48+
}
49+
},
50+
}
51+
</script>

apps/settings/src/main-personal-info.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import '@nextcloud/dialogs/styles/toast.scss'
2828

2929
import DisplayNameSection from './components/PersonalInfo/DisplayNameSection.vue'
3030
import EmailSection from './components/PersonalInfo/EmailSection/EmailSection.vue'
31+
import WebsiteSection from './components/PersonalInfo/WebsiteSection.vue'
3132
import TwitterSection from './components/PersonalInfo/TwitterSection.vue'
3233
import LanguageSection from './components/PersonalInfo/LanguageSection/LanguageSection.vue'
3334
import ProfileSection from './components/PersonalInfo/ProfileSection/ProfileSection.vue'
@@ -49,11 +50,13 @@ Vue.mixin({
4950

5051
const DisplayNameView = Vue.extend(DisplayNameSection)
5152
const EmailView = Vue.extend(EmailSection)
53+
const WebsiteView = Vue.extend(WebsiteSection)
5254
const TwitterView = Vue.extend(TwitterSection)
5355
const LanguageView = Vue.extend(LanguageSection)
5456

5557
new DisplayNameView().$mount('#vue-displayname-section')
5658
new EmailView().$mount('#vue-email-section')
59+
new WebsiteView().$mount('#vue-website-section')
5760
new TwitterView().$mount('#vue-twitter-section')
5861
new LanguageView().$mount('#vue-language-section')
5962

apps/settings/templates/settings/personal/personal.info.php

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -152,48 +152,7 @@
152152
</form>
153153
</div>
154154
<div class="personal-settings-setting-box">
155-
<form id="websiteform" class="section">
156-
<h3>
157-
<label for="website"><?php p($l->t('Website')); ?></label>
158-
<a href="#" class="federation-menu" aria-label="<?php p($l->t('Change privacy level of website')); ?>">
159-
<span class="icon-federation-menu icon-password">
160-
<span class="icon-triangle-s"></span>
161-
</span>
162-
</a>
163-
</h3>
164-
<?php if ($_['lookupServerUploadEnabled']) { ?>
165-
<div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') {
166-
p('hidden');
167-
} ?>">
168-
<img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src="
169-
<?php
170-
switch ($_['websiteVerification']) {
171-
case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
172-
p(image_path('core', 'actions/verifying.svg'));
173-
break;
174-
case \OC\Accounts\AccountManager::VERIFIED:
175-
p(image_path('core', 'actions/verified.svg'));
176-
break;
177-
default:
178-
p(image_path('core', 'actions/verify.svg'));
179-
}
180-
?>" <?php if ($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) {
181-
print_unescaped(' class="verify-action"');
182-
} ?>>
183-
<div class="verification-dialog popovermenu bubble menu">
184-
<div class="verification-dialog-content">
185-
<p class="explainVerification"></p>
186-
<p class="verificationCode"></p>
187-
<p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); ?></p>
188-
</div>
189-
</div>
190-
</div>
191-
<?php } ?>
192-
<input type="url" name="website" id="website" value="<?php p($_['website']); ?>" placeholder="<?php p($l->t('Link https://…')); ?>" autocomplete="on" autocapitalize="none" autocorrect="off" />
193-
<span class="icon-checkmark hidden"></span>
194-
<span class="icon-error hidden"></span>
195-
<input type="hidden" id="websitescope" value="<?php p($_['websiteScope']) ?>">
196-
</form>
155+
<div id="vue-website-section"></div>
197156
</div>
198157
<div class="personal-settings-setting-box">
199158
<div id="vue-twitter-section"></div>

0 commit comments

Comments
 (0)