Skip to content

Commit

Permalink
feat: add pronouns to account profile
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Mar 5, 2024
1 parent 80e4193 commit bd95aa8
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 5 deletions.
1 change: 1 addition & 0 deletions apps/provisioning_api/lib/Controller/AUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ protected function getUserData(string $userId, bool $includeScopes = false): ?ar
IAccountManager::PROPERTY_HEADLINE,
IAccountManager::PROPERTY_BIOGRAPHY,
IAccountManager::PROPERTY_PROFILE_ENABLED,
IAccountManager::PROPERTY_PRONOUNS,

Check failure

Code scanning / Psalm

UndefinedConstant Error

Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined

Check failure on line 203 in apps/provisioning_api/lib/Controller/AUserData.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedConstant

apps/provisioning_api/lib/Controller/AUserData.php:203:5: UndefinedConstant: Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined (see https://psalm.dev/020)
] as $propertyName) {
$property = $userAccount->getProperty($propertyName);
$data[$propertyName] = $property->getValue();
Expand Down
6 changes: 6 additions & 0 deletions apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ public function getEditableFieldsForUser(string $userId): DataResponse {
$permittedFields[] = IAccountManager::PROPERTY_HEADLINE;
$permittedFields[] = IAccountManager::PROPERTY_BIOGRAPHY;
$permittedFields[] = IAccountManager::PROPERTY_PROFILE_ENABLED;
$permittedFields[] = IAccountManager::PROPERTY_PRONOUNS;

Check failure

Code scanning / Psalm

UndefinedConstant Error

Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined

Check failure on line 717 in apps/provisioning_api/lib/Controller/UsersController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedConstant

apps/provisioning_api/lib/Controller/UsersController.php:717:24: UndefinedConstant: Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined (see https://psalm.dev/020)

return new DataResponse($permittedFields);
}
Expand Down Expand Up @@ -889,6 +890,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
$permittedFields[] = IAccountManager::PROPERTY_HEADLINE;
$permittedFields[] = IAccountManager::PROPERTY_BIOGRAPHY;
$permittedFields[] = IAccountManager::PROPERTY_PROFILE_ENABLED;
$permittedFields[] = IAccountManager::PROPERTY_PRONOUNS;

Check failure

Code scanning / Psalm

UndefinedConstant Error

Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined

Check failure on line 893 in apps/provisioning_api/lib/Controller/UsersController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedConstant

apps/provisioning_api/lib/Controller/UsersController.php:893:25: UndefinedConstant: Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined (see https://psalm.dev/020)
$permittedFields[] = IAccountManager::PROPERTY_PHONE . self::SCOPE_SUFFIX;
$permittedFields[] = IAccountManager::PROPERTY_ADDRESS . self::SCOPE_SUFFIX;
$permittedFields[] = IAccountManager::PROPERTY_WEBSITE . self::SCOPE_SUFFIX;
Expand All @@ -899,6 +901,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
$permittedFields[] = IAccountManager::PROPERTY_HEADLINE . self::SCOPE_SUFFIX;
$permittedFields[] = IAccountManager::PROPERTY_BIOGRAPHY . self::SCOPE_SUFFIX;
$permittedFields[] = IAccountManager::PROPERTY_PROFILE_ENABLED . self::SCOPE_SUFFIX;
$permittedFields[] = IAccountManager::PROPERTY_PRONOUNS . self::SCOPE_SUFFIX;

Check failure

Code scanning / Psalm

UndefinedConstant Error

Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined

Check failure on line 904 in apps/provisioning_api/lib/Controller/UsersController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedConstant

apps/provisioning_api/lib/Controller/UsersController.php:904:25: UndefinedConstant: Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined (see https://psalm.dev/020)

$permittedFields[] = IAccountManager::PROPERTY_AVATAR . self::SCOPE_SUFFIX;

Expand Down Expand Up @@ -940,6 +943,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
$permittedFields[] = self::USER_FIELD_QUOTA;
$permittedFields[] = self::USER_FIELD_NOTIFICATION_EMAIL;
$permittedFields[] = self::USER_FIELD_MANAGER;
$permittedFields[] = IAccountManager::PROPERTY_PRONOUNS;

Check failure

Code scanning / Psalm

UndefinedConstant Error

Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined

Check failure on line 946 in apps/provisioning_api/lib/Controller/UsersController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedConstant

apps/provisioning_api/lib/Controller/UsersController.php:946:26: UndefinedConstant: Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined (see https://psalm.dev/020)
} else {
// No rights
throw new OCSException('', OCSController::RESPOND_NOT_FOUND);
Expand Down Expand Up @@ -1069,6 +1073,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
case IAccountManager::PROPERTY_ROLE:
case IAccountManager::PROPERTY_HEADLINE:
case IAccountManager::PROPERTY_BIOGRAPHY:
case IAccountManager::PROPERTY_PRONOUNS:

Check failure

Code scanning / Psalm

UndefinedConstant Error

Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined

Check failure on line 1076 in apps/provisioning_api/lib/Controller/UsersController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedConstant

apps/provisioning_api/lib/Controller/UsersController.php:1076:9: UndefinedConstant: Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined (see https://psalm.dev/020)
$userAccount = $this->accountManager->getAccount($targetUser);
try {
$userProperty = $userAccount->getProperty($key);
Expand Down Expand Up @@ -1116,6 +1121,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
case IAccountManager::PROPERTY_BIOGRAPHY . self::SCOPE_SUFFIX:
case IAccountManager::PROPERTY_PROFILE_ENABLED . self::SCOPE_SUFFIX:
case IAccountManager::PROPERTY_AVATAR . self::SCOPE_SUFFIX:
case IAccountManager::PROPERTY_PRONOUNS . self::SCOPE_SUFFIX:

Check failure

Code scanning / Psalm

UndefinedConstant Error

Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined

Check failure on line 1124 in apps/provisioning_api/lib/Controller/UsersController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedConstant

apps/provisioning_api/lib/Controller/UsersController.php:1124:9: UndefinedConstant: Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined (see https://psalm.dev/020)
$propertyName = substr($key, 0, strlen($key) - strlen(self::SCOPE_SUFFIX));
$userAccount = $this->accountManager->getAccount($targetUser);
$userProperty = $userAccount->getProperty($propertyName);
Expand Down
1 change: 1 addition & 0 deletions apps/settings/lib/Settings/Personal/PersonalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public function getForm(): TemplateResponse {
'role' => $this->getProperty($account, IAccountManager::PROPERTY_ROLE),
'headline' => $this->getProperty($account, IAccountManager::PROPERTY_HEADLINE),
'biography' => $this->getProperty($account, IAccountManager::PROPERTY_BIOGRAPHY),
'pronouns' => $this->getProperty($account, IAccountManager::PROPERTY_PRONOUNS),

Check failure

Code scanning / Psalm

UndefinedConstant Error

Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined

Check failure on line 170 in apps/settings/lib/Settings/Personal/PersonalInfo.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedConstant

apps/settings/lib/Settings/Personal/PersonalInfo.php:170:47: UndefinedConstant: Constant OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS is not defined (see https://psalm.dev/020)
];

$accountParameters = [
Expand Down
51 changes: 51 additions & 0 deletions apps/settings/src/components/PersonalInfo/PronounsSection.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!--
- @copyright 2022 Christopher Ng <chrng8@gmail.com>
-
- @author Christopher Ng <chrng8@gmail.com>
-
- @license AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->

<template>
<AccountPropertySection v-bind.sync="pronouns"
autocomplete="organization-title"
:placeholder="t('settings', 'Your pronouns')" />
</template>

<script>
import { loadState } from '@nextcloud/initial-state'
import AccountPropertySection from './shared/AccountPropertySection.vue'
import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
const { pronouns } = loadState('settings', 'personalInfoParameters', {})
export default {
name: 'PronounsSection',
components: {
AccountPropertySection,
},
data() {
return {
pronouns: { ...pronouns, readable: NAME_READABLE_ENUM[pronouns.name] },
}
},
}
</script>
15 changes: 10 additions & 5 deletions apps/settings/src/constants/AccountPropertyConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ export const ACCOUNT_PROPERTY_ENUM = Object.freeze({
DISPLAYNAME: 'displayname',
EMAIL_COLLECTION: 'additional_mail',
EMAIL: 'email',
FEDIVERSE: 'fediverse',
HEADLINE: 'headline',
NOTIFICATION_EMAIL: 'notify_email',
FEDIVERSE: 'fediverse',
ORGANISATION: 'organisation',
PHONE: 'phone',
PROFILE_ENABLED: 'profile_enabled',
PRONOUNS: 'pronouns',
ROLE: 'role',
TWITTER: 'twitter',
WEBSITE: 'website',
Expand All @@ -54,13 +55,14 @@ export const ACCOUNT_PROPERTY_READABLE_ENUM = Object.freeze({
DISPLAYNAME: t('settings', 'Full name'),
EMAIL_COLLECTION: t('settings', 'Additional email'),
EMAIL: t('settings', 'Email'),
FEDIVERSE: t('settings', 'Fediverse (e.g. Mastodon)'),
HEADLINE: t('settings', 'Headline'),
ORGANISATION: t('settings', 'Organisation'),
PHONE: t('settings', 'Phone number'),
PROFILE_ENABLED: t('settings', 'Profile'),
PRONOUNS: t('settings', 'Pronouns'),
ROLE: t('settings', 'Role'),
TWITTER: t('settings', 'X (formerly Twitter)'),
FEDIVERSE: t('settings', 'Fediverse (e.g. Mastodon)'),
WEBSITE: t('settings', 'Website'),
})

Expand All @@ -71,13 +73,14 @@ export const NAME_READABLE_ENUM = Object.freeze({
[ACCOUNT_PROPERTY_ENUM.DISPLAYNAME]: ACCOUNT_PROPERTY_READABLE_ENUM.DISPLAYNAME,
[ACCOUNT_PROPERTY_ENUM.EMAIL_COLLECTION]: ACCOUNT_PROPERTY_READABLE_ENUM.EMAIL_COLLECTION,
[ACCOUNT_PROPERTY_ENUM.EMAIL]: ACCOUNT_PROPERTY_READABLE_ENUM.EMAIL,
[ACCOUNT_PROPERTY_ENUM.FEDIVERSE]: ACCOUNT_PROPERTY_READABLE_ENUM.FEDIVERSE,
[ACCOUNT_PROPERTY_ENUM.HEADLINE]: ACCOUNT_PROPERTY_READABLE_ENUM.HEADLINE,
[ACCOUNT_PROPERTY_ENUM.ORGANISATION]: ACCOUNT_PROPERTY_READABLE_ENUM.ORGANISATION,
[ACCOUNT_PROPERTY_ENUM.PHONE]: ACCOUNT_PROPERTY_READABLE_ENUM.PHONE,
[ACCOUNT_PROPERTY_ENUM.PROFILE_ENABLED]: ACCOUNT_PROPERTY_READABLE_ENUM.PROFILE_ENABLED,
[ACCOUNT_PROPERTY_ENUM.PRONOUNS]: ACCOUNT_PROPERTY_READABLE_ENUM.PRONOUNS,
[ACCOUNT_PROPERTY_ENUM.ROLE]: ACCOUNT_PROPERTY_READABLE_ENUM.ROLE,
[ACCOUNT_PROPERTY_ENUM.TWITTER]: ACCOUNT_PROPERTY_READABLE_ENUM.TWITTER,
[ACCOUNT_PROPERTY_ENUM.FEDIVERSE]: ACCOUNT_PROPERTY_READABLE_ENUM.FEDIVERSE,
[ACCOUNT_PROPERTY_ENUM.WEBSITE]: ACCOUNT_PROPERTY_READABLE_ENUM.WEBSITE,
})

Expand All @@ -94,13 +97,14 @@ export const PROPERTY_READABLE_KEYS_ENUM = Object.freeze({
[ACCOUNT_PROPERTY_READABLE_ENUM.DISPLAYNAME]: ACCOUNT_PROPERTY_ENUM.DISPLAYNAME,
[ACCOUNT_PROPERTY_READABLE_ENUM.EMAIL_COLLECTION]: ACCOUNT_PROPERTY_ENUM.EMAIL_COLLECTION,
[ACCOUNT_PROPERTY_READABLE_ENUM.EMAIL]: ACCOUNT_PROPERTY_ENUM.EMAIL,
[ACCOUNT_PROPERTY_READABLE_ENUM.FEDIVERSE]: ACCOUNT_PROPERTY_ENUM.FEDIVERSE,
[ACCOUNT_PROPERTY_READABLE_ENUM.HEADLINE]: ACCOUNT_PROPERTY_ENUM.HEADLINE,
[ACCOUNT_PROPERTY_READABLE_ENUM.ORGANISATION]: ACCOUNT_PROPERTY_ENUM.ORGANISATION,
[ACCOUNT_PROPERTY_READABLE_ENUM.PHONE]: ACCOUNT_PROPERTY_ENUM.PHONE,
[ACCOUNT_PROPERTY_READABLE_ENUM.PROFILE_ENABLED]: ACCOUNT_PROPERTY_ENUM.PROFILE_ENABLED,
[ACCOUNT_PROPERTY_READABLE_ENUM.PRONOUNS]: ACCOUNT_PROPERTY_ENUM.PRONOUNS,
[ACCOUNT_PROPERTY_READABLE_ENUM.ROLE]: ACCOUNT_PROPERTY_ENUM.ROLE,
[ACCOUNT_PROPERTY_READABLE_ENUM.TWITTER]: ACCOUNT_PROPERTY_ENUM.TWITTER,
[ACCOUNT_PROPERTY_READABLE_ENUM.FEDIVERSE]: ACCOUNT_PROPERTY_ENUM.FEDIVERSE,
[ACCOUNT_PROPERTY_READABLE_ENUM.WEBSITE]: ACCOUNT_PROPERTY_ENUM.WEBSITE,
})

Expand Down Expand Up @@ -136,13 +140,14 @@ export const PROPERTY_READABLE_SUPPORTED_SCOPES_ENUM = Object.freeze({
[ACCOUNT_PROPERTY_READABLE_ENUM.DISPLAYNAME]: [SCOPE_ENUM.LOCAL],
[ACCOUNT_PROPERTY_READABLE_ENUM.EMAIL_COLLECTION]: [SCOPE_ENUM.LOCAL],
[ACCOUNT_PROPERTY_READABLE_ENUM.EMAIL]: [SCOPE_ENUM.LOCAL],
[ACCOUNT_PROPERTY_READABLE_ENUM.FEDIVERSE]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
[ACCOUNT_PROPERTY_READABLE_ENUM.HEADLINE]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
[ACCOUNT_PROPERTY_READABLE_ENUM.ORGANISATION]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
[ACCOUNT_PROPERTY_READABLE_ENUM.PHONE]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
[ACCOUNT_PROPERTY_READABLE_ENUM.PROFILE_ENABLED]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
[ACCOUNT_PROPERTY_READABLE_ENUM.PRONOUNS]: [SCOPE_ENUM.LOCAL],
[ACCOUNT_PROPERTY_READABLE_ENUM.ROLE]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
[ACCOUNT_PROPERTY_READABLE_ENUM.TWITTER]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
[ACCOUNT_PROPERTY_READABLE_ENUM.FEDIVERSE]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
[ACCOUNT_PROPERTY_READABLE_ENUM.WEBSITE]: [SCOPE_ENUM.LOCAL, SCOPE_ENUM.PRIVATE],
})

Expand Down
3 changes: 3 additions & 0 deletions apps/settings/src/main-personal-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import DetailsSection from './components/PersonalInfo/DetailsSection.vue'
import DisplayNameSection from './components/PersonalInfo/DisplayNameSection.vue'
import EmailSection from './components/PersonalInfo/EmailSection/EmailSection.vue'
import PhoneSection from './components/PersonalInfo/PhoneSection.vue'
import PronounsSection from './components/PersonalInfo/PronounsSection.vue'
import LocationSection from './components/PersonalInfo/LocationSection.vue'
import WebsiteSection from './components/PersonalInfo/WebsiteSection.vue'
import TwitterSection from './components/PersonalInfo/TwitterSection.vue'
Expand Down Expand Up @@ -64,6 +65,7 @@ const TwitterView = Vue.extend(TwitterSection)
const FediverseView = Vue.extend(FediverseSection)
const LanguageView = Vue.extend(LanguageSection)
const LocaleView = Vue.extend(LocaleSection)
const PronounsView = Vue.extend(PronounsSection)

new AvatarView().$mount('#vue-avatar-section')
new DetailsView().$mount('#vue-details-section')
Expand All @@ -76,6 +78,7 @@ new TwitterView().$mount('#vue-twitter-section')
new FediverseView().$mount('#vue-fediverse-section')
new LanguageView().$mount('#vue-language-section')
new LocaleView().$mount('#vue-locale-section')
new PronounsView().$mount('#vue-pronouns-section')

if (profileEnabledGlobally) {
const ProfileView = Vue.extend(ProfileSection)
Expand Down
3 changes: 3 additions & 0 deletions apps/settings/templates/settings/personal/personal.info.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
<div class="personal-settings-setting-box">
<div id="vue-displayname-section"></div>
</div>
<div class="personal-settings-setting-box">
<div id="vue-pronouns-section"></div>
</div>
<div class="personal-settings-setting-box">
<div id="vue-email-section"></div>
</div>
Expand Down

0 comments on commit bd95aa8

Please sign in to comment.