mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[AAE-8201] - Add a way to hide libraries and secondary navbar sections (#2492)
* [AAE-8201] - Add a way to hide libraries and secondary navbar sections * Add new variable * Rename variable for toggling content service sections * Fix lint errors * Remove unnecessary or condition
This commit is contained in:
parent
9f0f4cc61f
commit
bacd9e5c10
@ -50,6 +50,7 @@ env:
|
|||||||
- APP_CONFIG_OAUTH2_HOST=http://localhost:4200/auth/realms/alfresco
|
- APP_CONFIG_OAUTH2_HOST=http://localhost:4200/auth/realms/alfresco
|
||||||
- APP_CONFIG_OAUTH2_CLIENTID=alfresco
|
- APP_CONFIG_OAUTH2_CLIENTID=alfresco
|
||||||
- APP_CONFIG_PLUGIN_AOS=true
|
- APP_CONFIG_PLUGIN_AOS=true
|
||||||
|
- APP_CONFIG_CONTENT_SERVICE=true
|
||||||
- APP_CONFIG_OAUTH2_IMPLICIT_FLOW=true
|
- APP_CONFIG_OAUTH2_IMPLICIT_FLOW=true
|
||||||
- APP_CONFIG_OAUTH2_SILENT_LOGIN=true
|
- APP_CONFIG_OAUTH2_SILENT_LOGIN=true
|
||||||
- APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/
|
- APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/
|
||||||
|
@ -34,6 +34,7 @@ ENV APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI="{protocol}//{hostname}{:port}/
|
|||||||
ENV APP_CONFIG_OAUTH2_REDIRECT_LOGIN="/"
|
ENV APP_CONFIG_OAUTH2_REDIRECT_LOGIN="/"
|
||||||
ENV APP_CONFIG_OAUTH2_REDIRECT_LOGOUT="/"
|
ENV APP_CONFIG_OAUTH2_REDIRECT_LOGOUT="/"
|
||||||
ENV APP_CONFIG_PLUGIN_AOS=true
|
ENV APP_CONFIG_PLUGIN_AOS=true
|
||||||
|
ENV APP_CONFIG_CONTENT_SERVICE=true
|
||||||
|
|
||||||
COPY docker/default.conf.template /etc/nginx/templates/
|
COPY docker/default.conf.template /etc/nginx/templates/
|
||||||
COPY docker/docker-entrypoint.d/* /docker-entrypoint.d/
|
COPY docker/docker-entrypoint.d/* /docker-entrypoint.d/
|
||||||
|
@ -29,3 +29,5 @@ APP_CONFIG_OAUTH2_REDIRECT_LOGIN=/
|
|||||||
APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/
|
APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/
|
||||||
# CONTENT - ALFRESCO OFFICE SERVICES PLUGIN RELATED
|
# CONTENT - ALFRESCO OFFICE SERVICES PLUGIN RELATED
|
||||||
APP_CONFIG_PLUGIN_AOS=true
|
APP_CONFIG_PLUGIN_AOS=true
|
||||||
|
# ALFRESCO CONTENT SERVICE RELATED
|
||||||
|
APP_CONFIG_CONTENT_SERVICE=true
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
"authType": "${APP_CONFIG_AUTH_TYPE}",
|
"authType": "${APP_CONFIG_AUTH_TYPE}",
|
||||||
"loginRoute": "login",
|
"loginRoute": "login",
|
||||||
"plugins":{
|
"plugins":{
|
||||||
"aosPlugin" : ${APP_CONFIG_PLUGIN_AOS}
|
"aosPlugin" : ${APP_CONFIG_PLUGIN_AOS},
|
||||||
|
"contentService": ${APP_CONFIG_CONTENT_SERVICE}
|
||||||
},
|
},
|
||||||
"oauth2": {
|
"oauth2": {
|
||||||
"host": "${APP_CONFIG_OAUTH2_HOST}",
|
"host": "${APP_CONFIG_OAUTH2_HOST}",
|
||||||
|
@ -54,6 +54,7 @@ import { LanguagePickerComponent } from '../components/common/language-picker/la
|
|||||||
import { LogoutComponent } from '../components/common/logout/logout.component';
|
import { LogoutComponent } from '../components/common/logout/logout.component';
|
||||||
import { AppExtensionService, ExtensionsDataLoaderGuard } from '@alfresco/aca-shared';
|
import { AppExtensionService, ExtensionsDataLoaderGuard } from '@alfresco/aca-shared';
|
||||||
import { PreviewComponent } from '../components/preview/preview.component';
|
import { PreviewComponent } from '../components/preview/preview.component';
|
||||||
|
import { ContentServiceExtensionService } from '../services/content-service-extension.service';
|
||||||
|
|
||||||
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
||||||
export function setupExtensions(service: AppExtensionService): () => void {
|
export function setupExtensions(service: AppExtensionService): () => void {
|
||||||
@ -71,7 +72,7 @@ export class CoreExtensionsModule {
|
|||||||
{
|
{
|
||||||
provide: APP_INITIALIZER,
|
provide: APP_INITIALIZER,
|
||||||
useFactory: setupExtensions,
|
useFactory: setupExtensions,
|
||||||
deps: [AppExtensionService],
|
deps: [AppExtensionService, ContentServiceExtensionService],
|
||||||
multi: true
|
multi: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -181,7 +182,8 @@ export class CoreExtensionsModule {
|
|||||||
|
|
||||||
'repository.isQuickShareEnabled': rules.hasQuickShareEnabled,
|
'repository.isQuickShareEnabled': rules.hasQuickShareEnabled,
|
||||||
'user.isAdmin': rules.isAdmin,
|
'user.isAdmin': rules.isAdmin,
|
||||||
'app.canShowLogout': rules.canShowLogout
|
'app.canShowLogout': rules.canShowLogout,
|
||||||
|
'app.isContentServiceEnabled': rules.isContentServiceEnabled
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||||
|
* pursuant to a written agreement and any use of this program without such an
|
||||||
|
* agreement is prohibited.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { ContentServiceExtensionService } from './content-service-extension.service';
|
||||||
|
import { AppConfigService, AppConfigServiceMock, setupTestBed } from '@alfresco/adf-core';
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { of } from 'rxjs';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
|
||||||
|
describe('ContentServiceExtensionService', () => {
|
||||||
|
let service: ContentServiceExtensionService;
|
||||||
|
let appConfig: AppConfigService;
|
||||||
|
|
||||||
|
setupTestBed({
|
||||||
|
imports: [HttpClientModule],
|
||||||
|
providers: [{ provide: AppConfigService, useClass: AppConfigServiceMock }]
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
service = TestBed.inject(ContentServiceExtensionService);
|
||||||
|
appConfig = TestBed.inject(AppConfigService);
|
||||||
|
appConfig.config = Object.assign(appConfig.config, {
|
||||||
|
plugins: {
|
||||||
|
contentService: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
appConfig.load();
|
||||||
|
appConfig.onLoad = of(appConfig.config);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set the content service to true when it is false in local storage and enabled in the app config', () => {
|
||||||
|
localStorage.setItem('contentService', 'false');
|
||||||
|
service.updateContentServiceAvailability();
|
||||||
|
|
||||||
|
expect(localStorage.getItem('contentService')).toEqual('true');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set the content service to false in local storage when it is false in the app config', () => {
|
||||||
|
appConfig.config.plugins.contentService = false;
|
||||||
|
appConfig.load();
|
||||||
|
appConfig.onLoad = of(appConfig.config);
|
||||||
|
service.updateContentServiceAvailability();
|
||||||
|
|
||||||
|
expect(localStorage.getItem('contentService')).toEqual('false');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
localStorage.clear();
|
||||||
|
});
|
||||||
|
});
|
42
app/src/app/services/content-service-extension.service.ts
Normal file
42
app/src/app/services/content-service-extension.service.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||||
|
* pursuant to a written agreement and any use of this program without such an
|
||||||
|
* agreement is prohibited.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { AppConfigService } from '@alfresco/adf-core';
|
||||||
|
import { take } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ContentServiceExtensionService {
|
||||||
|
constructor(private appConfigService: AppConfigService) {
|
||||||
|
this.updateContentServiceAvailability();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateContentServiceAvailability() {
|
||||||
|
this.appConfigService.onLoad.pipe(take(1)).subscribe((config) => {
|
||||||
|
if (config.plugins && config.plugins.contentService === false) {
|
||||||
|
this.disableContentServices();
|
||||||
|
} else {
|
||||||
|
this.enableContentServices();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private disableContentServices() {
|
||||||
|
if (localStorage) {
|
||||||
|
localStorage.setItem('contentService', 'false');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private enableContentServices() {
|
||||||
|
if (localStorage && localStorage.getItem('contentService') === 'false') {
|
||||||
|
localStorage.setItem('contentService', 'true');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -241,6 +241,9 @@
|
|||||||
"icon": "library_books",
|
"icon": "library_books",
|
||||||
"title": "APP.BROWSE.LIBRARIES.SIDENAV_LINK.LABEL",
|
"title": "APP.BROWSE.LIBRARIES.SIDENAV_LINK.LABEL",
|
||||||
"description": "APP.BROWSE.LIBRARIES.SIDENAV_LINK.TOOLTIP",
|
"description": "APP.BROWSE.LIBRARIES.SIDENAV_LINK.TOOLTIP",
|
||||||
|
"rules": {
|
||||||
|
"visible": "app.isContentServiceEnabled"
|
||||||
|
},
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"id": "app.navbar.libraries.favorite",
|
"id": "app.navbar.libraries.favorite",
|
||||||
@ -262,6 +265,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "app.navbar.secondary",
|
"id": "app.navbar.secondary",
|
||||||
|
"rules": {
|
||||||
|
"visible": "app.isContentServiceEnabled"
|
||||||
|
},
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"id": "app.navbar.shared",
|
"id": "app.navbar.shared",
|
||||||
|
@ -72,7 +72,6 @@ module.exports = function(config) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
singleRun: true,
|
singleRun: true,
|
||||||
|
|
||||||
captureTimeout: 180000,
|
captureTimeout: 180000,
|
||||||
browserDisconnectTimeout: 180000,
|
browserDisconnectTimeout: 180000,
|
||||||
browserDisconnectTolerance: 3,
|
browserDisconnectTolerance: 3,
|
||||||
|
@ -530,4 +530,21 @@ describe('app.evaluators', () => {
|
|||||||
expect(app.isLibraryManager(context)).toBe(false);
|
expect(app.isLibraryManager(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('isContentServiceEnabled', () => {
|
||||||
|
it('should return true when local storage has contentService set to true', () => {
|
||||||
|
localStorage.setItem('contentService', 'true');
|
||||||
|
expect(app.isContentServiceEnabled()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false when local storage has contentService set to false', () => {
|
||||||
|
localStorage.setItem('contentService', 'false');
|
||||||
|
expect(app.isContentServiceEnabled()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true when contentService is not defined in local storage', () => {
|
||||||
|
localStorage.clear();
|
||||||
|
expect(app.isContentServiceEnabled()).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -32,6 +32,12 @@ export interface AcaRuleContext extends RuleContext {
|
|||||||
withCredentials: boolean;
|
withCredentials: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the content plugin is enabled.
|
||||||
|
* JSON ref: `app.isContentServiceEnabled`
|
||||||
|
*/
|
||||||
|
export const isContentServiceEnabled = (): boolean => localStorage && localStorage.getItem('contentService') !== 'false';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if user can copy selected node.
|
* Checks if user can copy selected node.
|
||||||
* JSON ref: `app.canCopyNode`
|
* JSON ref: `app.canCopyNode`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user