Skip to content

Commit c6361da

Browse files
committed
Remake Twitter handle saving with Vue
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent d2d6bf0 commit c6361da

File tree

7 files changed

+60
-49
lines changed

7 files changed

+60
-49
lines changed

apps/settings/js/federationsettingsview.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@
129129
if (
130130
field === 'avatar' ||
131131
field === 'email' ||
132-
field === 'displayname'
132+
field === 'displayname' ||
133+
field === 'twitter'
133134
) {
134135
return;
135136
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ public function getForm(): TemplateResponse {
154154
'website' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getValue(),
155155
'websiteScope' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getScope(),
156156
'websiteVerification' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getVerified(),
157-
'twitter' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getValue(),
158-
'twitterScope' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getScope(),
159-
'twitterVerification' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getVerified(),
160157
'groups' => $this->getGroups($user),
161158
'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
162159
'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
@@ -165,6 +162,7 @@ public function getForm(): TemplateResponse {
165162
$personalInfoParameters = [
166163
'userId' => $uid,
167164
'displayName' => $this->getProperty($account, IAccountManager::PROPERTY_DISPLAYNAME),
165+
'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
168166
'emailMap' => $this->getEmailMap($account),
169167
'languageMap' => $this->getLanguageMap($user),
170168
'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 v-bind="twitter"
25+
:placeholder="t('settings', 'Your Twitter handle')" />
26+
</template>
27+
28+
<script>
29+
import { loadState } from '@nextcloud/initial-state'
30+
31+
import AccountPropertySection from './shared/AccountPropertySection.vue'
32+
33+
import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
34+
35+
const { twitter } = loadState('settings', 'personalInfoParameters', {})
36+
37+
export default {
38+
name: 'TwitterSection',
39+
40+
components: {
41+
AccountPropertySection,
42+
},
43+
44+
data() {
45+
return {
46+
twitter: { ...twitter, readable: NAME_READABLE_ENUM[twitter.name] },
47+
}
48+
},
49+
}
50+
</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 TwitterSection from './components/PersonalInfo/TwitterSection.vue'
3132
import LanguageSection from './components/PersonalInfo/LanguageSection/LanguageSection.vue'
3233
import ProfileSection from './components/PersonalInfo/ProfileSection/ProfileSection.vue'
3334
import OrganisationSection from './components/PersonalInfo/OrganisationSection.vue'
@@ -48,10 +49,12 @@ Vue.mixin({
4849

4950
const DisplayNameView = Vue.extend(DisplayNameSection)
5051
const EmailView = Vue.extend(EmailSection)
52+
const TwitterView = Vue.extend(TwitterSection)
5153
const LanguageView = Vue.extend(LanguageSection)
5254

5355
new DisplayNameView().$mount('#vue-displayname-section')
5456
new EmailView().$mount('#vue-email-section')
57+
new TwitterView().$mount('#vue-twitter-section')
5558
new LanguageView().$mount('#vue-language-section')
5659

5760
if (profileEnabledGlobally) {

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

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -196,48 +196,7 @@
196196
</form>
197197
</div>
198198
<div class="personal-settings-setting-box">
199-
<form id="twitterform" class="section">
200-
<h3>
201-
<label for="twitter"><?php p($l->t('Twitter')); ?></label>
202-
<a href="#" class="federation-menu" aria-label="<?php p($l->t('Change privacy level of Twitter profile')); ?>">
203-
<span class="icon-federation-menu icon-password">
204-
<span class="icon-triangle-s"></span>
205-
</span>
206-
</a>
207-
</h3>
208-
<?php if ($_['lookupServerUploadEnabled']) { ?>
209-
<div class="verify <?php if ($_['twitter'] === '' || $_['twitterScope'] !== 'public') {
210-
p('hidden');
211-
} ?>">
212-
<img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src="
213-
<?php
214-
switch ($_['twitterVerification']) {
215-
case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
216-
p(image_path('core', 'actions/verifying.svg'));
217-
break;
218-
case \OC\Accounts\AccountManager::VERIFIED:
219-
p(image_path('core', 'actions/verified.svg'));
220-
break;
221-
default:
222-
p(image_path('core', 'actions/verify.svg'));
223-
}
224-
?>" <?php if ($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) {
225-
print_unescaped(' class="verify-action"');
226-
} ?>>
227-
<div class="verification-dialog popovermenu bubble menu">
228-
<div class="verification-dialog-content">
229-
<p class="explainVerification"></p>
230-
<p class="verificationCode"></p>
231-
<p><?php p($l->t('It can take up to 24 hours before the account is displayed as verified.')); ?></p>
232-
</div>
233-
</div>
234-
</div>
235-
<?php } ?>
236-
<input type="text" name="twitter" id="twitter" value="<?php p($_['twitter']); ?>" placeholder="<?php p($l->t('Twitter handle @…')); ?>" autocomplete="on" autocapitalize="none" autocorrect="off" />
237-
<span class="icon-checkmark hidden"></span>
238-
<span class="icon-error hidden"></span>
239-
<input type="hidden" id="twitterscope" value="<?php p($_['twitterScope']) ?>">
240-
</form>
199+
<div id="vue-twitter-section"></div>
241200
</div>
242201
<?php if ($_['profileEnabledGlobally']) : ?>
243202
<div class="personal-settings-setting-box">

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)