From 027adfd932a5c93959d2779da439d19076dac109 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 28 Oct 2021 18:07:10 +0000 Subject: [PATCH] Add new profile visibility section Signed-off-by: Christopher Ng --- .../BiographySection/BiographySection.vue | 12 +----- .../DisplayNameSection/DisplayNameSection.vue | 12 +----- .../EmailSection/EmailSection.vue | 12 +----- .../HeadlineSection/HeadlineSection.vue | 12 +----- .../OrganisationSection.vue | 12 +----- .../ProfileVisibilitySection.vue | 37 ++++++++++++------- .../PersonalInfo/RoleSection/RoleSection.vue | 12 +----- .../shared/VisibilityDropdown.vue | 26 +++++++------ .../src/constants/AccountPropertyConstants.js | 2 +- apps/settings/src/main-personal-info.js | 23 ------------ .../settings/personal/personal.info.php | 12 ++---- core/src/views/Profile.vue | 2 +- 12 files changed, 51 insertions(+), 123 deletions(-) diff --git a/apps/settings/src/components/PersonalInfo/BiographySection/BiographySection.vue b/apps/settings/src/components/PersonalInfo/BiographySection/BiographySection.vue index 794d01aa95492..637c24e26657f 100644 --- a/apps/settings/src/components/PersonalInfo/BiographySection/BiographySection.vue +++ b/apps/settings/src/components/PersonalInfo/BiographySection/BiographySection.vue @@ -30,11 +30,6 @@ - - @@ -43,12 +38,10 @@ import { loadState } from '@nextcloud/initial-state' import Biography from './Biography' import HeaderBar from '../shared/HeaderBar' -import VisibilityDropdown from '../shared/VisibilityDropdown' -import { ACCOUNT_PROPERTY_ENUM, ACCOUNT_PROPERTY_READABLE_ENUM } from '../../../constants/AccountPropertyConstants' +import { ACCOUNT_PROPERTY_READABLE_ENUM } from '../../../constants/AccountPropertyConstants' const { biographyMap: { primaryBiography } } = loadState('settings', 'personalInfoParameters', {}) -const { profileConfig: { biography: { visibility } } } = loadState('settings', 'profileParameters', {}) export default { name: 'BiographySection', @@ -56,15 +49,12 @@ export default { components: { Biography, HeaderBar, - VisibilityDropdown, }, data() { return { accountProperty: ACCOUNT_PROPERTY_READABLE_ENUM.BIOGRAPHY, - accountPropertyId: ACCOUNT_PROPERTY_ENUM.BIOGRAPHY, primaryBiography, - visibility, } }, } diff --git a/apps/settings/src/components/PersonalInfo/DisplayNameSection/DisplayNameSection.vue b/apps/settings/src/components/PersonalInfo/DisplayNameSection/DisplayNameSection.vue index b46aea7285679..6f07d72d456fb 100644 --- a/apps/settings/src/components/PersonalInfo/DisplayNameSection/DisplayNameSection.vue +++ b/apps/settings/src/components/PersonalInfo/DisplayNameSection/DisplayNameSection.vue @@ -33,11 +33,6 @@ - - @@ -51,14 +46,12 @@ import { loadState } from '@nextcloud/initial-state' import DisplayName from './DisplayName' import HeaderBar from '../shared/HeaderBar' -import VisibilityDropdown from '../shared/VisibilityDropdown' -import { ACCOUNT_PROPERTY_ENUM, ACCOUNT_PROPERTY_READABLE_ENUM } from '../../../constants/AccountPropertyConstants' +import { ACCOUNT_PROPERTY_READABLE_ENUM } from '../../../constants/AccountPropertyConstants' import { validateStringInput } from '../../../utils/validate' const { displayNameMap: { primaryDisplayName } } = loadState('settings', 'personalInfoParameters', {}) const { displayNameChangeSupported } = loadState('settings', 'accountParameters', {}) -const { profileConfig: { displayname: { visibility } } } = loadState('settings', 'profileParameters', {}) export default { name: 'DisplayNameSection', @@ -66,16 +59,13 @@ export default { components: { DisplayName, HeaderBar, - VisibilityDropdown, }, data() { return { accountProperty: ACCOUNT_PROPERTY_READABLE_ENUM.DISPLAYNAME, - accountPropertyId: ACCOUNT_PROPERTY_ENUM.DISPLAYNAME, displayNameChangeSupported, primaryDisplayName, - visibility, } }, diff --git a/apps/settings/src/components/PersonalInfo/EmailSection/EmailSection.vue b/apps/settings/src/components/PersonalInfo/EmailSection/EmailSection.vue index 2a9aefd4162d7..f25b281782f72 100644 --- a/apps/settings/src/components/PersonalInfo/EmailSection/EmailSection.vue +++ b/apps/settings/src/components/PersonalInfo/EmailSection/EmailSection.vue @@ -40,11 +40,6 @@ :active-notification-email.sync="notificationEmail" @update:email="onUpdateEmail" @update:notification-email="onUpdateNotificationEmail" /> - - @@ -73,15 +68,13 @@ import { showError } from '@nextcloud/dialogs' import Email from './Email' import HeaderBar from '../shared/HeaderBar' -import VisibilityDropdown from '../shared/VisibilityDropdown' -import { ACCOUNT_PROPERTY_ENUM, ACCOUNT_PROPERTY_READABLE_ENUM, DEFAULT_ADDITIONAL_EMAIL_SCOPE } from '../../../constants/AccountPropertyConstants' +import { ACCOUNT_PROPERTY_READABLE_ENUM, DEFAULT_ADDITIONAL_EMAIL_SCOPE } from '../../../constants/AccountPropertyConstants' import { savePrimaryEmail, savePrimaryEmailScope, removeAdditionalEmail } from '../../../service/PersonalInfo/EmailService' import { validateEmail } from '../../../utils/validate' const { emailMap: { additionalEmails, primaryEmail, notificationEmail } } = loadState('settings', 'personalInfoParameters', {}) const { displayNameChangeSupported } = loadState('settings', 'accountParameters', {}) -const { profileConfig: { email: { visibility } } } = loadState('settings', 'profileParameters', {}) export default { name: 'EmailSection', @@ -89,19 +82,16 @@ export default { components: { HeaderBar, Email, - VisibilityDropdown, }, data() { return { accountProperty: ACCOUNT_PROPERTY_READABLE_ENUM.EMAIL, - accountPropertyId: ACCOUNT_PROPERTY_ENUM.EMAIL, additionalEmails, displayNameChangeSupported, primaryEmail, savePrimaryEmailScope, notificationEmail, - visibility, } }, diff --git a/apps/settings/src/components/PersonalInfo/HeadlineSection/HeadlineSection.vue b/apps/settings/src/components/PersonalInfo/HeadlineSection/HeadlineSection.vue index 96d5ade1ce6f7..0eb83be535c0c 100644 --- a/apps/settings/src/components/PersonalInfo/HeadlineSection/HeadlineSection.vue +++ b/apps/settings/src/components/PersonalInfo/HeadlineSection/HeadlineSection.vue @@ -30,11 +30,6 @@ - - @@ -43,12 +38,10 @@ import { loadState } from '@nextcloud/initial-state' import Headline from './Headline' import HeaderBar from '../shared/HeaderBar' -import VisibilityDropdown from '../shared/VisibilityDropdown' -import { ACCOUNT_PROPERTY_ENUM, ACCOUNT_PROPERTY_READABLE_ENUM } from '../../../constants/AccountPropertyConstants' +import { ACCOUNT_PROPERTY_READABLE_ENUM } from '../../../constants/AccountPropertyConstants' const { headlineMap: { primaryHeadline } } = loadState('settings', 'personalInfoParameters', {}) -const { profileConfig: { headline: { visibility } } } = loadState('settings', 'profileParameters', {}) export default { name: 'HeadlineSection', @@ -56,15 +49,12 @@ export default { components: { Headline, HeaderBar, - VisibilityDropdown, }, data() { return { accountProperty: ACCOUNT_PROPERTY_READABLE_ENUM.HEADLINE, - accountPropertyId: ACCOUNT_PROPERTY_ENUM.HEADLINE, primaryHeadline, - visibility, } }, } diff --git a/apps/settings/src/components/PersonalInfo/OrganisationSection/OrganisationSection.vue b/apps/settings/src/components/PersonalInfo/OrganisationSection/OrganisationSection.vue index 57515ad7496b4..420f79fc8d03b 100644 --- a/apps/settings/src/components/PersonalInfo/OrganisationSection/OrganisationSection.vue +++ b/apps/settings/src/components/PersonalInfo/OrganisationSection/OrganisationSection.vue @@ -30,11 +30,6 @@ - - @@ -43,12 +38,10 @@ import { loadState } from '@nextcloud/initial-state' import Organisation from './Organisation' import HeaderBar from '../shared/HeaderBar' -import VisibilityDropdown from '../shared/VisibilityDropdown' -import { ACCOUNT_PROPERTY_ENUM, ACCOUNT_PROPERTY_READABLE_ENUM } from '../../../constants/AccountPropertyConstants' +import { ACCOUNT_PROPERTY_READABLE_ENUM } from '../../../constants/AccountPropertyConstants' const { organisationMap: { primaryOrganisation } } = loadState('settings', 'personalInfoParameters', {}) -const { profileConfig: { organisation: { visibility } } } = loadState('settings', 'profileParameters', {}) export default { name: 'OrganisationSection', @@ -56,15 +49,12 @@ export default { components: { Organisation, HeaderBar, - VisibilityDropdown, }, data() { return { accountProperty: ACCOUNT_PROPERTY_READABLE_ENUM.ORGANISATION, - accountPropertyId: ACCOUNT_PROPERTY_ENUM.ORGANISATION, primaryOrganisation, - visibility, } }, } diff --git a/apps/settings/src/components/PersonalInfo/ProfileVisibilitySection/ProfileVisibilitySection.vue b/apps/settings/src/components/PersonalInfo/ProfileVisibilitySection/ProfileVisibilitySection.vue index c27bef347c62d..e6f6677c1b054 100644 --- a/apps/settings/src/components/PersonalInfo/ProfileVisibilitySection/ProfileVisibilitySection.vue +++ b/apps/settings/src/components/PersonalInfo/ProfileVisibilitySection/ProfileVisibilitySection.vue @@ -25,14 +25,17 @@ - - - {{ t('settings', 'The more restrictive setting of either visibility or scope is respected on your Profile — For example, when visibility is set to "Show to everyone" and scope is set to "Private", "Private" will be respected') }} + + {{ t('settings', 'The more restrictive setting of either visibility or scope is respected on your Profile. For example, if visibility is set to "Show to everyone" and scope is set to "Private", "Private" is respected.') }} + + +
+ +
@@ -42,7 +45,7 @@ import { subscribe, unsubscribe } from '@nextcloud/event-bus' import HeaderBar from '../shared/HeaderBar' import VisibilityDropdown from '../shared/VisibilityDropdown' -import { ACCOUNT_PROPERTY_ENUM, PROFILE_READABLE_ENUM } from '../../../constants/AccountPropertyConstants' +import { PROFILE_READABLE_ENUM } from '../../../constants/AccountPropertyConstants' const { profileConfig } = loadState('settings', 'profileParameters', {}) const { profileEnabled } = loadState('settings', 'personalInfoParameters', false) @@ -60,9 +63,8 @@ export default { heading: PROFILE_READABLE_ENUM.PROFILE_VISIBILITY, profileEnabled, visibilityArray: Object.entries(profileConfig) - // Filter for profile parameters registered by apps in this section as visibility controls for the rest (account properties) are handled in their respective property sections - .filter(([paramId, { displayId, visibility }]) => !Object.values(ACCOUNT_PROPERTY_ENUM).includes(paramId)) - .map(([paramId, { displayId, visibility }]) => ({ id: paramId, displayId, visibility })), + .map(([paramId, { appId, displayId, visibility }]) => ({ id: paramId, appId, displayId, visibility })) + .sort((a, b) => a.appId === b.appId ? a.displayId.localeCompare(b.displayId) : (a.appId !== 'core' ? -1 : 1)), } }, @@ -91,10 +93,11 @@ export default { diff --git a/apps/settings/src/constants/AccountPropertyConstants.js b/apps/settings/src/constants/AccountPropertyConstants.js index 6e39718f1c2d4..ea8aa76703dad 100644 --- a/apps/settings/src/constants/AccountPropertyConstants.js +++ b/apps/settings/src/constants/AccountPropertyConstants.js @@ -63,7 +63,7 @@ export const ACCOUNT_PROPERTY_READABLE_ENUM = Object.freeze({ /** Enum of profile specific sections to human readable names */ export const PROFILE_READABLE_ENUM = Object.freeze({ - PROFILE_VISIBILITY: t('settings', 'Profile Visibility'), + PROFILE_VISIBILITY: t('settings', 'Profile visibility'), }) /** Enum of readable account properties to account property keys used by the server */ diff --git a/apps/settings/src/main-personal-info.js b/apps/settings/src/main-personal-info.js index 95169aee7e6ab..f496c43cb25ee 100644 --- a/apps/settings/src/main-personal-info.js +++ b/apps/settings/src/main-personal-info.js @@ -22,7 +22,6 @@ import Vue from 'vue' import { getRequestToken } from '@nextcloud/auth' -import { loadState } from '@nextcloud/initial-state' import { translate as t } from '@nextcloud/l10n' import '@nextcloud/dialogs/styles/toast.scss' @@ -37,7 +36,6 @@ import RoleSection from './components/PersonalInfo/RoleSection/RoleSection' import HeadlineSection from './components/PersonalInfo/HeadlineSection/HeadlineSection' import BiographySection from './components/PersonalInfo/BiographySection/BiographySection' import ProfileVisibilitySection from './components/PersonalInfo/ProfileVisibilitySection/ProfileVisibilitySection' -import VisibilityDropdown from './components/PersonalInfo/shared/VisibilityDropdown' __webpack_nonce__ = btoa(getRequestToken()) @@ -59,7 +57,6 @@ const RoleView = Vue.extend(RoleSection) const HeadlineView = Vue.extend(HeadlineSection) const BiographyView = Vue.extend(BiographySection) const ProfileVisibilityView = Vue.extend(ProfileVisibilitySection) -const VisibilityDropdownView = Vue.extend(VisibilityDropdown) new DisplayNameView().$mount('#vue-displayname-section') new EmailView().$mount('#vue-email-section') @@ -70,23 +67,3 @@ new RoleView().$mount('#vue-role-section') new HeadlineView().$mount('#vue-headline-section') new BiographyView().$mount('#vue-biography-section') new ProfileVisibilityView().$mount('#vue-profile-visibility-section') - -// Profile visibility dropdowns -const { profileConfig } = loadState('settings', 'profileParameters', {}) -const visibilityDropdownParamIds = [ - 'avatar', - 'phone', - 'address', - 'website', - 'twitter', -] - -for (const paramId of visibilityDropdownParamIds) { - const { displayId } = profileConfig[paramId] - new VisibilityDropdownView({ - propsData: { - paramId, - displayId, - }, - }).$mount(`#vue-profile-visibility-${paramId}`) -} diff --git a/apps/settings/templates/settings/personal/personal.info.php b/apps/settings/templates/settings/personal/personal.info.php index 4cd0e4e34d6a2..bcd8315fc431c 100644 --- a/apps/settings/templates/settings/personal/personal.info.php +++ b/apps/settings/templates/settings/personal/personal.info.php @@ -80,7 +80,6 @@ -
@@ -133,7 +132,6 @@ -
@@ -150,7 +148,6 @@ -
@@ -195,7 +192,6 @@ -
@@ -240,7 +236,6 @@ -
@@ -261,9 +256,6 @@
-
-
-
@@ -310,3 +302,7 @@
+ +
+
+
diff --git a/core/src/views/Profile.vue b/core/src/views/Profile.vue index d16a3661b2261..afb794a08551e 100644 --- a/core/src/views/Profile.vue +++ b/core/src/views/Profile.vue @@ -142,7 +142,7 @@ fill-color="var(--color-text-maxcontrast)" :size="60" />

{{ displayname || userId }} {{ t('core', 'hasn\'t added any info yet') }}

-

{{ t('core', 'The headline and about section will show up here') }}

+

{{ t('core', 'The headline and about sections will show up here') }}