diff --git a/moodle.config.json b/moodle.config.json index 8c8a4ed568c..7943fc831c3 100644 --- a/moodle.config.json +++ b/moodle.config.json @@ -136,5 +136,12 @@ } }, "clearIABSessionWhenAutoLogin": "android", - "collapsibleItemsExpanded": false + "collapsibleItemsExpanded": false, + "overrideMainMenuButtons": [ + { + "handler": "CoreSearch", + "icon": "fas-book", + "priority": 2000 + } + ] } diff --git a/src/addons/badges/constants.ts b/src/addons/badges/constants.ts new file mode 100644 index 00000000000..f744a571757 --- /dev/null +++ b/src/addons/badges/constants.ts @@ -0,0 +1,20 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { CORE_USER_FEATURE_PREFIX } from '@features/user/constants'; + +export const ADDONS_BADGES_COMPONENT_NAME = 'AddonBadges'; + +export const ADDONS_BADGES_USER_MENU_FEATURE_NAME = `${CORE_USER_FEATURE_PREFIX}${ADDONS_BADGES_COMPONENT_NAME}`; +export const ADDONS_BADGES_ACCOUNT_FEATURE_NAME = `${ADDONS_BADGES_USER_MENU_FEATURE_NAME}:account`; diff --git a/src/addons/badges/services/handlers/mybadges-link.ts b/src/addons/badges/services/handlers/mybadges-link.ts index d6e49a90eef..ff7e145a496 100644 --- a/src/addons/badges/services/handlers/mybadges-link.ts +++ b/src/addons/badges/services/handlers/mybadges-link.ts @@ -18,6 +18,7 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; import { AddonBadges } from '../badges'; +import { ADDONS_BADGES_USER_MENU_FEATURE_NAME } from '@addons/badges/constants'; /** * Handler to treat links to user badges page. @@ -26,7 +27,7 @@ import { AddonBadges } from '../badges'; export class AddonBadgesMyBadgesLinkHandlerService extends CoreContentLinksHandlerBase { name = 'AddonBadgesMyBadgesLinkHandler'; - featureName = 'CoreUserDelegate_AddonBadges'; + featureName = ADDONS_BADGES_USER_MENU_FEATURE_NAME; pattern = /\/badges\/mybadges\.php/; /** diff --git a/src/addons/badges/services/handlers/push-click.ts b/src/addons/badges/services/handlers/push-click.ts index e0620087f88..2978299b57b 100644 --- a/src/addons/badges/services/handlers/push-click.ts +++ b/src/addons/badges/services/handlers/push-click.ts @@ -22,6 +22,7 @@ import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifi import { CoreNavigator } from '@services/navigator'; import { AddonBadgesHelper } from '../badges-helper'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { ADDONS_BADGES_USER_MENU_FEATURE_NAME } from '@addons/badges/constants'; /** * Handler for badges push notifications clicks. @@ -31,7 +32,7 @@ export class AddonBadgesPushClickHandlerService implements CorePushNotifications name = 'AddonBadgesPushClickHandler'; priority = 200; - featureName = 'CoreUserDelegate_AddonBadges'; + featureName = ADDONS_BADGES_USER_MENU_FEATURE_NAME; /** * @inheritdoc diff --git a/src/addons/badges/services/handlers/user.ts b/src/addons/badges/services/handlers/user.ts index 1f8201bdf81..4cfdaac84c0 100644 --- a/src/addons/badges/services/handlers/user.ts +++ b/src/addons/badges/services/handlers/user.ts @@ -24,6 +24,11 @@ import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { makeSingleton } from '@singletons'; import { AddonBadges } from '../badges'; +import { + ADDONS_BADGES_ACCOUNT_FEATURE_NAME, + ADDONS_BADGES_COMPONENT_NAME, + ADDONS_BADGES_USER_MENU_FEATURE_NAME, +} from '@addons/badges/constants'; /** * Profile badges handler. @@ -31,7 +36,8 @@ import { AddonBadges } from '../badges'; @Injectable({ providedIn: 'root' }) export class AddonBadgesUserHandlerService implements CoreUserProfileHandler { - name = 'AddonBadges:fakename'; // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext. + // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext. + name = `${ADDONS_BADGES_COMPONENT_NAME}:fakename`; priority = 300; type = CoreUserProfileHandlerType.LIST_ITEM; @@ -57,10 +63,10 @@ export class AddonBadgesUserHandlerService implements CoreUserProfileHandler { } if (context === CoreUserDelegateContext.USER_MENU) { - if (currentSite.isFeatureDisabled('CoreUserDelegate_AddonBadges:account')) { + if (currentSite.isFeatureDisabled(ADDONS_BADGES_ACCOUNT_FEATURE_NAME)) { return false; } - } else if (currentSite.isFeatureDisabled('CoreUserDelegate_AddonBadges')) { + } else if (currentSite.isFeatureDisabled(ADDONS_BADGES_USER_MENU_FEATURE_NAME)) { return false; } diff --git a/src/addons/block/globalsearch/services/block-handler.ts b/src/addons/block/globalsearch/services/block-handler.ts index c52944926a4..76fcc80b3da 100644 --- a/src/addons/block/globalsearch/services/block-handler.ts +++ b/src/addons/block/globalsearch/services/block-handler.ts @@ -17,7 +17,7 @@ import { CoreBlockHandlerData } from '@features/block/services/block-delegate'; import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler'; import { makeSingleton } from '@singletons'; import { CoreCourseBlock } from '@features/course/services/course'; -import { CORE_SEARCH_PAGE_NAME } from '@features/search/services/handlers/mainmenu'; +import { CORE_SEARCH_PAGE_NAME } from '@features/search/constants'; import { CoreSearchGlobalSearch } from '@features/search/services/global-search'; import { ContextLevel } from '@/core/constants'; diff --git a/src/addons/blog/constants.ts b/src/addons/blog/constants.ts index 207f56235f9..b9ba785d761 100644 --- a/src/addons/blog/constants.ts +++ b/src/addons/blog/constants.ts @@ -12,12 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { CORE_USER_FEATURE_PREFIX } from '@features/user/constants'; + export const ADDON_BLOG_MAINMENU_PAGE_NAME = 'blog'; export const ADDON_BLOG_ENTRY_UPDATED = 'blog_entry_updated'; export const ADDON_BLOG_AUTO_SYNCED = 'addon_blog_autom_synced'; export const ADDON_BLOG_MANUAL_SYNCED = 'addon_blog_manual_synced'; export const ADDON_BLOG_SYNC_ID = 'blog'; +export const ADDONS_BLOG_COMPONENT_NAME = 'AddonBlog'; + +const ADDONS_BLOG_GLOBAL_FEATURE_NAME = `${CORE_USER_FEATURE_PREFIX}${ADDONS_BLOG_COMPONENT_NAME}`; +export const ADDONS_BLOG_ACCOUNT_FEATURE_NAME = `${ADDONS_BLOG_GLOBAL_FEATURE_NAME}:account`; +export const ADDONS_BLOG_USER_MENU_FEATURE_NAME = `${ADDONS_BLOG_GLOBAL_FEATURE_NAME}:blogs`; + /** * Restriction level of user blog visualization. */ diff --git a/src/addons/blog/services/handlers/course-option.ts b/src/addons/blog/services/handlers/course-option.ts index 7ff4decfccd..1f1d8f6cc19 100644 --- a/src/addons/blog/services/handlers/course-option.ts +++ b/src/addons/blog/services/handlers/course-option.ts @@ -26,7 +26,7 @@ import { CoreSites } from '@services/sites'; import { CoreWSFile } from '@services/ws'; import { makeSingleton } from '@singletons'; import { AddonBlog } from '../blog'; -import { ADDON_BLOG_MAINMENU_PAGE_NAME } from '@addons/blog/constants'; +import { ADDON_BLOG_MAINMENU_PAGE_NAME, ADDONS_BLOG_COMPONENT_NAME } from '@addons/blog/constants'; /** * Course nav handler. @@ -34,7 +34,7 @@ import { ADDON_BLOG_MAINMENU_PAGE_NAME } from '@addons/blog/constants'; @Injectable({ providedIn: 'root' }) export class AddonBlogCourseOptionHandlerService implements CoreCourseOptionsHandler { - name = 'AddonBlog'; + name = ADDONS_BLOG_COMPONENT_NAME; priority = 100; /** diff --git a/src/addons/blog/services/handlers/edit-entry-link.ts b/src/addons/blog/services/handlers/edit-entry-link.ts index fa8d0b6eaed..aba55e5b1cd 100644 --- a/src/addons/blog/services/handlers/edit-entry-link.ts +++ b/src/addons/blog/services/handlers/edit-entry-link.ts @@ -19,6 +19,7 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; import { AddonBlog } from '../blog'; +import { ADDONS_BLOG_USER_MENU_FEATURE_NAME } from '@addons/blog/constants'; /** * Handler to treat links to edit blog entry page. @@ -27,7 +28,7 @@ import { AddonBlog } from '../blog'; export class AddonBlogEditEntryLinkHandlerService extends CoreContentLinksHandlerBase { name = 'AddonBlogEditEntryLinkHandler'; - featureName = 'CoreUserDelegate_AddonBlog:blogs'; + featureName = ADDONS_BLOG_USER_MENU_FEATURE_NAME; pattern = /\/blog\/(add|edit)\.php/; /** diff --git a/src/addons/blog/services/handlers/index-link.ts b/src/addons/blog/services/handlers/index-link.ts index af292cdc496..50c48ef5a31 100644 --- a/src/addons/blog/services/handlers/index-link.ts +++ b/src/addons/blog/services/handlers/index-link.ts @@ -19,6 +19,7 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; import { AddonBlog } from '../blog'; +import { ADDONS_BLOG_USER_MENU_FEATURE_NAME } from '@addons/blog/constants'; /** * Handler to treat links to blog page. @@ -27,7 +28,7 @@ import { AddonBlog } from '../blog'; export class AddonBlogIndexLinkHandlerService extends CoreContentLinksHandlerBase { name = 'AddonBlogIndexLinkHandler'; - featureName = 'CoreUserDelegate_AddonBlog:blogs'; + featureName = ADDONS_BLOG_USER_MENU_FEATURE_NAME; pattern = /\/blog\/index\.php/; /** diff --git a/src/addons/blog/services/handlers/mainmenu.ts b/src/addons/blog/services/handlers/mainmenu.ts index eb99ca3464a..be9a4ea0794 100644 --- a/src/addons/blog/services/handlers/mainmenu.ts +++ b/src/addons/blog/services/handlers/mainmenu.ts @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@features/mainmenu/services/mainmenu-delegate'; import { makeSingleton } from '@singletons'; import { AddonBlog } from '../blog'; -import { ADDON_BLOG_MAINMENU_PAGE_NAME } from '@addons/blog/constants'; +import { ADDON_BLOG_MAINMENU_PAGE_NAME, ADDONS_BLOG_COMPONENT_NAME } from '@addons/blog/constants'; /** * Handler to inject an option into main menu. @@ -24,7 +24,7 @@ import { ADDON_BLOG_MAINMENU_PAGE_NAME } from '@addons/blog/constants'; @Injectable({ providedIn: 'root' }) export class AddonBlogMainMenuHandlerService implements CoreMainMenuHandler { - name = 'AddonBlog'; + name = ADDONS_BLOG_COMPONENT_NAME; priority = 500; /** diff --git a/src/addons/blog/services/handlers/user.ts b/src/addons/blog/services/handlers/user.ts index bd172554a78..9de3dc5e5ec 100644 --- a/src/addons/blog/services/handlers/user.ts +++ b/src/addons/blog/services/handlers/user.ts @@ -23,6 +23,11 @@ import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { makeSingleton } from '@singletons'; import { AddonBlog } from '../blog'; +import { + ADDONS_BLOG_ACCOUNT_FEATURE_NAME, + ADDONS_BLOG_USER_MENU_FEATURE_NAME, + ADDONS_BLOG_COMPONENT_NAME, +} from '@addons/blog/constants'; /** * Profile item handler. @@ -30,7 +35,7 @@ import { AddonBlog } from '../blog'; @Injectable({ providedIn: 'root' }) export class AddonBlogUserHandlerService implements CoreUserProfileHandler { - name = 'AddonBlog'; // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext. + name = ADDONS_BLOG_COMPONENT_NAME; // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext. priority = 200; type = CoreUserProfileHandlerType.LIST_ITEM; @@ -52,10 +57,10 @@ export class AddonBlogUserHandlerService implements CoreUserProfileHandler { } if (context === CoreUserDelegateContext.USER_MENU) { - if (currentSite.isFeatureDisabled('CoreUserDelegate_AddonBlog:account')) { + if (currentSite.isFeatureDisabled(ADDONS_BLOG_ACCOUNT_FEATURE_NAME)) { return false; } - } else if (currentSite.isFeatureDisabled('CoreUserDelegate_AddonBlog:blogs')) { + } else if (currentSite.isFeatureDisabled(ADDONS_BLOG_USER_MENU_FEATURE_NAME)) { return false; } diff --git a/src/addons/calendar/constants.ts b/src/addons/calendar/constants.ts index 0ae5daca278..d0912fbdc29 100644 --- a/src/addons/calendar/constants.ts +++ b/src/addons/calendar/constants.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { MAIN_MENU_FEATURE_PREFIX } from '@features/mainmenu/constants'; import { CORE_USER_TF_12, CORE_USER_TF_24 } from '@features/user/constants'; export const ADDON_CALENDAR_COMPONENT = 'AddonCalendarEvents'; @@ -45,6 +46,9 @@ export const ADDON_CALENDAR_DELETED_EVENT_EVENT = 'addon_calendar_deleted_event' export const ADDON_CALENDAR_UNDELETED_EVENT_EVENT = 'addon_calendar_undeleted_event'; export const ADDON_CALENDAR_FILTER_CHANGED_EVENT = 'addon_calendar_filter_changed_event'; +export const ADDONS_CALENDAR_COMPONENT_NAME = 'AddonCalendar'; +export const ADDONS_CALENDAR_MENU_FEATURE_NAME = `${MAIN_MENU_FEATURE_PREFIX}${ADDONS_CALENDAR_COMPONENT_NAME}`; + /** * Context levels enumeration. */ diff --git a/src/addons/calendar/services/calendar.ts b/src/addons/calendar/services/calendar.ts index c1ebdf93a96..29e176c780d 100644 --- a/src/addons/calendar/services/calendar.ts +++ b/src/addons/calendar/services/calendar.ts @@ -55,6 +55,7 @@ import { ADDON_CALENDAR_STARTING_WEEK_DAY, ADDON_CALENDAR_UNDELETED_EVENT_EVENT, AddonCalendarEventType, + ADDONS_CALENDAR_MENU_FEATURE_NAME, } from '../constants'; import { REMINDERS_DEFAULT_REMINDER_TIMEBEFORE } from '@features/reminders/constants'; import { AddonCalendarFilter } from './calendar-helper'; @@ -1252,7 +1253,7 @@ export class AddonCalendarProvider { isCalendarDisabledInSite(site?: CoreSite): boolean { site = site || CoreSites.getCurrentSite(); - return !!site?.isFeatureDisabled('CoreMainMenuDelegate_AddonCalendar'); + return !!site?.isFeatureDisabled(ADDONS_CALENDAR_MENU_FEATURE_NAME); } /** diff --git a/src/addons/calendar/services/handlers/mainmenu.ts b/src/addons/calendar/services/handlers/mainmenu.ts index 1b9269f13d1..81d925617d7 100644 --- a/src/addons/calendar/services/handlers/mainmenu.ts +++ b/src/addons/calendar/services/handlers/mainmenu.ts @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; import { AddonCalendar } from '../calendar'; import { makeSingleton } from '@singletons'; import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@features/mainmenu/services/mainmenu-delegate'; -import { ADDON_CALENDAR_PAGE_NAME } from '@addons/calendar/constants'; +import { ADDON_CALENDAR_PAGE_NAME, ADDONS_CALENDAR_COMPONENT_NAME } from '@addons/calendar/constants'; /** * Handler to inject an option into main menu. @@ -24,7 +24,7 @@ import { ADDON_CALENDAR_PAGE_NAME } from '@addons/calendar/constants'; @Injectable({ providedIn: 'root' }) export class AddonCalendarMainMenuHandlerService implements CoreMainMenuHandler { - name = 'AddonCalendar'; + name = ADDONS_CALENDAR_COMPONENT_NAME; priority = 550; /** diff --git a/src/addons/competency/constants.ts b/src/addons/competency/constants.ts index 79e27e47b60..6461594e35c 100644 --- a/src/addons/competency/constants.ts +++ b/src/addons/competency/constants.ts @@ -12,10 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { CORE_USER_FEATURE_PREFIX } from '@features/user/constants'; + export const ADDON_COMPETENCY_LEARNING_PLANS_PAGE = 'learning-plans'; export const ADDON_COMPETENCY_COMPETENCIES_PAGE = 'competencies'; export const ADDON_COMPETENCY_SUMMARY_PAGE = 'summary'; +export const ADDONS_COMPETENCY_COMPONENT_NAME = 'AddonCompetency'; +export const ADDONS_COMPETENCY_ACCOUNT_FEATURE_NAME = `${CORE_USER_FEATURE_PREFIX}${ADDONS_COMPETENCY_COMPONENT_NAME}`; +export const ADDONS_COMPETENCY_USER_MENU_FEATURE_NAME = `${ADDONS_COMPETENCY_ACCOUNT_FEATURE_NAME}:learningPlan`; + /** * Learning plan status. */ diff --git a/src/addons/competency/services/competency.ts b/src/addons/competency/services/competency.ts index 4d2f6de5470..10a19efe516 100644 --- a/src/addons/competency/services/competency.ts +++ b/src/addons/competency/services/competency.ts @@ -22,7 +22,11 @@ import { CoreSites } from '@services/sites'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { makeSingleton } from '@singletons'; import { CoreTextFormat } from '@singletons/text'; -import { AddonCompetencyLearningPlanStatus, AddonCompetencyReviewStatus } from '../constants'; +import { + AddonCompetencyLearningPlanStatus, + AddonCompetencyReviewStatus, + ADDONS_COMPETENCY_ACCOUNT_FEATURE_NAME, +} from '../constants'; import { CoreCourseSummaryExporterData } from '@features/courses/services/courses'; /** @@ -47,7 +51,7 @@ export class AddonCompetencyProvider { } return site.canUseAdvancedFeature('enablecompetencies') && - !(site.isFeatureDisabled('CoreUserDelegate_AddonCompetency') && + !(site.isFeatureDisabled(ADDONS_COMPETENCY_ACCOUNT_FEATURE_NAME) && site.isFeatureDisabled('CoreCourseOptionsDelegate_AddonCompetency')); } diff --git a/src/addons/competency/services/handlers/course-option.ts b/src/addons/competency/services/handlers/course-option.ts index 62a400083e6..eeaf4def418 100644 --- a/src/addons/competency/services/handlers/course-option.ts +++ b/src/addons/competency/services/handlers/course-option.ts @@ -24,7 +24,7 @@ import { AddonCompetency } from '../competency'; import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { CoreFilterHelper } from '@features/filter/services/filter-helper'; import { ContextLevel } from '@/core/constants'; -import { ADDON_COMPETENCY_COMPETENCIES_PAGE } from '@addons/competency/constants'; +import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDONS_COMPETENCY_COMPONENT_NAME } from '@addons/competency/constants'; /** * Course nav handler. @@ -32,7 +32,7 @@ import { ADDON_COMPETENCY_COMPETENCIES_PAGE } from '@addons/competency/constants @Injectable( { providedIn: 'root' }) export class AddonCompetencyCourseOptionHandlerService implements CoreCourseOptionsHandler { - name = 'AddonCompetency'; + name = ADDONS_COMPETENCY_COMPONENT_NAME; priority = 300; /** diff --git a/src/addons/competency/services/handlers/user.ts b/src/addons/competency/services/handlers/user.ts index 15c853ee393..38e99786512 100644 --- a/src/addons/competency/services/handlers/user.ts +++ b/src/addons/competency/services/handlers/user.ts @@ -12,7 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/constants'; +import { + ADDON_COMPETENCY_COMPETENCIES_PAGE, + ADDON_COMPETENCY_LEARNING_PLANS_PAGE, + ADDONS_COMPETENCY_COMPONENT_NAME, + ADDONS_COMPETENCY_USER_MENU_FEATURE_NAME, + ADDONS_COMPETENCY_ACCOUNT_FEATURE_NAME, +} from '@addons/competency/constants'; import { Injectable } from '@angular/core'; import { CORE_COURSE_PAGE_NAME } from '@features/course/constants'; import { CoreUserProfile } from '@features/user/services/user'; @@ -35,7 +41,7 @@ import { AddonCompetency } from '../competency'; export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler { // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext. - name = 'AddonCompetency:fakename'; + name = `${ADDONS_COMPETENCY_COMPONENT_NAME}:fakename`; priority = 100; type = CoreUserProfileHandlerType.LIST_ITEM; cacheEnabled = true; @@ -58,10 +64,10 @@ export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler } if (context === CoreUserDelegateContext.USER_MENU) { - if (currentSite.isFeatureDisabled('CoreUserDelegate_AddonCompetency')) { + if (currentSite.isFeatureDisabled(ADDONS_COMPETENCY_ACCOUNT_FEATURE_NAME)) { return false; } - } else if (currentSite.isFeatureDisabled('CoreUserDelegate_AddonCompetency:learningPlan')) { + } else if (currentSite.isFeatureDisabled(ADDONS_COMPETENCY_USER_MENU_FEATURE_NAME)) { return false; } diff --git a/src/addons/messages/constants.ts b/src/addons/messages/constants.ts index 5419a6e3710..0a557fea843 100644 --- a/src/addons/messages/constants.ts +++ b/src/addons/messages/constants.ts @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { MAIN_MENU_FEATURE_PREFIX } from '@features/mainmenu/constants'; + export const ADDON_MESSAGES_NEW_MESSAGE_EVENT = 'addon_messages_new_message_event'; export const ADDON_MESSAGES_READ_CHANGED_EVENT = 'addon_messages_read_changed_event'; // Notify a conversation should be opened. @@ -27,6 +29,9 @@ export const ADDON_MESSAGES_PUSH_SIMULATION_COMPONENT = 'AddonMessagesPushSimula export const ADDON_MESSAGES_PAGE_NAME = 'messages'; export const ADDON_MESSAGES_SETTINGS_PAGE_NAME = 'messages'; +export const ADDONS_MESSAGES_COMPONENT_NAME = 'AddonMessages'; +export const ADDONS_MESSAGES_MENU_FEATURE_NAME = `${MAIN_MENU_FEATURE_PREFIX}${ADDONS_MESSAGES_COMPONENT_NAME}`; + export const enum AddonMessagesMessagePrivacy { COURSEMEMBER = 0, // Privacy setting for being messaged by anyone within courses user is member. ONLYCONTACTS = 1, // Privacy setting for being messaged only by contacts. diff --git a/src/addons/messages/services/handlers/mainmenu.ts b/src/addons/messages/services/handlers/mainmenu.ts index 5da9745b89a..ef62c941286 100644 --- a/src/addons/messages/services/handlers/mainmenu.ts +++ b/src/addons/messages/services/handlers/mainmenu.ts @@ -30,6 +30,8 @@ import { ADDON_MESSAGES_UNREAD_CONVERSATION_COUNTS_EVENT, ADDON_MESSAGES_CONTACT_REQUESTS_COUNT_EVENT, ADDON_MESSAGES_PAGE_NAME, + ADDONS_MESSAGES_MENU_FEATURE_NAME, + ADDONS_MESSAGES_COMPONENT_NAME, } from '@addons/messages/constants'; import { MAIN_MENU_HANDLER_BADGE_UPDATED_EVENT } from '@features/mainmenu/constants'; @@ -39,7 +41,7 @@ import { MAIN_MENU_HANDLER_BADGE_UPDATED_EVENT } from '@features/mainmenu/consta @Injectable({ providedIn: 'root' }) export class AddonMessagesMainMenuHandlerService implements CoreMainMenuHandler, CoreCronHandler { - name = 'AddonMessages'; + name = ADDONS_MESSAGES_COMPONENT_NAME; priority = 700; protected handler: CoreMainMenuHandlerToDisplay = { @@ -196,7 +198,7 @@ export class AddonMessagesMainMenuHandlerService implements CoreMainMenuHandler, if ( !CoreSites.isCurrentSite(siteId) || !site || - site.isFeatureDisabled('CoreMainMenuDelegate_AddonMessages') || + site.isFeatureDisabled(ADDONS_MESSAGES_MENU_FEATURE_NAME) || !enabled ) { return; diff --git a/src/addons/messages/services/handlers/push-click.ts b/src/addons/messages/services/handlers/push-click.ts index 8c05dc4c872..0163b34f327 100644 --- a/src/addons/messages/services/handlers/push-click.ts +++ b/src/addons/messages/services/handlers/push-click.ts @@ -19,7 +19,7 @@ import { CoreNavigator } from '@services/navigator'; import { CoreUtils } from '@singletons/utils'; import { makeSingleton } from '@singletons'; import { AddonMessages } from '../messages'; -import { ADDON_MESSAGES_PAGE_NAME } from '@addons/messages/constants'; +import { ADDON_MESSAGES_PAGE_NAME, ADDONS_MESSAGES_MENU_FEATURE_NAME } from '@addons/messages/constants'; /** * Handler for messaging push notifications clicks. @@ -29,7 +29,7 @@ export class AddonMessagesPushClickHandlerService implements CorePushNotificatio name = 'AddonMessagesPushClickHandler'; priority = 200; - featureName = 'CoreMainMenuDelegate_AddonMessages'; + featureName = ADDONS_MESSAGES_MENU_FEATURE_NAME; /** * Check if a notification click is handled by this handler. diff --git a/src/addons/messages/services/handlers/settings.ts b/src/addons/messages/services/handlers/settings.ts index 0d2e76914e3..bb19be4f360 100644 --- a/src/addons/messages/services/handlers/settings.ts +++ b/src/addons/messages/services/handlers/settings.ts @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; import { CoreSettingsHandler, CoreSettingsHandlerData } from '@features/settings/services/settings-delegate'; import { makeSingleton } from '@singletons'; import { AddonMessages } from '../messages'; -import { ADDON_MESSAGES_SETTINGS_PAGE_NAME } from '@addons/messages/constants'; +import { ADDON_MESSAGES_SETTINGS_PAGE_NAME, ADDONS_MESSAGES_COMPONENT_NAME } from '@addons/messages/constants'; /** * Message settings handler. @@ -24,7 +24,7 @@ import { ADDON_MESSAGES_SETTINGS_PAGE_NAME } from '@addons/messages/constants'; @Injectable({ providedIn: 'root' }) export class AddonMessagesSettingsHandlerService implements CoreSettingsHandler { - name = 'AddonMessages'; + name = ADDONS_MESSAGES_COMPONENT_NAME; priority = 600; /** diff --git a/src/addons/notifications/constants.ts b/src/addons/notifications/constants.ts index a02fcfa489f..66fb36e5f20 100644 --- a/src/addons/notifications/constants.ts +++ b/src/addons/notifications/constants.ts @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { MAIN_MENU_FEATURE_PREFIX } from '@features/mainmenu/constants'; + export const ADDONS_NOTIFICATIONS_READ_CHANGED_EVENT = 'addon_notifications_read_changed_event'; export const ADDONS_NOTIFICATIONS_READ_CRON_EVENT = 'addon_notifications_read_cron_event'; @@ -21,3 +23,6 @@ export const ADDONS_NOTIFICATIONS_LIST_LIMIT = 20; export const ADDONS_NOTICATIONS_MAIN_PAGE_NAME = 'notifications'; export const ADDONS_NOTICATIONS_SETTINGS_PAGE_NAME = 'notifications'; + +export const ADDONS_NOTICATIONS_COMPONENT_NAME = 'AddonNotifications'; +export const ADDONS_NOTICATIONS_MENU_FEATURE_NAME = `${MAIN_MENU_FEATURE_PREFIX}${ADDONS_NOTICATIONS_COMPONENT_NAME}`; diff --git a/src/addons/notifications/services/handlers/cron.ts b/src/addons/notifications/services/handlers/cron.ts index 06ff8d29cc1..ac81c192299 100644 --- a/src/addons/notifications/services/handlers/cron.ts +++ b/src/addons/notifications/services/handlers/cron.ts @@ -19,7 +19,7 @@ import { CorePlatform } from '@services/platform'; import { CoreSites } from '@services/sites'; import { makeSingleton } from '@singletons'; import { CoreEvents } from '@singletons/events'; -import { ADDONS_NOTIFICATIONS_READ_CRON_EVENT } from '@addons/notifications/constants'; +import { ADDONS_NOTICATIONS_MENU_FEATURE_NAME, ADDONS_NOTIFICATIONS_READ_CRON_EVENT } from '@addons/notifications/constants'; /** * Notifications cron handler. @@ -59,7 +59,7 @@ export class AddonNotificationsCronHandlerService implements CoreCronHandler { if ( !CoreSites.isCurrentSite(siteId) || !site || - site.isFeatureDisabled('CoreMainMenuDelegate_AddonNotifications') + site.isFeatureDisabled(ADDONS_NOTICATIONS_MENU_FEATURE_NAME) ) { return; } diff --git a/src/addons/notifications/services/handlers/mainmenu.ts b/src/addons/notifications/services/handlers/mainmenu.ts index 0e17c6c760b..8a6c2ac2f32 100644 --- a/src/addons/notifications/services/handlers/mainmenu.ts +++ b/src/addons/notifications/services/handlers/mainmenu.ts @@ -24,6 +24,7 @@ import { CorePushNotificationsDelegate } from '@features/pushnotifications/servi import { AddonNotifications } from '../notifications'; import { MAIN_MENU_HANDLER_BADGE_UPDATED_EVENT } from '@features/mainmenu/constants'; import { + ADDONS_NOTICATIONS_COMPONENT_NAME, ADDONS_NOTICATIONS_MAIN_PAGE_NAME, ADDONS_NOTIFICATIONS_READ_CHANGED_EVENT, ADDONS_NOTIFICATIONS_READ_CRON_EVENT, @@ -35,7 +36,7 @@ import { @Injectable({ providedIn: 'root' }) export class AddonNotificationsMainMenuHandlerService implements CoreMainMenuHandler { - name = 'AddonNotifications'; + name = ADDONS_NOTICATIONS_COMPONENT_NAME; priority = 600; protected handlerData: CoreMainMenuHandlerData = { diff --git a/src/addons/notifications/services/handlers/notifications-link.ts b/src/addons/notifications/services/handlers/notifications-link.ts index 498986846c7..b0dd49b8546 100644 --- a/src/addons/notifications/services/handlers/notifications-link.ts +++ b/src/addons/notifications/services/handlers/notifications-link.ts @@ -18,7 +18,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; -import { ADDONS_NOTICATIONS_MAIN_PAGE_NAME } from '@addons/notifications/constants'; +import { ADDONS_NOTICATIONS_MAIN_PAGE_NAME, ADDONS_NOTICATIONS_MENU_FEATURE_NAME } from '@addons/notifications/constants'; /** * Handler to treat links to notifications. @@ -28,7 +28,7 @@ export class AddonNotificationsLinkHandlerService extends CoreContentLinksHandle name = 'AddonNotificationsLinkHandler'; pattern = /\/message\/output\/popup\/notifications\.php/; - featureName = 'CoreMainMenuDelegate_AddonNotifications'; + featureName =ADDONS_NOTICATIONS_MENU_FEATURE_NAME; /** * @inheritdoc diff --git a/src/addons/notifications/services/handlers/preferences-link.ts b/src/addons/notifications/services/handlers/preferences-link.ts index b914e99c9a9..7ed7f5252db 100644 --- a/src/addons/notifications/services/handlers/preferences-link.ts +++ b/src/addons/notifications/services/handlers/preferences-link.ts @@ -19,7 +19,7 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { makeSingleton } from '@singletons'; -import { ADDONS_NOTICATIONS_SETTINGS_PAGE_NAME } from '@addons/notifications/constants'; +import { ADDONS_NOTICATIONS_MENU_FEATURE_NAME, ADDONS_NOTICATIONS_SETTINGS_PAGE_NAME } from '@addons/notifications/constants'; /** * Handler to treat links to notification preferences. @@ -30,7 +30,7 @@ export class AddonNotificationsPreferencesLinkHandlerService extends CoreContent name = 'AddonNotificationsPreferencesLinkHandler'; pattern = /\/message\/notificationpreferences\.php/; checkAllUsers = true; - featureName = 'CoreMainMenuDelegate_AddonNotifications'; + featureName = ADDONS_NOTICATIONS_MENU_FEATURE_NAME; /** * @inheritdoc diff --git a/src/addons/notifications/services/handlers/push-click.ts b/src/addons/notifications/services/handlers/push-click.ts index 4fa4795095c..0d2fbe167ba 100644 --- a/src/addons/notifications/services/handlers/push-click.ts +++ b/src/addons/notifications/services/handlers/push-click.ts @@ -25,7 +25,7 @@ import { AddonNotificationsHelper } from '../notifications-helper'; import { CoreViewer } from '@features/viewer/services/viewer'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreOpener } from '@singletons/opener'; -import { ADDONS_NOTICATIONS_MAIN_PAGE_NAME } from '@addons/notifications/constants'; +import { ADDONS_NOTICATIONS_MAIN_PAGE_NAME, ADDONS_NOTICATIONS_MENU_FEATURE_NAME } from '@addons/notifications/constants'; /** * Handler for non-messaging push notifications clicks. @@ -35,7 +35,7 @@ export class AddonNotificationsPushClickHandlerService implements CorePushNotifi name = 'AddonNotificationsPushClickHandler'; priority = 0; // Low priority so it's used as a fallback if no other handler treats the notification. - featureName = 'CoreMainMenuDelegate_AddonNotifications'; + featureName = ADDONS_NOTICATIONS_MENU_FEATURE_NAME; /** * Check if a notification click is handled by this handler. diff --git a/src/addons/notifications/services/handlers/settings.ts b/src/addons/notifications/services/handlers/settings.ts index 36b3f15d238..e263b05d749 100644 --- a/src/addons/notifications/services/handlers/settings.ts +++ b/src/addons/notifications/services/handlers/settings.ts @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; import { makeSingleton } from '@singletons'; import { CoreSettingsHandler, CoreSettingsHandlerData } from '@features/settings/services/settings-delegate'; -import { ADDONS_NOTICATIONS_SETTINGS_PAGE_NAME } from '@addons/notifications/constants'; +import { ADDONS_NOTICATIONS_COMPONENT_NAME, ADDONS_NOTICATIONS_SETTINGS_PAGE_NAME } from '@addons/notifications/constants'; /** * Notifications settings handler. @@ -24,7 +24,7 @@ import { ADDONS_NOTICATIONS_SETTINGS_PAGE_NAME } from '@addons/notifications/con @Injectable({ providedIn: 'root' }) export class AddonNotificationsSettingsHandlerService implements CoreSettingsHandler { - name = 'AddonNotifications'; + name = ADDONS_NOTICATIONS_COMPONENT_NAME; priority = 500; /** diff --git a/src/addons/privatefiles/constants.ts b/src/addons/privatefiles/constants.ts index 8007665a571..39797453cc2 100644 --- a/src/addons/privatefiles/constants.ts +++ b/src/addons/privatefiles/constants.ts @@ -13,3 +13,5 @@ // limitations under the License. export const ADDON_PRIVATE_FILES_PAGE_NAME = 'private'; + +export const ADDON_PRIVATE_FILES_COMPONENT_NAME = 'AddonPrivateFiles'; diff --git a/src/addons/privatefiles/services/handlers/user.ts b/src/addons/privatefiles/services/handlers/user.ts index 017d34254bc..014e02cd581 100644 --- a/src/addons/privatefiles/services/handlers/user.ts +++ b/src/addons/privatefiles/services/handlers/user.ts @@ -25,7 +25,7 @@ import { import { CoreUserProfile } from '@features/user/services/user'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { ADDON_PRIVATE_FILES_PAGE_NAME } from '@addons/privatefiles/constants'; +import { ADDON_PRIVATE_FILES_COMPONENT_NAME, ADDON_PRIVATE_FILES_PAGE_NAME } from '@addons/privatefiles/constants'; /** * Handler to inject an option into user menu. @@ -33,7 +33,7 @@ import { ADDON_PRIVATE_FILES_PAGE_NAME } from '@addons/privatefiles/constants'; @Injectable({ providedIn: 'root' }) export class AddonPrivateFilesUserHandlerService implements CoreUserProfileHandler { - name = 'AddonPrivateFiles'; + name = ADDON_PRIVATE_FILES_COMPONENT_NAME; priority = 400; type = CoreUserProfileHandlerType.LIST_ITEM; cacheEnabled = true; diff --git a/src/core/classes/delegate-sorted.ts b/src/core/classes/delegate-sorted.ts index d6e110d5f5a..1d41f2bc1dc 100644 --- a/src/core/classes/delegate-sorted.ts +++ b/src/core/classes/delegate-sorted.ts @@ -106,13 +106,9 @@ export class CoreSortedDelegate< const displayData: DisplayType[] = []; for (const name in this.enabledHandlers) { - const handler = this.enabledHandlers[name]; - const data = handler.getDisplayData(); + const handler = this.getHandlerDisplayData(name); - data.priority = data.priority ?? handler.priority ?? 0; - data.name = handler.name; - - displayData.push(data); + displayData.push(handler); } // Sort them by priority. @@ -123,4 +119,20 @@ export class CoreSortedDelegate< this.sortedHandlers = displayData; } + /** + * Get display data for a handler. + * + * @param name Name of the handler. + * @returns Display data. + */ + protected getHandlerDisplayData(name: string): DisplayType { + const handler = this.enabledHandlers[name]; + const data: DisplayType = handler.getDisplayData(); + + data.priority = data.priority ?? handler.priority ?? 0; + data.name = handler.name; + + return data; + } + } diff --git a/src/core/classes/sites/authenticated-site.ts b/src/core/classes/sites/authenticated-site.ts index 1d5976d8cf4..9a1dfb594a4 100644 --- a/src/core/classes/sites/authenticated-site.ts +++ b/src/core/classes/sites/authenticated-site.ts @@ -1472,8 +1472,8 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite { * - Greater or equal than 3.2.3 but lower than 3.3. * - Greater or equal than 3.0.5 but lower than 3.1. * - * This function only accepts versions from 2.4.0 and above. If any of the versions supplied isn't found, it will assume - * it's the last released major version. + * This function only accepts versions from MINIMUM_MOODLE_VERSION and above. + * If any of the versions supplied isn't found, it will assume it's the last released major version. */ isVersionGreaterEqualThan(versions: string | string[]): boolean { const info = this.getInfo(); diff --git a/src/core/classes/sites/unauthenticated-site.ts b/src/core/classes/sites/unauthenticated-site.ts index 6f8ebb03662..aecd8d31e8c 100644 --- a/src/core/classes/sites/unauthenticated-site.ts +++ b/src/core/classes/sites/unauthenticated-site.ts @@ -32,6 +32,9 @@ export class CoreUnauthenticatedSite { // List of regular expressions to convert the old nomenclature to new nomenclature for disabled features. protected static readonly DISABLED_FEATURES_COMPAT_REGEXPS: { old: RegExp; new: string }[] = [ + // @deprecatedonmoodle 3.7 + { old: /remoteAddOn_/g, new: 'sitePlugin_' }, + // @deprecatedonmoodle 5.2 { old: /\$mmLoginEmailSignup/g, new: 'CoreLoginEmailSignup' }, { old: /\$mmSideMenuDelegate/g, new: 'CoreMainMenuDelegate' }, { old: /\$mmCoursesDelegate/g, new: 'CoreCourseOptionsDelegate' }, @@ -75,7 +78,6 @@ export class CoreUnauthenticatedSite { { old: /_mmaModUrl/g, new: '_AddonModUrl' }, { old: /_mmaModWiki/g, new: '_AddonModWiki' }, { old: /_mmaModWorkshop/g, new: '_AddonModWorkshop' }, - { old: /remoteAddOn_/g, new: 'sitePlugin_' }, { old: /AddonNotes:addNote/g, new: 'AddonNotes:notes' }, { old: /CoreMainMenuDelegate_AddonCompetency/g, new: 'CoreUserDelegate_AddonCompetency' }, { old: /CoreMainMenuDelegate_AddonPrivateFiles/g, new: 'CoreUserDelegate_AddonPrivateFiles' }, diff --git a/src/core/features/courses/constants.ts b/src/core/features/courses/constants.ts index 86dda304abb..31746ae647c 100644 --- a/src/core/features/courses/constants.ts +++ b/src/core/features/courses/constants.ts @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { MAIN_MENU_FEATURE_PREFIX } from '@features/mainmenu/constants'; + export const CORE_COURSES_ENROL_INVALID_KEY = 'CoreCoursesEnrolInvalidKey'; export const CORE_COURSES_MY_COURSES_CHANGED_EVENT = 'courses_my_courses_changed'; // User course list changed while app is running. @@ -28,9 +30,16 @@ export const CORE_COURSES_DASHBOARD_DOWNLOAD_ENABLED_CHANGED_EVENT = 'dashboard_ // Features. export const CORE_COURSE_DOWNLOAD_FEATURE_NAME = 'NoDelegate_CoreCourseDownload'; export const CORE_COURSES_DOWNLOAD_FEATURE_NAME = 'NoDelegate_CoreCoursesDownload'; -export const CORE_COURSES_MYCOURSES_MENU_FEATURE_NAME = 'CoreMainMenuDelegate_CoreCourses'; export const CORE_COURSES_SEARCH_FEATURE_NAME = 'CoreCourseOptionsDelegate_search'; +export const CORE_COURSES_COMPONENT_NAME = 'CoreCourses'; +export const CORE_COURSES_MENU_FEATURE_NAME = `${MAIN_MENU_FEATURE_PREFIX}${CORE_COURSES_COMPONENT_NAME}`; + +export const CORE_COURSES_MY_COURSES_COMPONENT_NAME = 'CoreCoursesMyCourses'; + +export const CORE_COURSES_DASHBOARD_COMPONENT_NAME = 'CoreCoursesDashboard'; +export const CORE_COURSES_DASHBOARD_MENU_FEATURE_NAME = `${MAIN_MENU_FEATURE_PREFIX}${CORE_COURSES_DASHBOARD_COMPONENT_NAME}`; + // Actions for event CORE_COURSES_MY_COURSES_UPDATED_EVENT. export const CoreCoursesMyCoursesUpdatedEventAction = { /* eslint-disable @typescript-eslint/naming-convention */ diff --git a/src/core/features/courses/services/courses.ts b/src/core/features/courses/services/courses.ts index 0764082e130..d493231a65f 100644 --- a/src/core/features/courses/services/courses.ts +++ b/src/core/features/courses/services/courses.ts @@ -35,7 +35,7 @@ import { CORE_COURSES_STATE_HIDDEN, CORE_COURSES_DOWNLOAD_FEATURE_NAME, CORE_COURSE_DOWNLOAD_FEATURE_NAME, - CORE_COURSES_MYCOURSES_MENU_FEATURE_NAME, + CORE_COURSES_MENU_FEATURE_NAME, CORE_COURSES_SEARCH_FEATURE_NAME, } from '../constants'; import { CoreTextFormat } from '@singletons/text'; @@ -296,7 +296,7 @@ export class CoreCoursesProvider { isMyCoursesDisabledInSite(site?: CoreSite): boolean { site = site || CoreSites.getCurrentSite(); - return !site || site.isFeatureDisabled(CORE_COURSES_MYCOURSES_MENU_FEATURE_NAME); + return !site || site.isFeatureDisabled(CORE_COURSES_MENU_FEATURE_NAME); } /** diff --git a/src/core/features/courses/services/dashboard.ts b/src/core/features/courses/services/dashboard.ts index bbcccacb6ea..a8ae35fbc98 100644 --- a/src/core/features/courses/services/dashboard.ts +++ b/src/core/features/courses/services/dashboard.ts @@ -24,7 +24,7 @@ import { firstValueFrom } from 'rxjs'; import { asyncObservable } from '@/core/utils/rxjs'; import { CoreSiteWSPreSets, WSObservable } from '@classes/sites/authenticated-site'; import { CoreCacheUpdateFrequency } from '@/core/constants'; -import { CoreCoursesMyPageName } from '../constants'; +import { CORE_COURSES_DASHBOARD_MENU_FEATURE_NAME, CoreCoursesMyPageName } from '../constants'; import { CORE_BLOCKS_DASHBOARD_FALLBACK_MYOVERVIEW_BLOCK, CoreBlocksRegion } from '@features/block/constants'; /** @@ -235,7 +235,7 @@ export class CoreCoursesDashboardProvider { isDisabledInSite(site?: CoreSite): boolean { site = site || CoreSites.getCurrentSite(); - return !!site?.isFeatureDisabled('CoreMainMenuDelegate_CoreCoursesDashboard'); + return !!site?.isFeatureDisabled(CORE_COURSES_DASHBOARD_MENU_FEATURE_NAME); } } diff --git a/src/core/features/courses/services/handlers/courses-index-link.ts b/src/core/features/courses/services/handlers/courses-index-link.ts index a9c62b5a8af..2b025ccd314 100644 --- a/src/core/features/courses/services/handlers/courses-index-link.ts +++ b/src/core/features/courses/services/handlers/courses-index-link.ts @@ -18,7 +18,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; -import { CORE_COURSES_MYCOURSES_PAGE_NAME } from '@features/courses/constants'; +import { CORE_COURSES_MENU_FEATURE_NAME, CORE_COURSES_MYCOURSES_PAGE_NAME } from '@features/courses/constants'; /** * Handler to treat links to course index (list of courses). @@ -27,7 +27,7 @@ import { CORE_COURSES_MYCOURSES_PAGE_NAME } from '@features/courses/constants'; export class CoreCoursesIndexLinkHandlerService extends CoreContentLinksHandlerBase { name = 'CoreCoursesIndexLinkHandler'; - featureName = 'CoreMainMenuDelegate_CoreCourses'; + featureName = CORE_COURSES_MENU_FEATURE_NAME; pattern = /\/course\/?(index\.php.*)?$/; /** diff --git a/src/core/features/courses/services/handlers/my-courses-mainmenu.ts b/src/core/features/courses/services/handlers/my-courses-mainmenu.ts index 40482f89a6a..553e822bfaa 100644 --- a/src/core/features/courses/services/handlers/my-courses-mainmenu.ts +++ b/src/core/features/courses/services/handlers/my-courses-mainmenu.ts @@ -20,7 +20,11 @@ import { CoreSites } from '@services/sites'; import { makeSingleton } from '@singletons'; import { CoreCourses } from '../courses'; import { CoreDashboardHomeHandler } from './dashboard-home'; -import { CORE_COURSES_MYCOURSES_PAGE_NAME, CoreCoursesMyPageName } from '@features/courses/constants'; +import { + CORE_COURSES_MY_COURSES_COMPONENT_NAME, + CORE_COURSES_MYCOURSES_PAGE_NAME, + CoreCoursesMyPageName, +} from '@features/courses/constants'; import { CoreCoursesDashboard } from '../dashboard'; import { CoreBlockDelegate } from '@features/block/services/block-delegate'; @@ -30,7 +34,8 @@ import { CoreBlockDelegate } from '@features/block/services/block-delegate'; @Injectable({ providedIn: 'root' }) export class CoreCoursesMyCoursesMainMenuHandlerService implements CoreMainMenuHandler { - name = 'CoreCoursesMyCourses'; + // @todo: Check why the component name does not match the disabled feature name. + name = CORE_COURSES_MY_COURSES_COMPONENT_NAME; priority = 900; /** diff --git a/src/core/features/dataprivacy/constants.ts b/src/core/features/dataprivacy/constants.ts index 4a17949ec32..a558b168d0b 100644 --- a/src/core/features/dataprivacy/constants.ts +++ b/src/core/features/dataprivacy/constants.ts @@ -12,7 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { CORE_USER_FEATURE_PREFIX } from '@features/user/constants'; + // Routing. export const CORE_DATAPRIVACY_PAGE_NAME = 'dataprivacy'; -export const CORE_DATAPRIVACY_FEATURE_NAME = 'CoreUserDelegate_CoreDataPrivacy'; +export const CORE_DATAPRIVACY_COMPONENT_NAME = 'CoreDataPrivacy'; +export const CORE_DATAPRIVACY_FEATURE_NAME = `${CORE_USER_FEATURE_PREFIX}${CORE_DATAPRIVACY_COMPONENT_NAME}`; diff --git a/src/core/features/grades/constants.ts b/src/core/features/grades/constants.ts index 4f514651f6b..8ed9fb56374 100644 --- a/src/core/features/grades/constants.ts +++ b/src/core/features/grades/constants.ts @@ -12,10 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { CORE_USER_FEATURE_PREFIX } from '@features/user/constants'; + export const GRADES_PAGE_NAME = 'grades'; export const GRADES_PARTICIPANTS_PAGE_NAME = 'participant-grades'; -export const CORE_GRADES_COURSE_OPTION_NAME = 'CoreGrades'; // Tabname. +export const CORE_GRADES_COMPONENT_NAME = 'CoreGrades'; +export const CORE_GRADES_ACCOUNT_FEATURE_NAME = `${CORE_USER_FEATURE_PREFIX}${CORE_GRADES_COMPONENT_NAME}`; +export const CORE_GRADES_USER_MENU_FEATURE_NAME = `${CORE_GRADES_ACCOUNT_FEATURE_NAME}:viewGrades`; + +export const CORE_GRADES_COURSE_OPTION_NAME = CORE_GRADES_COMPONENT_NAME; // Tabname on course. export const enum CoreGradeType { NONE = 0, // Moodle's GRADE_TYPE_NONE. diff --git a/src/core/features/grades/services/handlers/user.ts b/src/core/features/grades/services/handlers/user.ts index 85449506fa5..f5e39ad085a 100644 --- a/src/core/features/grades/services/handlers/user.ts +++ b/src/core/features/grades/services/handlers/user.ts @@ -28,7 +28,12 @@ import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { makeSingleton } from '@singletons'; -import { GRADES_PAGE_NAME } from '../../constants'; +import { + CORE_GRADES_ACCOUNT_FEATURE_NAME, + CORE_GRADES_COMPONENT_NAME, + CORE_GRADES_USER_MENU_FEATURE_NAME, + GRADES_PAGE_NAME, +} from '../../constants'; /** * Profile grades handler. @@ -37,7 +42,7 @@ import { GRADES_PAGE_NAME } from '../../constants'; export class CoreGradesUserHandlerService implements CoreUserProfileHandler { // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext. - name = 'CoreGrades:fakename'; + name = `${CORE_GRADES_COMPONENT_NAME}:fakename`; priority = 500; type = CoreUserProfileHandlerType.LIST_ITEM; cacheEnabled = true; @@ -60,10 +65,10 @@ export class CoreGradesUserHandlerService implements CoreUserProfileHandler { } if (context === CoreUserDelegateContext.USER_MENU) { - if (currentSite.isFeatureDisabled('CoreUserDelegate_CoreGrades')) { + if (currentSite.isFeatureDisabled(CORE_GRADES_ACCOUNT_FEATURE_NAME)) { return false; } - } else if (currentSite.isFeatureDisabled('CoreUserDelegate_CoreGrades:viewGrades')) { + } else if (currentSite.isFeatureDisabled(CORE_GRADES_USER_MENU_FEATURE_NAME)) { return false; } diff --git a/src/core/features/mainmenu/constants.ts b/src/core/features/mainmenu/constants.ts index 40544260308..c0cce2fe349 100644 --- a/src/core/features/mainmenu/constants.ts +++ b/src/core/features/mainmenu/constants.ts @@ -20,6 +20,10 @@ export const MAIN_MENU_MORE_PAGE_NAME = 'more'; export const MAIN_MENU_HANDLER_BADGE_UPDATED_EVENT = 'main_menu_handler_badge_updated'; export const MAIN_MENU_VISIBILITY_UPDATED_EVENT = 'main_menu_visbility_updated'; +export const MAIN_MENU_FEATURE_PREFIX = 'CoreMainMenuDelegate_'; + +export const CORE_HOME_COMPONENT_NAME = 'CoreHome'; + /** * Pacement of the main menu in the app. */ diff --git a/src/core/features/mainmenu/pages/more/more.ts b/src/core/features/mainmenu/pages/more/more.ts index f50e42ab42b..0689f6611b3 100644 --- a/src/core/features/mainmenu/pages/more/more.ts +++ b/src/core/features/mainmenu/pages/more/more.ts @@ -28,6 +28,7 @@ import { CoreSharedModule } from '@/core/shared.module'; import { CoreMainMenuUserButtonComponent } from '../../components/user-menu-button/user-menu-button'; import { CoreContentLinksHelper } from '@features/contentlinks/services/contentlinks-helper'; import { CoreUrl } from '@singletons/url'; +import { CORE_QRREADER_MENU_FEATURE_NAME } from '@features/viewer/constants'; /** * Page that displays the more page of the app. @@ -64,7 +65,7 @@ export default class CoreMainMenuMorePage implements OnInit, OnDestroy { this.loadCustomMenuItems(); this.showScanQR = CoreQRScan.canScanQR() && - !CoreSites.getCurrentSite()?.isFeatureDisabled('CoreMainMenuDelegate_QrReader'); + !CoreSites.getCurrentSite()?.isFeatureDisabled(CORE_QRREADER_MENU_FEATURE_NAME); } /** diff --git a/src/core/features/mainmenu/services/handlers/mainmenu.ts b/src/core/features/mainmenu/services/handlers/mainmenu.ts index 25c6402017b..2bf59a93c92 100644 --- a/src/core/features/mainmenu/services/handlers/mainmenu.ts +++ b/src/core/features/mainmenu/services/handlers/mainmenu.ts @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; import { makeSingleton } from '@singletons'; import { CoreMainMenuHomeDelegate } from '../home-delegate'; import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '../mainmenu-delegate'; -import { MAIN_MENU_HOME_PAGE_NAME } from '@features/mainmenu/constants'; +import { CORE_HOME_COMPONENT_NAME, MAIN_MENU_HOME_PAGE_NAME } from '@features/mainmenu/constants'; /** * Handler to add Home into main menu. @@ -24,7 +24,7 @@ import { MAIN_MENU_HOME_PAGE_NAME } from '@features/mainmenu/constants'; @Injectable({ providedIn: 'root' }) export class CoreMainMenuHomeHandlerService implements CoreMainMenuHandler { - name = 'CoreHome'; + name = CORE_HOME_COMPONENT_NAME; priority = 1000; /** diff --git a/src/core/features/mainmenu/services/mainmenu-delegate.ts b/src/core/features/mainmenu/services/mainmenu-delegate.ts index a732c407fce..b90f5edebba 100644 --- a/src/core/features/mainmenu/services/mainmenu-delegate.ts +++ b/src/core/features/mainmenu/services/mainmenu-delegate.ts @@ -18,6 +18,12 @@ import { Params } from '@angular/router'; import { CoreDelegateDisplayHandler, CoreDelegateToDisplay } from '@classes/delegate'; import { CoreSortedDelegate } from '@classes/delegate-sorted'; import { makeSingleton } from '@singletons'; +import { MAIN_MENU_FEATURE_PREFIX } from '../constants'; +import { CoreConstants } from '@/core/constants'; +import { CoreEvents } from '@singletons/events'; +import { CoreConfig, CoreConfigProvider } from '@services/config'; +import { ADDONS_BLOG_COMPONENT_NAME } from '@addons/blog/constants'; +import { CoreMainMenuOverrideItem } from './mainmenu'; /** * Interface that all main menu handlers must implement. @@ -106,7 +112,55 @@ export interface CoreMainMenuHandlerToDisplay extends CoreDelegateToDisplay, Cor @Injectable({ providedIn: 'root' }) export class CoreMainMenuDelegateService extends CoreSortedDelegate { - protected featurePrefix = 'CoreMainMenuDelegate_'; + protected featurePrefix = MAIN_MENU_FEATURE_PREFIX; + protected previousEnvironment: CoreMainMenuOverrideItem[] = []; + + constructor() { + super(); + + CoreEvents.on(CoreConfigProvider.ENVIRONMENT_UPDATED, (config) => { + const newConfig = config.overrideMainMenuButtons ?? []; + if (JSON.stringify(this.previousEnvironment) === JSON.stringify(newConfig)) { + return; + } + this.updateHandlers(); + }); + + setTimeout(() => { + CoreConfig.patchEnvironment({ + overrideMainMenuButtons: [ + { + handler: ADDONS_BLOG_COMPONENT_NAME, + icon: 'fas-house', + priority: 3000, + }, + ], + }); + }, 30000); + } + + /** + * @inheritdoc + */ + protected getHandlerDisplayData(name: string): CoreMainMenuHandlerToDisplay { + const data = super.getHandlerDisplayData(name); + + // Override priority and icon if needed. + const config = CoreConstants.CONFIG.overrideMainMenuButtons ?? []; + this.previousEnvironment = config; + + const override = config.find((entry) => entry.handler === name); + if (override) { + if (override.priority !== undefined) { + data.priority = override.priority; + } + if (override.icon !== undefined) { + data.icon = override.icon; + } + } + + return data; + } } diff --git a/src/core/features/mainmenu/services/mainmenu.ts b/src/core/features/mainmenu/services/mainmenu.ts index 94d0c8a7d06..4557d0406a0 100644 --- a/src/core/features/mainmenu/services/mainmenu.ts +++ b/src/core/features/mainmenu/services/mainmenu.ts @@ -374,3 +374,12 @@ export type CoreMainMenuHandlerBadgeUpdatedEventData = { handler: string; // Handler name. value: number; // New counter value. }; + +/** + * Override for a main menu item. + */ +export type CoreMainMenuOverrideItem = { + handler: string; // Handler name. + icon?: string; // New icon name. + priority?: number; // New priority. +}; diff --git a/src/core/features/policy/constants.ts b/src/core/features/policy/constants.ts index 88e436d5a44..bff434a0239 100644 --- a/src/core/features/policy/constants.ts +++ b/src/core/features/policy/constants.ts @@ -12,7 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { CORE_USER_FEATURE_PREFIX } from '@features/user/constants'; + // Routing. export const POLICY_PAGE_NAME = 'policy'; export const SITE_POLICY_PAGE_NAME = 'sitepolicy'; export const ACCEPTANCES_PAGE_NAME = 'acceptances'; + +export const CORE_POLICY_COMPONENT_NAME = 'CorePolicy'; +export const CORE_POLICY_FEATURE_NAME = `${CORE_USER_FEATURE_PREFIX}${CORE_POLICY_COMPONENT_NAME}`; diff --git a/src/core/features/policy/services/handlers/acceptances-link.ts b/src/core/features/policy/services/handlers/acceptances-link.ts index 69485e126c5..2c63ac8273c 100644 --- a/src/core/features/policy/services/handlers/acceptances-link.ts +++ b/src/core/features/policy/services/handlers/acceptances-link.ts @@ -18,7 +18,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; -import { ACCEPTANCES_PAGE_NAME, POLICY_PAGE_NAME } from '@features/policy/constants'; +import { ACCEPTANCES_PAGE_NAME, CORE_POLICY_FEATURE_NAME, POLICY_PAGE_NAME } from '@features/policy/constants'; import { CoreSites } from '@services/sites'; /** @@ -29,7 +29,7 @@ export class CorePolicyAcceptancesLinkHandlerService extends CoreContentLinksHan name = 'CorePolicyAcceptancesLinkHandler'; pattern = /\/admin\/tool\/policy\/user\.php/; - featureName = 'CoreUserDelegate_CorePolicy'; + featureName = CORE_POLICY_FEATURE_NAME; /** * @inheritdoc diff --git a/src/core/features/search/constants.ts b/src/core/features/search/constants.ts new file mode 100644 index 00000000000..be8d7d2e2c3 --- /dev/null +++ b/src/core/features/search/constants.ts @@ -0,0 +1,17 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +export const CORE_SEARCH_COMPONENT_NAME = 'CoreSearch'; + +export const CORE_SEARCH_PAGE_NAME = 'search'; diff --git a/src/core/features/search/search.module.ts b/src/core/features/search/search.module.ts index 7e6097e61ec..6927bc90c69 100644 --- a/src/core/features/search/search.module.ts +++ b/src/core/features/search/search.module.ts @@ -17,7 +17,8 @@ import { Routes } from '@angular/router'; import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module'; import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu-delegate'; -import { CoreSearchMainMenuHandler, CORE_SEARCH_PAGE_NAME } from '@features/search/services/handlers/mainmenu'; +import { CoreSearchMainMenuHandler } from '@features/search/services/handlers/mainmenu'; +import { CORE_SEARCH_PAGE_NAME } from '@features/search/constants'; import { CORE_SITE_SCHEMAS } from '@services/sites'; diff --git a/src/core/features/search/services/handlers/global-search-link.ts b/src/core/features/search/services/handlers/global-search-link.ts index 055708e3b95..76e3886b8e8 100644 --- a/src/core/features/search/services/handlers/global-search-link.ts +++ b/src/core/features/search/services/handlers/global-search-link.ts @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreSearchGlobalSearch } from '@features/search/services/global-search'; -import { CORE_SEARCH_PAGE_NAME } from '@features/search/services/handlers/mainmenu'; +import { CORE_SEARCH_PAGE_NAME } from '@features/search/constants'; import { CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; diff --git a/src/core/features/search/services/handlers/mainmenu.ts b/src/core/features/search/services/handlers/mainmenu.ts index e97531ae8f0..8bd9194784d 100644 --- a/src/core/features/search/services/handlers/mainmenu.ts +++ b/src/core/features/search/services/handlers/mainmenu.ts @@ -16,8 +16,7 @@ import { Injectable } from '@angular/core'; import { makeSingleton } from '@singletons'; import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@features/mainmenu/services/mainmenu-delegate'; import { CoreSearchGlobalSearch } from '@features/search/services/global-search'; - -export const CORE_SEARCH_PAGE_NAME = 'search'; +import { CORE_SEARCH_COMPONENT_NAME, CORE_SEARCH_PAGE_NAME } from '@features/search/constants'; /** * Handler to inject an option into main menu. @@ -25,7 +24,7 @@ export const CORE_SEARCH_PAGE_NAME = 'search'; @Injectable({ providedIn: 'root' }) export class CoreSearchMainMenuHandlerService implements CoreMainMenuHandler { - name = 'CoreSearch'; + name = CORE_SEARCH_COMPONENT_NAME; priority = 575; /** diff --git a/src/core/features/sitehome/constants.ts b/src/core/features/sitehome/constants.ts index de6734527e9..cabb2c4ed3d 100644 --- a/src/core/features/sitehome/constants.ts +++ b/src/core/features/sitehome/constants.ts @@ -12,4 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { MAIN_MENU_FEATURE_PREFIX } from '@features/mainmenu/constants'; + export const CORE_SITEHOME_PAGE_NAME = 'site'; + +export const CORE_SITEHOME_COMPONENT_NAME = 'CoreSiteHome'; +export const CORE_SITEHOME_MENU_FEATURE_NAME = `${MAIN_MENU_FEATURE_PREFIX}${CORE_SITEHOME_COMPONENT_NAME}`; diff --git a/src/core/features/sitehome/services/handlers/index-link.ts b/src/core/features/sitehome/services/handlers/index-link.ts index 0afbe946189..cbce21dd035 100644 --- a/src/core/features/sitehome/services/handlers/index-link.ts +++ b/src/core/features/sitehome/services/handlers/index-link.ts @@ -21,7 +21,7 @@ import { CoreSiteHome } from '../sitehome'; import { makeSingleton } from '@singletons'; import { CoreNavigator } from '@services/navigator'; import { Params } from '@angular/router'; -import { CORE_SITEHOME_PAGE_NAME } from '@features/sitehome/constants'; +import { CORE_SITEHOME_MENU_FEATURE_NAME, CORE_SITEHOME_PAGE_NAME } from '@features/sitehome/constants'; import { MAIN_MENU_HOME_PAGE_NAME } from '@features/mainmenu/constants'; /** @@ -31,7 +31,7 @@ import { MAIN_MENU_HOME_PAGE_NAME } from '@features/mainmenu/constants'; export class CoreSiteHomeIndexLinkHandlerService extends CoreContentLinksHandlerBase { name = 'CoreSiteHomeIndexLinkHandler'; - featureName = 'CoreMainMenuDelegate_CoreSiteHome'; + featureName = CORE_SITEHOME_MENU_FEATURE_NAME; pattern = /(\/course\/view\.php.*([?&]id=\d+)|\/index\.php(\?redirect=0)?|\/?\?redirect=0)/; /** diff --git a/src/core/features/sitehome/services/sitehome.ts b/src/core/features/sitehome/services/sitehome.ts index 3594f103c9e..e4a38ff8c9d 100644 --- a/src/core/features/sitehome/services/sitehome.ts +++ b/src/core/features/sitehome/services/sitehome.ts @@ -23,6 +23,7 @@ import { AddonModForumData } from '@addons/mod/forum/services/forum'; import { CoreError } from '@classes/errors/error'; import { CoreBlockHelper } from '@features/block/services/block-helper'; import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; +import { CORE_SITEHOME_MENU_FEATURE_NAME } from '../constants'; /** * Items with index 1 and 3 were removed on 2.5 and not being supported in the app. @@ -148,7 +149,7 @@ export class CoreSiteHomeProvider { isDisabledInSite(site: CoreSite): boolean { site = site || CoreSites.getCurrentSite(); - return site.isFeatureDisabled('CoreMainMenuDelegate_CoreSiteHome'); + return site.isFeatureDisabled(CORE_SITEHOME_MENU_FEATURE_NAME); } /** diff --git a/src/core/features/tag/constants.ts b/src/core/features/tag/constants.ts index 8c014e19447..2f69598d590 100644 --- a/src/core/features/tag/constants.ts +++ b/src/core/features/tag/constants.ts @@ -13,3 +13,5 @@ // limitations under the License. export const CORE_TAG_MAIN_MENU_PAGE_NAME = 'tag'; + +export const CORE_TAG_COMPONENT_NAME = 'CoreTag'; diff --git a/src/core/features/tag/services/handlers/mainmenu.ts b/src/core/features/tag/services/handlers/mainmenu.ts index 042e505baad..874ac9f207a 100644 --- a/src/core/features/tag/services/handlers/mainmenu.ts +++ b/src/core/features/tag/services/handlers/mainmenu.ts @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; import { CoreTag } from '../tag'; import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@features/mainmenu/services/mainmenu-delegate'; import { makeSingleton } from '@singletons'; -import { CORE_TAG_MAIN_MENU_PAGE_NAME } from '@features/tag/constants'; +import { CORE_TAG_COMPONENT_NAME, CORE_TAG_MAIN_MENU_PAGE_NAME } from '@features/tag/constants'; /** * Handler to inject an option into main menu. @@ -24,7 +24,7 @@ import { CORE_TAG_MAIN_MENU_PAGE_NAME } from '@features/tag/constants'; @Injectable({ providedIn: 'root' }) export class CoreTagMainMenuHandlerService implements CoreMainMenuHandler { - name = 'CoreTag'; + name = CORE_TAG_COMPONENT_NAME; priority = 400; /** diff --git a/src/core/features/user/constants.ts b/src/core/features/user/constants.ts index 6e588c09b39..098ef5ba707 100644 --- a/src/core/features/user/constants.ts +++ b/src/core/features/user/constants.ts @@ -19,6 +19,11 @@ export const CORE_PARTICIPANTS_COURSE_OPTION_NAME = 'CoreUserParticipants'; // T // Events. export const CORE_USER_AUTO_SYNCED = 'core_user_autom_synced'; +// Features. +export const CORE_USER_FEATURE_PREFIX = 'CoreUserDelegate_'; + +export const CORE_USER_PICTURE_FEATURE_NAME = `${CORE_USER_FEATURE_PREFIX}picture`; + /** * Profile picture updated event. */ diff --git a/src/core/features/user/services/user-delegate.ts b/src/core/features/user/services/user-delegate.ts index a41be757652..6b99f10da8d 100644 --- a/src/core/features/user/services/user-delegate.ts +++ b/src/core/features/user/services/user-delegate.ts @@ -22,7 +22,7 @@ import { CoreUserProfile } from './user'; import { makeSingleton } from '@singletons'; import { CoreCourses, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { CoreSites } from '@services/sites'; -import { CORE_USER_PROFILE_REFRESHED } from '../constants'; +import { CORE_USER_FEATURE_PREFIX, CORE_USER_PROFILE_REFRESHED } from '../constants'; export enum CoreUserProfileHandlerType { LIST_ITEM = 'listitem', // User profile handler type to be shown as a list item. @@ -30,19 +30,6 @@ export enum CoreUserProfileHandlerType { BUTTON = 'button', // User profile handler type to be shown as a button. } -declare module '@singletons/events' { - - /** - * Augment CoreEventsData interface with events specific to this service. - * - * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation - */ - export interface CoreEventsData { - [USER_DELEGATE_UPDATE_HANDLER_EVENT]: CoreUserUpdateHandlerData; - } - -} - /** * Interface that all user profile handlers must implement. */ @@ -188,11 +175,6 @@ export interface CoreUserProfileHandlerToDisplay { type: string; } -/** - * Delegate update handler event. - */ -export const USER_DELEGATE_UPDATE_HANDLER_EVENT = 'CoreUserDelegate_update_handler_event'; - /** * Service to interact with plugins to be shown in user profile. Provides functions to register a plugin * and notify an update in the data. @@ -224,7 +206,7 @@ export class CoreUserDelegateService extends CoreDelegate> = {}; - protected featurePrefix = 'CoreUserDelegate_'; + protected featurePrefix = CORE_USER_FEATURE_PREFIX; // Hold the handlers and the observable to notify them for each user. protected userHandlers: Record> = {}; @@ -232,21 +214,6 @@ export class CoreUserDelegateService extends CoreDelegate { - const handlersData = this.getHandlersData(data.userId, data.context, data.contextId); - - // Search the handler. - const handler = handlersData.handlers.find((userHandler) => userHandler.name == data.handler); - - if (!handler) { - return; - } - - // Update the data and notify. - Object.assign(handler.data, data.data); - handlersData.observable.next(handlersData.handlers); - }); - CoreEvents.on(CoreEvents.LOGOUT, () => { this.clearHandlerCache(); }); @@ -537,14 +504,3 @@ export enum CoreUserDelegateContext { COURSE = 'course', USER_MENU = 'user_menu', } - -/** - * Data passed to UPDATE_HANDLER_EVENT event. - */ -export type CoreUserUpdateHandlerData = { - handler: string; // Name of the handler. - userId: number; // User affected. - context: CoreUserDelegateContext; // Context affected. - contextId?: number; // ID related to the context. - data: Record; // Data to set to the handler. -}; diff --git a/src/core/features/user/services/user.ts b/src/core/features/user/services/user.ts index aee71e6983d..9393f02c270 100644 --- a/src/core/features/user/services/user.ts +++ b/src/core/features/user/services/user.ts @@ -33,6 +33,7 @@ import { CORE_USER_PROFILE_REFRESHED, CORE_USER_PROFILE_PICTURE_UPDATED, CORE_USER_PARTICIPANTS_LIST_LIMIT, + CORE_USER_PICTURE_FEATURE_NAME, } from '../constants'; import { CoreUserPreferences } from './user-preferences'; @@ -491,7 +492,7 @@ export class CoreUserProvider { isUpdatePictureDisabledInSite(site?: CoreSite): boolean { site = site || CoreSites.getCurrentSite(); - return !!site?.isFeatureDisabled('CoreUserDelegate_picture'); + return !!site?.isFeatureDisabled(CORE_USER_PICTURE_FEATURE_NAME); } /** diff --git a/src/core/features/viewer/constants.ts b/src/core/features/viewer/constants.ts index 3b56833d18d..73b1ceed315 100644 --- a/src/core/features/viewer/constants.ts +++ b/src/core/features/viewer/constants.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { MAIN_MENU_FEATURE_PREFIX } from '@features/mainmenu/constants'; import { CoreViewerReadingModeSettings } from './services/viewer'; export const CORE_READING_MODE_SETTINGS = 'CoreReadingModeSettings'; @@ -31,3 +32,6 @@ export const CORE_READING_MODE_DEFAULT_SETTINGS: CoreViewerReadingModeSettings = showMultimedia: false, theme: CoreViewerReadingModeThemes.HCM, }; + +export const CORE_QRREADER_COMPONENT_NAME = 'QrReader'; +export const CORE_QRREADER_MENU_FEATURE_NAME = `${MAIN_MENU_FEATURE_PREFIX}${CORE_QRREADER_COMPONENT_NAME}`; diff --git a/src/types/config.d.ts b/src/types/config.d.ts index 2ea72b85b89..5422161234f 100644 --- a/src/types/config.d.ts +++ b/src/types/config.d.ts @@ -13,7 +13,7 @@ // limitations under the License. import { CoreColorScheme, CoreZoomLevel } from '@features/settings/services/settings-helper'; -import { CoreMainMenuLocalizedCustomItem } from '@features/mainmenu/services/mainmenu'; +import { CoreMainMenuLocalizedCustomItem, CoreMainMenuOverrideItem } from '@features/mainmenu/services/mainmenu'; import { CoreLoginSiteInfo, CoreSitesDemoSiteData } from '@services/sites'; import { OpenFileAction } from '@singletons/opener'; import { CoreLoginSiteFinderSettings, CoreLoginSiteSelectorListMethod } from '@features/login/services/login-helper'; @@ -80,4 +80,5 @@ export interface EnvironmentConfig { clearIABSessionWhenAutoLogin?: 'android' | 'ios' | 'all'; // Clear the session every time a new IAB is opened with auto-login. disabledFeatures?: string; // Disabled features for the whole app, using the same format as tool_mobile_disabledfeatures. collapsibleItemsExpanded: boolean; // Expand or collapse the collapsible items by default. + overrideMainMenuButtons: CoreMainMenuOverrideItem[]; // Override main menu items. }