Skip to content

Commit

Permalink
[WHIP]
Browse files Browse the repository at this point in the history
- Provide icons as URLs instead of CSS classes
- Add entrypoint to contacts menu as displayname link and as action
- Add entrypoint to Avatar component in Talk through contacts menu actions provider (propagates to everything which uses ContactsMenuController)
- Use helper function to check if the profile is enabled
- Refine scope handling
- Handle disabled profile state for contacts menu and Avatar entrypoints
- General design, UX, and other improvements
- Some cleanup

Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Sep 17, 2021
1 parent e1ccc49 commit ae3fe4d
Show file tree
Hide file tree
Showing 29 changed files with 497 additions and 213 deletions.
16 changes: 3 additions & 13 deletions apps/settings/lib/Settings/Personal/PersonalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
use OCP\AppFramework\Services\IInitialState;

class PersonalInfo implements ISettings {
use \OC\Accounts\TAccountsHelper;

/** @var IConfig */
private $config;
Expand Down Expand Up @@ -158,7 +159,7 @@ public function getForm(): TemplateResponse {
'displayNameMap' => $this->getDisplayNameMap($account),
'emailMap' => $this->getEmailMap($account),
'languageMap' => $this->getLanguageMap($user),
'profileEnabled' => $this->getProfileEnabled($account),
'profileEnabled' => $this->isProfileEnabled($account),
'companyMap' => $this->getCompanyMap($account),
'jobTitleMap' => $this->getJobTitleMap($account),
'headlineMap' => $this->getHeadlineMap($account),
Expand Down Expand Up @@ -307,7 +308,7 @@ private function getDisplayNameMap(IAccount $account): array {
* returns the primary email and additional emails in an
* associative array
*/
private function getEmails(IAccount $account): array {
private function getEmailMap(IAccount $account): array {
$systemEmail = [
'value' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(),
'scope' => $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope(),
Expand Down Expand Up @@ -434,15 +435,4 @@ private function getMessageParameters(IAccount $account): array {
}
return $messageParameters;
}

/**
* returns the profile enabled state
*/
private function getProfileEnabled(IAccount $account): bool {
return filter_var(
$account->getProperty(IAccountManager::PROPERTY_PROFILE_ENABLED)->getValue(),
FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import Email from './Email'
import HeaderBar from '../shared/HeaderBar'

import { ACCOUNT_PROPERTY_READABLE_ENUM, DEFAULT_ADDITIONAL_EMAIL_SCOPE } from '../../../constants/AccountPropertyConstants'
import { savePrimaryEmail, removeAdditionalEmail } from '../../../service/PersonalInfo/EmailService'
import { savePrimaryEmail, savePrimaryEmailScope, removeAdditionalEmail } from '../../../service/PersonalInfo/EmailService'
import { validateEmail } from '../../../utils/validate'

const { emailMap: { additionalEmails, primaryEmail, notificationEmail } } = loadState('settings', 'personalInfoParameters', {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
:user="userId"
:size="48"
:show-user-status="true"
:show-user-status-compact="true"
:show-user-status-compact="false"
:disable-menu="true"
:disable-tooltip="true"
@click.native.prevent.stop="openStatusModal" />
Expand Down Expand Up @@ -87,7 +87,7 @@ export default {

profilePageLink() {
if (this.profileEnabled) {
return generateUrl('u/{userId}', { userId: getCurrentUser().uid })
return generateUrl('/u/{userId}', { userId: getCurrentUser().uid })
}
// Since an anchor element is used rather than a button for better UX,
// this hack removes href if the profile is disabled so that disabling pointer-events is not needed to prevent a click from opening a page
Expand Down Expand Up @@ -115,14 +115,14 @@ export default {
box-shadow: 0 2px 9px var(--color-box-shadow);

&:hover {
box-shadow: 0 2px 10px rgba(77, 77, 77, 0.65);
box-shadow: 0 2px 12px var(--color-box-shadow);
}

&.disabled {
filter: grayscale(1);
opacity: 0.5;
cursor: default;
box-shadow: 0 2px 9px rgba(77, 77, 77, 0.1);
box-shadow: 0 0 3px var(--color-box-shadow);

& *,
&::v-deep * {
Expand Down
14 changes: 7 additions & 7 deletions apps/settings/src/constants/AccountPropertyConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export const ACCOUNT_SETTING_PROPERTY_READABLE_ENUM = Object.freeze({

/** Enum of scopes */
export const SCOPE_ENUM = Object.freeze({
LOCAL: 'v2-local',
PRIVATE: 'v2-private',
LOCAL: 'v2-local',
FEDERATED: 'v2-federated',
PUBLISHED: 'v2-published',
})
Expand Down Expand Up @@ -126,18 +126,18 @@ export const SCOPE_SUFFIX = 'Scope'
* *Used for federation control*
*/
export const SCOPE_PROPERTY_ENUM = Object.freeze({
[SCOPE_ENUM.LOCAL]: {
name: SCOPE_ENUM.LOCAL,
displayName: t('settings', 'Local'),
tooltip: t('settings', 'Only visible to people on this instance and guests'),
iconClass: 'icon-password',
},
[SCOPE_ENUM.PRIVATE]: {
name: SCOPE_ENUM.PRIVATE,
displayName: t('settings', 'Private'),
tooltip: t('settings', 'Only visible to people matched via phone number integration through Talk on mobile'),
iconClass: 'icon-phone',
},
[SCOPE_ENUM.LOCAL]: {
name: SCOPE_ENUM.LOCAL,
displayName: t('settings', 'Local'),
tooltip: t('settings', 'Only visible to people on this instance and guests'),
iconClass: 'icon-password',
},
[SCOPE_ENUM.FEDERATED]: {
name: SCOPE_ENUM.FEDERATED,
displayName: t('settings', 'Federated'),
Expand Down
23 changes: 3 additions & 20 deletions apps/user_status/lib/Listener/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\UserStatus\Listener;

use OCP\Accounts\IAccount;
use OCP\Accounts\IAccountManager;
use OCP\IUserSession;
use OCA\UserStatus\AppInfo\Application;
use OCA\UserStatus\Service\JSDataService;
use OCP\Accounts\PropertyDoesNotExistException;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IInitialStateService;
use OCP\User\Events\BeforeUserLoggedInEvent;
use OCP\User\Events\PostLoginEvent;
use OCP\User\Events\UserLiveStatusEvent;

class BeforeTemplateRenderedListener implements IEventListener {
use \OC\Accounts\TAccountsHelper;

/** @var IAccountManager */
private $accountManager;
Expand Down Expand Up @@ -99,24 +96,10 @@ public function handle(Event $event): void {
});

$this->initialState->provideLazyInitialState(Application::APP_ID, 'profileEnabled', function () use ($account) {
return ['profileEnabled' => $this->getProfileEnabled($account)];
return ['profileEnabled' => $this->isProfileEnabled($account)];
});

\OCP\Util::addScript('user_status', 'user-status-menu');
\OCP\Util::addStyle('user_status', 'user-status-menu');
}

/**
* returns the profile enabled state
*
* @param IAccount $account
* @return bool
*/
private function getProfileEnabled(IAccount $account): bool {
return filter_var(
$account->getProperty(IAccountManager::PROPERTY_PROFILE_ENABLED)->getValue(),
FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE,
);
}
}
Loading

0 comments on commit ae3fe4d

Please sign in to comment.