From 407b67989d86344ab0cf296585de127586df7a80 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 26 Oct 2023 10:30:22 -0700 Subject: [PATCH 1/7] enh: Register profile nav entry Signed-off-by: Christopher Ng --- lib/private/NavigationManager.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index d34ba5fed98..30476d26f60 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -219,6 +219,18 @@ class NavigationManager implements INavigationManager { } if ($this->userSession->isLoggedIn()) { + // Profile + $this->add([ + 'type' => 'settings', + 'id' => 'profile', + 'order' => 1, + 'href' => $this->urlGenerator->linkToRoute( + 'core.ProfilePage.index', + ['targetUserId' => $this->userSession->getUser()->getUID()], + ), + 'name' => $l->t('View profile'), + ]); + // Accessibility settings if ($this->appManager->isEnabledForUser('theming', $this->userSession->getUser())) { $this->add([ @@ -230,6 +242,7 @@ class NavigationManager implements INavigationManager { 'icon' => $this->urlGenerator->imagePath('theming', 'accessibility-dark.svg'), ]); } + if ($this->isAdmin()) { // App management $this->add([ From d899e676de6c71396bfb7600e7814356bf26ff98 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 26 Oct 2023 10:30:22 -0700 Subject: [PATCH 2/7] fix: Set profile as active nav entry Signed-off-by: Christopher Ng --- core/Controller/ProfilePageController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/Controller/ProfilePageController.php b/core/Controller/ProfilePageController.php index eacdd14c932..f8d9053edfa 100644 --- a/core/Controller/ProfilePageController.php +++ b/core/Controller/ProfilePageController.php @@ -40,6 +40,7 @@ use OCP\IUserSession; use OCP\Share\IManager as IShareManager; use OCP\UserStatus\IManager as IUserStatusManager; use OCP\EventDispatcher\IEventDispatcher; +use OCP\INavigationManager; #[IgnoreOpenAPI] class ProfilePageController extends Controller { @@ -52,6 +53,7 @@ class ProfilePageController extends Controller { private IUserManager $userManager, private IUserSession $userSession, private IUserStatusManager $userStatusManager, + private INavigationManager $navigationManager, private IEventDispatcher $eventDispatcher, ) { parent::__construct($appName, $request); @@ -104,6 +106,8 @@ class ProfilePageController extends Controller { $this->profileManager->getProfileFields($targetUser, $visitingUser), ); + $this->navigationManager->setActiveEntry('profile'); + $this->eventDispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($targetUserId)); \OCP\Util::addScript('core', 'profile'); From 4c8256c15bd9ffa84e60ad5df68cf1b18f3acac3 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 26 Oct 2023 10:30:22 -0700 Subject: [PATCH 3/7] fix: Remove profile from UserStatus component Signed-off-by: Christopher Ng --- apps/user_status/src/UserStatus.vue | 156 +++++----------------------- 1 file changed, 25 insertions(+), 131 deletions(-) diff --git a/apps/user_status/src/UserStatus.vue b/apps/user_status/src/UserStatus.vue index 36ed0d9790f..77a8b6c3bc9 100644 --- a/apps/user_status/src/UserStatus.vue +++ b/apps/user_status/src/UserStatus.vue @@ -21,28 +21,13 @@
    - + { const statusMap = Object.fromEntries( @@ -95,12 +101,14 @@ export default { components: { NcAvatar, NcHeaderMenu, + ProfileUserMenuEntry, UserMenuEntry, }, data() { return { - settingsNavEntries, + profileEntry, + otherEntries, displayName: getCurrentUser()?.displayName, userId: getCurrentUser()?.uid, isLoadingUserStatus: true, From 439a6fbbdc484c33938559bcce1b5f3f4b188b82 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 26 Oct 2023 10:30:22 -0700 Subject: [PATCH 5/7] fix: Settings nav entries typing Signed-off-by: Christopher Ng --- core/src/views/UserMenu.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/views/UserMenu.vue b/core/src/views/UserMenu.vue index 7c03a11cf3d..0b96ab3cc66 100644 --- a/core/src/views/UserMenu.vue +++ b/core/src/views/UserMenu.vue @@ -80,7 +80,7 @@ import logger from '../logger.js' * @property {string} classes - Classes for custom styling */ -/** @type {SettingNavEntry[]} */ +/** @type {Record} */ const settingsNavEntries = loadState('core', 'settingsNavEntries', []) const { profile: profileEntry, ...otherEntries } = settingsNavEntries From ce5e290d584cf7b9163dfe62fad43572f0f31533 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 26 Oct 2023 10:30:22 -0700 Subject: [PATCH 6/7] fix(tests): Test profile entry Signed-off-by: Christopher Ng --- tests/lib/NavigationManagerTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php index 64ffd64394d..8edf7ecb9cc 100644 --- a/tests/lib/NavigationManagerTest.php +++ b/tests/lib/NavigationManagerTest.php @@ -276,6 +276,17 @@ class NavigationManagerTest extends TestCase { ] ]; $defaults = [ + 'profile' => [ + 'type' => 'settings', + 'id' => 'profile', + 'order' => 1, + 'href' => '/apps/test/', + 'name' => 'View profile', + 'icon' => '', + 'active' => false, + 'classes' => '', + 'unread' => 0, + ], 'accessibility_settings' => [ 'type' => 'settings', 'id' => 'accessibility_settings', @@ -339,6 +350,7 @@ class NavigationManagerTest extends TestCase { return [ 'minimalistic' => [ array_merge( + ['profile' => $defaults['profile']], ['accessibility_settings' => $defaults['accessibility_settings']], ['settings' => $defaults['settings']], ['test' => [ @@ -365,6 +377,7 @@ class NavigationManagerTest extends TestCase { ], 'minimalistic-settings' => [ array_merge( + ['profile' => $defaults['profile']], ['accessibility_settings' => $defaults['accessibility_settings']], ['settings' => $defaults['settings']], ['test' => [ @@ -388,6 +401,7 @@ class NavigationManagerTest extends TestCase { ], 'with-multiple' => [ array_merge( + ['profile' => $defaults['profile']], ['accessibility_settings' => $defaults['accessibility_settings']], ['settings' => $defaults['settings']], ['test' => [ @@ -429,6 +443,7 @@ class NavigationManagerTest extends TestCase { ], 'admin' => [ array_merge( + ['profile' => $defaults['profile']], $adminSettings, $apps, ['test' => [ @@ -456,6 +471,7 @@ class NavigationManagerTest extends TestCase { ], 'no name' => [ array_merge( + ['profile' => $defaults['profile']], $adminSettings, $apps, ['logout' => $defaults['logout']] From fc43c283052878e267f03a39bf923073659c6906 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 26 Oct 2023 10:30:22 -0700 Subject: [PATCH 7/7] chore: compile assets Signed-off-by: Christopher Ng --- dist/core-main.js | 4 ++-- dist/core-main.js.map | 2 +- dist/settings-vue-settings-admin-ai.js | 4 ++-- dist/settings-vue-settings-admin-ai.js.map | 2 +- dist/user_status-menu.js | 4 ++-- dist/user_status-menu.js.map | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dist/core-main.js b/dist/core-main.js index 36b4b5fdffa..f472d3dc66d 100644 --- a/dist/core-main.js +++ b/dist/core-main.js @@ -1,3 +1,3 @@ /*! For license information please see core-main.js.LICENSE.txt */ -!function(){var e,i,o,r={30929:function(e,i,o){"use strict";var r={};o.r(r),o.d(r,{deleteKey:function(){return k},getApps:function(){return C},getKeys:function(){return x},getValue:function(){return y},setValue:function(){return w}});var s={};o.r(s),o.d(s,{formatLinksPlain:function(){return Mn},formatLinksRich:function(){return Tn},plainToRich:function(){return In},richToPlain:function(){return Sn}});var a={};o.r(a),o.d(a,{dismiss:function(){return zn},query:function(){return On}}),o(28594),o(35666);var c=o(69183),u=o(59050),l=o(19755),h=o.n(l),d=o(64024),p=o(25108),A={updatableNotification:null,getDefaultNotificationFunction:null,setDefault:function(t){this.getDefaultNotificationFunction=t},hide:function(t,e){u.default.isFunction(t)&&(e=t,t=void 0),t?(t.each((function(){h()(this)[0].toastify?h()(this)[0].toastify.hideToast():p.error("cannot hide toast because object is not set"),this===this.updatableNotification&&(this.updatableNotification=null)})),e&&e.call(),this.getDefaultNotificationFunction&&this.getDefaultNotificationFunction()):p.error("Missing argument $row in OC.Notification.hide() call, caller needs to be adjusted to only dismiss its own notification")},showHtml:function(t,e){(e=e||{}).isHTML=!0,e.timeout=e.timeout?e.timeout:d.Rl;var n=(0,d.PV)(t,e);return n.toastElement.toastify=n,h()(n.toastElement)},show:function(t,e){(e=e||{}).timeout=e.timeout?e.timeout:d.Rl;var n=(0,d.PV)(function(t){return t.toString().split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""").split("'").join("'")}(t),e);return n.toastElement.toastify=n,h()(n.toastElement)},showUpdate:function(t){return this.updatableNotification&&this.updatableNotification.hideToast(),this.updatableNotification=(0,d.PV)(t,{timeout:d.Rl}),this.updatableNotification.toastElement.toastify=this.updatableNotification,h()(this.updatableNotification.toastElement)},showTemporary:function(t,e){(e=e||{}).timeout=e.timeout||d.TN;var n=(0,d.PV)(t,e);return n.toastElement.toastify=n,h()(n.toastElement)},isHidden:function(){return!h()("#content").find(".toastify").length}},f=u.default.throttle((function(){A.showTemporary(t("core","Connection to server lost"))}),7e3,{trailing:!1}),g=!1,m={enableDynamicSlideToggle:function(){g=!0},showAppSidebar:function(t){(t||h()("#app-sidebar")).removeClass("disappear").show(),h()("#app-content").trigger(new(h().Event)("appresized"))},hideAppSidebar:function(t){(t||h()("#app-sidebar")).hide().addClass("disappear"),h()("#app-content").trigger(new(h().Event)("appresized"))}},v=o(79753);function b(t,e,n){"post"!==t&&"delete"!==t||!It.PasswordConfirmation.requiresPasswordConfirmation()?(n=n||{},h().ajax({type:t.toUpperCase(),url:(0,v.generateOcsUrl)("apps/provisioning_api/api/v1/config/apps")+e,data:n.data||{},success:n.success,error:n.error})):It.PasswordConfirmation.requirePasswordConfirmation(_.bind(b,this,t,e,n))}function C(t){b("get","",t)}function x(t,e){b("get","/"+t,e)}function y(t,e,n,i){(i=i||{}).data={defaultValue:n},b("get","/"+t+"/"+e,i)}function w(t,e,n,i){(i=i||{}).data={value:n},b("post","/"+t+"/"+e,i)}function k(t,e,n){b("delete","/"+t+"/"+e,n)}var B=window.oc_appconfig||{},E={getValue:function(t,e,n,i){y(t,e,n,{success:i})},setValue:function(t,e,n){w(t,e,n)},getApps:function(t){C({success:t})},getKeys:function(t,e){x(t,{success:e})},deleteKey:function(t,e){k(t,e)}},D=void 0!==window._oc_appswebroots&&window._oc_appswebroots,I=o(72316),S=o.n(I),T=o(76591),M=o(25108),P={create:"POST",update:"PROPPATCH",patch:"PROPPATCH",delete:"DELETE",read:"PROPFIND"};function O(t,e){if(u.default.isArray(t))return u.default.map(t,(function(t){return O(t,e)}));var n={href:t.href};return u.default.each(t.propStat,(function(t){if("HTTP/1.1 200 OK"===t.status)for(var i in t.properties){var o=i;i in e&&(o=e[i]),n[o]=t.properties[i]}})),n.id||(n.id=z(n.href)),n}function z(t){var e=t.indexOf("?");e>0&&(t=t.substr(0,e));var n,i=t.split("/");do{n=i[i.length-1],i.pop()}while(!n&&i.length>0);return n}function R(t){return t>=200&&t<=299}function N(t,e,n,i){return t.propPatch(e.url,function(t,e){var n,i={};for(n in t){var o=e[n],r=t[n];o||(M.warn('No matching DAV property for property "'+n),o=n),(u.default.isBoolean(r)||u.default.isNumber(r))&&(r=""+r),i[o]=r}return i}(n.changed,e.davProperties),i).then((function(t){R(t.status)?u.default.isFunction(e.success)&&e.success(n.toJSON()):u.default.isFunction(e.error)&&e.error(t)}))}var H=S().noConflict();Object.assign(H,{davCall:function(t,e){var n=new T.dav.Client({baseUrl:t.url,xmlNamespaces:u.default.extend({"DAV:":"d","http://owncloud.org/ns":"oc"},t.xmlNamespaces||{})});n.resolveUrl=function(){return t.url};var i=u.default.extend({"X-Requested-With":"XMLHttpRequest",requesttoken:OC.requestToken},t.headers);return"PROPFIND"===t.type?function(t,e,n,i){return t.propFind(e.url,u.default.values(e.davProperties)||[],e.depth,i).then((function(t){if(R(t.status)){if(u.default.isFunction(e.success)){var n=u.default.invert(e.davProperties),i=O(t.body,n);e.depth>0&&i.shift(),e.success(i)}}else u.default.isFunction(e.error)&&e.error(t)}))}(n,t,0,i):"PROPPATCH"===t.type?N(n,t,e,i):"MKCOL"===t.type?function(t,e,n,i){return t.request(e.type,e.url,i,null).then((function(o){R(o.status)?N(t,e,n,i):u.default.isFunction(e.error)&&e.error(o)}))}(n,t,e,i):function(t,e,n,i){return i["Content-Type"]="application/json",t.request(e.type,e.url,i,e.data).then((function(t){if(R(t.status)){if(u.default.isFunction(e.success)){if("PUT"===e.type||"POST"===e.type||"MKCOL"===e.type){var i=t.body||n.toJSON(),o=t.xhr.getResponseHeader("Content-Location");return"POST"===e.type&&o&&(i.id=z(o)),void e.success(i)}if(207===t.status){var r=u.default.invert(e.davProperties);e.success(O(t.body,r))}else e.success(t.body)}}else u.default.isFunction(e.error)&&e.error(t)}))}(n,t,e,i)},davSync:function(t){return function(e,n,i){var o={type:P[e]||e},r=n instanceof t.Collection;if("update"===e&&(n.hasInnerCollection?o.type="MKCOL":(n.usePUT||n.collection&&n.collection.usePUT)&&(o.type="PUT")),i.url||(o.url=u.default.result(n,"url")||function(){throw new Error('A "url" property or function must be specified')}()),null!=i.data||!n||"create"!==e&&"update"!==e&&"patch"!==e||(o.data=JSON.stringify(i.attrs||n.toJSON(i))),"PROPFIND"!==o.type&&(o.processData=!1),"PROPFIND"===o.type||"PROPPATCH"===o.type){var s=n.davProperties;!s&&n.model&&(s=n.model.prototype.davProperties),s&&(u.default.isFunction(s)?o.davProperties=s.call(n):o.davProperties=s),o.davProperties=u.default.extend(o.davProperties||{},i.davProperties),u.default.isUndefined(i.depth)&&(i.depth=r?1:0)}var a=i.error;i.error=function(t,e,n){i.textStatus=e,i.errorThrown=n,a&&a.call(i.context,t,e,n)};var c=i.xhr=t.davCall(u.default.extend(o,i),n);return n.trigger("request",n,c,i),c}}(H)});var j=H,L=o(65358),U=window._oc_config||{},F=document.getElementsByTagName("head")[0].getAttribute("data-user"),W=document.getElementsByTagName("head")[0].getAttribute("data-user-displayname"),Y=void 0!==F&&F,Q=o(96384),q=o(59546),G=o(62520);function X(t){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},X(t)}var V={YES_NO_BUTTONS:70,OK_BUTTONS:71,FILEPICKER_TYPE_CHOOSE:1,FILEPICKER_TYPE_MOVE:2,FILEPICKER_TYPE_COPY:3,FILEPICKER_TYPE_COPY_MOVE:4,FILEPICKER_TYPE_CUSTOM:5,dialogsCounter:0,alert:function(t,e,n,i){this.message(t,e,"alert",V.OK_BUTTON,n,i)},info:function(t,e,n,i){this.message(t,e,"info",V.OK_BUTTON,n,i)},confirm:function(t,e,n,i){return this.message(t,e,"notice",V.YES_NO_BUTTONS,n,i)},confirmDestructive:function(t,e,n,i,o){return this.message(t,e,"none",n,i,void 0===o||o)},confirmHtml:function(t,e,n,i){return this.message(t,e,"notice",V.YES_NO_BUTTONS,n,i,!0)},prompt:function(e,n,i,o,r,s){return h().when(this._getMessageTemplate()).then((function(a){var c="oc-dialog-"+V.dialogsCounter+"-content",l="#"+c,d=a.octemplate({dialog_name:c,title:n,message:e,type:"notice"}),p=h()("");p.attr("type",s?"password":"text").attr("id",c+"-input").attr("placeholder",r);var A=h()("