MOBILE-3966 core: Support new disabled features values
parent
101faf20aa
commit
d46bc0601f
|
@ -21,6 +21,7 @@ import {
|
|||
CoreUserProfileHandlerData,
|
||||
} from '@features/user/services/user-delegate';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonBadges } from '../badges';
|
||||
|
||||
|
@ -30,7 +31,7 @@ import { AddonBadges } from '../badges';
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonBadgesUserHandlerService implements CoreUserProfileHandler {
|
||||
|
||||
name = 'AddonBadges';
|
||||
name = 'AddonBadges:fakename'; // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext.
|
||||
priority = 50;
|
||||
type = CoreUserDelegateService.TYPE_NEW_PAGE;
|
||||
|
||||
|
@ -49,11 +50,24 @@ export class AddonBadgesUserHandlerService implements CoreUserProfileHandler {
|
|||
courseId: number,
|
||||
navOptions?: CoreCourseUserAdminOrNavOptionIndexed,
|
||||
): Promise<boolean> {
|
||||
// Check if feature is disabled.
|
||||
const currentSite = CoreSites.getCurrentSite();
|
||||
if (!currentSite) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context === CoreUserDelegateContext.USER_MENU) {
|
||||
if (currentSite.isFeatureDisabled('CoreUserDelegate_AddonBadges:account')) {
|
||||
return false;
|
||||
}
|
||||
} else if (currentSite.isFeatureDisabled('CoreUserDelegate_AddonBadges')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (navOptions && navOptions.badges !== undefined) {
|
||||
return navOptions.badges;
|
||||
}
|
||||
|
||||
// If we reach here, it means we are opening the user site profile.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,14 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreUserProfileHandler, CoreUserProfileHandlerData, CoreUserDelegateService } from '@features/user/services/user-delegate';
|
||||
import {
|
||||
CoreUserProfileHandler,
|
||||
CoreUserProfileHandlerData,
|
||||
CoreUserDelegateService,
|
||||
CoreUserDelegateContext,
|
||||
} from '@features/user/services/user-delegate';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonBlog } from '../blog';
|
||||
|
||||
|
@ -24,7 +30,7 @@ import { AddonBlog } from '../blog';
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonBlogUserHandlerService implements CoreUserProfileHandler {
|
||||
|
||||
name = 'AddonBlog:blogs';
|
||||
name = 'AddonBlog'; // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext.
|
||||
priority = 300;
|
||||
type = CoreUserDelegateService.TYPE_NEW_PAGE;
|
||||
|
||||
|
@ -35,6 +41,27 @@ export class AddonBlogUserHandlerService implements CoreUserProfileHandler {
|
|||
return AddonBlog.isPluginEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async isEnabledForContext(context: CoreUserDelegateContext): Promise<boolean> {
|
||||
// Check if feature is disabled.
|
||||
const currentSite = CoreSites.getCurrentSite();
|
||||
if (!currentSite) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context === CoreUserDelegateContext.USER_MENU) {
|
||||
if (currentSite.isFeatureDisabled('CoreUserDelegate_AddonBlog:account')) {
|
||||
return false;
|
||||
}
|
||||
} else if (currentSite.isFeatureDisabled('CoreUserDelegate_AddonBlog:blogs')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
|
|
@ -24,6 +24,7 @@ import {
|
|||
} from '@features/user/services/user-delegate';
|
||||
import { PARTICIPANTS_PAGE_NAME } from '@features/user/user.module';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonCompetency } from '../competency';
|
||||
|
||||
|
@ -33,7 +34,7 @@ import { AddonCompetency } from '../competency';
|
|||
@Injectable( { providedIn: 'root' })
|
||||
export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler {
|
||||
|
||||
name = 'AddonCompetency:learningPlan';
|
||||
name = 'AddonCompetency'; // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext.
|
||||
priority = 900;
|
||||
type = CoreUserDelegateService.TYPE_NEW_PAGE;
|
||||
cacheEnabled = true;
|
||||
|
@ -45,6 +46,28 @@ export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async isEnabledForContext(context: CoreUserDelegateContext): Promise<boolean> {
|
||||
// Check if feature is disabled.
|
||||
const currentSite = CoreSites.getCurrentSite();
|
||||
if (!currentSite) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context === CoreUserDelegateContext.USER_MENU) {
|
||||
// This option used to belong to main menu, check the original disabled feature value.
|
||||
if (currentSite.isFeatureDisabled('CoreMainMenuDelegate_AddonCompetency')) {
|
||||
return false;
|
||||
}
|
||||
} else if (currentSite.isFeatureDisabled('CoreUserDelegate_AddonCompetency:learningPlan')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
|
|
@ -30,7 +30,7 @@ import { AddonCourseCompletion } from '../coursecompletion';
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonCourseCompletionUserHandlerService implements CoreUserProfileHandler {
|
||||
|
||||
name = 'AddonCourseCompletion';
|
||||
name = 'AddonCourseCompletion:viewCompletion';
|
||||
type = CoreUserDelegateService.TYPE_NEW_PAGE;
|
||||
priority = 200;
|
||||
cacheEnabled = true;
|
||||
|
|
|
@ -46,11 +46,30 @@ export class AddonPrivateFilesUserHandlerService implements CoreUserProfileHandl
|
|||
return AddonPrivateFiles.isPluginEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async isEnabledForContext(context: CoreUserDelegateContext): Promise<boolean> {
|
||||
// Private files only available in user menu.
|
||||
if (context !== CoreUserDelegateContext.USER_MENU) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if feature is disabled.
|
||||
const currentSite = CoreSites.getCurrentSite();
|
||||
if (!currentSite) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// This option used to belong to main menu, check the original disabled feature value.
|
||||
return !currentSite.isFeatureDisabled('CoreMainMenuDelegate_AddonPrivateFiles');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async isEnabledForUser(user: CoreUserProfile, context: CoreUserDelegateContext): Promise<boolean> {
|
||||
// Private files only available for the current user in user menu.
|
||||
// Private files only available for the current user.
|
||||
return user.id == CoreSites.getCurrentSiteUserId() && context === CoreUserDelegateContext.USER_MENU;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import { makeSingleton } from '@singletons';
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreGradesUserHandlerService implements CoreUserProfileHandler {
|
||||
|
||||
name = 'CoreGrades:viewGrades';
|
||||
name = 'CoreGrades'; // This name doesn't match any disabled feature, they'll be checked in isEnabledForContext.
|
||||
priority = 400;
|
||||
type = CoreUserDelegateService.TYPE_NEW_PAGE;
|
||||
cacheEnabled = true;
|
||||
|
@ -52,6 +52,21 @@ export class CoreGradesUserHandlerService implements CoreUserProfileHandler {
|
|||
* @inheritdoc
|
||||
*/
|
||||
async isEnabledForContext(context: CoreUserDelegateContext, courseId: number): Promise<boolean> {
|
||||
// Check if feature is disabled.
|
||||
const currentSite = CoreSites.getCurrentSite();
|
||||
if (!currentSite) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context === CoreUserDelegateContext.USER_MENU) {
|
||||
// This option used to belong to main menu, check the original disabled feature value.
|
||||
if (currentSite.isFeatureDisabled('CoreMainMenuDelegate_CoreGrades')) {
|
||||
return false;
|
||||
}
|
||||
} else if (currentSite.isFeatureDisabled('CoreUserDelegate_CoreGrades:viewGrades')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context === CoreUserDelegateContext.COURSE) {
|
||||
return CoreUtils.ignoreErrors(CoreGrades.isPluginEnabledForCourse(courseId), false);
|
||||
} else {
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
</ion-list>
|
||||
</ion-content>
|
||||
<ion-footer>
|
||||
<ion-item button lines="full" (click)="switchAccounts($event)" detail="true" class="ion-text-wrap">
|
||||
<ion-item *ngIf="displaySwitchAccount" button lines="full" (click)="switchAccounts($event)" detail="true" class="ion-text-wrap">
|
||||
<ion-icon name="fas-exchange-alt" slot="start" aria-hidden="true"></ion-icon>
|
||||
<ion-label>
|
||||
<p class="item-heading">{{ 'core.mainmenu.switchaccount' | translate }}</p>
|
||||
|
|
|
@ -49,6 +49,7 @@ export class CoreMainMenuUserMenuComponent implements OnInit, OnDestroy {
|
|||
handlersLoaded = false;
|
||||
loaded = false;
|
||||
user?: CoreUserProfile;
|
||||
displaySwitchAccount = true;
|
||||
|
||||
protected subscription!: Subscription;
|
||||
|
||||
|
@ -60,6 +61,7 @@ export class CoreMainMenuUserMenuComponent implements OnInit, OnDestroy {
|
|||
this.siteInfo = currentSite.getInfo();
|
||||
this.siteName = currentSite.getSiteName();
|
||||
this.siteUrl = currentSite.getURL();
|
||||
this.displaySwitchAccount = !currentSite.isFeatureDisabled('NoDelegate_SwitchAccount');
|
||||
|
||||
this.loaded = true;
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ export class CoreTextUtilsProvider {
|
|||
{ old: /files_sitefiles/g, new: 'AddonPrivateFilesSiteFiles' },
|
||||
{ old: /files_upload/g, new: 'AddonPrivateFilesUpload' },
|
||||
{ old: /_mmaModAssign/g, new: '_AddonModAssign' },
|
||||
{ old: /_mmaModBigbluebuttonbn/g, new: '_AddonModBBB' },
|
||||
{ old: /_mmaModBook/g, new: '_AddonModBook' },
|
||||
{ old: /_mmaModChat/g, new: '_AddonModChat' },
|
||||
{ old: /_mmaModChoice/g, new: '_AddonModChoice' },
|
||||
|
|
Loading…
Reference in New Issue