Skip to content

Commit a1fae05

Browse files
authored
Merge pull request #33310 from nextcloud/enh/27869/website
2 parents 47584ee + e2efbab commit a1fae05

File tree

9 files changed

+87
-51
lines changed

9 files changed

+87
-51
lines changed

apps/settings/js/federationsettingsview.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@
132132
field === 'email' ||
133133
field === 'displayname' ||
134134
field === 'twitter' ||
135-
field === 'address'
135+
field === 'address' ||
136+
field === 'website'
136137
) {
137138
return;
138139
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ public function getForm(): TemplateResponse {
149149
'avatarScope' => $account->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope(),
150150
'phone' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getValue(),
151151
'phoneScope' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getScope(),
152-
'website' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getValue(),
153-
'websiteScope' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getScope(),
154-
'websiteVerification' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getVerified(),
155152
'groups' => $this->getGroups($user),
156153
'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
157154
'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
@@ -162,6 +159,7 @@ public function getForm(): TemplateResponse {
162159
'displayName' => $this->getProperty($account, IAccountManager::PROPERTY_DISPLAYNAME),
163160
'emailMap' => $this->getEmailMap($account),
164161
'location' => $this->getProperty($account, IAccountManager::PROPERTY_ADDRESS),
162+
'website' => $this->getProperty($account, IAccountManager::PROPERTY_WEBSITE),
165163
'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
166164
'languageMap' => $this->getLanguageMap($user),
167165
'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!--
2+
- @copyright 2022 Christopher Ng <[email protected]>
3+
-
4+
- @author Christopher Ng <[email protected]>
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 v-bind.sync="website"
25+
:placeholder="t('settings', 'Your website')"
26+
type="url"
27+
:on-validate="onValidate" />
28+
</template>
29+
30+
<script>
31+
import { loadState } from '@nextcloud/initial-state'
32+
33+
import AccountPropertySection from './shared/AccountPropertySection.vue'
34+
35+
import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
36+
import { validateUrl } from '../../utils/validate.js'
37+
38+
const { website } = loadState('settings', 'personalInfoParameters', {})
39+
40+
export default {
41+
name: 'WebsiteSection',
42+
43+
components: {
44+
AccountPropertySection,
45+
},
46+
47+
data() {
48+
return {
49+
website: { ...website, readable: NAME_READABLE_ENUM[website.name] },
50+
}
51+
},
52+
53+
methods: {
54+
onValidate(value) {
55+
return validateUrl(value)
56+
},
57+
},
58+
}
59+
</script>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import '@nextcloud/dialogs/styles/toast.scss'
2929
import DisplayNameSection from './components/PersonalInfo/DisplayNameSection.vue'
3030
import EmailSection from './components/PersonalInfo/EmailSection/EmailSection.vue'
3131
import LocationSection from './components/PersonalInfo/LocationSection.vue'
32+
import WebsiteSection from './components/PersonalInfo/WebsiteSection.vue'
3233
import TwitterSection from './components/PersonalInfo/TwitterSection.vue'
3334
import LanguageSection from './components/PersonalInfo/LanguageSection/LanguageSection.vue'
3435
import ProfileSection from './components/PersonalInfo/ProfileSection/ProfileSection.vue'
@@ -51,12 +52,14 @@ Vue.mixin({
5152
const DisplayNameView = Vue.extend(DisplayNameSection)
5253
const EmailView = Vue.extend(EmailSection)
5354
const LocationView = Vue.extend(LocationSection)
55+
const WebsiteView = Vue.extend(WebsiteSection)
5456
const TwitterView = Vue.extend(TwitterSection)
5557
const LanguageView = Vue.extend(LanguageSection)
5658

5759
new DisplayNameView().$mount('#vue-displayname-section')
5860
new EmailView().$mount('#vue-email-section')
5961
new LocationView().$mount('#vue-location-section')
62+
new WebsiteView().$mount('#vue-website-section')
6063
new TwitterView().$mount('#vue-twitter-section')
6164
new LanguageView().$mount('#vue-language-section')
6265

apps/settings/src/utils/validate.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* TODO add nice validation errors for Profile page settings modal
2727
*/
2828

29-
import { VALIDATE_EMAIL_REGEX } from '../constants/AccountPropertyConstants'
29+
import { VALIDATE_EMAIL_REGEX } from '../constants/AccountPropertyConstants.js'
3030

3131
/**
3232
* Validate the email input
@@ -46,6 +46,22 @@ export function validateEmail(input) {
4646
&& encodeURIComponent(input).replace(/%../g, 'x').length <= 320
4747
}
4848

49+
/**
50+
* Validate the URL input
51+
*
52+
* @param {string} input the input
53+
* @return {boolean}
54+
*/
55+
export function validateUrl(input) {
56+
try {
57+
// eslint-disable-next-line no-new
58+
new URL(input)
59+
return true
60+
} catch (e) {
61+
return false
62+
}
63+
}
64+
4965
/**
5066
* Validate the language input
5167
*

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

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

dist/settings-vue-settings-admin-basic-settings.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-personal-info.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-personal-info.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)