Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Emails UI and Integration #27379

Merged
merged 5 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/settings/js/federationsettingsview.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@
_registerEvents: function() {
var self = this;
_.each(this._inputFields, function(field) {
if (field === 'avatar') {
if (
field === 'avatar' ||
field === 'email'
) {
return;
}
self.$('#' + field).keyUpDelayedOrEnter(_.bind(self._onInputChanged, self), true);
Expand Down
34 changes: 17 additions & 17 deletions apps/settings/js/vue-settings-admin-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-admin-security.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions apps/settings/js/vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions apps/settings/js/vue-settings-nextcloud-pdf.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-nextcloud-pdf.js.map

Large diffs are not rendered by default.

227 changes: 227 additions & 0 deletions apps/settings/js/vue-settings-personal-info.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/settings/js/vue-settings-personal-info.js.map

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions apps/settings/js/vue-settings-personal-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-personal-security.js.map

Large diffs are not rendered by default.

43 changes: 32 additions & 11 deletions apps/settings/js/vue-settings-personal-webauthn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-personal-webauthn.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions apps/settings/js/vue-settings-users-a4d4d1172ce22a84ac4a.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions apps/settings/js/vue-settings-users-b9836024eef7aa79cd9f.js

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

50 changes: 49 additions & 1 deletion apps/settings/lib/Settings/Personal/PersonalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Christopher Ng <chrng8@gmail.com>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
Expand Down Expand Up @@ -48,6 +49,8 @@
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\Settings\ISettings;
use OCP\Accounts\IAccountProperty;
use OCP\AppFramework\Services\IInitialState;

class PersonalInfo implements ISettings {

Expand All @@ -65,6 +68,8 @@ class PersonalInfo implements ISettings {
private $l10nFactory;
/** @var IL10N */
private $l;
/** @var IInitialState */
private $initialStateService;

public function __construct(
IConfig $config,
Expand All @@ -73,7 +78,8 @@ public function __construct(
IAccountManager $accountManager,
IAppManager $appManager,
IFactory $l10nFactory,
IL10N $l
IL10N $l,
IInitialState $initialStateService
) {
$this->config = $config;
$this->userManager = $userManager;
Expand All @@ -82,6 +88,7 @@ public function __construct(
$this->appManager = $appManager;
$this->l10nFactory = $l10nFactory;
$this->l = $l;
$this->initialStateService = $initialStateService;
}

public function getForm(): TemplateResponse {
Expand Down Expand Up @@ -138,6 +145,14 @@ public function getForm(): TemplateResponse {
'groups' => $this->getGroups($user),
] + $messageParameters + $languageParameters + $localeParameters;

$emails = $this->getEmails($account);

$accountParameters = [
'displayNameChangeSupported' => $user->canChangeDisplayName(),
];

$this->initialStateService->provideInitialState('emails', $emails);
$this->initialStateService->provideInitialState('accountParameters', $accountParameters);

return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
}
Expand Down Expand Up @@ -180,6 +195,39 @@ static function (IGroup $group) {
return $groups;
}

/**
* returns the primary email and additional emails in an
* associative array
*
* @param IAccount $account
* @return array
*/
private function getEmails(IAccount $account): array {
$primaryEmail = [
'value' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(),
'scope' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope(),
'verified' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getVerified(),
];

$additionalEmails = array_map(
function (IAccountProperty $property) {
return [
'value' => $property->getValue(),
'scope' => $property->getScope(),
'verified' => $property->getVerified(),
];
},
$account->getPropertyCollection(IAccountManager::COLLECTION_EMAIL)->getProperties()
);

$emails = [
'primaryEmail' => $primaryEmail,
'additionalEmails' => $additionalEmails,
];

return $emails;
}

/**
* returns the user language, common language and other languages in an
* associative array
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!--
skjnldsv marked this conversation as resolved.
Show resolved Hide resolved
- @copyright 2021, Christopher Ng <chrng8@gmail.com>
-
- @author Christopher Ng <chrng8@gmail.com>
-
- @license GNU AGPL version 3 or any later version
-
- 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>
<button
:disabled="disabled"
@click.stop.prevent="onClick">
<span class="icon icon-add" />
{{ t('settings', 'Add') }}
</button>
</template>

<script>
export default {
name: 'AddButton',

props: {
disabled: {
type: Boolean,
default: true,
},
},

methods: {
onClick(e) {
this.$emit('click', e)
},
},
}
</script>

<style lang="scss" scoped>
button {
height: 44px;
padding: 0 16px;
border: none;
background-color: transparent;

&:hover {
background-color: rgba(127, 127, 127, .15);
}

&:enabled {
opacity: 0.4 !important;

.icon {
opacity: 0.8 !important;
}
}

&:enabled:hover {
background-color: rgba(127, 127, 127, .25);
opacity: 0.8 !important;
}

.icon {
margin-right: 8px;
}
}
</style>
Loading