MOBILE-4002 dashboard: Check new setting to disable dashboard
parent
3f68944a66
commit
43d7ccc345
|
@ -15,6 +15,8 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreBlockDelegate } from '@features/block/services/block-delegate';
|
import { CoreBlockDelegate } from '@features/block/services/block-delegate';
|
||||||
import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
|
import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
|
||||||
|
import { CoreSites } from '@services/sites';
|
||||||
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreCoursesDashboard } from '../dashboard';
|
import { CoreCoursesDashboard } from '../dashboard';
|
||||||
|
|
||||||
|
@ -45,40 +47,25 @@ export class CoreDashboardHomeHandlerService implements CoreMainMenuHomeHandler
|
||||||
* @return Whether or not the handler is enabled on a site level.
|
* @return Whether or not the handler is enabled on a site level.
|
||||||
*/
|
*/
|
||||||
async isEnabledForSite(siteId?: string): Promise<boolean> {
|
async isEnabledForSite(siteId?: string): Promise<boolean> {
|
||||||
const promises: Promise<void>[] = [];
|
const site = await CoreSites.getSite(siteId);
|
||||||
let blocksEnabled = false;
|
|
||||||
let dashboardAvailable = false;
|
|
||||||
let dashboardEnabled = false;
|
|
||||||
|
|
||||||
// Check if blocks and 3.6 dashboard is enabled.
|
// Check if blocks and 3.6 dashboard is enabled.
|
||||||
promises.push(CoreBlockDelegate.areBlocksDisabled(siteId).then((disabled) => {
|
const [blocksDisabled, dashboardDisabled, dashboardAvailable, dashboardConfig] = await Promise.all([
|
||||||
blocksEnabled = !disabled;
|
CoreBlockDelegate.areBlocksDisabled(site.getId()),
|
||||||
|
CoreCoursesDashboard.isDisabled(site.getId()),
|
||||||
|
CoreCoursesDashboard.isAvailable(site.getId()),
|
||||||
|
CoreUtils.ignoreErrors(site.getConfig('enabledashboard'), '1'),
|
||||||
|
]);
|
||||||
|
const dashboardEnabled = !dashboardDisabled && dashboardConfig !== '0';
|
||||||
|
|
||||||
return;
|
if (dashboardAvailable && dashboardEnabled && !blocksDisabled) {
|
||||||
}));
|
|
||||||
|
|
||||||
promises.push(CoreCoursesDashboard.isDisabled(siteId).then((disabled) => {
|
|
||||||
dashboardEnabled = !disabled;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}));
|
|
||||||
|
|
||||||
promises.push(CoreCoursesDashboard.isAvailable(siteId).then((available) => {
|
|
||||||
dashboardAvailable = available;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}));
|
|
||||||
|
|
||||||
await Promise.all(promises);
|
|
||||||
|
|
||||||
if (dashboardAvailable && dashboardEnabled && blocksEnabled) {
|
|
||||||
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, siteId);
|
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, siteId);
|
||||||
|
|
||||||
return CoreBlockDelegate.hasSupportedBlock(blocks.mainBlocks) || CoreBlockDelegate.hasSupportedBlock(blocks.sideBlocks);
|
return CoreBlockDelegate.hasSupportedBlock(blocks.mainBlocks) || CoreBlockDelegate.hasSupportedBlock(blocks.sideBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dashboard is enabled but not available, we will fake blocks.
|
// Dashboard is enabled but not available, we will fake blocks.
|
||||||
return dashboardEnabled && blocksEnabled;
|
return dashboardEnabled && !blocksDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue